babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @param mimeType defines the optional mime type of the file being loaded
  1073. * @returns true if the loader can load the specified file
  1074. */
  1075. canLoad(extension: string, mimeType?: string): boolean;
  1076. /**
  1077. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Engines/IPipelineContext" {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _getVertexShaderCode(): string | null;
  1109. /** @hidden */
  1110. _getFragmentShaderCode(): string | null;
  1111. /** @hidden */
  1112. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1113. }
  1114. }
  1115. declare module "babylonjs/Meshes/dataBuffer" {
  1116. /**
  1117. * Class used to store gfx data (like WebGLBuffer)
  1118. */
  1119. export class DataBuffer {
  1120. /**
  1121. * Gets or sets the number of objects referencing this buffer
  1122. */
  1123. references: number;
  1124. /** Gets or sets the size of the underlying buffer */
  1125. capacity: number;
  1126. /**
  1127. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1128. */
  1129. is32Bits: boolean;
  1130. /**
  1131. * Gets the underlying buffer
  1132. */
  1133. get underlyingResource(): any;
  1134. }
  1135. }
  1136. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1137. /** @hidden */
  1138. export interface IShaderProcessor {
  1139. attributeProcessor?: (attribute: string) => string;
  1140. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1141. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1142. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1143. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1144. lineProcessor?: (line: string, isFragment: boolean) => string;
  1145. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1147. }
  1148. }
  1149. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1150. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1151. /** @hidden */
  1152. export interface ProcessingOptions {
  1153. defines: string[];
  1154. indexParameters: any;
  1155. isFragment: boolean;
  1156. shouldUseHighPrecisionShader: boolean;
  1157. supportsUniformBuffers: boolean;
  1158. shadersRepository: string;
  1159. includesShadersStore: {
  1160. [key: string]: string;
  1161. };
  1162. processor?: IShaderProcessor;
  1163. version: string;
  1164. platformName: string;
  1165. lookForClosingBracketForUniformBuffer?: boolean;
  1166. }
  1167. }
  1168. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1169. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1170. /** @hidden */
  1171. export class ShaderCodeNode {
  1172. line: string;
  1173. children: ShaderCodeNode[];
  1174. additionalDefineKey?: string;
  1175. additionalDefineValue?: string;
  1176. isValid(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. process(preprocessors: {
  1180. [key: string]: string;
  1181. }, options: ProcessingOptions): string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1185. /** @hidden */
  1186. export class ShaderCodeCursor {
  1187. private _lines;
  1188. lineIndex: number;
  1189. get currentLine(): string;
  1190. get canRead(): boolean;
  1191. set lines(value: string[]);
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1195. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1196. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1197. /** @hidden */
  1198. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1199. process(preprocessors: {
  1200. [key: string]: string;
  1201. }, options: ProcessingOptions): string;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1205. /** @hidden */
  1206. export class ShaderDefineExpression {
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. private static _OperatorPriority;
  1211. private static _Stack;
  1212. static postfixToInfix(postfix: string[]): string;
  1213. static infixToPostfix(infix: string): string[];
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1217. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1218. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1219. /** @hidden */
  1220. export class ShaderCodeTestNode extends ShaderCodeNode {
  1221. testExpression: ShaderDefineExpression;
  1222. isValid(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. not: boolean;
  1233. constructor(define: string, not?: boolean);
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1254. leftOperand: ShaderDefineExpression;
  1255. rightOperand: ShaderDefineExpression;
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1262. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Offline/IOfflineProvider" {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/filesInputStore" {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module "babylonjs/Misc/retryStrategy" {
  1326. import { WebRequest } from "babylonjs/Misc/webRequest";
  1327. /**
  1328. * Class used to define a retry strategy when error happens while loading assets
  1329. */
  1330. export class RetryStrategy {
  1331. /**
  1332. * Function used to defines an exponential back off strategy
  1333. * @param maxRetries defines the maximum number of retries (3 by default)
  1334. * @param baseInterval defines the interval between retries
  1335. * @returns the strategy function to use
  1336. */
  1337. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/baseError" {
  1341. /**
  1342. * @ignore
  1343. * Application error to support additional information when loading a file
  1344. */
  1345. export abstract class BaseError extends Error {
  1346. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1347. }
  1348. }
  1349. declare module "babylonjs/Misc/fileTools" {
  1350. import { WebRequest } from "babylonjs/Misc/webRequest";
  1351. import { Nullable } from "babylonjs/types";
  1352. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1353. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1354. import { BaseError } from "babylonjs/Misc/baseError";
  1355. /** @ignore */
  1356. export class LoadFileError extends BaseError {
  1357. request?: WebRequest;
  1358. file?: File;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. * @param file defines the optional file
  1364. */
  1365. constructor(message: string, object?: WebRequest | File);
  1366. }
  1367. /** @ignore */
  1368. export class RequestFileError extends BaseError {
  1369. request: WebRequest;
  1370. /**
  1371. * Creates a new LoadFileError
  1372. * @param message defines the message of the error
  1373. * @param request defines the optional web request
  1374. */
  1375. constructor(message: string, request: WebRequest);
  1376. }
  1377. /** @ignore */
  1378. export class ReadFileError extends BaseError {
  1379. file: File;
  1380. /**
  1381. * Creates a new ReadFileError
  1382. * @param message defines the message of the error
  1383. * @param file defines the optional file
  1384. */
  1385. constructor(message: string, file: File);
  1386. }
  1387. /**
  1388. * @hidden
  1389. */
  1390. export class FileTools {
  1391. /**
  1392. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1393. */
  1394. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1395. /**
  1396. * Gets or sets the base URL to use to load assets
  1397. */
  1398. static BaseUrl: string;
  1399. /**
  1400. * Default behaviour for cors in the application.
  1401. * It can be a string if the expected behavior is identical in the entire app.
  1402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1403. */
  1404. static CorsBehavior: string | ((url: string | string[]) => string);
  1405. /**
  1406. * Gets or sets a function used to pre-process url before using them to load assets
  1407. */
  1408. static PreprocessUrl: (url: string) => string;
  1409. /**
  1410. * Removes unwanted characters from an url
  1411. * @param url defines the url to clean
  1412. * @returns the cleaned url
  1413. */
  1414. private static _CleanUrl;
  1415. /**
  1416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1417. * @param url define the url we are trying
  1418. * @param element define the dom element where to configure the cors policy
  1419. */
  1420. static SetCorsBehavior(url: string | string[], element: {
  1421. crossOrigin: string | null;
  1422. }): void;
  1423. /**
  1424. * Loads an image as an HTMLImageElement.
  1425. * @param input url string, ArrayBuffer, or Blob to load
  1426. * @param onLoad callback called when the image successfully loads
  1427. * @param onError callback called when the image fails to load
  1428. * @param offlineProvider offline provider for caching
  1429. * @param mimeType optional mime type
  1430. * @returns the HTMLImageElement of the loaded image
  1431. */
  1432. 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>;
  1433. /**
  1434. * Reads a file from a File object
  1435. * @param file defines the file to load
  1436. * @param onSuccess defines the callback to call when data is loaded
  1437. * @param onProgress defines the callback to call during loading process
  1438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1439. * @param onError defines the callback to call when an error occurs
  1440. * @returns a file request object
  1441. */
  1442. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file from a url
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param offlineProvider defines the offline provider for caching
  1449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1450. * @param onError callback called when the file fails to load
  1451. * @returns a file request object
  1452. */
  1453. 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;
  1454. /**
  1455. * Loads a file
  1456. * @param url url to load
  1457. * @param onSuccess callback called when the file successfully loads
  1458. * @param onProgress callback called while file is loading (if the server supports this mode)
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @param onOpened callback called when the web request is opened
  1462. * @returns a file request object
  1463. */
  1464. 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;
  1465. /**
  1466. * Checks if the loaded document was accessed via `file:`-Protocol.
  1467. * @returns boolean
  1468. */
  1469. static IsFileURL(): boolean;
  1470. }
  1471. }
  1472. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1473. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1474. import { WebRequest } from "babylonjs/Misc/webRequest";
  1475. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1476. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1477. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1478. /** @hidden */
  1479. export class ShaderProcessor {
  1480. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1481. private static _ProcessPrecision;
  1482. private static _ExtractOperation;
  1483. private static _BuildSubExpression;
  1484. private static _BuildExpression;
  1485. private static _MoveCursorWithinIf;
  1486. private static _MoveCursor;
  1487. private static _EvaluatePreProcessors;
  1488. private static _PreparePreProcessors;
  1489. private static _ProcessShaderConversion;
  1490. private static _ProcessIncludes;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. * @hidden
  1501. */
  1502. 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;
  1503. }
  1504. }
  1505. declare module "babylonjs/Maths/math.like" {
  1506. import { float, int, DeepImmutable } from "babylonjs/types";
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor4Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. a: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IColor3Like {
  1520. r: float;
  1521. g: float;
  1522. b: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector4Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. w: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IVector3Like {
  1537. x: float;
  1538. y: float;
  1539. z: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector2Like {
  1545. x: float;
  1546. y: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IMatrixLike {
  1552. toArray(): DeepImmutable<Float32Array>;
  1553. updateFlag: int;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IViewportLike {
  1559. x: float;
  1560. y: float;
  1561. width: float;
  1562. height: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IPlaneLike {
  1568. normal: IVector3Like;
  1569. d: float;
  1570. normalize(): void;
  1571. }
  1572. }
  1573. declare module "babylonjs/Materials/iEffectFallbacks" {
  1574. import { Effect } from "babylonjs/Materials/effect";
  1575. /**
  1576. * Interface used to define common properties for effect fallbacks
  1577. */
  1578. export interface IEffectFallbacks {
  1579. /**
  1580. * Removes the defines that should be removed when falling back.
  1581. * @param currentDefines defines the current define statements for the shader.
  1582. * @param effect defines the current effect we try to compile
  1583. * @returns The resulting defines with defines of the current rank removed.
  1584. */
  1585. reduce(currentDefines: string, effect: Effect): string;
  1586. /**
  1587. * Removes the fallback from the bound mesh.
  1588. */
  1589. unBindMesh(): void;
  1590. /**
  1591. * Checks to see if more fallbacks are still availible.
  1592. */
  1593. hasMoreFallbacks: boolean;
  1594. }
  1595. }
  1596. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1597. /**
  1598. * Class used to evalaute queries containing `and` and `or` operators
  1599. */
  1600. export class AndOrNotEvaluator {
  1601. /**
  1602. * Evaluate a query
  1603. * @param query defines the query to evaluate
  1604. * @param evaluateCallback defines the callback used to filter result
  1605. * @returns true if the query matches
  1606. */
  1607. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1608. private static _HandleParenthesisContent;
  1609. private static _SimplifyNegation;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/tags" {
  1613. /**
  1614. * Class used to store custom tags
  1615. */
  1616. export class Tags {
  1617. /**
  1618. * Adds support for tags on the given object
  1619. * @param obj defines the object to use
  1620. */
  1621. static EnableFor(obj: any): void;
  1622. /**
  1623. * Removes tags support
  1624. * @param obj defines the object to use
  1625. */
  1626. static DisableFor(obj: any): void;
  1627. /**
  1628. * Gets a boolean indicating if the given object has tags
  1629. * @param obj defines the object to use
  1630. * @returns a boolean
  1631. */
  1632. static HasTags(obj: any): boolean;
  1633. /**
  1634. * Gets the tags available on a given object
  1635. * @param obj defines the object to use
  1636. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1637. * @returns the tags
  1638. */
  1639. static GetTags(obj: any, asString?: boolean): any;
  1640. /**
  1641. * Adds tags to an object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1644. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1645. */
  1646. static AddTagsTo(obj: any, tagsString: string): void;
  1647. /**
  1648. * @hidden
  1649. */
  1650. static _AddTagTo(obj: any, tag: string): void;
  1651. /**
  1652. * Removes specific tags from a specific object
  1653. * @param obj defines the object to use
  1654. * @param tagsString defines the tags to remove
  1655. */
  1656. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _RemoveTagFrom(obj: any, tag: string): void;
  1661. /**
  1662. * Defines if tags hosted on an object match a given query
  1663. * @param obj defines the object to use
  1664. * @param tagsQuery defines the tag query
  1665. * @returns a boolean
  1666. */
  1667. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1668. }
  1669. }
  1670. declare module "babylonjs/Maths/math.scalar" {
  1671. /**
  1672. * Scalar computation library
  1673. */
  1674. export class Scalar {
  1675. /**
  1676. * Two pi constants convenient for computation.
  1677. */
  1678. static TwoPi: number;
  1679. /**
  1680. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1681. * @param a number
  1682. * @param b number
  1683. * @param epsilon (default = 1.401298E-45)
  1684. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1685. */
  1686. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1687. /**
  1688. * Returns a string : the upper case translation of the number i to hexadecimal.
  1689. * @param i number
  1690. * @returns the upper case translation of the number i to hexadecimal.
  1691. */
  1692. static ToHex(i: number): string;
  1693. /**
  1694. * Returns -1 if value is negative and +1 is value is positive.
  1695. * @param value the value
  1696. * @returns the value itself if it's equal to zero.
  1697. */
  1698. static Sign(value: number): number;
  1699. /**
  1700. * Returns the value itself if it's between min and max.
  1701. * Returns min if the value is lower than min.
  1702. * Returns max if the value is greater than max.
  1703. * @param value the value to clmap
  1704. * @param min the min value to clamp to (default: 0)
  1705. * @param max the max value to clamp to (default: 1)
  1706. * @returns the clamped value
  1707. */
  1708. static Clamp(value: number, min?: number, max?: number): number;
  1709. /**
  1710. * the log2 of value.
  1711. * @param value the value to compute log2 of
  1712. * @returns the log2 of value.
  1713. */
  1714. static Log2(value: number): number;
  1715. /**
  1716. * Loops the value, so that it is never larger than length and never smaller than 0.
  1717. *
  1718. * This is similar to the modulo operator but it works with floating point numbers.
  1719. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1720. * With t = 5 and length = 2.5, the result would be 0.0.
  1721. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1722. * @param value the value
  1723. * @param length the length
  1724. * @returns the looped value
  1725. */
  1726. static Repeat(value: number, length: number): number;
  1727. /**
  1728. * Normalize the value between 0.0 and 1.0 using min and max values
  1729. * @param value value to normalize
  1730. * @param min max to normalize between
  1731. * @param max min to normalize between
  1732. * @returns the normalized value
  1733. */
  1734. static Normalize(value: number, min: number, max: number): number;
  1735. /**
  1736. * Denormalize the value from 0.0 and 1.0 using min and max values
  1737. * @param normalized value to denormalize
  1738. * @param min max to denormalize between
  1739. * @param max min to denormalize between
  1740. * @returns the denormalized value
  1741. */
  1742. static Denormalize(normalized: number, min: number, max: number): number;
  1743. /**
  1744. * Calculates the shortest difference between two given angles given in degrees.
  1745. * @param current current angle in degrees
  1746. * @param target target angle in degrees
  1747. * @returns the delta
  1748. */
  1749. static DeltaAngle(current: number, target: number): number;
  1750. /**
  1751. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1752. * @param tx value
  1753. * @param length length
  1754. * @returns The returned value will move back and forth between 0 and length
  1755. */
  1756. static PingPong(tx: number, length: number): number;
  1757. /**
  1758. * Interpolates between min and max with smoothing at the limits.
  1759. *
  1760. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1761. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1762. * @param from from
  1763. * @param to to
  1764. * @param tx value
  1765. * @returns the smooth stepped value
  1766. */
  1767. static SmoothStep(from: number, to: number, tx: number): number;
  1768. /**
  1769. * Moves a value current towards target.
  1770. *
  1771. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1772. * Negative values of maxDelta pushes the value away from target.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting value
  1777. */
  1778. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1781. *
  1782. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1783. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1784. * @param current current value
  1785. * @param target target value
  1786. * @param maxDelta max distance to move
  1787. * @returns resulting angle
  1788. */
  1789. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1790. /**
  1791. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static Lerp(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1800. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1801. * @param start start value
  1802. * @param end target value
  1803. * @param amount amount to lerp between
  1804. * @returns the lerped value
  1805. */
  1806. static LerpAngle(start: number, end: number, amount: number): number;
  1807. /**
  1808. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1809. * @param a start value
  1810. * @param b target value
  1811. * @param value value between a and b
  1812. * @returns the inverseLerp value
  1813. */
  1814. static InverseLerp(a: number, b: number, value: number): number;
  1815. /**
  1816. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1817. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1818. * @param value1 spline value
  1819. * @param tangent1 spline value
  1820. * @param value2 spline value
  1821. * @param tangent2 spline value
  1822. * @param amount input value
  1823. * @returns hermite result
  1824. */
  1825. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1826. /**
  1827. * Returns a random float number between and min and max values
  1828. * @param min min value of random
  1829. * @param max max value of random
  1830. * @returns random value
  1831. */
  1832. static RandomRange(min: number, max: number): number;
  1833. /**
  1834. * This function returns percentage of a number in a given range.
  1835. *
  1836. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1837. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1838. * @param number to convert to percentage
  1839. * @param min min range
  1840. * @param max max range
  1841. * @returns the percentage
  1842. */
  1843. static RangeToPercent(number: number, min: number, max: number): number;
  1844. /**
  1845. * This function returns number that corresponds to the percentage in a given range.
  1846. *
  1847. * PercentToRange(0.34,0,100) will return 34.
  1848. * @param percent to convert to number
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the number
  1852. */
  1853. static PercentToRange(percent: number, min: number, max: number): number;
  1854. /**
  1855. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1856. * @param angle The angle to normalize in radian.
  1857. * @return The converted angle.
  1858. */
  1859. static NormalizeRadians(angle: number): number;
  1860. }
  1861. }
  1862. declare module "babylonjs/Maths/math.constants" {
  1863. /**
  1864. * Constant used to convert a value to gamma space
  1865. * @ignorenaming
  1866. */
  1867. export const ToGammaSpace: number;
  1868. /**
  1869. * Constant used to convert a value to linear space
  1870. * @ignorenaming
  1871. */
  1872. export const ToLinearSpace = 2.2;
  1873. /**
  1874. * Constant used to define the minimal number value in Babylon.js
  1875. * @ignorenaming
  1876. */
  1877. let Epsilon: number;
  1878. export { Epsilon };
  1879. }
  1880. declare module "babylonjs/Maths/math.viewport" {
  1881. /**
  1882. * Class used to represent a viewport on screen
  1883. */
  1884. export class Viewport {
  1885. /** viewport left coordinate */
  1886. x: number;
  1887. /** viewport top coordinate */
  1888. y: number;
  1889. /**viewport width */
  1890. width: number;
  1891. /** viewport height */
  1892. height: number;
  1893. /**
  1894. * Creates a Viewport object located at (x, y) and sized (width, height)
  1895. * @param x defines viewport left coordinate
  1896. * @param y defines viewport top coordinate
  1897. * @param width defines the viewport width
  1898. * @param height defines the viewport height
  1899. */
  1900. constructor(
  1901. /** viewport left coordinate */
  1902. x: number,
  1903. /** viewport top coordinate */
  1904. y: number,
  1905. /**viewport width */
  1906. width: number,
  1907. /** viewport height */
  1908. height: number);
  1909. /**
  1910. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1911. * @param renderWidth defines the rendering width
  1912. * @param renderHeight defines the rendering height
  1913. * @returns a new Viewport
  1914. */
  1915. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1916. /**
  1917. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1918. * @param renderWidth defines the rendering width
  1919. * @param renderHeight defines the rendering height
  1920. * @param ref defines the target viewport
  1921. * @returns the current viewport
  1922. */
  1923. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1924. /**
  1925. * Returns a new Viewport copied from the current one
  1926. * @returns a new Viewport
  1927. */
  1928. clone(): Viewport;
  1929. }
  1930. }
  1931. declare module "babylonjs/Misc/arrayTools" {
  1932. /**
  1933. * Class containing a set of static utilities functions for arrays.
  1934. */
  1935. export class ArrayTools {
  1936. /**
  1937. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1938. * @param size the number of element to construct and put in the array
  1939. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1940. * @returns a new array filled with new objects
  1941. */
  1942. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1943. }
  1944. }
  1945. declare module "babylonjs/Maths/math.plane" {
  1946. import { DeepImmutable } from "babylonjs/types";
  1947. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1948. /**
  1949. * Represents a plane by the equation ax + by + cz + d = 0
  1950. */
  1951. export class Plane {
  1952. private static _TmpMatrix;
  1953. /**
  1954. * Normal of the plane (a,b,c)
  1955. */
  1956. normal: Vector3;
  1957. /**
  1958. * d component of the plane
  1959. */
  1960. d: number;
  1961. /**
  1962. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1963. * @param a a component of the plane
  1964. * @param b b component of the plane
  1965. * @param c c component of the plane
  1966. * @param d d component of the plane
  1967. */
  1968. constructor(a: number, b: number, c: number, d: number);
  1969. /**
  1970. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1971. */
  1972. asArray(): number[];
  1973. /**
  1974. * @returns a new plane copied from the current Plane.
  1975. */
  1976. clone(): Plane;
  1977. /**
  1978. * @returns the string "Plane".
  1979. */
  1980. getClassName(): string;
  1981. /**
  1982. * @returns the Plane hash code.
  1983. */
  1984. getHashCode(): number;
  1985. /**
  1986. * Normalize the current Plane in place.
  1987. * @returns the updated Plane.
  1988. */
  1989. normalize(): Plane;
  1990. /**
  1991. * Applies a transformation the plane and returns the result
  1992. * @param transformation the transformation matrix to be applied to the plane
  1993. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1994. */
  1995. transform(transformation: DeepImmutable<Matrix>): Plane;
  1996. /**
  1997. * Compute the dot product between the point and the plane normal
  1998. * @param point point to calculate the dot product with
  1999. * @returns the dot product (float) of the point coordinates and the plane normal.
  2000. */
  2001. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2002. /**
  2003. * Updates the current Plane from the plane defined by the three given points.
  2004. * @param point1 one of the points used to contruct the plane
  2005. * @param point2 one of the points used to contruct the plane
  2006. * @param point3 one of the points used to contruct the plane
  2007. * @returns the updated Plane.
  2008. */
  2009. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2010. /**
  2011. * Checks if the plane is facing a given direction
  2012. * @param direction the direction to check if the plane is facing
  2013. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2014. * @returns True is the vector "direction" is the same side than the plane normal.
  2015. */
  2016. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2017. /**
  2018. * Calculates the distance to a point
  2019. * @param point point to calculate distance to
  2020. * @returns the signed distance (float) from the given point to the Plane.
  2021. */
  2022. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2023. /**
  2024. * Creates a plane from an array
  2025. * @param array the array to create a plane from
  2026. * @returns a new Plane from the given array.
  2027. */
  2028. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2029. /**
  2030. * Creates a plane from three points
  2031. * @param point1 point used to create the plane
  2032. * @param point2 point used to create the plane
  2033. * @param point3 point used to create the plane
  2034. * @returns a new Plane defined by the three given points.
  2035. */
  2036. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2037. /**
  2038. * Creates a plane from an origin point and a normal
  2039. * @param origin origin of the plane to be constructed
  2040. * @param normal normal of the plane to be constructed
  2041. * @returns a new Plane the normal vector to this plane at the given origin point.
  2042. * Note : the vector "normal" is updated because normalized.
  2043. */
  2044. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2045. /**
  2046. * Calculates the distance from a plane and a point
  2047. * @param origin origin of the plane to be constructed
  2048. * @param normal normal of the plane to be constructed
  2049. * @param point point to calculate distance to
  2050. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2051. */
  2052. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2053. }
  2054. }
  2055. declare module "babylonjs/Maths/math.vector" {
  2056. import { Viewport } from "babylonjs/Maths/math.viewport";
  2057. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2058. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2059. import { Plane } from "babylonjs/Maths/math.plane";
  2060. /**
  2061. * Class representing a vector containing 2 coordinates
  2062. */
  2063. export class Vector2 {
  2064. /** defines the first coordinate */
  2065. x: number;
  2066. /** defines the second coordinate */
  2067. y: number;
  2068. /**
  2069. * Creates a new Vector2 from the given x and y coordinates
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. */
  2073. constructor(
  2074. /** defines the first coordinate */
  2075. x?: number,
  2076. /** defines the second coordinate */
  2077. y?: number);
  2078. /**
  2079. * Gets a string with the Vector2 coordinates
  2080. * @returns a string with the Vector2 coordinates
  2081. */
  2082. toString(): string;
  2083. /**
  2084. * Gets class name
  2085. * @returns the string "Vector2"
  2086. */
  2087. getClassName(): string;
  2088. /**
  2089. * Gets current vector hash code
  2090. * @returns the Vector2 hash code as a number
  2091. */
  2092. getHashCode(): number;
  2093. /**
  2094. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2095. * @param array defines the source array
  2096. * @param index defines the offset in source array
  2097. * @returns the current Vector2
  2098. */
  2099. toArray(array: FloatArray, index?: number): Vector2;
  2100. /**
  2101. * Copy the current vector to an array
  2102. * @returns a new array with 2 elements: the Vector2 coordinates.
  2103. */
  2104. asArray(): number[];
  2105. /**
  2106. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2107. * @param source defines the source Vector2
  2108. * @returns the current updated Vector2
  2109. */
  2110. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the Vector2 coordinates with the given floats
  2113. * @param x defines the first coordinate
  2114. * @param y defines the second coordinate
  2115. * @returns the current updated Vector2
  2116. */
  2117. copyFromFloats(x: number, y: number): Vector2;
  2118. /**
  2119. * Sets the Vector2 coordinates with the given floats
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. * @returns the current updated Vector2
  2123. */
  2124. set(x: number, y: number): Vector2;
  2125. /**
  2126. * Add another vector with the current one
  2127. * @param otherVector defines the other vector
  2128. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2129. */
  2130. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2131. /**
  2132. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2133. * @param otherVector defines the other vector
  2134. * @param result defines the target vector
  2135. * @returns the unmodified current Vector2
  2136. */
  2137. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2138. /**
  2139. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns the current updated Vector2
  2142. */
  2143. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2146. * @param otherVector defines the other vector
  2147. * @returns a new Vector2
  2148. */
  2149. addVector3(otherVector: Vector3): Vector2;
  2150. /**
  2151. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. subtract(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Multiplies in place the current Vector2 coordinates by the given ones
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2190. * @param x defines the first coordinate
  2191. * @param y defines the second coordinate
  2192. * @returns a new Vector2
  2193. */
  2194. multiplyByFloats(x: number, y: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns a new Vector2
  2199. */
  2200. divide(otherVector: Vector2): Vector2;
  2201. /**
  2202. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @param result defines the target vector
  2205. * @returns the unmodified current Vector2
  2206. */
  2207. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2208. /**
  2209. * Divides the current Vector2 coordinates by the given ones
  2210. * @param otherVector defines the other vector
  2211. * @returns the current updated Vector2
  2212. */
  2213. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 with current Vector2 negated coordinates
  2216. * @returns a new Vector2
  2217. */
  2218. negate(): Vector2;
  2219. /**
  2220. * Negate this vector in place
  2221. * @returns this
  2222. */
  2223. negateInPlace(): Vector2;
  2224. /**
  2225. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2226. * @param result defines the Vector3 object where to store the result
  2227. * @returns the current Vector2
  2228. */
  2229. negateToRef(result: Vector2): Vector2;
  2230. /**
  2231. * Multiply the Vector2 coordinates by scale
  2232. * @param scale defines the scaling factor
  2233. * @returns the current updated Vector2
  2234. */
  2235. scaleInPlace(scale: number): Vector2;
  2236. /**
  2237. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2238. * @param scale defines the scaling factor
  2239. * @returns a new Vector2
  2240. */
  2241. scale(scale: number): Vector2;
  2242. /**
  2243. * Scale the current Vector2 values by a factor to a given Vector2
  2244. * @param scale defines the scale factor
  2245. * @param result defines the Vector2 object where to store the result
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. scaleToRef(scale: number, result: Vector2): Vector2;
  2249. /**
  2250. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2251. * @param scale defines the scale factor
  2252. * @param result defines the Vector2 object where to store the result
  2253. * @returns the unmodified current Vector2
  2254. */
  2255. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2256. /**
  2257. * Gets a boolean if two vectors are equals
  2258. * @param otherVector defines the other vector
  2259. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2260. */
  2261. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2262. /**
  2263. * Gets a boolean if two vectors are equals (using an epsilon value)
  2264. * @param otherVector defines the other vector
  2265. * @param epsilon defines the minimal distance to consider equality
  2266. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2267. */
  2268. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. floor(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 from current Vector2 floored values
  2276. * @returns a new Vector2
  2277. */
  2278. fract(): Vector2;
  2279. /**
  2280. * Gets the length of the vector
  2281. * @returns the vector length (float)
  2282. */
  2283. length(): number;
  2284. /**
  2285. * Gets the vector squared length
  2286. * @returns the vector squared length (float)
  2287. */
  2288. lengthSquared(): number;
  2289. /**
  2290. * Normalize the vector
  2291. * @returns the current updated Vector2
  2292. */
  2293. normalize(): Vector2;
  2294. /**
  2295. * Gets a new Vector2 copied from the Vector2
  2296. * @returns a new Vector2
  2297. */
  2298. clone(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(0, 0)
  2301. * @returns a new Vector2
  2302. */
  2303. static Zero(): Vector2;
  2304. /**
  2305. * Gets a new Vector2(1, 1)
  2306. * @returns a new Vector2
  2307. */
  2308. static One(): Vector2;
  2309. /**
  2310. * Gets a new Vector2 set from the given index element of the given array
  2311. * @param array defines the data source
  2312. * @param offset defines the offset in the data source
  2313. * @returns a new Vector2
  2314. */
  2315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2316. /**
  2317. * Sets "result" from the given index element of the given array
  2318. * @param array defines the data source
  2319. * @param offset defines the offset in the data source
  2320. * @param result defines the target vector
  2321. */
  2322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2323. /**
  2324. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2325. * @param value1 defines 1st point of control
  2326. * @param value2 defines 2nd point of control
  2327. * @param value3 defines 3rd point of control
  2328. * @param value4 defines 4th point of control
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * 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".
  2335. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2336. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2337. * @param value defines the value to clamp
  2338. * @param min defines the lower limit
  2339. * @param max defines the upper limit
  2340. * @returns a new Vector2
  2341. */
  2342. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2345. * @param value1 defines the 1st control point
  2346. * @param tangent1 defines the outgoing tangent
  2347. * @param value2 defines the 2nd control point
  2348. * @param tangent2 defines the incoming tangent
  2349. * @param amount defines the interpolation factor
  2350. * @returns a new Vector2
  2351. */
  2352. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2353. /**
  2354. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2355. * @param start defines the start vector
  2356. * @param end defines the end vector
  2357. * @param amount defines the interpolation factor
  2358. * @returns a new Vector2
  2359. */
  2360. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2361. /**
  2362. * Gets the dot product of the vector "left" and the vector "right"
  2363. * @param left defines first vector
  2364. * @param right defines second vector
  2365. * @returns the dot product (float)
  2366. */
  2367. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2368. /**
  2369. * Returns a new Vector2 equal to the normalized given vector
  2370. * @param vector defines the vector to normalize
  2371. * @returns a new Vector2
  2372. */
  2373. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2376. * @param left defines 1st vector
  2377. * @param right defines 2nd vector
  2378. * @returns a new Vector2
  2379. */
  2380. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2383. * @param left defines 1st vector
  2384. * @param right defines 2nd vector
  2385. * @returns a new Vector2
  2386. */
  2387. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2388. /**
  2389. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2390. * @param vector defines the vector to transform
  2391. * @param transformation defines the matrix to apply
  2392. * @returns a new Vector2
  2393. */
  2394. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2395. /**
  2396. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2397. * @param vector defines the vector to transform
  2398. * @param transformation defines the matrix to apply
  2399. * @param result defines the target vector
  2400. */
  2401. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2402. /**
  2403. * Determines if a given vector is included in a triangle
  2404. * @param p defines the vector to test
  2405. * @param p0 defines 1st triangle point
  2406. * @param p1 defines 2nd triangle point
  2407. * @param p2 defines 3rd triangle point
  2408. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2409. */
  2410. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2411. /**
  2412. * Gets the distance between the vectors "value1" and "value2"
  2413. * @param value1 defines first vector
  2414. * @param value2 defines second vector
  2415. * @returns the distance between vectors
  2416. */
  2417. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2418. /**
  2419. * Returns the squared distance between the vectors "value1" and "value2"
  2420. * @param value1 defines first vector
  2421. * @param value2 defines second vector
  2422. * @returns the squared distance between vectors
  2423. */
  2424. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2427. * @param value1 defines first vector
  2428. * @param value2 defines second vector
  2429. * @returns a new Vector2
  2430. */
  2431. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2432. /**
  2433. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2434. * @param p defines the middle point
  2435. * @param segA defines one point of the segment
  2436. * @param segB defines the other point of the segment
  2437. * @returns the shortest distance
  2438. */
  2439. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2440. }
  2441. /**
  2442. * Class used to store (x,y,z) vector representation
  2443. * A Vector3 is the main object used in 3D geometry
  2444. * It can represent etiher the coordinates of a point the space, either a direction
  2445. * Reminder: js uses a left handed forward facing system
  2446. */
  2447. export class Vector3 {
  2448. private static _UpReadOnly;
  2449. private static _ZeroReadOnly;
  2450. /** @hidden */
  2451. _x: number;
  2452. /** @hidden */
  2453. _y: number;
  2454. /** @hidden */
  2455. _z: number;
  2456. /** @hidden */
  2457. _isDirty: boolean;
  2458. /** Gets or sets the x coordinate */
  2459. get x(): number;
  2460. set x(value: number);
  2461. /** Gets or sets the y coordinate */
  2462. get y(): number;
  2463. set y(value: number);
  2464. /** Gets or sets the z coordinate */
  2465. get z(): number;
  2466. set z(value: number);
  2467. /**
  2468. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2469. * @param x defines the first coordinates (on X axis)
  2470. * @param y defines the second coordinates (on Y axis)
  2471. * @param z defines the third coordinates (on Z axis)
  2472. */
  2473. constructor(x?: number, y?: number, z?: number);
  2474. /**
  2475. * Creates a string representation of the Vector3
  2476. * @returns a string with the Vector3 coordinates.
  2477. */
  2478. toString(): string;
  2479. /**
  2480. * Gets the class name
  2481. * @returns the string "Vector3"
  2482. */
  2483. getClassName(): string;
  2484. /**
  2485. * Creates the Vector3 hash code
  2486. * @returns a number which tends to be unique between Vector3 instances
  2487. */
  2488. getHashCode(): number;
  2489. /**
  2490. * Creates an array containing three elements : the coordinates of the Vector3
  2491. * @returns a new array of numbers
  2492. */
  2493. asArray(): number[];
  2494. /**
  2495. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2496. * @param array defines the destination array
  2497. * @param index defines the offset in the destination array
  2498. * @returns the current Vector3
  2499. */
  2500. toArray(array: FloatArray, index?: number): Vector3;
  2501. /**
  2502. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2503. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2504. */
  2505. toQuaternion(): Quaternion;
  2506. /**
  2507. * Adds the given vector to the current Vector3
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Adds the given coordinates to the current Vector3
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the resulting Vector3
  2524. */
  2525. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Subtract the given vector from the current Vector3
  2535. * @param otherVector defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the resulting Vector3
  2543. */
  2544. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the resulting Vector3
  2558. */
  2559. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2562. * @param x defines the x coordinate of the operand
  2563. * @param y defines the y coordinate of the operand
  2564. * @param z defines the z coordinate of the operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2569. /**
  2570. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2571. * @returns a new Vector3
  2572. */
  2573. negate(): Vector3;
  2574. /**
  2575. * Negate this vector in place
  2576. * @returns this
  2577. */
  2578. negateInPlace(): Vector3;
  2579. /**
  2580. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2581. * @param result defines the Vector3 object where to store the result
  2582. * @returns the current Vector3
  2583. */
  2584. negateToRef(result: Vector3): Vector3;
  2585. /**
  2586. * Multiplies the Vector3 coordinates by the float "scale"
  2587. * @param scale defines the multiplier factor
  2588. * @returns the current updated Vector3
  2589. */
  2590. scaleInPlace(scale: number): Vector3;
  2591. /**
  2592. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns a new Vector3
  2595. */
  2596. scale(scale: number): Vector3;
  2597. /**
  2598. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2599. * @param scale defines the multiplier factor
  2600. * @param result defines the Vector3 object where to store the result
  2601. * @returns the current Vector3
  2602. */
  2603. scaleToRef(scale: number, result: Vector3): Vector3;
  2604. /**
  2605. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2606. * @param scale defines the scale factor
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the unmodified current Vector3
  2609. */
  2610. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2611. /**
  2612. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2613. * @param origin defines the origin of the projection ray
  2614. * @param plane defines the plane to project to
  2615. * @returns the projected vector3
  2616. */
  2617. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2618. /**
  2619. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2620. * @param origin defines the origin of the projection ray
  2621. * @param plane defines the plane to project to
  2622. * @param result defines the Vector3 where to store the result
  2623. */
  2624. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2625. /**
  2626. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2627. * @param otherVector defines the second operand
  2628. * @returns true if both vectors are equals
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2633. * @param otherVector defines the second operand
  2634. * @param epsilon defines the minimal distance to define values as equals
  2635. * @returns true if both vectors are distant less than epsilon
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2638. /**
  2639. * Returns true if the current Vector3 coordinates equals the given floats
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns true if both vectors are equals
  2644. */
  2645. equalsToFloats(x: number, y: number, z: number): boolean;
  2646. /**
  2647. * Multiplies the current Vector3 coordinates by the given ones
  2648. * @param otherVector defines the second operand
  2649. * @returns the current updated Vector3
  2650. */
  2651. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2654. * @param otherVector defines the second operand
  2655. * @returns the new Vector3
  2656. */
  2657. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2660. * @param otherVector defines the second operand
  2661. * @param result defines the Vector3 object where to store the result
  2662. * @returns the current Vector3
  2663. */
  2664. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the new Vector3
  2671. */
  2672. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2675. * @param otherVector defines the second operand
  2676. * @returns the new Vector3
  2677. */
  2678. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2679. /**
  2680. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2681. * @param otherVector defines the second operand
  2682. * @param result defines the Vector3 object where to store the result
  2683. * @returns the current Vector3
  2684. */
  2685. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2686. /**
  2687. * Divides the current Vector3 coordinates by the given ones.
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. divideInPlace(otherVector: Vector3): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2694. * @param other defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2706. * @param x defines the x coordinate of the operand
  2707. * @param y defines the y coordinate of the operand
  2708. * @param z defines the z coordinate of the operand
  2709. * @returns the current updated Vector3
  2710. */
  2711. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2712. /**
  2713. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2720. /**
  2721. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2722. * Check if is non uniform within a certain amount of decimal places to account for this
  2723. * @param epsilon the amount the values can differ
  2724. * @returns if the the vector is non uniform to a certain number of decimal places
  2725. */
  2726. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2727. /**
  2728. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2729. */
  2730. get isNonUniform(): boolean;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. floor(): Vector3;
  2736. /**
  2737. * Gets a new Vector3 from current Vector3 floored values
  2738. * @returns a new Vector3
  2739. */
  2740. fract(): Vector3;
  2741. /**
  2742. * Gets the length of the Vector3
  2743. * @returns the length of the Vector3
  2744. */
  2745. length(): number;
  2746. /**
  2747. * Gets the squared length of the Vector3
  2748. * @returns squared length of the Vector3
  2749. */
  2750. lengthSquared(): number;
  2751. /**
  2752. * Normalize the current Vector3.
  2753. * Please note that this is an in place operation.
  2754. * @returns the current updated Vector3
  2755. */
  2756. normalize(): Vector3;
  2757. /**
  2758. * Reorders the x y z properties of the vector in place
  2759. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2760. * @returns the current updated vector
  2761. */
  2762. reorderInPlace(order: string): this;
  2763. /**
  2764. * Rotates the vector around 0,0,0 by a quaternion
  2765. * @param quaternion the rotation quaternion
  2766. * @param result vector to store the result
  2767. * @returns the resulting vector
  2768. */
  2769. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2770. /**
  2771. * Rotates a vector around a given point
  2772. * @param quaternion the rotation quaternion
  2773. * @param point the point to rotate around
  2774. * @param result vector to store the result
  2775. * @returns the resulting vector
  2776. */
  2777. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2778. /**
  2779. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2780. * The cross product is then orthogonal to both current and "other"
  2781. * @param other defines the right operand
  2782. * @returns the cross product
  2783. */
  2784. cross(other: Vector3): Vector3;
  2785. /**
  2786. * Normalize the current Vector3 with the given input length.
  2787. * Please note that this is an in place operation.
  2788. * @param len the length of the vector
  2789. * @returns the current updated Vector3
  2790. */
  2791. normalizeFromLength(len: number): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to a new vector
  2794. * @returns the new Vector3
  2795. */
  2796. normalizeToNew(): Vector3;
  2797. /**
  2798. * Normalize the current Vector3 to the reference
  2799. * @param reference define the Vector3 to update
  2800. * @returns the updated Vector3
  2801. */
  2802. normalizeToRef(reference: Vector3): Vector3;
  2803. /**
  2804. * Creates a new Vector3 copied from the current Vector3
  2805. * @returns the new Vector3
  2806. */
  2807. clone(): Vector3;
  2808. /**
  2809. * Copies the given vector coordinates to the current Vector3 ones
  2810. * @param source defines the source Vector3
  2811. * @returns the current updated Vector3
  2812. */
  2813. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * Copies the given floats to the current Vector3 coordinates
  2816. * @param x defines the x coordinate of the operand
  2817. * @param y defines the y coordinate of the operand
  2818. * @param z defines the z coordinate of the operand
  2819. * @returns the current updated Vector3
  2820. */
  2821. copyFromFloats(x: number, y: number, z: number): Vector3;
  2822. /**
  2823. * Copies the given floats to the current Vector3 coordinates
  2824. * @param x defines the x coordinate of the operand
  2825. * @param y defines the y coordinate of the operand
  2826. * @param z defines the z coordinate of the operand
  2827. * @returns the current updated Vector3
  2828. */
  2829. set(x: number, y: number, z: number): Vector3;
  2830. /**
  2831. * Copies the given float to the current Vector3 coordinates
  2832. * @param v defines the x, y and z coordinates of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. setAll(v: number): Vector3;
  2836. /**
  2837. * Get the clip factor between two vectors
  2838. * @param vector0 defines the first operand
  2839. * @param vector1 defines the second operand
  2840. * @param axis defines the axis to use
  2841. * @param size defines the size along the axis
  2842. * @returns the clip factor
  2843. */
  2844. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2845. /**
  2846. * Get angle between two vectors
  2847. * @param vector0 angle between vector0 and vector1
  2848. * @param vector1 angle between vector0 and vector1
  2849. * @param normal direction of the normal
  2850. * @return the angle between vector0 and vector1
  2851. */
  2852. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2853. /**
  2854. * Returns a new Vector3 set from the index "offset" of the given array
  2855. * @param array defines the source array
  2856. * @param offset defines the offset in the source array
  2857. * @returns the new Vector3
  2858. */
  2859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2860. /**
  2861. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2862. * @param array defines the source array
  2863. * @param offset defines the offset in the source array
  2864. * @returns the new Vector3
  2865. * @deprecated Please use FromArray instead.
  2866. */
  2867. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2868. /**
  2869. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2870. * @param array defines the source array
  2871. * @param offset defines the offset in the source array
  2872. * @param result defines the Vector3 where to store the result
  2873. */
  2874. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2875. /**
  2876. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2877. * @param array defines the source array
  2878. * @param offset defines the offset in the source array
  2879. * @param result defines the Vector3 where to store the result
  2880. * @deprecated Please use FromArrayToRef instead.
  2881. */
  2882. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2883. /**
  2884. * Sets the given vector "result" with the given floats.
  2885. * @param x defines the x coordinate of the source
  2886. * @param y defines the y coordinate of the source
  2887. * @param z defines the z coordinate of the source
  2888. * @param result defines the Vector3 where to store the result
  2889. */
  2890. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2891. /**
  2892. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2893. * @returns a new empty Vector3
  2894. */
  2895. static Zero(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2898. * @returns a new unit Vector3
  2899. */
  2900. static One(): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2903. * @returns a new up Vector3
  2904. */
  2905. static Up(): Vector3;
  2906. /**
  2907. * Gets a up Vector3 that must not be updated
  2908. */
  2909. static get UpReadOnly(): DeepImmutable<Vector3>;
  2910. /**
  2911. * Gets a zero Vector3 that must not be updated
  2912. */
  2913. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2916. * @returns a new down Vector3
  2917. */
  2918. static Down(): Vector3;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2921. * @param rightHandedSystem is the scene right-handed (negative z)
  2922. * @returns a new forward Vector3
  2923. */
  2924. static Forward(rightHandedSystem?: boolean): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative-z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Backward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2933. * @returns a new right Vector3
  2934. */
  2935. static Right(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2938. * @returns a new left Vector3
  2939. */
  2940. static Left(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2943. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2944. * @param vector defines the Vector3 to transform
  2945. * @param transformation defines the transformation matrix
  2946. * @returns the transformed Vector3
  2947. */
  2948. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2951. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2952. * @param vector defines the Vector3 to transform
  2953. * @param transformation defines the transformation matrix
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2959. * This method computes tranformed coordinates only, not transformed direction vectors
  2960. * @param x define the x coordinate of the source vector
  2961. * @param y define the y coordinate of the source vector
  2962. * @param z define the z coordinate of the source vector
  2963. * @param transformation defines the transformation matrix
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2970. * @param vector defines the Vector3 to transform
  2971. * @param transformation defines the transformation matrix
  2972. * @returns the new Vector3
  2973. */
  2974. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2975. /**
  2976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2977. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2978. * @param vector defines the Vector3 to transform
  2979. * @param transformation defines the transformation matrix
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2986. * @param x define the x coordinate of the source vector
  2987. * @param y define the y coordinate of the source vector
  2988. * @param z define the z coordinate of the source vector
  2989. * @param transformation defines the transformation matrix
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2995. * @param value1 defines the first control point
  2996. * @param value2 defines the second control point
  2997. * @param value3 defines the third control point
  2998. * @param value4 defines the fourth control point
  2999. * @param amount defines the amount on the spline to use
  3000. * @returns the new Vector3
  3001. */
  3002. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * 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"
  3005. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3006. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3007. * @param value defines the current value
  3008. * @param min defines the lower range value
  3009. * @param max defines the upper range value
  3010. * @returns the new Vector3
  3011. */
  3012. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * 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"
  3015. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3016. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3017. * @param value defines the current value
  3018. * @param min defines the lower range value
  3019. * @param max defines the upper range value
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3023. /**
  3024. * Checks if a given vector is inside a specific range
  3025. * @param v defines the vector to test
  3026. * @param min defines the minimum range
  3027. * @param max defines the maximum range
  3028. */
  3029. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3030. /**
  3031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3032. * @param value1 defines the first control point
  3033. * @param tangent1 defines the first tangent vector
  3034. * @param value2 defines the second control point
  3035. * @param tangent2 defines the second tangent vector
  3036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3037. * @returns the new Vector3
  3038. */
  3039. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3040. /**
  3041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3042. * @param start defines the start value
  3043. * @param end defines the end value
  3044. * @param amount max defines amount between both (between 0 and 1)
  3045. * @returns the new Vector3
  3046. */
  3047. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3050. * @param start defines the start value
  3051. * @param end defines the end value
  3052. * @param amount max defines amount between both (between 0 and 1)
  3053. * @param result defines the Vector3 where to store the result
  3054. */
  3055. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3056. /**
  3057. * Returns the dot product (float) between the vectors "left" and "right"
  3058. * @param left defines the left operand
  3059. * @param right defines the right operand
  3060. * @returns the dot product
  3061. */
  3062. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3063. /**
  3064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3065. * The cross product is then orthogonal to both "left" and "right"
  3066. * @param left defines the left operand
  3067. * @param right defines the right operand
  3068. * @returns the cross product
  3069. */
  3070. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Sets the given vector "result" with the cross product of "left" and "right"
  3073. * The cross product is then orthogonal to both "left" and "right"
  3074. * @param left defines the left operand
  3075. * @param right defines the right operand
  3076. * @param result defines the Vector3 where to store the result
  3077. */
  3078. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3079. /**
  3080. * Returns a new Vector3 as the normalization of the given vector
  3081. * @param vector defines the Vector3 to normalize
  3082. * @returns the new Vector3
  3083. */
  3084. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3085. /**
  3086. * Sets the given vector "result" with the normalization of the given first vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Project a Vector3 onto screen space
  3093. * @param vector defines the Vector3 to project
  3094. * @param world defines the world matrix to use
  3095. * @param transform defines the transform (view x projection) matrix to use
  3096. * @param viewport defines the screen viewport to use
  3097. * @returns the new Vector3
  3098. */
  3099. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3100. /** @hidden */
  3101. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3102. /**
  3103. * Unproject from screen space to object space
  3104. * @param source defines the screen space Vector3 to use
  3105. * @param viewportWidth defines the current width of the viewport
  3106. * @param viewportHeight defines the current height of the viewport
  3107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3108. * @param transform defines the transform (view x projection) matrix to use
  3109. * @returns the new Vector3
  3110. */
  3111. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3112. /**
  3113. * Unproject from screen space to object space
  3114. * @param source defines the screen space Vector3 to use
  3115. * @param viewportWidth defines the current width of the viewport
  3116. * @param viewportHeight defines the current height of the viewport
  3117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3118. * @param view defines the view matrix to use
  3119. * @param projection defines the projection matrix to use
  3120. * @returns the new Vector3
  3121. */
  3122. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3123. /**
  3124. * Unproject from screen space to object space
  3125. * @param source defines the screen space Vector3 to use
  3126. * @param viewportWidth defines the current width of the viewport
  3127. * @param viewportHeight defines the current height of the viewport
  3128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3129. * @param view defines the view matrix to use
  3130. * @param projection defines the projection matrix to use
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param sourceX defines the screen space x coordinate to use
  3137. * @param sourceY defines the screen space y coordinate to use
  3138. * @param sourceZ defines the screen space z coordinate to use
  3139. * @param viewportWidth defines the current width of the viewport
  3140. * @param viewportHeight defines the current height of the viewport
  3141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3142. * @param view defines the view matrix to use
  3143. * @param projection defines the projection matrix to use
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Gets the minimal coordinate values between two Vector3
  3149. * @param left defines the first operand
  3150. * @param right defines the second operand
  3151. * @returns the new Vector3
  3152. */
  3153. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3154. /**
  3155. * Gets the maximal coordinate values between two Vector3
  3156. * @param left defines the first operand
  3157. * @param right defines the second operand
  3158. * @returns the new Vector3
  3159. */
  3160. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Returns the distance between the vectors "value1" and "value2"
  3163. * @param value1 defines the first operand
  3164. * @param value2 defines the second operand
  3165. * @returns the distance
  3166. */
  3167. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3168. /**
  3169. * Returns the squared distance between the vectors "value1" and "value2"
  3170. * @param value1 defines the first operand
  3171. * @param value2 defines the second operand
  3172. * @returns the squared distance
  3173. */
  3174. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3175. /**
  3176. * Returns a new Vector3 located at the center between "value1" and "value2"
  3177. * @param value1 defines the first operand
  3178. * @param value2 defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3184. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3185. * to something in order to rotate it from its local system to the given target system
  3186. * Note: axis1, axis2 and axis3 are normalized during this operation
  3187. * @param axis1 defines the first axis
  3188. * @param axis2 defines the second axis
  3189. * @param axis3 defines the third axis
  3190. * @returns a new Vector3
  3191. */
  3192. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3195. * @param axis1 defines the first axis
  3196. * @param axis2 defines the second axis
  3197. * @param axis3 defines the third axis
  3198. * @param ref defines the Vector3 where to store the result
  3199. */
  3200. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3201. }
  3202. /**
  3203. * Vector4 class created for EulerAngle class conversion to Quaternion
  3204. */
  3205. export class Vector4 {
  3206. /** x value of the vector */
  3207. x: number;
  3208. /** y value of the vector */
  3209. y: number;
  3210. /** z value of the vector */
  3211. z: number;
  3212. /** w value of the vector */
  3213. w: number;
  3214. /**
  3215. * Creates a Vector4 object from the given floats.
  3216. * @param x x value of the vector
  3217. * @param y y value of the vector
  3218. * @param z z value of the vector
  3219. * @param w w value of the vector
  3220. */
  3221. constructor(
  3222. /** x value of the vector */
  3223. x: number,
  3224. /** y value of the vector */
  3225. y: number,
  3226. /** z value of the vector */
  3227. z: number,
  3228. /** w value of the vector */
  3229. w: number);
  3230. /**
  3231. * Returns the string with the Vector4 coordinates.
  3232. * @returns a string containing all the vector values
  3233. */
  3234. toString(): string;
  3235. /**
  3236. * Returns the string "Vector4".
  3237. * @returns "Vector4"
  3238. */
  3239. getClassName(): string;
  3240. /**
  3241. * Returns the Vector4 hash code.
  3242. * @returns a unique hash code
  3243. */
  3244. getHashCode(): number;
  3245. /**
  3246. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3247. * @returns the resulting array
  3248. */
  3249. asArray(): number[];
  3250. /**
  3251. * Populates the given array from the given index with the Vector4 coordinates.
  3252. * @param array array to populate
  3253. * @param index index of the array to start at (default: 0)
  3254. * @returns the Vector4.
  3255. */
  3256. toArray(array: FloatArray, index?: number): Vector4;
  3257. /**
  3258. * Adds the given vector to the current Vector4.
  3259. * @param otherVector the vector to add
  3260. * @returns the updated Vector4.
  3261. */
  3262. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3265. * @param otherVector the vector to add
  3266. * @returns the resulting vector
  3267. */
  3268. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @param result the vector to store the result
  3273. * @returns the current Vector4.
  3274. */
  3275. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3276. /**
  3277. * Subtract in place the given vector from the current Vector4.
  3278. * @param otherVector the vector to subtract
  3279. * @returns the updated Vector4.
  3280. */
  3281. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3284. * @param otherVector the vector to add
  3285. * @returns the new vector with the result
  3286. */
  3287. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to subtract
  3291. * @param result the vector to store the result
  3292. * @returns the current Vector4.
  3293. */
  3294. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3295. /**
  3296. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3297. */
  3298. /**
  3299. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3300. * @param x value to subtract
  3301. * @param y value to subtract
  3302. * @param z value to subtract
  3303. * @param w value to subtract
  3304. * @returns new vector containing the result
  3305. */
  3306. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3309. * @param x value to subtract
  3310. * @param y value to subtract
  3311. * @param z value to subtract
  3312. * @param w value to subtract
  3313. * @param result the vector to store the result in
  3314. * @returns the current Vector4.
  3315. */
  3316. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3317. /**
  3318. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3319. * @returns a new vector with the negated values
  3320. */
  3321. negate(): Vector4;
  3322. /**
  3323. * Negate this vector in place
  3324. * @returns this
  3325. */
  3326. negateInPlace(): Vector4;
  3327. /**
  3328. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3329. * @param result defines the Vector3 object where to store the result
  3330. * @returns the current Vector4
  3331. */
  3332. negateToRef(result: Vector4): Vector4;
  3333. /**
  3334. * Multiplies the current Vector4 coordinates by scale (float).
  3335. * @param scale the number to scale with
  3336. * @returns the updated Vector4.
  3337. */
  3338. scaleInPlace(scale: number): Vector4;
  3339. /**
  3340. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns a new vector with the result
  3343. */
  3344. scale(scale: number): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @param result a vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. scaleToRef(scale: number, result: Vector4): Vector4;
  3352. /**
  3353. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3354. * @param scale defines the scale factor
  3355. * @param result defines the Vector4 object where to store the result
  3356. * @returns the unmodified current Vector4
  3357. */
  3358. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3359. /**
  3360. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3361. * @param otherVector the vector to compare against
  3362. * @returns true if they are equal
  3363. */
  3364. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3367. * @param otherVector vector to compare against
  3368. * @param epsilon (Default: very small number)
  3369. * @returns true if they are equal
  3370. */
  3371. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3372. /**
  3373. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3374. * @param x x value to compare against
  3375. * @param y y value to compare against
  3376. * @param z z value to compare against
  3377. * @param w w value to compare against
  3378. * @returns true if equal
  3379. */
  3380. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3381. /**
  3382. * Multiplies in place the current Vector4 by the given one.
  3383. * @param otherVector vector to multiple with
  3384. * @returns the updated Vector4.
  3385. */
  3386. multiplyInPlace(otherVector: Vector4): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns resulting new vector
  3391. */
  3392. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @param result vector to store the result
  3397. * @returns the current Vector4.
  3398. */
  3399. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3400. /**
  3401. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3402. * @param x x value multiply with
  3403. * @param y y value multiply with
  3404. * @param z z value multiply with
  3405. * @param w w value multiply with
  3406. * @returns resulting new vector
  3407. */
  3408. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3411. * @param otherVector vector to devide with
  3412. * @returns resulting new vector
  3413. */
  3414. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @param result vector to store the result
  3419. * @returns the current Vector4.
  3420. */
  3421. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3422. /**
  3423. * Divides the current Vector3 coordinates by the given ones.
  3424. * @param otherVector vector to devide with
  3425. * @returns the updated Vector3.
  3426. */
  3427. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3430. * @param other defines the second operand
  3431. * @returns the current updated Vector4
  3432. */
  3433. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector4 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. floor(): Vector4;
  3445. /**
  3446. * Gets a new Vector4 from current Vector3 floored values
  3447. * @returns a new Vector4
  3448. */
  3449. fract(): Vector4;
  3450. /**
  3451. * Returns the Vector4 length (float).
  3452. * @returns the length
  3453. */
  3454. length(): number;
  3455. /**
  3456. * Returns the Vector4 squared length (float).
  3457. * @returns the length squared
  3458. */
  3459. lengthSquared(): number;
  3460. /**
  3461. * Normalizes in place the Vector4.
  3462. * @returns the updated Vector4.
  3463. */
  3464. normalize(): Vector4;
  3465. /**
  3466. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3467. * @returns this converted to a new vector3
  3468. */
  3469. toVector3(): Vector3;
  3470. /**
  3471. * Returns a new Vector4 copied from the current one.
  3472. * @returns the new cloned vector
  3473. */
  3474. clone(): Vector4;
  3475. /**
  3476. * Updates the current Vector4 with the given one coordinates.
  3477. * @param source the source vector to copy from
  3478. * @returns the updated Vector4.
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3481. /**
  3482. * Updates the current Vector4 coordinates with the given floats.
  3483. * @param x float to copy from
  3484. * @param y float to copy from
  3485. * @param z float to copy from
  3486. * @param w float to copy from
  3487. * @returns the updated Vector4.
  3488. */
  3489. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Updates the current Vector4 coordinates with the given floats.
  3492. * @param x float to set from
  3493. * @param y float to set from
  3494. * @param z float to set from
  3495. * @param w float to set from
  3496. * @returns the updated Vector4.
  3497. */
  3498. set(x: number, y: number, z: number, w: number): Vector4;
  3499. /**
  3500. * Copies the given float to the current Vector3 coordinates
  3501. * @param v defines the x, y, z and w coordinates of the operand
  3502. * @returns the current updated Vector3
  3503. */
  3504. setAll(v: number): Vector4;
  3505. /**
  3506. * Returns a new Vector4 set from the starting index of the given array.
  3507. * @param array the array to pull values from
  3508. * @param offset the offset into the array to start at
  3509. * @returns the new vector
  3510. */
  3511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3512. /**
  3513. * Updates the given vector "result" from the starting index of the given array.
  3514. * @param array the array to pull values from
  3515. * @param offset the offset into the array to start at
  3516. * @param result the vector to store the result in
  3517. */
  3518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3519. /**
  3520. * Updates the given vector "result" from the starting index of the given Float32Array.
  3521. * @param array the array to pull values from
  3522. * @param offset the offset into the array to start at
  3523. * @param result the vector to store the result in
  3524. */
  3525. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3526. /**
  3527. * Updates the given vector "result" coordinates from the given floats.
  3528. * @param x float to set from
  3529. * @param y float to set from
  3530. * @param z float to set from
  3531. * @param w float to set from
  3532. * @param result the vector to the floats in
  3533. */
  3534. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3535. /**
  3536. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3537. * @returns the new vector
  3538. */
  3539. static Zero(): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3542. * @returns the new vector
  3543. */
  3544. static One(): Vector4;
  3545. /**
  3546. * Returns a new normalized Vector4 from the given one.
  3547. * @param vector the vector to normalize
  3548. * @returns the vector
  3549. */
  3550. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the normalization of the given one.
  3553. * @param vector the vector to normalize
  3554. * @param result the vector to store the result in
  3555. */
  3556. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3557. /**
  3558. * Returns a vector with the minimum values from the left and right vectors
  3559. * @param left left vector to minimize
  3560. * @param right right vector to minimize
  3561. * @returns a new vector with the minimum of the left and right vector values
  3562. */
  3563. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3564. /**
  3565. * Returns a vector with the maximum values from the left and right vectors
  3566. * @param left left vector to maximize
  3567. * @param right right vector to maximize
  3568. * @returns a new vector with the maximum of the left and right vector values
  3569. */
  3570. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3571. /**
  3572. * Returns the distance (float) between the vectors "value1" and "value2".
  3573. * @param value1 value to calulate the distance between
  3574. * @param value2 value to calulate the distance between
  3575. * @return the distance between the two vectors
  3576. */
  3577. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3578. /**
  3579. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3580. * @param value1 value to calulate the distance between
  3581. * @param value2 value to calulate the distance between
  3582. * @return the distance between the two vectors squared
  3583. */
  3584. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3585. /**
  3586. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3587. * @param value1 value to calulate the center between
  3588. * @param value2 value to calulate the center between
  3589. * @return the center between the two vectors
  3590. */
  3591. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3594. * This methods computes transformed normalized direction vectors only.
  3595. * @param vector the vector to transform
  3596. * @param transformation the transformation matrix to apply
  3597. * @returns the new vector
  3598. */
  3599. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3600. /**
  3601. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3602. * This methods computes transformed normalized direction vectors only.
  3603. * @param vector the vector to transform
  3604. * @param transformation the transformation matrix to apply
  3605. * @param result the vector to store the result in
  3606. */
  3607. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3608. /**
  3609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param x value to transform
  3612. * @param y value to transform
  3613. * @param z value to transform
  3614. * @param w value to transform
  3615. * @param transformation the transformation matrix to apply
  3616. * @param result the vector to store the results in
  3617. */
  3618. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3619. /**
  3620. * Creates a new Vector4 from a Vector3
  3621. * @param source defines the source data
  3622. * @param w defines the 4th component (default is 0)
  3623. * @returns a new Vector4
  3624. */
  3625. static FromVector3(source: Vector3, w?: number): Vector4;
  3626. }
  3627. /**
  3628. * Class used to store quaternion data
  3629. * @see https://en.wikipedia.org/wiki/Quaternion
  3630. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3631. */
  3632. export class Quaternion {
  3633. /** @hidden */
  3634. _x: number;
  3635. /** @hidden */
  3636. _y: number;
  3637. /** @hidden */
  3638. _z: number;
  3639. /** @hidden */
  3640. _w: number;
  3641. /** @hidden */
  3642. _isDirty: boolean;
  3643. /** Gets or sets the x coordinate */
  3644. get x(): number;
  3645. set x(value: number);
  3646. /** Gets or sets the y coordinate */
  3647. get y(): number;
  3648. set y(value: number);
  3649. /** Gets or sets the z coordinate */
  3650. get z(): number;
  3651. set z(value: number);
  3652. /** Gets or sets the w coordinate */
  3653. get w(): number;
  3654. set w(value: number);
  3655. /**
  3656. * Creates a new Quaternion from the given floats
  3657. * @param x defines the first component (0 by default)
  3658. * @param y defines the second component (0 by default)
  3659. * @param z defines the third component (0 by default)
  3660. * @param w defines the fourth component (1.0 by default)
  3661. */
  3662. constructor(x?: number, y?: number, z?: number, w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * 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)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * 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
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. 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;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. 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;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * 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"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * 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".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * 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"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * 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".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * 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.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * 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)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @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
  5102. * @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
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. 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);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. 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;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. 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;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. 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);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * 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;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * 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).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * 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).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * 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.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * 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.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * 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.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * 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.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * 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).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * 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).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * 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.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * 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.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * 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.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * 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.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * 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).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * 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).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * 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.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * 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.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * 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.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * 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.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * 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).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * 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).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * 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.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * 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.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * 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.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * 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.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { Scene } from "babylonjs/scene";
  9454. import { ActionManager } from "babylonjs/Actions/actionManager";
  9455. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9456. import { Node } from "babylonjs/node";
  9457. /**
  9458. * Interface used to define Action
  9459. */
  9460. export interface IAction {
  9461. /**
  9462. * Trigger for the action
  9463. */
  9464. trigger: number;
  9465. /** Options of the trigger */
  9466. triggerOptions: any;
  9467. /**
  9468. * Gets the trigger parameters
  9469. * @returns the trigger parameters
  9470. */
  9471. getTriggerParameter(): any;
  9472. /**
  9473. * Internal only - executes current action event
  9474. * @hidden
  9475. */
  9476. _executeCurrent(evt?: ActionEvent): void;
  9477. /**
  9478. * Serialize placeholder for child classes
  9479. * @param parent of child
  9480. * @returns the serialized object
  9481. */
  9482. serialize(parent: any): any;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _prepare(): void;
  9488. /**
  9489. * Internal only - manager for action
  9490. * @hidden
  9491. */
  9492. _actionManager: AbstractActionManager;
  9493. /**
  9494. * Adds action to chain of actions, may be a DoNothingAction
  9495. * @param action defines the next action to execute
  9496. * @returns The action passed in
  9497. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9498. */
  9499. then(action: IAction): IAction;
  9500. }
  9501. /**
  9502. * The action to be carried out following a trigger
  9503. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9504. */
  9505. export class Action implements IAction {
  9506. /** the trigger, with or without parameters, for the action */
  9507. triggerOptions: any;
  9508. /**
  9509. * Trigger for the action
  9510. */
  9511. trigger: number;
  9512. /**
  9513. * Internal only - manager for action
  9514. * @hidden
  9515. */
  9516. _actionManager: ActionManager;
  9517. private _nextActiveAction;
  9518. private _child;
  9519. private _condition?;
  9520. private _triggerParameter;
  9521. /**
  9522. * An event triggered prior to action being executed.
  9523. */
  9524. onBeforeExecuteObservable: Observable<Action>;
  9525. /**
  9526. * Creates a new Action
  9527. * @param triggerOptions the trigger, with or without parameters, for the action
  9528. * @param condition an optional determinant of action
  9529. */
  9530. constructor(
  9531. /** the trigger, with or without parameters, for the action */
  9532. triggerOptions: any, condition?: Condition);
  9533. /**
  9534. * Internal only
  9535. * @hidden
  9536. */
  9537. _prepare(): void;
  9538. /**
  9539. * Gets the trigger parameters
  9540. * @returns the trigger parameters
  9541. */
  9542. getTriggerParameter(): any;
  9543. /**
  9544. * Internal only - executes current action event
  9545. * @hidden
  9546. */
  9547. _executeCurrent(evt?: ActionEvent): void;
  9548. /**
  9549. * Execute placeholder for child classes
  9550. * @param evt optional action event
  9551. */
  9552. execute(evt?: ActionEvent): void;
  9553. /**
  9554. * Skips to next active action
  9555. */
  9556. skipToNextActiveAction(): void;
  9557. /**
  9558. * Adds action to chain of actions, may be a DoNothingAction
  9559. * @param action defines the next action to execute
  9560. * @returns The action passed in
  9561. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9562. */
  9563. then(action: Action): Action;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _getProperty(propertyPath: string): string;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. _getEffectiveTarget(target: any, propertyPath: string): any;
  9574. /**
  9575. * Serialize placeholder for child classes
  9576. * @param parent of child
  9577. * @returns the serialized object
  9578. */
  9579. serialize(parent: any): any;
  9580. /**
  9581. * Internal only called by serialize
  9582. * @hidden
  9583. */
  9584. protected _serialize(serializedAction: any, parent?: any): any;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. static _SerializeValueAsString: (value: any) => string;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. static _GetTargetProperty: (target: Scene | Node) => {
  9595. name: string;
  9596. targetType: string;
  9597. value: string;
  9598. };
  9599. }
  9600. }
  9601. declare module "babylonjs/Actions/condition" {
  9602. import { ActionManager } from "babylonjs/Actions/actionManager";
  9603. /**
  9604. * A Condition applied to an Action
  9605. */
  9606. export class Condition {
  9607. /**
  9608. * Internal only - manager for action
  9609. * @hidden
  9610. */
  9611. _actionManager: ActionManager;
  9612. /**
  9613. * Internal only
  9614. * @hidden
  9615. */
  9616. _evaluationId: number;
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _currentResult: boolean;
  9622. /**
  9623. * Creates a new Condition
  9624. * @param actionManager the manager of the action the condition is applied to
  9625. */
  9626. constructor(actionManager: ActionManager);
  9627. /**
  9628. * Check if the current condition is valid
  9629. * @returns a boolean
  9630. */
  9631. isValid(): boolean;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. _getProperty(propertyPath: string): string;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. _getEffectiveTarget(target: any, propertyPath: string): any;
  9642. /**
  9643. * Serialize placeholder for child classes
  9644. * @returns the serialized object
  9645. */
  9646. serialize(): any;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. protected _serialize(serializedCondition: any): any;
  9652. }
  9653. /**
  9654. * Defines specific conditional operators as extensions of Condition
  9655. */
  9656. export class ValueCondition extends Condition {
  9657. /** path to specify the property of the target the conditional operator uses */
  9658. propertyPath: string;
  9659. /** the value compared by the conditional operator against the current value of the property */
  9660. value: any;
  9661. /** the conditional operator, default ValueCondition.IsEqual */
  9662. operator: number;
  9663. /**
  9664. * Internal only
  9665. * @hidden
  9666. */
  9667. private static _IsEqual;
  9668. /**
  9669. * Internal only
  9670. * @hidden
  9671. */
  9672. private static _IsDifferent;
  9673. /**
  9674. * Internal only
  9675. * @hidden
  9676. */
  9677. private static _IsGreater;
  9678. /**
  9679. * Internal only
  9680. * @hidden
  9681. */
  9682. private static _IsLesser;
  9683. /**
  9684. * returns the number for IsEqual
  9685. */
  9686. static get IsEqual(): number;
  9687. /**
  9688. * Returns the number for IsDifferent
  9689. */
  9690. static get IsDifferent(): number;
  9691. /**
  9692. * Returns the number for IsGreater
  9693. */
  9694. static get IsGreater(): number;
  9695. /**
  9696. * Returns the number for IsLesser
  9697. */
  9698. static get IsLesser(): number;
  9699. /**
  9700. * Internal only The action manager for the condition
  9701. * @hidden
  9702. */
  9703. _actionManager: ActionManager;
  9704. /**
  9705. * Internal only
  9706. * @hidden
  9707. */
  9708. private _target;
  9709. /**
  9710. * Internal only
  9711. * @hidden
  9712. */
  9713. private _effectiveTarget;
  9714. /**
  9715. * Internal only
  9716. * @hidden
  9717. */
  9718. private _property;
  9719. /**
  9720. * Creates a new ValueCondition
  9721. * @param actionManager manager for the action the condition applies to
  9722. * @param target for the action
  9723. * @param propertyPath path to specify the property of the target the conditional operator uses
  9724. * @param value the value compared by the conditional operator against the current value of the property
  9725. * @param operator the conditional operator, default ValueCondition.IsEqual
  9726. */
  9727. constructor(actionManager: ActionManager, target: any,
  9728. /** path to specify the property of the target the conditional operator uses */
  9729. propertyPath: string,
  9730. /** the value compared by the conditional operator against the current value of the property */
  9731. value: any,
  9732. /** the conditional operator, default ValueCondition.IsEqual */
  9733. operator?: number);
  9734. /**
  9735. * Compares the given value with the property value for the specified conditional operator
  9736. * @returns the result of the comparison
  9737. */
  9738. isValid(): boolean;
  9739. /**
  9740. * Serialize the ValueCondition into a JSON compatible object
  9741. * @returns serialization object
  9742. */
  9743. serialize(): any;
  9744. /**
  9745. * Gets the name of the conditional operator for the ValueCondition
  9746. * @param operator the conditional operator
  9747. * @returns the name
  9748. */
  9749. static GetOperatorName(operator: number): string;
  9750. }
  9751. /**
  9752. * Defines a predicate condition as an extension of Condition
  9753. */
  9754. export class PredicateCondition extends Condition {
  9755. /** defines the predicate function used to validate the condition */
  9756. predicate: () => boolean;
  9757. /**
  9758. * Internal only - manager for action
  9759. * @hidden
  9760. */
  9761. _actionManager: ActionManager;
  9762. /**
  9763. * Creates a new PredicateCondition
  9764. * @param actionManager manager for the action the condition applies to
  9765. * @param predicate defines the predicate function used to validate the condition
  9766. */
  9767. constructor(actionManager: ActionManager,
  9768. /** defines the predicate function used to validate the condition */
  9769. predicate: () => boolean);
  9770. /**
  9771. * @returns the validity of the predicate condition
  9772. */
  9773. isValid(): boolean;
  9774. }
  9775. /**
  9776. * Defines a state condition as an extension of Condition
  9777. */
  9778. export class StateCondition extends Condition {
  9779. /** Value to compare with target state */
  9780. value: string;
  9781. /**
  9782. * Internal only - manager for action
  9783. * @hidden
  9784. */
  9785. _actionManager: ActionManager;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. private _target;
  9791. /**
  9792. * Creates a new StateCondition
  9793. * @param actionManager manager for the action the condition applies to
  9794. * @param target of the condition
  9795. * @param value to compare with target state
  9796. */
  9797. constructor(actionManager: ActionManager, target: any,
  9798. /** Value to compare with target state */
  9799. value: string);
  9800. /**
  9801. * Gets a boolean indicating if the current condition is met
  9802. * @returns the validity of the state
  9803. */
  9804. isValid(): boolean;
  9805. /**
  9806. * Serialize the StateCondition into a JSON compatible object
  9807. * @returns serialization object
  9808. */
  9809. serialize(): any;
  9810. }
  9811. }
  9812. declare module "babylonjs/Actions/directActions" {
  9813. import { Action } from "babylonjs/Actions/action";
  9814. import { Condition } from "babylonjs/Actions/condition";
  9815. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9816. /**
  9817. * This defines an action responsible to toggle a boolean once triggered.
  9818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9819. */
  9820. export class SwitchBooleanAction extends Action {
  9821. /**
  9822. * The path to the boolean property in the target object
  9823. */
  9824. propertyPath: string;
  9825. private _target;
  9826. private _effectiveTarget;
  9827. private _property;
  9828. /**
  9829. * Instantiate the action
  9830. * @param triggerOptions defines the trigger options
  9831. * @param target defines the object containing the boolean
  9832. * @param propertyPath defines the path to the boolean property in the target object
  9833. * @param condition defines the trigger related conditions
  9834. */
  9835. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9836. /** @hidden */
  9837. _prepare(): void;
  9838. /**
  9839. * Execute the action toggle the boolean value.
  9840. */
  9841. execute(): void;
  9842. /**
  9843. * Serializes the actions and its related information.
  9844. * @param parent defines the object to serialize in
  9845. * @returns the serialized object
  9846. */
  9847. serialize(parent: any): any;
  9848. }
  9849. /**
  9850. * This defines an action responsible to set a the state field of the target
  9851. * to a desired value once triggered.
  9852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9853. */
  9854. export class SetStateAction extends Action {
  9855. /**
  9856. * The value to store in the state field.
  9857. */
  9858. value: string;
  9859. private _target;
  9860. /**
  9861. * Instantiate the action
  9862. * @param triggerOptions defines the trigger options
  9863. * @param target defines the object containing the state property
  9864. * @param value defines the value to store in the state field
  9865. * @param condition defines the trigger related conditions
  9866. */
  9867. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9868. /**
  9869. * Execute the action and store the value on the target state property.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a property of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetValueAction extends Action {
  9885. /**
  9886. * The path of the property to set in the target.
  9887. */
  9888. propertyPath: string;
  9889. /**
  9890. * The value to set in the property
  9891. */
  9892. value: any;
  9893. private _target;
  9894. private _effectiveTarget;
  9895. private _property;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the object containing the property
  9900. * @param propertyPath defines the path of the property to set in the target
  9901. * @param value defines the value to set in the property
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and set the targetted property to the desired value.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to increment the target value
  9920. * to a desired value once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class IncrementValueAction extends Action {
  9924. /**
  9925. * The path of the property to increment in the target.
  9926. */
  9927. propertyPath: string;
  9928. /**
  9929. * The value we should increment the property by.
  9930. */
  9931. value: any;
  9932. private _target;
  9933. private _effectiveTarget;
  9934. private _property;
  9935. /**
  9936. * Instantiate the action
  9937. * @param triggerOptions defines the trigger options
  9938. * @param target defines the object containing the property
  9939. * @param propertyPath defines the path of the property to increment in the target
  9940. * @param value defines the value value we should increment the property by
  9941. * @param condition defines the trigger related conditions
  9942. */
  9943. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9944. /** @hidden */
  9945. _prepare(): void;
  9946. /**
  9947. * Execute the action and increment the target of the value amount.
  9948. */
  9949. execute(): void;
  9950. /**
  9951. * Serializes the actions and its related information.
  9952. * @param parent defines the object to serialize in
  9953. * @returns the serialized object
  9954. */
  9955. serialize(parent: any): any;
  9956. }
  9957. /**
  9958. * This defines an action responsible to start an animation once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class PlayAnimationAction extends Action {
  9962. /**
  9963. * Where the animation should start (animation frame)
  9964. */
  9965. from: number;
  9966. /**
  9967. * Where the animation should stop (animation frame)
  9968. */
  9969. to: number;
  9970. /**
  9971. * Define if the animation should loop or stop after the first play.
  9972. */
  9973. loop?: boolean;
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target animation or animation name
  9979. * @param from defines from where the animation should start (animation frame)
  9980. * @param end defines where the animation should stop (animation frame)
  9981. * @param loop defines if the animation should loop or stop after the first play
  9982. * @param condition defines the trigger related conditions
  9983. */
  9984. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9985. /** @hidden */
  9986. _prepare(): void;
  9987. /**
  9988. * Execute the action and play the animation.
  9989. */
  9990. execute(): void;
  9991. /**
  9992. * Serializes the actions and its related information.
  9993. * @param parent defines the object to serialize in
  9994. * @returns the serialized object
  9995. */
  9996. serialize(parent: any): any;
  9997. }
  9998. /**
  9999. * This defines an action responsible to stop an animation once triggered.
  10000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10001. */
  10002. export class StopAnimationAction extends Action {
  10003. private _target;
  10004. /**
  10005. * Instantiate the action
  10006. * @param triggerOptions defines the trigger options
  10007. * @param target defines the target animation or animation name
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions: any, target: any, condition?: Condition);
  10011. /** @hidden */
  10012. _prepare(): void;
  10013. /**
  10014. * Execute the action and stop the animation.
  10015. */
  10016. execute(): void;
  10017. /**
  10018. * Serializes the actions and its related information.
  10019. * @param parent defines the object to serialize in
  10020. * @returns the serialized object
  10021. */
  10022. serialize(parent: any): any;
  10023. }
  10024. /**
  10025. * This defines an action responsible that does nothing once triggered.
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10027. */
  10028. export class DoNothingAction extends Action {
  10029. /**
  10030. * Instantiate the action
  10031. * @param triggerOptions defines the trigger options
  10032. * @param condition defines the trigger related conditions
  10033. */
  10034. constructor(triggerOptions?: any, condition?: Condition);
  10035. /**
  10036. * Execute the action and do nothing.
  10037. */
  10038. execute(): void;
  10039. /**
  10040. * Serializes the actions and its related information.
  10041. * @param parent defines the object to serialize in
  10042. * @returns the serialized object
  10043. */
  10044. serialize(parent: any): any;
  10045. }
  10046. /**
  10047. * This defines an action responsible to trigger several actions once triggered.
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10049. */
  10050. export class CombineAction extends Action {
  10051. /**
  10052. * The list of aggregated animations to run.
  10053. */
  10054. children: Action[];
  10055. /**
  10056. * Instantiate the action
  10057. * @param triggerOptions defines the trigger options
  10058. * @param children defines the list of aggregated animations to run
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and executes all the aggregated actions.
  10066. */
  10067. execute(evt: ActionEvent): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to run code (external event) once triggered.
  10077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10078. */
  10079. export class ExecuteCodeAction extends Action {
  10080. /**
  10081. * The callback function to run.
  10082. */
  10083. func: (evt: ActionEvent) => void;
  10084. /**
  10085. * Instantiate the action
  10086. * @param triggerOptions defines the trigger options
  10087. * @param func defines the callback function to run
  10088. * @param condition defines the trigger related conditions
  10089. */
  10090. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10091. /**
  10092. * Execute the action and run the attached code.
  10093. */
  10094. execute(evt: ActionEvent): void;
  10095. }
  10096. /**
  10097. * This defines an action responsible to set the parent property of the target once triggered.
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10099. */
  10100. export class SetParentAction extends Action {
  10101. private _parent;
  10102. private _target;
  10103. /**
  10104. * Instantiate the action
  10105. * @param triggerOptions defines the trigger options
  10106. * @param target defines the target containing the parent property
  10107. * @param parent defines from where the animation should start (animation frame)
  10108. * @param condition defines the trigger related conditions
  10109. */
  10110. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10111. /** @hidden */
  10112. _prepare(): void;
  10113. /**
  10114. * Execute the action and set the parent property.
  10115. */
  10116. execute(): void;
  10117. /**
  10118. * Serializes the actions and its related information.
  10119. * @param parent defines the object to serialize in
  10120. * @returns the serialized object
  10121. */
  10122. serialize(parent: any): any;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/actionManager" {
  10126. import { Nullable } from "babylonjs/types";
  10127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10128. import { Scene } from "babylonjs/scene";
  10129. import { IAction } from "babylonjs/Actions/action";
  10130. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10131. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10132. /**
  10133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10136. */
  10137. export class ActionManager extends AbstractActionManager {
  10138. /**
  10139. * Nothing
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly NothingTrigger: number;
  10143. /**
  10144. * On pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickTrigger: number;
  10148. /**
  10149. * On left pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnLeftPickTrigger: number;
  10153. /**
  10154. * On right pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnRightPickTrigger: number;
  10158. /**
  10159. * On center pick
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnCenterPickTrigger: number;
  10163. /**
  10164. * On pick down
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPickDownTrigger: number;
  10168. /**
  10169. * On double pick
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnDoublePickTrigger: number;
  10173. /**
  10174. * On pick up
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPickUpTrigger: number;
  10178. /**
  10179. * On pick out.
  10180. * This trigger will only be raised if you also declared a OnPickDown
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickOutTrigger: number;
  10184. /**
  10185. * On long press
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnLongPressTrigger: number;
  10189. /**
  10190. * On pointer over
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOverTrigger: number;
  10194. /**
  10195. * On pointer out
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnPointerOutTrigger: number;
  10199. /**
  10200. * On every frame
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnEveryFrameTrigger: number;
  10204. /**
  10205. * On intersection enter
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionEnterTrigger: number;
  10209. /**
  10210. * On intersection exit
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnIntersectionExitTrigger: number;
  10214. /**
  10215. * On key down
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyDownTrigger: number;
  10219. /**
  10220. * On key up
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnKeyUpTrigger: number;
  10224. private _scene;
  10225. /**
  10226. * Creates a new action manager
  10227. * @param scene defines the hosting scene
  10228. */
  10229. constructor(scene: Scene);
  10230. /**
  10231. * Releases all associated resources
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * Gets hosting scene
  10236. * @returns the hosting scene
  10237. */
  10238. getScene(): Scene;
  10239. /**
  10240. * Does this action manager handles actions of any of the given triggers
  10241. * @param triggers defines the triggers to be tested
  10242. * @return a boolean indicating whether one (or more) of the triggers is handled
  10243. */
  10244. hasSpecificTriggers(triggers: number[]): boolean;
  10245. /**
  10246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10247. * speed.
  10248. * @param triggerA defines the trigger to be tested
  10249. * @param triggerB defines the trigger to be tested
  10250. * @return a boolean indicating whether one (or more) of the triggers is handled
  10251. */
  10252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10253. /**
  10254. * Does this action manager handles actions of a given trigger
  10255. * @param trigger defines the trigger to be tested
  10256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10257. * @return whether the trigger is handled
  10258. */
  10259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10260. /**
  10261. * Does this action manager has pointer triggers
  10262. */
  10263. get hasPointerTriggers(): boolean;
  10264. /**
  10265. * Does this action manager has pick triggers
  10266. */
  10267. get hasPickTriggers(): boolean;
  10268. /**
  10269. * Registers an action to this action manager
  10270. * @param action defines the action to be registered
  10271. * @return the action amended (prepared) after registration
  10272. */
  10273. registerAction(action: IAction): Nullable<IAction>;
  10274. /**
  10275. * Unregisters an action to this action manager
  10276. * @param action defines the action to be unregistered
  10277. * @return a boolean indicating whether the action has been unregistered
  10278. */
  10279. unregisterAction(action: IAction): Boolean;
  10280. /**
  10281. * Process a specific trigger
  10282. * @param trigger defines the trigger to process
  10283. * @param evt defines the event details to be processed
  10284. */
  10285. processTrigger(trigger: number, evt?: IActionEvent): void;
  10286. /** @hidden */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /** @hidden */
  10289. _getProperty(propertyPath: string): string;
  10290. /**
  10291. * Serialize this manager to a JSON object
  10292. * @param name defines the property name to store this manager
  10293. * @returns a JSON representation of this manager
  10294. */
  10295. serialize(name: string): any;
  10296. /**
  10297. * Creates a new ActionManager from a JSON data
  10298. * @param parsedActions defines the JSON data to read from
  10299. * @param object defines the hosting mesh
  10300. * @param scene defines the hosting scene
  10301. */
  10302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10303. /**
  10304. * Get a trigger name by index
  10305. * @param trigger defines the trigger index
  10306. * @returns a trigger name
  10307. */
  10308. static GetTriggerName(trigger: number): string;
  10309. }
  10310. }
  10311. declare module "babylonjs/Sprites/sprite" {
  10312. import { Vector3 } from "babylonjs/Maths/math.vector";
  10313. import { Nullable } from "babylonjs/types";
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10316. import { Color4 } from "babylonjs/Maths/math.color";
  10317. import { Observable } from "babylonjs/Misc/observable";
  10318. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10319. import { Animation } from "babylonjs/Animations/animation";
  10320. /**
  10321. * Class used to represent a sprite
  10322. * @see https://doc.babylonjs.com/babylon101/sprites
  10323. */
  10324. export class Sprite implements IAnimatable {
  10325. /** defines the name */
  10326. name: string;
  10327. /** Gets or sets the current world position */
  10328. position: Vector3;
  10329. /** Gets or sets the main color */
  10330. color: Color4;
  10331. /** Gets or sets the width */
  10332. width: number;
  10333. /** Gets or sets the height */
  10334. height: number;
  10335. /** Gets or sets rotation angle */
  10336. angle: number;
  10337. /** Gets or sets the cell index in the sprite sheet */
  10338. cellIndex: number;
  10339. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10340. cellRef: string;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10342. invertU: boolean;
  10343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10344. invertV: boolean;
  10345. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10346. disposeWhenFinishedAnimating: boolean;
  10347. /** Gets the list of attached animations */
  10348. animations: Nullable<Array<Animation>>;
  10349. /** Gets or sets a boolean indicating if the sprite can be picked */
  10350. isPickable: boolean;
  10351. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10352. useAlphaForPicking: boolean;
  10353. /** @hidden */
  10354. _xOffset: number;
  10355. /** @hidden */
  10356. _yOffset: number;
  10357. /** @hidden */
  10358. _xSize: number;
  10359. /** @hidden */
  10360. _ySize: number;
  10361. /**
  10362. * Gets or sets the associated action manager
  10363. */
  10364. actionManager: Nullable<ActionManager>;
  10365. /**
  10366. * An event triggered when the control has been disposed
  10367. */
  10368. onDisposeObservable: Observable<Sprite>;
  10369. private _animationStarted;
  10370. private _loopAnimation;
  10371. private _fromIndex;
  10372. private _toIndex;
  10373. private _delay;
  10374. private _direction;
  10375. private _manager;
  10376. private _time;
  10377. private _onAnimationEnd;
  10378. /**
  10379. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10380. */
  10381. isVisible: boolean;
  10382. /**
  10383. * Gets or sets the sprite size
  10384. */
  10385. get size(): number;
  10386. set size(value: number);
  10387. /**
  10388. * Returns a boolean indicating if the animation is started
  10389. */
  10390. get animationStarted(): boolean;
  10391. /**
  10392. * Gets or sets the unique id of the sprite
  10393. */
  10394. uniqueId: number;
  10395. /**
  10396. * Gets the manager of this sprite
  10397. */
  10398. get manager(): ISpriteManager;
  10399. /**
  10400. * Creates a new Sprite
  10401. * @param name defines the name
  10402. * @param manager defines the manager
  10403. */
  10404. constructor(
  10405. /** defines the name */
  10406. name: string, manager: ISpriteManager);
  10407. /**
  10408. * Returns the string "Sprite"
  10409. * @returns "Sprite"
  10410. */
  10411. getClassName(): string;
  10412. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10413. get fromIndex(): number;
  10414. set fromIndex(value: number);
  10415. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10416. get toIndex(): number;
  10417. set toIndex(value: number);
  10418. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10419. get loopAnimation(): boolean;
  10420. set loopAnimation(value: boolean);
  10421. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10422. get delay(): number;
  10423. set delay(value: number);
  10424. /**
  10425. * Starts an animation
  10426. * @param from defines the initial key
  10427. * @param to defines the end key
  10428. * @param loop defines if the animation must loop
  10429. * @param delay defines the start delay (in ms)
  10430. * @param onAnimationEnd defines a callback to call when animation ends
  10431. */
  10432. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10433. /** Stops current animation (if any) */
  10434. stopAnimation(): void;
  10435. /** @hidden */
  10436. _animate(deltaTime: number): void;
  10437. /** Release associated resources */
  10438. dispose(): void;
  10439. /**
  10440. * Serializes the sprite to a JSON object
  10441. * @returns the JSON object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Parses a JSON object to create a new sprite
  10446. * @param parsedSprite The JSON object to parse
  10447. * @param manager defines the hosting manager
  10448. * @returns the new sprite
  10449. */
  10450. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10451. }
  10452. }
  10453. declare module "babylonjs/Collisions/pickingInfo" {
  10454. import { Nullable } from "babylonjs/types";
  10455. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10457. import { Sprite } from "babylonjs/Sprites/sprite";
  10458. import { Ray } from "babylonjs/Culling/ray";
  10459. /**
  10460. * Information about the result of picking within a scene
  10461. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10462. */
  10463. export class PickingInfo {
  10464. /** @hidden */
  10465. _pickingUnavailable: boolean;
  10466. /**
  10467. * If the pick collided with an object
  10468. */
  10469. hit: boolean;
  10470. /**
  10471. * Distance away where the pick collided
  10472. */
  10473. distance: number;
  10474. /**
  10475. * The location of pick collision
  10476. */
  10477. pickedPoint: Nullable<Vector3>;
  10478. /**
  10479. * The mesh corresponding the the pick collision
  10480. */
  10481. pickedMesh: Nullable<AbstractMesh>;
  10482. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bu: number;
  10484. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10485. bv: number;
  10486. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. faceId: number;
  10488. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10489. subMeshFaceId: number;
  10490. /** Id of the the submesh that was picked */
  10491. subMeshId: number;
  10492. /** If a sprite was picked, this will be the sprite the pick collided with */
  10493. pickedSprite: Nullable<Sprite>;
  10494. /**
  10495. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10496. */
  10497. originMesh: Nullable<AbstractMesh>;
  10498. /**
  10499. * The ray that was used to perform the picking.
  10500. */
  10501. ray: Nullable<Ray>;
  10502. /**
  10503. * Gets the normal correspodning to the face the pick collided with
  10504. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10505. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10506. * @returns The normal correspodning to the face the pick collided with
  10507. */
  10508. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10509. /**
  10510. * Gets the texture coordinates of where the pick occured
  10511. * @returns the vector containing the coordnates of the texture
  10512. */
  10513. getTextureCoordinates(): Nullable<Vector2>;
  10514. }
  10515. }
  10516. declare module "babylonjs/Culling/ray" {
  10517. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10520. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10521. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10522. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10523. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10524. import { Plane } from "babylonjs/Maths/math.plane";
  10525. /**
  10526. * Class representing a ray with position and direction
  10527. */
  10528. export class Ray {
  10529. /** origin point */
  10530. origin: Vector3;
  10531. /** direction */
  10532. direction: Vector3;
  10533. /** length of the ray */
  10534. length: number;
  10535. private static readonly TmpVector3;
  10536. private _tmpRay;
  10537. /**
  10538. * Creates a new ray
  10539. * @param origin origin point
  10540. * @param direction direction
  10541. * @param length length of the ray
  10542. */
  10543. constructor(
  10544. /** origin point */
  10545. origin: Vector3,
  10546. /** direction */
  10547. direction: Vector3,
  10548. /** length of the ray */
  10549. length?: number);
  10550. /**
  10551. * Checks if the ray intersects a box
  10552. * This does not account for the ray lenght by design to improve perfs.
  10553. * @param minimum bound of the box
  10554. * @param maximum bound of the box
  10555. * @param intersectionTreshold extra extend to be added to the box in all direction
  10556. * @returns if the box was hit
  10557. */
  10558. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10559. /**
  10560. * Checks if the ray intersects a box
  10561. * This does not account for the ray lenght by design to improve perfs.
  10562. * @param box the bounding box to check
  10563. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10564. * @returns if the box was hit
  10565. */
  10566. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10567. /**
  10568. * If the ray hits a sphere
  10569. * @param sphere the bounding sphere to check
  10570. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10571. * @returns true if it hits the sphere
  10572. */
  10573. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10574. /**
  10575. * If the ray hits a triange
  10576. * @param vertex0 triangle vertex
  10577. * @param vertex1 triangle vertex
  10578. * @param vertex2 triangle vertex
  10579. * @returns intersection information if hit
  10580. */
  10581. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10582. /**
  10583. * Checks if ray intersects a plane
  10584. * @param plane the plane to check
  10585. * @returns the distance away it was hit
  10586. */
  10587. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10588. /**
  10589. * Calculate the intercept of a ray on a given axis
  10590. * @param axis to check 'x' | 'y' | 'z'
  10591. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10592. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10593. */
  10594. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10595. /**
  10596. * Checks if ray intersects a mesh
  10597. * @param mesh the mesh to check
  10598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10599. * @returns picking info of the intersecton
  10600. */
  10601. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10602. /**
  10603. * Checks if ray intersects a mesh
  10604. * @param meshes the meshes to check
  10605. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10606. * @param results array to store result in
  10607. * @returns Array of picking infos
  10608. */
  10609. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10610. private _comparePickingInfo;
  10611. private static smallnum;
  10612. private static rayl;
  10613. /**
  10614. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10615. * @param sega the first point of the segment to test the intersection against
  10616. * @param segb the second point of the segment to test the intersection against
  10617. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10618. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10619. */
  10620. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10621. /**
  10622. * Update the ray from viewport position
  10623. * @param x position
  10624. * @param y y position
  10625. * @param viewportWidth viewport width
  10626. * @param viewportHeight viewport height
  10627. * @param world world matrix
  10628. * @param view view matrix
  10629. * @param projection projection matrix
  10630. * @returns this ray updated
  10631. */
  10632. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10633. /**
  10634. * Creates a ray with origin and direction of 0,0,0
  10635. * @returns the new ray
  10636. */
  10637. static Zero(): Ray;
  10638. /**
  10639. * Creates a new ray from screen space and viewport
  10640. * @param x position
  10641. * @param y y position
  10642. * @param viewportWidth viewport width
  10643. * @param viewportHeight viewport height
  10644. * @param world world matrix
  10645. * @param view view matrix
  10646. * @param projection projection matrix
  10647. * @returns new ray
  10648. */
  10649. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10650. /**
  10651. * 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
  10652. * transformed to the given world matrix.
  10653. * @param origin The origin point
  10654. * @param end The end point
  10655. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10656. * @returns the new ray
  10657. */
  10658. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10659. /**
  10660. * Transforms a ray by a matrix
  10661. * @param ray ray to transform
  10662. * @param matrix matrix to apply
  10663. * @returns the resulting new ray
  10664. */
  10665. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10666. /**
  10667. * Transforms a ray by a matrix
  10668. * @param ray ray to transform
  10669. * @param matrix matrix to apply
  10670. * @param result ray to store result in
  10671. */
  10672. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10673. /**
  10674. * Unproject a ray from screen space to object space
  10675. * @param sourceX defines the screen space x coordinate to use
  10676. * @param sourceY defines the screen space y coordinate to use
  10677. * @param viewportWidth defines the current width of the viewport
  10678. * @param viewportHeight defines the current height of the viewport
  10679. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10680. * @param view defines the view matrix to use
  10681. * @param projection defines the projection matrix to use
  10682. */
  10683. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10684. }
  10685. /**
  10686. * Type used to define predicate used to select faces when a mesh intersection is detected
  10687. */
  10688. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10689. module "babylonjs/scene" {
  10690. interface Scene {
  10691. /** @hidden */
  10692. _tempPickingRay: Nullable<Ray>;
  10693. /** @hidden */
  10694. _cachedRayForTransform: Ray;
  10695. /** @hidden */
  10696. _pickWithRayInverseMatrix: Matrix;
  10697. /** @hidden */
  10698. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10699. /** @hidden */
  10700. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10701. }
  10702. }
  10703. }
  10704. declare module "babylonjs/sceneComponent" {
  10705. import { Scene } from "babylonjs/scene";
  10706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10708. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10709. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10710. import { Nullable } from "babylonjs/types";
  10711. import { Camera } from "babylonjs/Cameras/camera";
  10712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10713. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10714. import { AbstractScene } from "babylonjs/abstractScene";
  10715. import { Mesh } from "babylonjs/Meshes/mesh";
  10716. /**
  10717. * Groups all the scene component constants in one place to ease maintenance.
  10718. * @hidden
  10719. */
  10720. export class SceneComponentConstants {
  10721. static readonly NAME_EFFECTLAYER: string;
  10722. static readonly NAME_LAYER: string;
  10723. static readonly NAME_LENSFLARESYSTEM: string;
  10724. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10725. static readonly NAME_PARTICLESYSTEM: string;
  10726. static readonly NAME_GAMEPAD: string;
  10727. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10728. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10729. static readonly NAME_PREPASSRENDERER: string;
  10730. static readonly NAME_DEPTHRENDERER: string;
  10731. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10732. static readonly NAME_SPRITE: string;
  10733. static readonly NAME_OUTLINERENDERER: string;
  10734. static readonly NAME_PROCEDURALTEXTURE: string;
  10735. static readonly NAME_SHADOWGENERATOR: string;
  10736. static readonly NAME_OCTREE: string;
  10737. static readonly NAME_PHYSICSENGINE: string;
  10738. static readonly NAME_AUDIO: string;
  10739. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10740. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10741. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10742. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10743. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10744. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10745. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10746. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10747. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10748. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10749. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10750. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10751. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10752. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10753. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10754. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10755. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10756. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10757. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10758. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10759. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10760. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10761. static readonly STEP_AFTERRENDER_AUDIO: number;
  10762. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10763. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10764. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10765. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10766. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10767. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10768. static readonly STEP_POINTERMOVE_SPRITE: number;
  10769. static readonly STEP_POINTERDOWN_SPRITE: number;
  10770. static readonly STEP_POINTERUP_SPRITE: number;
  10771. }
  10772. /**
  10773. * This represents a scene component.
  10774. *
  10775. * This is used to decouple the dependency the scene is having on the different workloads like
  10776. * layers, post processes...
  10777. */
  10778. export interface ISceneComponent {
  10779. /**
  10780. * The name of the component. Each component must have a unique name.
  10781. */
  10782. name: string;
  10783. /**
  10784. * The scene the component belongs to.
  10785. */
  10786. scene: Scene;
  10787. /**
  10788. * Register the component to one instance of a scene.
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. }
  10801. /**
  10802. * This represents a SERIALIZABLE scene component.
  10803. *
  10804. * This extends Scene Component to add Serialization methods on top.
  10805. */
  10806. export interface ISceneSerializableComponent extends ISceneComponent {
  10807. /**
  10808. * Adds all the elements from the container to the scene
  10809. * @param container the container holding the elements
  10810. */
  10811. addFromContainer(container: AbstractScene): void;
  10812. /**
  10813. * Removes all the elements in the container from the scene
  10814. * @param container contains the elements to remove
  10815. * @param dispose if the removed element should be disposed (default: false)
  10816. */
  10817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10818. /**
  10819. * Serializes the component data to the specified json object
  10820. * @param serializationObject The object to serialize to
  10821. */
  10822. serialize(serializationObject: any): void;
  10823. }
  10824. /**
  10825. * Strong typing of a Mesh related stage step action
  10826. */
  10827. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10828. /**
  10829. * Strong typing of a Evaluate Sub Mesh related stage step action
  10830. */
  10831. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10832. /**
  10833. * Strong typing of a Active Mesh related stage step action
  10834. */
  10835. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10836. /**
  10837. * Strong typing of a Camera related stage step action
  10838. */
  10839. export type CameraStageAction = (camera: Camera) => void;
  10840. /**
  10841. * Strong typing of a Camera Frame buffer related stage step action
  10842. */
  10843. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10844. /**
  10845. * Strong typing of a Render Target related stage step action
  10846. */
  10847. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10848. /**
  10849. * Strong typing of a RenderingGroup related stage step action
  10850. */
  10851. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10852. /**
  10853. * Strong typing of a Mesh Render related stage step action
  10854. */
  10855. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10856. /**
  10857. * Strong typing of a simple stage step action
  10858. */
  10859. export type SimpleStageAction = () => void;
  10860. /**
  10861. * Strong typing of a render target action.
  10862. */
  10863. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10864. /**
  10865. * Strong typing of a pointer move action.
  10866. */
  10867. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10868. /**
  10869. * Strong typing of a pointer up/down action.
  10870. */
  10871. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10872. /**
  10873. * Representation of a stage in the scene (Basically a list of ordered steps)
  10874. * @hidden
  10875. */
  10876. export class Stage<T extends Function> extends Array<{
  10877. index: number;
  10878. component: ISceneComponent;
  10879. action: T;
  10880. }> {
  10881. /**
  10882. * Hide ctor from the rest of the world.
  10883. * @param items The items to add.
  10884. */
  10885. private constructor();
  10886. /**
  10887. * Creates a new Stage.
  10888. * @returns A new instance of a Stage
  10889. */
  10890. static Create<T extends Function>(): Stage<T>;
  10891. /**
  10892. * Registers a step in an ordered way in the targeted stage.
  10893. * @param index Defines the position to register the step in
  10894. * @param component Defines the component attached to the step
  10895. * @param action Defines the action to launch during the step
  10896. */
  10897. registerStep(index: number, component: ISceneComponent, action: T): void;
  10898. /**
  10899. * Clears all the steps from the stage.
  10900. */
  10901. clear(): void;
  10902. }
  10903. }
  10904. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10905. import { Nullable } from "babylonjs/types";
  10906. import { Observable } from "babylonjs/Misc/observable";
  10907. import { Scene } from "babylonjs/scene";
  10908. import { Sprite } from "babylonjs/Sprites/sprite";
  10909. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10910. import { Ray } from "babylonjs/Culling/ray";
  10911. import { Camera } from "babylonjs/Cameras/camera";
  10912. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10913. import { ISceneComponent } from "babylonjs/sceneComponent";
  10914. module "babylonjs/scene" {
  10915. interface Scene {
  10916. /** @hidden */
  10917. _pointerOverSprite: Nullable<Sprite>;
  10918. /** @hidden */
  10919. _pickedDownSprite: Nullable<Sprite>;
  10920. /** @hidden */
  10921. _tempSpritePickingRay: Nullable<Ray>;
  10922. /**
  10923. * All of the sprite managers added to this scene
  10924. * @see https://doc.babylonjs.com/babylon101/sprites
  10925. */
  10926. spriteManagers: Array<ISpriteManager>;
  10927. /**
  10928. * An event triggered when sprites rendering is about to start
  10929. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10930. */
  10931. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10932. /**
  10933. * An event triggered when sprites rendering is done
  10934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10935. */
  10936. onAfterSpritesRenderingObservable: Observable<Scene>;
  10937. /** @hidden */
  10938. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10939. /** Launch a ray to try to pick a sprite in the scene
  10940. * @param x position on screen
  10941. * @param y position on screen
  10942. * @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
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** Use the given ray to pick a sprite in the scene
  10949. * @param ray The ray (in world space) to use to pick meshes
  10950. * @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
  10951. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10952. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10953. * @returns a PickingInfo
  10954. */
  10955. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10956. /** @hidden */
  10957. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Launch a ray to try to pick sprites in the scene
  10959. * @param x position on screen
  10960. * @param y position on screen
  10961. * @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
  10962. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10963. * @returns a PickingInfo array
  10964. */
  10965. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10966. /** Use the given ray to pick sprites in the scene
  10967. * @param ray The ray (in world space) to use to pick meshes
  10968. * @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
  10969. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10970. * @returns a PickingInfo array
  10971. */
  10972. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10973. /**
  10974. * Force the sprite under the pointer
  10975. * @param sprite defines the sprite to use
  10976. */
  10977. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10978. /**
  10979. * Gets the sprite under the pointer
  10980. * @returns a Sprite or null if no sprite is under the pointer
  10981. */
  10982. getPointerOverSprite(): Nullable<Sprite>;
  10983. }
  10984. }
  10985. /**
  10986. * Defines the sprite scene component responsible to manage sprites
  10987. * in a given scene.
  10988. */
  10989. export class SpriteSceneComponent implements ISceneComponent {
  10990. /**
  10991. * The component name helpfull to identify the component in the list of scene components.
  10992. */
  10993. readonly name: string;
  10994. /**
  10995. * The scene the component belongs to.
  10996. */
  10997. scene: Scene;
  10998. /** @hidden */
  10999. private _spritePredicate;
  11000. /**
  11001. * Creates a new instance of the component for the given scene
  11002. * @param scene Defines the scene to register the component in
  11003. */
  11004. constructor(scene: Scene);
  11005. /**
  11006. * Registers the component in a given scene
  11007. */
  11008. register(): void;
  11009. /**
  11010. * Rebuilds the elements related to this component in case of
  11011. * context lost for instance.
  11012. */
  11013. rebuild(): void;
  11014. /**
  11015. * Disposes the component and the associated ressources.
  11016. */
  11017. dispose(): void;
  11018. private _pickSpriteButKeepRay;
  11019. private _pointerMove;
  11020. private _pointerDown;
  11021. private _pointerUp;
  11022. }
  11023. }
  11024. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11025. /** @hidden */
  11026. export var fogFragmentDeclaration: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11032. /** @hidden */
  11033. export var fogFragment: {
  11034. name: string;
  11035. shader: string;
  11036. };
  11037. }
  11038. declare module "babylonjs/Shaders/sprites.fragment" {
  11039. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11040. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11041. /** @hidden */
  11042. export var spritesPixelShader: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11048. /** @hidden */
  11049. export var fogVertexDeclaration: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Shaders/sprites.vertex" {
  11055. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11056. /** @hidden */
  11057. export var spritesVertexShader: {
  11058. name: string;
  11059. shader: string;
  11060. };
  11061. }
  11062. declare module "babylonjs/Sprites/spriteManager" {
  11063. import { IDisposable, Scene } from "babylonjs/scene";
  11064. import { Nullable } from "babylonjs/types";
  11065. import { Observable } from "babylonjs/Misc/observable";
  11066. import { Sprite } from "babylonjs/Sprites/sprite";
  11067. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11068. import { Camera } from "babylonjs/Cameras/camera";
  11069. import { Texture } from "babylonjs/Materials/Textures/texture";
  11070. import "babylonjs/Shaders/sprites.fragment";
  11071. import "babylonjs/Shaders/sprites.vertex";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. /**
  11074. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11075. */
  11076. export interface ISpriteManager extends IDisposable {
  11077. /**
  11078. * Gets manager's name
  11079. */
  11080. name: string;
  11081. /**
  11082. * Restricts the camera to viewing objects with the same layerMask.
  11083. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11084. */
  11085. layerMask: number;
  11086. /**
  11087. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11088. */
  11089. isPickable: boolean;
  11090. /**
  11091. * Gets the hosting scene
  11092. */
  11093. scene: Scene;
  11094. /**
  11095. * Specifies the rendering group id for this mesh (0 by default)
  11096. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11097. */
  11098. renderingGroupId: number;
  11099. /**
  11100. * Defines the list of sprites managed by the manager.
  11101. */
  11102. sprites: Array<Sprite>;
  11103. /**
  11104. * Gets or sets the spritesheet texture
  11105. */
  11106. texture: Texture;
  11107. /** Defines the default width of a cell in the spritesheet */
  11108. cellWidth: number;
  11109. /** Defines the default height of a cell in the spritesheet */
  11110. cellHeight: number;
  11111. /**
  11112. * Tests the intersection of a sprite with a specific ray.
  11113. * @param ray The ray we are sending to test the collision
  11114. * @param camera The camera space we are sending rays in
  11115. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11116. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11117. * @returns picking info or null.
  11118. */
  11119. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11120. /**
  11121. * Intersects the sprites with a ray
  11122. * @param ray defines the ray to intersect with
  11123. * @param camera defines the current active camera
  11124. * @param predicate defines a predicate used to select candidate sprites
  11125. * @returns null if no hit or a PickingInfo array
  11126. */
  11127. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11128. /**
  11129. * Renders the list of sprites on screen.
  11130. */
  11131. render(): void;
  11132. }
  11133. /**
  11134. * Class used to manage multiple sprites on the same spritesheet
  11135. * @see https://doc.babylonjs.com/babylon101/sprites
  11136. */
  11137. export class SpriteManager implements ISpriteManager {
  11138. /** defines the manager's name */
  11139. name: string;
  11140. /** Define the Url to load snippets */
  11141. static SnippetUrl: string;
  11142. /** Snippet ID if the manager was created from the snippet server */
  11143. snippetId: string;
  11144. /** Gets the list of sprites */
  11145. sprites: Sprite[];
  11146. /** Gets or sets the rendering group id (0 by default) */
  11147. renderingGroupId: number;
  11148. /** Gets or sets camera layer mask */
  11149. layerMask: number;
  11150. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11151. fogEnabled: boolean;
  11152. /** Gets or sets a boolean indicating if the sprites are pickable */
  11153. isPickable: boolean;
  11154. /** Defines the default width of a cell in the spritesheet */
  11155. cellWidth: number;
  11156. /** Defines the default height of a cell in the spritesheet */
  11157. cellHeight: number;
  11158. /** Associative array from JSON sprite data file */
  11159. private _cellData;
  11160. /** Array of sprite names from JSON sprite data file */
  11161. private _spriteMap;
  11162. /** True when packed cell data from JSON file is ready*/
  11163. private _packedAndReady;
  11164. private _textureContent;
  11165. /**
  11166. * An event triggered when the manager is disposed.
  11167. */
  11168. onDisposeObservable: Observable<SpriteManager>;
  11169. private _onDisposeObserver;
  11170. /**
  11171. * Callback called when the manager is disposed
  11172. */
  11173. set onDispose(callback: () => void);
  11174. private _capacity;
  11175. private _fromPacked;
  11176. private _spriteTexture;
  11177. private _epsilon;
  11178. private _scene;
  11179. private _vertexData;
  11180. private _buffer;
  11181. private _vertexBuffers;
  11182. private _indexBuffer;
  11183. private _effectBase;
  11184. private _effectFog;
  11185. /**
  11186. * Gets or sets the unique id of the sprite
  11187. */
  11188. uniqueId: number;
  11189. /**
  11190. * Gets the array of sprites
  11191. */
  11192. get children(): Sprite[];
  11193. /**
  11194. * Gets the hosting scene
  11195. */
  11196. get scene(): Scene;
  11197. /**
  11198. * Gets the capacity of the manager
  11199. */
  11200. get capacity(): number;
  11201. /**
  11202. * Gets or sets the spritesheet texture
  11203. */
  11204. get texture(): Texture;
  11205. set texture(value: Texture);
  11206. private _blendMode;
  11207. /**
  11208. * Blend mode use to render the particle, it can be any of
  11209. * the static Constants.ALPHA_x properties provided in this class.
  11210. * Default value is Constants.ALPHA_COMBINE
  11211. */
  11212. get blendMode(): number;
  11213. set blendMode(blendMode: number);
  11214. /** Disables writing to the depth buffer when rendering the sprites.
  11215. * It can be handy to disable depth writing when using textures without alpha channel
  11216. * and setting some specific blend modes.
  11217. */
  11218. disableDepthWrite: boolean;
  11219. /**
  11220. * Creates a new sprite manager
  11221. * @param name defines the manager's name
  11222. * @param imgUrl defines the sprite sheet url
  11223. * @param capacity defines the maximum allowed number of sprites
  11224. * @param cellSize defines the size of a sprite cell
  11225. * @param scene defines the hosting scene
  11226. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11227. * @param samplingMode defines the smapling mode to use with spritesheet
  11228. * @param fromPacked set to false; do not alter
  11229. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11230. */
  11231. constructor(
  11232. /** defines the manager's name */
  11233. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11234. /**
  11235. * Returns the string "SpriteManager"
  11236. * @returns "SpriteManager"
  11237. */
  11238. getClassName(): string;
  11239. private _makePacked;
  11240. private _appendSpriteVertex;
  11241. private _checkTextureAlpha;
  11242. /**
  11243. * Intersects the sprites with a ray
  11244. * @param ray defines the ray to intersect with
  11245. * @param camera defines the current active camera
  11246. * @param predicate defines a predicate used to select candidate sprites
  11247. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11248. * @returns null if no hit or a PickingInfo
  11249. */
  11250. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11251. /**
  11252. * Intersects the sprites with a ray
  11253. * @param ray defines the ray to intersect with
  11254. * @param camera defines the current active camera
  11255. * @param predicate defines a predicate used to select candidate sprites
  11256. * @returns null if no hit or a PickingInfo array
  11257. */
  11258. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11259. /**
  11260. * Render all child sprites
  11261. */
  11262. render(): void;
  11263. /**
  11264. * Release associated resources
  11265. */
  11266. dispose(): void;
  11267. /**
  11268. * Serializes the sprite manager to a JSON object
  11269. * @param serializeTexture defines if the texture must be serialized as well
  11270. * @returns the JSON object
  11271. */
  11272. serialize(serializeTexture?: boolean): any;
  11273. /**
  11274. * Parses a JSON object to create a new sprite manager.
  11275. * @param parsedManager The JSON object to parse
  11276. * @param scene The scene to create the sprite managerin
  11277. * @param rootUrl The root url to use to load external dependencies like texture
  11278. * @returns the new sprite manager
  11279. */
  11280. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11281. /**
  11282. * Creates a sprite manager from a snippet saved in a remote file
  11283. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11284. * @param url defines the url to load from
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. /**
  11291. * Creates a sprite manager from a snippet saved by the sprite editor
  11292. * @param snippetId defines the snippet to load
  11293. * @param scene defines the hosting scene
  11294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11295. * @returns a promise that will resolve to the new sprite manager
  11296. */
  11297. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11298. }
  11299. }
  11300. declare module "babylonjs/Misc/gradients" {
  11301. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11302. /** Interface used by value gradients (color, factor, ...) */
  11303. export interface IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. }
  11309. /** Class used to store color4 gradient */
  11310. export class ColorGradient implements IValueGradient {
  11311. /**
  11312. * Gets or sets the gradient value (between 0 and 1)
  11313. */
  11314. gradient: number;
  11315. /**
  11316. * Gets or sets first associated color
  11317. */
  11318. color1: Color4;
  11319. /**
  11320. * Gets or sets second associated color
  11321. */
  11322. color2?: Color4 | undefined;
  11323. /**
  11324. * Creates a new color4 gradient
  11325. * @param gradient gets or sets the gradient value (between 0 and 1)
  11326. * @param color1 gets or sets first associated color
  11327. * @param color2 gets or sets first second color
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets first associated color
  11336. */
  11337. color1: Color4,
  11338. /**
  11339. * Gets or sets second associated color
  11340. */
  11341. color2?: Color4 | undefined);
  11342. /**
  11343. * Will get a color picked randomly between color1 and color2.
  11344. * If color2 is undefined then color1 will be used
  11345. * @param result defines the target Color4 to store the result in
  11346. */
  11347. getColorToRef(result: Color4): void;
  11348. }
  11349. /** Class used to store color 3 gradient */
  11350. export class Color3Gradient implements IValueGradient {
  11351. /**
  11352. * Gets or sets the gradient value (between 0 and 1)
  11353. */
  11354. gradient: number;
  11355. /**
  11356. * Gets or sets the associated color
  11357. */
  11358. color: Color3;
  11359. /**
  11360. * Creates a new color3 gradient
  11361. * @param gradient gets or sets the gradient value (between 0 and 1)
  11362. * @param color gets or sets associated color
  11363. */
  11364. constructor(
  11365. /**
  11366. * Gets or sets the gradient value (between 0 and 1)
  11367. */
  11368. gradient: number,
  11369. /**
  11370. * Gets or sets the associated color
  11371. */
  11372. color: Color3);
  11373. }
  11374. /** Class used to store factor gradient */
  11375. export class FactorGradient implements IValueGradient {
  11376. /**
  11377. * Gets or sets the gradient value (between 0 and 1)
  11378. */
  11379. gradient: number;
  11380. /**
  11381. * Gets or sets first associated factor
  11382. */
  11383. factor1: number;
  11384. /**
  11385. * Gets or sets second associated factor
  11386. */
  11387. factor2?: number | undefined;
  11388. /**
  11389. * Creates a new factor gradient
  11390. * @param gradient gets or sets the gradient value (between 0 and 1)
  11391. * @param factor1 gets or sets first associated factor
  11392. * @param factor2 gets or sets second associated factor
  11393. */
  11394. constructor(
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number,
  11399. /**
  11400. * Gets or sets first associated factor
  11401. */
  11402. factor1: number,
  11403. /**
  11404. * Gets or sets second associated factor
  11405. */
  11406. factor2?: number | undefined);
  11407. /**
  11408. * Will get a number picked randomly between factor1 and factor2.
  11409. * If factor2 is undefined then factor1 will be used
  11410. * @returns the picked number
  11411. */
  11412. getFactor(): number;
  11413. }
  11414. /**
  11415. * Helper used to simplify some generic gradient tasks
  11416. */
  11417. export class GradientHelper {
  11418. /**
  11419. * Gets the current gradient from an array of IValueGradient
  11420. * @param ratio defines the current ratio to get
  11421. * @param gradients defines the array of IValueGradient
  11422. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11423. */
  11424. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11425. }
  11426. }
  11427. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11428. import { Nullable } from "babylonjs/types";
  11429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11430. import { Scene } from "babylonjs/scene";
  11431. module "babylonjs/Engines/thinEngine" {
  11432. interface ThinEngine {
  11433. /**
  11434. * Creates a raw texture
  11435. * @param data defines the data to store in the texture
  11436. * @param width defines the width of the texture
  11437. * @param height defines the height of the texture
  11438. * @param format defines the format of the data
  11439. * @param generateMipMaps defines if the engine should generate the mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11442. * @param compression defines the compression used (null by default)
  11443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11444. * @returns the raw texture inside an InternalTexture
  11445. */
  11446. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11447. /**
  11448. * Update a raw texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store in the texture
  11451. * @param format defines the format of the data
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store in the texture
  11459. * @param format defines the format of the data
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the compression used (null by default)
  11462. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11463. */
  11464. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11465. /**
  11466. * Creates a new raw cube texture
  11467. * @param data defines the array of data to use to create each face
  11468. * @param size defines the size of the textures
  11469. * @param format defines the format of the data
  11470. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11471. * @param generateMipMaps defines if the engine should generate the mip levels
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11474. * @param compression defines the compression used (null by default)
  11475. * @returns the cube texture as an InternalTexture
  11476. */
  11477. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11478. /**
  11479. * Update a raw cube texture
  11480. * @param texture defines the texture to udpdate
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11484. * @param invertY defines if data must be stored with Y axis inverted
  11485. */
  11486. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11487. /**
  11488. * Update a raw cube texture
  11489. * @param texture defines the texture to udpdate
  11490. * @param data defines the data to store
  11491. * @param format defines the data format
  11492. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11493. * @param invertY defines if data must be stored with Y axis inverted
  11494. * @param compression defines the compression used (null by default)
  11495. */
  11496. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11497. /**
  11498. * Update a raw cube texture
  11499. * @param texture defines the texture to udpdate
  11500. * @param data defines the data to store
  11501. * @param format defines the data format
  11502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11503. * @param invertY defines if data must be stored with Y axis inverted
  11504. * @param compression defines the compression used (null by default)
  11505. * @param level defines which level of the texture to update
  11506. */
  11507. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11508. /**
  11509. * Creates a new raw cube texture from a specified url
  11510. * @param url defines the url where the data is located
  11511. * @param scene defines the current scene
  11512. * @param size defines the size of the textures
  11513. * @param format defines the format of the data
  11514. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11515. * @param noMipmap defines if the engine should avoid generating the mip levels
  11516. * @param callback defines a callback used to extract texture data from loaded data
  11517. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11518. * @param onLoad defines a callback called when texture is loaded
  11519. * @param onError defines a callback called if there is an error
  11520. * @returns the cube texture as an InternalTexture
  11521. */
  11522. 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;
  11523. /**
  11524. * Creates a new raw cube texture from a specified url
  11525. * @param url defines the url where the data is located
  11526. * @param scene defines the current scene
  11527. * @param size defines the size of the textures
  11528. * @param format defines the format of the data
  11529. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11530. * @param noMipmap defines if the engine should avoid generating the mip levels
  11531. * @param callback defines a callback used to extract texture data from loaded data
  11532. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11533. * @param onLoad defines a callback called when texture is loaded
  11534. * @param onError defines a callback called if there is an error
  11535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. * @returns the cube texture as an InternalTexture
  11538. */
  11539. 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;
  11540. /**
  11541. * Creates a new raw 3D texture
  11542. * @param data defines the data used to create the texture
  11543. * @param width defines the width of the texture
  11544. * @param height defines the height of the texture
  11545. * @param depth defines the depth of the texture
  11546. * @param format defines the format of the texture
  11547. * @param generateMipMaps defines if the engine must generate mip levels
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11550. * @param compression defines the compressed used (can be null)
  11551. * @param textureType defines the compressed used (can be null)
  11552. * @returns a new raw 3D texture (stored in an InternalTexture)
  11553. */
  11554. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11555. /**
  11556. * Update a raw 3D texture
  11557. * @param texture defines the texture to update
  11558. * @param data defines the data to store
  11559. * @param format defines the data format
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. */
  11562. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11563. /**
  11564. * Update a raw 3D texture
  11565. * @param texture defines the texture to update
  11566. * @param data defines the data to store
  11567. * @param format defines the data format
  11568. * @param invertY defines if data must be stored with Y axis inverted
  11569. * @param compression defines the used compression (can be null)
  11570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11571. */
  11572. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11573. /**
  11574. * Creates a new raw 2D array texture
  11575. * @param data defines the data used to create the texture
  11576. * @param width defines the width of the texture
  11577. * @param height defines the height of the texture
  11578. * @param depth defines the number of layers of the texture
  11579. * @param format defines the format of the texture
  11580. * @param generateMipMaps defines if the engine must generate mip levels
  11581. * @param invertY defines if data must be stored with Y axis inverted
  11582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11583. * @param compression defines the compressed used (can be null)
  11584. * @param textureType defines the compressed used (can be null)
  11585. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11586. */
  11587. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11588. /**
  11589. * Update a raw 2D array texture
  11590. * @param texture defines the texture to update
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param invertY defines if data must be stored with Y axis inverted
  11594. */
  11595. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11596. /**
  11597. * Update a raw 2D array texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store
  11600. * @param format defines the data format
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. * @param compression defines the used compression (can be null)
  11603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11604. */
  11605. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11606. }
  11607. }
  11608. }
  11609. declare module "babylonjs/Materials/Textures/rawTexture" {
  11610. import { Scene } from "babylonjs/scene";
  11611. import { Texture } from "babylonjs/Materials/Textures/texture";
  11612. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11613. /**
  11614. * Raw texture can help creating a texture directly from an array of data.
  11615. * This can be super useful if you either get the data from an uncompressed source or
  11616. * if you wish to create your texture pixel by pixel.
  11617. */
  11618. export class RawTexture extends Texture {
  11619. /**
  11620. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11621. */
  11622. format: number;
  11623. /**
  11624. * Instantiates a new RawTexture.
  11625. * Raw texture can help creating a texture directly from an array of data.
  11626. * This can be super useful if you either get the data from an uncompressed source or
  11627. * if you wish to create your texture pixel by pixel.
  11628. * @param data define the array of data to use to create the texture
  11629. * @param width define the width of the texture
  11630. * @param height define the height of the texture
  11631. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11632. * @param scene define the scene the texture belongs to
  11633. * @param generateMipMaps define whether mip maps should be generated or not
  11634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11637. */
  11638. constructor(data: ArrayBufferView, width: number, height: number,
  11639. /**
  11640. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11641. */
  11642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11643. /**
  11644. * Updates the texture underlying data.
  11645. * @param data Define the new data of the texture
  11646. */
  11647. update(data: ArrayBufferView): void;
  11648. /**
  11649. * Creates a luminance texture from some data.
  11650. * @param data Define the texture data
  11651. * @param width Define the width of the texture
  11652. * @param height Define the height of the texture
  11653. * @param scene Define the scene the texture belongs to
  11654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11657. * @returns the luminance texture
  11658. */
  11659. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11660. /**
  11661. * Creates a luminance alpha texture from some data.
  11662. * @param data Define the texture data
  11663. * @param width Define the width of the texture
  11664. * @param height Define the height of the texture
  11665. * @param scene Define the scene the texture belongs to
  11666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11669. * @returns the luminance alpha texture
  11670. */
  11671. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11672. /**
  11673. * Creates an alpha texture from some data.
  11674. * @param data Define the texture data
  11675. * @param width Define the width of the texture
  11676. * @param height Define the height of the texture
  11677. * @param scene Define the scene the texture belongs to
  11678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11681. * @returns the alpha texture
  11682. */
  11683. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11684. /**
  11685. * Creates a RGB texture from some data.
  11686. * @param data Define the texture data
  11687. * @param width Define the width of the texture
  11688. * @param height Define the height of the texture
  11689. * @param scene Define the scene the texture belongs to
  11690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11694. * @returns the RGB alpha texture
  11695. */
  11696. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11697. /**
  11698. * Creates a RGBA texture from some data.
  11699. * @param data Define the texture data
  11700. * @param width Define the width of the texture
  11701. * @param height Define the height of the texture
  11702. * @param scene Define the scene the texture belongs to
  11703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11707. * @returns the RGBA texture
  11708. */
  11709. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11710. /**
  11711. * Creates a R texture from some data.
  11712. * @param data Define the texture data
  11713. * @param width Define the width of the texture
  11714. * @param height Define the height of the texture
  11715. * @param scene Define the scene the texture belongs to
  11716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11720. * @returns the R texture
  11721. */
  11722. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11723. }
  11724. }
  11725. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11726. import { Scene } from "babylonjs/scene";
  11727. import { ISceneComponent } from "babylonjs/sceneComponent";
  11728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11729. module "babylonjs/abstractScene" {
  11730. interface AbstractScene {
  11731. /**
  11732. * The list of procedural textures added to the scene
  11733. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11734. */
  11735. proceduralTextures: Array<ProceduralTexture>;
  11736. }
  11737. }
  11738. /**
  11739. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11740. * in a given scene.
  11741. */
  11742. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11743. /**
  11744. * The component name helpfull to identify the component in the list of scene components.
  11745. */
  11746. readonly name: string;
  11747. /**
  11748. * The scene the component belongs to.
  11749. */
  11750. scene: Scene;
  11751. /**
  11752. * Creates a new instance of the component for the given scene
  11753. * @param scene Defines the scene to register the component in
  11754. */
  11755. constructor(scene: Scene);
  11756. /**
  11757. * Registers the component in a given scene
  11758. */
  11759. register(): void;
  11760. /**
  11761. * Rebuilds the elements related to this component in case of
  11762. * context lost for instance.
  11763. */
  11764. rebuild(): void;
  11765. /**
  11766. * Disposes the component and the associated ressources.
  11767. */
  11768. dispose(): void;
  11769. private _beforeClear;
  11770. }
  11771. }
  11772. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11774. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11775. module "babylonjs/Engines/thinEngine" {
  11776. interface ThinEngine {
  11777. /**
  11778. * Creates a new render target cube texture
  11779. * @param size defines the size of the texture
  11780. * @param options defines the options used to create the texture
  11781. * @returns a new render target cube texture stored in an InternalTexture
  11782. */
  11783. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11784. }
  11785. }
  11786. }
  11787. declare module "babylonjs/Shaders/procedural.vertex" {
  11788. /** @hidden */
  11789. export var proceduralVertexShader: {
  11790. name: string;
  11791. shader: string;
  11792. };
  11793. }
  11794. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11795. import { Observable } from "babylonjs/Misc/observable";
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Scene } from "babylonjs/scene";
  11798. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11799. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11800. import { Effect } from "babylonjs/Materials/effect";
  11801. import { Texture } from "babylonjs/Materials/Textures/texture";
  11802. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11803. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11804. import "babylonjs/Shaders/procedural.vertex";
  11805. /**
  11806. * 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.
  11807. * This is the base class of any Procedural texture and contains most of the shareable code.
  11808. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11809. */
  11810. export class ProceduralTexture extends Texture {
  11811. isCube: boolean;
  11812. /**
  11813. * Define if the texture is enabled or not (disabled texture will not render)
  11814. */
  11815. isEnabled: boolean;
  11816. /**
  11817. * Define if the texture must be cleared before rendering (default is true)
  11818. */
  11819. autoClear: boolean;
  11820. /**
  11821. * Callback called when the texture is generated
  11822. */
  11823. onGenerated: () => void;
  11824. /**
  11825. * Event raised when the texture is generated
  11826. */
  11827. onGeneratedObservable: Observable<ProceduralTexture>;
  11828. /** @hidden */
  11829. _generateMipMaps: boolean;
  11830. /** @hidden **/
  11831. _effect: Effect;
  11832. /** @hidden */
  11833. _textures: {
  11834. [key: string]: Texture;
  11835. };
  11836. /** @hidden */
  11837. protected _fallbackTexture: Nullable<Texture>;
  11838. private _size;
  11839. private _currentRefreshId;
  11840. private _frameId;
  11841. private _refreshRate;
  11842. private _vertexBuffers;
  11843. private _indexBuffer;
  11844. private _uniforms;
  11845. private _samplers;
  11846. private _fragment;
  11847. private _floats;
  11848. private _ints;
  11849. private _floatsArrays;
  11850. private _colors3;
  11851. private _colors4;
  11852. private _vectors2;
  11853. private _vectors3;
  11854. private _matrices;
  11855. private _fallbackTextureUsed;
  11856. private _fullEngine;
  11857. private _cachedDefines;
  11858. private _contentUpdateId;
  11859. private _contentData;
  11860. /**
  11861. * Instantiates a new procedural texture.
  11862. * 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.
  11863. * This is the base class of any Procedural texture and contains most of the shareable code.
  11864. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11865. * @param name Define the name of the texture
  11866. * @param size Define the size of the texture to create
  11867. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11868. * @param scene Define the scene the texture belongs to
  11869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11870. * @param generateMipMaps Define if the texture should creates mip maps or not
  11871. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11872. */
  11873. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11874. /**
  11875. * The effect that is created when initializing the post process.
  11876. * @returns The created effect corresponding the the postprocess.
  11877. */
  11878. getEffect(): Effect;
  11879. /**
  11880. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11881. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11882. */
  11883. getContent(): Nullable<ArrayBufferView>;
  11884. private _createIndexBuffer;
  11885. /** @hidden */
  11886. _rebuild(): void;
  11887. /**
  11888. * Resets the texture in order to recreate its associated resources.
  11889. * This can be called in case of context loss
  11890. */
  11891. reset(): void;
  11892. protected _getDefines(): string;
  11893. /**
  11894. * Is the texture ready to be used ? (rendered at least once)
  11895. * @returns true if ready, otherwise, false.
  11896. */
  11897. isReady(): boolean;
  11898. /**
  11899. * Resets the refresh counter of the texture and start bak from scratch.
  11900. * Could be useful to regenerate the texture if it is setup to render only once.
  11901. */
  11902. resetRefreshCounter(): void;
  11903. /**
  11904. * Set the fragment shader to use in order to render the texture.
  11905. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11906. */
  11907. setFragment(fragment: any): void;
  11908. /**
  11909. * Define the refresh rate of the texture or the rendering frequency.
  11910. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11911. */
  11912. get refreshRate(): number;
  11913. set refreshRate(value: number);
  11914. /** @hidden */
  11915. _shouldRender(): boolean;
  11916. /**
  11917. * Get the size the texture is rendering at.
  11918. * @returns the size (texture is always squared)
  11919. */
  11920. getRenderSize(): number;
  11921. /**
  11922. * Resize the texture to new value.
  11923. * @param size Define the new size the texture should have
  11924. * @param generateMipMaps Define whether the new texture should create mip maps
  11925. */
  11926. resize(size: number, generateMipMaps: boolean): void;
  11927. private _checkUniform;
  11928. /**
  11929. * Set a texture in the shader program used to render.
  11930. * @param name Define the name of the uniform samplers as defined in the shader
  11931. * @param texture Define the texture to bind to this sampler
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setTexture(name: string, texture: Texture): ProceduralTexture;
  11935. /**
  11936. * Set a float in the shader.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setFloat(name: string, value: number): ProceduralTexture;
  11942. /**
  11943. * Set a int in the shader.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setInt(name: string, value: number): ProceduralTexture;
  11949. /**
  11950. * Set an array of floats in the shader.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setFloats(name: string, value: number[]): ProceduralTexture;
  11956. /**
  11957. * Set a vec3 in the shader from a Color3.
  11958. * @param name Define the name of the uniform as defined in the shader
  11959. * @param value Define the value to give to the uniform
  11960. * @return the texture itself allowing "fluent" like uniform updates
  11961. */
  11962. setColor3(name: string, value: Color3): ProceduralTexture;
  11963. /**
  11964. * Set a vec4 in the shader from a Color4.
  11965. * @param name Define the name of the uniform as defined in the shader
  11966. * @param value Define the value to give to the uniform
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setColor4(name: string, value: Color4): ProceduralTexture;
  11970. /**
  11971. * Set a vec2 in the shader from a Vector2.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setVector2(name: string, value: Vector2): ProceduralTexture;
  11977. /**
  11978. * Set a vec3 in the shader from a Vector3.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setVector3(name: string, value: Vector3): ProceduralTexture;
  11984. /**
  11985. * Set a mat4 in the shader from a MAtrix.
  11986. * @param name Define the name of the uniform as defined in the shader
  11987. * @param value Define the value to give to the uniform
  11988. * @return the texture itself allowing "fluent" like uniform updates
  11989. */
  11990. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11991. /**
  11992. * Render the texture to its associated render target.
  11993. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11994. */
  11995. render(useCameraPostProcess?: boolean): void;
  11996. /**
  11997. * Clone the texture.
  11998. * @returns the cloned texture
  11999. */
  12000. clone(): ProceduralTexture;
  12001. /**
  12002. * Dispose the texture and release its asoociated resources.
  12003. */
  12004. dispose(): void;
  12005. }
  12006. }
  12007. declare module "babylonjs/Particles/baseParticleSystem" {
  12008. import { Nullable } from "babylonjs/types";
  12009. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12011. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12012. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12013. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12014. import { Scene } from "babylonjs/scene";
  12015. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12016. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12017. import { Texture } from "babylonjs/Materials/Textures/texture";
  12018. import { Color4 } from "babylonjs/Maths/math.color";
  12019. import { Animation } from "babylonjs/Animations/animation";
  12020. /**
  12021. * This represents the base class for particle system in Babylon.
  12022. * 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.
  12023. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12024. * @example https://doc.babylonjs.com/babylon101/particles
  12025. */
  12026. export class BaseParticleSystem {
  12027. /**
  12028. * Source color is added to the destination color without alpha affecting the result
  12029. */
  12030. static BLENDMODE_ONEONE: number;
  12031. /**
  12032. * Blend current color and particle color using particle’s alpha
  12033. */
  12034. static BLENDMODE_STANDARD: number;
  12035. /**
  12036. * Add current color and particle color multiplied by particle’s alpha
  12037. */
  12038. static BLENDMODE_ADD: number;
  12039. /**
  12040. * Multiply current color with particle color
  12041. */
  12042. static BLENDMODE_MULTIPLY: number;
  12043. /**
  12044. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12045. */
  12046. static BLENDMODE_MULTIPLYADD: number;
  12047. /**
  12048. * List of animations used by the particle system.
  12049. */
  12050. animations: Animation[];
  12051. /**
  12052. * Gets or sets the unique id of the particle system
  12053. */
  12054. uniqueId: number;
  12055. /**
  12056. * The id of the Particle system.
  12057. */
  12058. id: string;
  12059. /**
  12060. * The friendly name of the Particle system.
  12061. */
  12062. name: string;
  12063. /**
  12064. * Snippet ID if the particle system was created from the snippet server
  12065. */
  12066. snippetId: string;
  12067. /**
  12068. * The rendering group used by the Particle system to chose when to render.
  12069. */
  12070. renderingGroupId: number;
  12071. /**
  12072. * The emitter represents the Mesh or position we are attaching the particle system to.
  12073. */
  12074. emitter: Nullable<AbstractMesh | Vector3>;
  12075. /**
  12076. * The maximum number of particles to emit per frame
  12077. */
  12078. emitRate: number;
  12079. /**
  12080. * If you want to launch only a few particles at once, that can be done, as well.
  12081. */
  12082. manualEmitCount: number;
  12083. /**
  12084. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12085. */
  12086. updateSpeed: number;
  12087. /**
  12088. * The amount of time the particle system is running (depends of the overall update speed).
  12089. */
  12090. targetStopDuration: number;
  12091. /**
  12092. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12093. */
  12094. disposeOnStop: boolean;
  12095. /**
  12096. * Minimum power of emitting particles.
  12097. */
  12098. minEmitPower: number;
  12099. /**
  12100. * Maximum power of emitting particles.
  12101. */
  12102. maxEmitPower: number;
  12103. /**
  12104. * Minimum life time of emitting particles.
  12105. */
  12106. minLifeTime: number;
  12107. /**
  12108. * Maximum life time of emitting particles.
  12109. */
  12110. maxLifeTime: number;
  12111. /**
  12112. * Minimum Size of emitting particles.
  12113. */
  12114. minSize: number;
  12115. /**
  12116. * Maximum Size of emitting particles.
  12117. */
  12118. maxSize: number;
  12119. /**
  12120. * Minimum scale of emitting particles on X axis.
  12121. */
  12122. minScaleX: number;
  12123. /**
  12124. * Maximum scale of emitting particles on X axis.
  12125. */
  12126. maxScaleX: number;
  12127. /**
  12128. * Minimum scale of emitting particles on Y axis.
  12129. */
  12130. minScaleY: number;
  12131. /**
  12132. * Maximum scale of emitting particles on Y axis.
  12133. */
  12134. maxScaleY: number;
  12135. /**
  12136. * Gets or sets the minimal initial rotation in radians.
  12137. */
  12138. minInitialRotation: number;
  12139. /**
  12140. * Gets or sets the maximal initial rotation in radians.
  12141. */
  12142. maxInitialRotation: number;
  12143. /**
  12144. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12145. */
  12146. minAngularSpeed: number;
  12147. /**
  12148. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12149. */
  12150. maxAngularSpeed: number;
  12151. /**
  12152. * The texture used to render each particle. (this can be a spritesheet)
  12153. */
  12154. particleTexture: Nullable<Texture>;
  12155. /**
  12156. * The layer mask we are rendering the particles through.
  12157. */
  12158. layerMask: number;
  12159. /**
  12160. * This can help using your own shader to render the particle system.
  12161. * The according effect will be created
  12162. */
  12163. customShader: any;
  12164. /**
  12165. * By default particle system starts as soon as they are created. This prevents the
  12166. * automatic start to happen and let you decide when to start emitting particles.
  12167. */
  12168. preventAutoStart: boolean;
  12169. private _noiseTexture;
  12170. /**
  12171. * Gets or sets a texture used to add random noise to particle positions
  12172. */
  12173. get noiseTexture(): Nullable<ProceduralTexture>;
  12174. set noiseTexture(value: Nullable<ProceduralTexture>);
  12175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12176. noiseStrength: Vector3;
  12177. /**
  12178. * Callback triggered when the particle animation is ending.
  12179. */
  12180. onAnimationEnd: Nullable<() => void>;
  12181. /**
  12182. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12183. */
  12184. blendMode: number;
  12185. /**
  12186. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12187. * to override the particles.
  12188. */
  12189. forceDepthWrite: boolean;
  12190. /** 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 */
  12191. preWarmCycles: number;
  12192. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12193. preWarmStepOffset: number;
  12194. /**
  12195. * 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)
  12196. */
  12197. spriteCellChangeSpeed: number;
  12198. /**
  12199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12200. */
  12201. startSpriteCellID: number;
  12202. /**
  12203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12204. */
  12205. endSpriteCellID: number;
  12206. /**
  12207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12208. */
  12209. spriteCellWidth: number;
  12210. /**
  12211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12212. */
  12213. spriteCellHeight: number;
  12214. /**
  12215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12216. */
  12217. spriteRandomStartCell: boolean;
  12218. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12219. translationPivot: Vector2;
  12220. /** @hidden */
  12221. protected _isAnimationSheetEnabled: boolean;
  12222. /**
  12223. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12224. */
  12225. beginAnimationOnStart: boolean;
  12226. /**
  12227. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12228. */
  12229. beginAnimationFrom: number;
  12230. /**
  12231. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12232. */
  12233. beginAnimationTo: number;
  12234. /**
  12235. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12236. */
  12237. beginAnimationLoop: boolean;
  12238. /**
  12239. * Gets or sets a world offset applied to all particles
  12240. */
  12241. worldOffset: Vector3;
  12242. /**
  12243. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12244. */
  12245. get isAnimationSheetEnabled(): boolean;
  12246. set isAnimationSheetEnabled(value: boolean);
  12247. /**
  12248. * Get hosting scene
  12249. * @returns the scene
  12250. */
  12251. getScene(): Scene;
  12252. /**
  12253. * You can use gravity if you want to give an orientation to your particles.
  12254. */
  12255. gravity: Vector3;
  12256. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12257. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12258. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12259. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12260. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12261. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12262. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12263. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12264. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12265. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12266. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12267. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12268. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12269. /**
  12270. * Defines the delay in milliseconds before starting the system (0 by default)
  12271. */
  12272. startDelay: number;
  12273. /**
  12274. * Gets the current list of drag gradients.
  12275. * You must use addDragGradient and removeDragGradient to udpate this list
  12276. * @returns the list of drag gradients
  12277. */
  12278. getDragGradients(): Nullable<Array<FactorGradient>>;
  12279. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12280. limitVelocityDamping: number;
  12281. /**
  12282. * Gets the current list of limit velocity gradients.
  12283. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12284. * @returns the list of limit velocity gradients
  12285. */
  12286. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12287. /**
  12288. * Gets the current list of color gradients.
  12289. * You must use addColorGradient and removeColorGradient to udpate this list
  12290. * @returns the list of color gradients
  12291. */
  12292. getColorGradients(): Nullable<Array<ColorGradient>>;
  12293. /**
  12294. * Gets the current list of size gradients.
  12295. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12296. * @returns the list of size gradients
  12297. */
  12298. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12299. /**
  12300. * Gets the current list of color remap gradients.
  12301. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12302. * @returns the list of color remap gradients
  12303. */
  12304. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12305. /**
  12306. * Gets the current list of alpha remap gradients.
  12307. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12308. * @returns the list of alpha remap gradients
  12309. */
  12310. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12311. /**
  12312. * Gets the current list of life time gradients.
  12313. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12314. * @returns the list of life time gradients
  12315. */
  12316. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12317. /**
  12318. * Gets the current list of angular speed gradients.
  12319. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12320. * @returns the list of angular speed gradients
  12321. */
  12322. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12323. /**
  12324. * Gets the current list of velocity gradients.
  12325. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12326. * @returns the list of velocity gradients
  12327. */
  12328. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12329. /**
  12330. * Gets the current list of start size gradients.
  12331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12332. * @returns the list of start size gradients
  12333. */
  12334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12335. /**
  12336. * Gets the current list of emit rate gradients.
  12337. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12338. * @returns the list of emit rate gradients
  12339. */
  12340. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12341. /**
  12342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12344. */
  12345. get direction1(): Vector3;
  12346. set direction1(value: Vector3);
  12347. /**
  12348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12350. */
  12351. get direction2(): Vector3;
  12352. set direction2(value: Vector3);
  12353. /**
  12354. * 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.
  12355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12356. */
  12357. get minEmitBox(): Vector3;
  12358. set minEmitBox(value: Vector3);
  12359. /**
  12360. * 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.
  12361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12362. */
  12363. get maxEmitBox(): Vector3;
  12364. set maxEmitBox(value: Vector3);
  12365. /**
  12366. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12367. */
  12368. color1: Color4;
  12369. /**
  12370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12371. */
  12372. color2: Color4;
  12373. /**
  12374. * Color the particle will have at the end of its lifetime
  12375. */
  12376. colorDead: Color4;
  12377. /**
  12378. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12379. */
  12380. textureMask: Color4;
  12381. /**
  12382. * The particle emitter type defines the emitter used by the particle system.
  12383. * It can be for example box, sphere, or cone...
  12384. */
  12385. particleEmitterType: IParticleEmitterType;
  12386. /** @hidden */
  12387. _isSubEmitter: boolean;
  12388. /**
  12389. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12390. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12391. */
  12392. billboardMode: number;
  12393. protected _isBillboardBased: boolean;
  12394. /**
  12395. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12396. */
  12397. get isBillboardBased(): boolean;
  12398. set isBillboardBased(value: boolean);
  12399. /**
  12400. * The scene the particle system belongs to.
  12401. */
  12402. protected _scene: Scene;
  12403. /**
  12404. * Local cache of defines for image processing.
  12405. */
  12406. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12407. /**
  12408. * Default configuration related to image processing available in the standard Material.
  12409. */
  12410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12411. /**
  12412. * Gets the image processing configuration used either in this material.
  12413. */
  12414. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12415. /**
  12416. * Sets the Default image processing configuration used either in the this material.
  12417. *
  12418. * If sets to null, the scene one is in use.
  12419. */
  12420. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12421. /**
  12422. * Attaches a new image processing configuration to the Standard Material.
  12423. * @param configuration
  12424. */
  12425. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12426. /** @hidden */
  12427. protected _reset(): void;
  12428. /** @hidden */
  12429. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12430. /**
  12431. * Instantiates a particle system.
  12432. * 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.
  12433. * @param name The name of the particle system
  12434. */
  12435. constructor(name: string);
  12436. /**
  12437. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12440. * @returns the emitter
  12441. */
  12442. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12443. /**
  12444. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12445. * @param radius The radius of the hemisphere to emit from
  12446. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12447. * @returns the emitter
  12448. */
  12449. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12450. /**
  12451. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12452. * @param radius The radius of the sphere to emit from
  12453. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12454. * @returns the emitter
  12455. */
  12456. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12457. /**
  12458. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12459. * @param radius The radius of the sphere to emit from
  12460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12462. * @returns the emitter
  12463. */
  12464. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12465. /**
  12466. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12467. * @param radius The radius of the emission cylinder
  12468. * @param height The height of the emission cylinder
  12469. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12470. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12471. * @returns the emitter
  12472. */
  12473. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12474. /**
  12475. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12476. * @param radius The radius of the cylinder to emit from
  12477. * @param height The height of the emission cylinder
  12478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12481. * @returns the emitter
  12482. */
  12483. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12484. /**
  12485. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12486. * @param radius The radius of the cone to emit from
  12487. * @param angle The base angle of the cone
  12488. * @returns the emitter
  12489. */
  12490. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12491. /**
  12492. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12495. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12496. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12497. * @returns the emitter
  12498. */
  12499. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12500. }
  12501. }
  12502. declare module "babylonjs/Particles/subEmitter" {
  12503. import { Scene } from "babylonjs/scene";
  12504. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12505. /**
  12506. * Type of sub emitter
  12507. */
  12508. export enum SubEmitterType {
  12509. /**
  12510. * Attached to the particle over it's lifetime
  12511. */
  12512. ATTACHED = 0,
  12513. /**
  12514. * Created when the particle dies
  12515. */
  12516. END = 1
  12517. }
  12518. /**
  12519. * Sub emitter class used to emit particles from an existing particle
  12520. */
  12521. export class SubEmitter {
  12522. /**
  12523. * the particle system to be used by the sub emitter
  12524. */
  12525. particleSystem: ParticleSystem;
  12526. /**
  12527. * Type of the submitter (Default: END)
  12528. */
  12529. type: SubEmitterType;
  12530. /**
  12531. * 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)
  12532. * Note: This only is supported when using an emitter of type Mesh
  12533. */
  12534. inheritDirection: boolean;
  12535. /**
  12536. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12537. */
  12538. inheritedVelocityAmount: number;
  12539. /**
  12540. * Creates a sub emitter
  12541. * @param particleSystem the particle system to be used by the sub emitter
  12542. */
  12543. constructor(
  12544. /**
  12545. * the particle system to be used by the sub emitter
  12546. */
  12547. particleSystem: ParticleSystem);
  12548. /**
  12549. * Clones the sub emitter
  12550. * @returns the cloned sub emitter
  12551. */
  12552. clone(): SubEmitter;
  12553. /**
  12554. * Serialize current object to a JSON object
  12555. * @returns the serialized object
  12556. */
  12557. serialize(): any;
  12558. /** @hidden */
  12559. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12560. /**
  12561. * Creates a new SubEmitter from a serialized JSON version
  12562. * @param serializationObject defines the JSON object to read from
  12563. * @param scene defines the hosting scene
  12564. * @param rootUrl defines the rootUrl for data loading
  12565. * @returns a new SubEmitter
  12566. */
  12567. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12568. /** Release associated resources */
  12569. dispose(): void;
  12570. }
  12571. }
  12572. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12573. /** @hidden */
  12574. export var imageProcessingDeclaration: {
  12575. name: string;
  12576. shader: string;
  12577. };
  12578. }
  12579. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12580. /** @hidden */
  12581. export var imageProcessingFunctions: {
  12582. name: string;
  12583. shader: string;
  12584. };
  12585. }
  12586. declare module "babylonjs/Shaders/particles.fragment" {
  12587. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12588. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12590. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12591. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12592. /** @hidden */
  12593. export var particlesPixelShader: {
  12594. name: string;
  12595. shader: string;
  12596. };
  12597. }
  12598. declare module "babylonjs/Shaders/particles.vertex" {
  12599. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12601. /** @hidden */
  12602. export var particlesVertexShader: {
  12603. name: string;
  12604. shader: string;
  12605. };
  12606. }
  12607. declare module "babylonjs/Particles/particleSystem" {
  12608. import { Nullable } from "babylonjs/types";
  12609. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12612. import { Effect } from "babylonjs/Materials/effect";
  12613. import { Scene, IDisposable } from "babylonjs/scene";
  12614. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12615. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12616. import { Particle } from "babylonjs/Particles/particle";
  12617. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12618. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12619. import "babylonjs/Shaders/particles.fragment";
  12620. import "babylonjs/Shaders/particles.vertex";
  12621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12622. /**
  12623. * This represents a particle system in Babylon.
  12624. * 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.
  12625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12626. * @example https://doc.babylonjs.com/babylon101/particles
  12627. */
  12628. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12629. /**
  12630. * Billboard mode will only apply to Y axis
  12631. */
  12632. static readonly BILLBOARDMODE_Y: number;
  12633. /**
  12634. * Billboard mode will apply to all axes
  12635. */
  12636. static readonly BILLBOARDMODE_ALL: number;
  12637. /**
  12638. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12639. */
  12640. static readonly BILLBOARDMODE_STRETCHED: number;
  12641. /**
  12642. * This function can be defined to provide custom update for active particles.
  12643. * This function will be called instead of regular update (age, position, color, etc.).
  12644. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12645. */
  12646. updateFunction: (particles: Particle[]) => void;
  12647. private _emitterWorldMatrix;
  12648. /**
  12649. * This function can be defined to specify initial direction for every new particle.
  12650. * It by default use the emitterType defined function
  12651. */
  12652. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12653. /**
  12654. * This function can be defined to specify initial position for every new particle.
  12655. * It by default use the emitterType defined function
  12656. */
  12657. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12658. /**
  12659. * @hidden
  12660. */
  12661. _inheritedVelocityOffset: Vector3;
  12662. /**
  12663. * An event triggered when the system is disposed
  12664. */
  12665. onDisposeObservable: Observable<IParticleSystem>;
  12666. private _onDisposeObserver;
  12667. /**
  12668. * Sets a callback that will be triggered when the system is disposed
  12669. */
  12670. set onDispose(callback: () => void);
  12671. private _particles;
  12672. private _epsilon;
  12673. private _capacity;
  12674. private _stockParticles;
  12675. private _newPartsExcess;
  12676. private _vertexData;
  12677. private _vertexBuffer;
  12678. private _vertexBuffers;
  12679. private _spriteBuffer;
  12680. private _indexBuffer;
  12681. private _effect;
  12682. private _customEffect;
  12683. private _cachedDefines;
  12684. private _scaledColorStep;
  12685. private _colorDiff;
  12686. private _scaledDirection;
  12687. private _scaledGravity;
  12688. private _currentRenderId;
  12689. private _alive;
  12690. private _useInstancing;
  12691. private _started;
  12692. private _stopped;
  12693. private _actualFrame;
  12694. private _scaledUpdateSpeed;
  12695. private _vertexBufferSize;
  12696. /** @hidden */
  12697. _currentEmitRateGradient: Nullable<FactorGradient>;
  12698. /** @hidden */
  12699. _currentEmitRate1: number;
  12700. /** @hidden */
  12701. _currentEmitRate2: number;
  12702. /** @hidden */
  12703. _currentStartSizeGradient: Nullable<FactorGradient>;
  12704. /** @hidden */
  12705. _currentStartSize1: number;
  12706. /** @hidden */
  12707. _currentStartSize2: number;
  12708. private readonly _rawTextureWidth;
  12709. private _rampGradientsTexture;
  12710. private _useRampGradients;
  12711. /** Gets or sets a boolean indicating that ramp gradients must be used
  12712. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12713. */
  12714. get useRampGradients(): boolean;
  12715. set useRampGradients(value: boolean);
  12716. /**
  12717. * 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.
  12718. * 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: [])
  12719. */
  12720. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12721. private _subEmitters;
  12722. /**
  12723. * @hidden
  12724. * If the particle systems emitter should be disposed when the particle system is disposed
  12725. */
  12726. _disposeEmitterOnDispose: boolean;
  12727. /**
  12728. * The current active Sub-systems, this property is used by the root particle system only.
  12729. */
  12730. activeSubSystems: Array<ParticleSystem>;
  12731. /**
  12732. * Specifies if the particles are updated in emitter local space or world space
  12733. */
  12734. isLocal: boolean;
  12735. private _rootParticleSystem;
  12736. /**
  12737. * Gets the current list of active particles
  12738. */
  12739. get particles(): Particle[];
  12740. /**
  12741. * Gets the number of particles active at the same time.
  12742. * @returns The number of active particles.
  12743. */
  12744. getActiveCount(): number;
  12745. /**
  12746. * Returns the string "ParticleSystem"
  12747. * @returns a string containing the class name
  12748. */
  12749. getClassName(): string;
  12750. /**
  12751. * Gets a boolean indicating that the system is stopping
  12752. * @returns true if the system is currently stopping
  12753. */
  12754. isStopping(): boolean;
  12755. /**
  12756. * Gets the custom effect used to render the particles
  12757. * @param blendMode Blend mode for which the effect should be retrieved
  12758. * @returns The effect
  12759. */
  12760. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12761. /**
  12762. * Sets the custom effect used to render the particles
  12763. * @param effect The effect to set
  12764. * @param blendMode Blend mode for which the effect should be set
  12765. */
  12766. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12767. /** @hidden */
  12768. private _onBeforeDrawParticlesObservable;
  12769. /**
  12770. * Observable that will be called just before the particles are drawn
  12771. */
  12772. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12773. /**
  12774. * Gets the name of the particle vertex shader
  12775. */
  12776. get vertexShaderName(): string;
  12777. /**
  12778. * Instantiates a particle system.
  12779. * 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.
  12780. * @param name The name of the particle system
  12781. * @param capacity The max number of particles alive at the same time
  12782. * @param scene The scene the particle system belongs to
  12783. * @param customEffect a custom effect used to change the way particles are rendered by default
  12784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12785. * @param epsilon Offset used to render the particles
  12786. */
  12787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12788. private _addFactorGradient;
  12789. private _removeFactorGradient;
  12790. /**
  12791. * Adds a new life time gradient
  12792. * @param gradient defines the gradient to use (between 0 and 1)
  12793. * @param factor defines the life time factor to affect to the specified gradient
  12794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12795. * @returns the current particle system
  12796. */
  12797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12798. /**
  12799. * Remove a specific life time gradient
  12800. * @param gradient defines the gradient to remove
  12801. * @returns the current particle system
  12802. */
  12803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12804. /**
  12805. * Adds a new size gradient
  12806. * @param gradient defines the gradient to use (between 0 and 1)
  12807. * @param factor defines the size factor to affect to the specified gradient
  12808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12809. * @returns the current particle system
  12810. */
  12811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12812. /**
  12813. * Remove a specific size gradient
  12814. * @param gradient defines the gradient to remove
  12815. * @returns the current particle system
  12816. */
  12817. removeSizeGradient(gradient: number): IParticleSystem;
  12818. /**
  12819. * Adds a new color remap gradient
  12820. * @param gradient defines the gradient to use (between 0 and 1)
  12821. * @param min defines the color remap minimal range
  12822. * @param max defines the color remap maximal range
  12823. * @returns the current particle system
  12824. */
  12825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12826. /**
  12827. * Remove a specific color remap gradient
  12828. * @param gradient defines the gradient to remove
  12829. * @returns the current particle system
  12830. */
  12831. removeColorRemapGradient(gradient: number): IParticleSystem;
  12832. /**
  12833. * Adds a new alpha remap gradient
  12834. * @param gradient defines the gradient to use (between 0 and 1)
  12835. * @param min defines the alpha remap minimal range
  12836. * @param max defines the alpha remap maximal range
  12837. * @returns the current particle system
  12838. */
  12839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12840. /**
  12841. * Remove a specific alpha remap gradient
  12842. * @param gradient defines the gradient to remove
  12843. * @returns the current particle system
  12844. */
  12845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12846. /**
  12847. * Adds a new angular speed gradient
  12848. * @param gradient defines the gradient to use (between 0 and 1)
  12849. * @param factor defines the angular speed to affect to the specified gradient
  12850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12851. * @returns the current particle system
  12852. */
  12853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12854. /**
  12855. * Remove a specific angular speed gradient
  12856. * @param gradient defines the gradient to remove
  12857. * @returns the current particle system
  12858. */
  12859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12860. /**
  12861. * Adds a new velocity gradient
  12862. * @param gradient defines the gradient to use (between 0 and 1)
  12863. * @param factor defines the velocity to affect to the specified gradient
  12864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12865. * @returns the current particle system
  12866. */
  12867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12868. /**
  12869. * Remove a specific velocity gradient
  12870. * @param gradient defines the gradient to remove
  12871. * @returns the current particle system
  12872. */
  12873. removeVelocityGradient(gradient: number): IParticleSystem;
  12874. /**
  12875. * Adds a new limit velocity gradient
  12876. * @param gradient defines the gradient to use (between 0 and 1)
  12877. * @param factor defines the limit velocity value to affect to the specified gradient
  12878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12879. * @returns the current particle system
  12880. */
  12881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12882. /**
  12883. * Remove a specific limit velocity gradient
  12884. * @param gradient defines the gradient to remove
  12885. * @returns the current particle system
  12886. */
  12887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12888. /**
  12889. * Adds a new drag gradient
  12890. * @param gradient defines the gradient to use (between 0 and 1)
  12891. * @param factor defines the drag value to affect to the specified gradient
  12892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12893. * @returns the current particle system
  12894. */
  12895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12896. /**
  12897. * Remove a specific drag gradient
  12898. * @param gradient defines the gradient to remove
  12899. * @returns the current particle system
  12900. */
  12901. removeDragGradient(gradient: number): IParticleSystem;
  12902. /**
  12903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12904. * @param gradient defines the gradient to use (between 0 and 1)
  12905. * @param factor defines the emit rate value to affect to the specified gradient
  12906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12907. * @returns the current particle system
  12908. */
  12909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12910. /**
  12911. * Remove a specific emit rate gradient
  12912. * @param gradient defines the gradient to remove
  12913. * @returns the current particle system
  12914. */
  12915. removeEmitRateGradient(gradient: number): IParticleSystem;
  12916. /**
  12917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12918. * @param gradient defines the gradient to use (between 0 and 1)
  12919. * @param factor defines the start size value to affect to the specified gradient
  12920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12921. * @returns the current particle system
  12922. */
  12923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12924. /**
  12925. * Remove a specific start size gradient
  12926. * @param gradient defines the gradient to remove
  12927. * @returns the current particle system
  12928. */
  12929. removeStartSizeGradient(gradient: number): IParticleSystem;
  12930. private _createRampGradientTexture;
  12931. /**
  12932. * Gets the current list of ramp gradients.
  12933. * You must use addRampGradient and removeRampGradient to udpate this list
  12934. * @returns the list of ramp gradients
  12935. */
  12936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12937. /** Force the system to rebuild all gradients that need to be resync */
  12938. forceRefreshGradients(): void;
  12939. private _syncRampGradientTexture;
  12940. /**
  12941. * Adds a new ramp gradient used to remap particle colors
  12942. * @param gradient defines the gradient to use (between 0 and 1)
  12943. * @param color defines the color to affect to the specified gradient
  12944. * @returns the current particle system
  12945. */
  12946. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12947. /**
  12948. * Remove a specific ramp gradient
  12949. * @param gradient defines the gradient to remove
  12950. * @returns the current particle system
  12951. */
  12952. removeRampGradient(gradient: number): ParticleSystem;
  12953. /**
  12954. * Adds a new color gradient
  12955. * @param gradient defines the gradient to use (between 0 and 1)
  12956. * @param color1 defines the color to affect to the specified gradient
  12957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12958. * @returns this particle system
  12959. */
  12960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12961. /**
  12962. * Remove a specific color gradient
  12963. * @param gradient defines the gradient to remove
  12964. * @returns this particle system
  12965. */
  12966. removeColorGradient(gradient: number): IParticleSystem;
  12967. private _fetchR;
  12968. protected _reset(): void;
  12969. private _resetEffect;
  12970. private _createVertexBuffers;
  12971. private _createIndexBuffer;
  12972. /**
  12973. * Gets the maximum number of particles active at the same time.
  12974. * @returns The max number of active particles.
  12975. */
  12976. getCapacity(): number;
  12977. /**
  12978. * Gets whether there are still active particles in the system.
  12979. * @returns True if it is alive, otherwise false.
  12980. */
  12981. isAlive(): boolean;
  12982. /**
  12983. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12984. * @returns True if it has been started, otherwise false.
  12985. */
  12986. isStarted(): boolean;
  12987. private _prepareSubEmitterInternalArray;
  12988. /**
  12989. * Starts the particle system and begins to emit
  12990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12991. */
  12992. start(delay?: number): void;
  12993. /**
  12994. * Stops the particle system.
  12995. * @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.
  12996. */
  12997. stop(stopSubEmitters?: boolean): void;
  12998. /**
  12999. * Remove all active particles
  13000. */
  13001. reset(): void;
  13002. /**
  13003. * @hidden (for internal use only)
  13004. */
  13005. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13006. /**
  13007. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13008. * Its lifetime will start back at 0.
  13009. */
  13010. recycleParticle: (particle: Particle) => void;
  13011. private _stopSubEmitters;
  13012. private _createParticle;
  13013. private _removeFromRoot;
  13014. private _emitFromParticle;
  13015. private _update;
  13016. /** @hidden */
  13017. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13018. /** @hidden */
  13019. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13020. /**
  13021. * Fill the defines array according to the current settings of the particle system
  13022. * @param defines Array to be updated
  13023. * @param blendMode blend mode to take into account when updating the array
  13024. */
  13025. fillDefines(defines: Array<string>, blendMode: number): void;
  13026. /**
  13027. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13028. * @param uniforms Uniforms array to fill
  13029. * @param attributes Attributes array to fill
  13030. * @param samplers Samplers array to fill
  13031. */
  13032. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13033. /** @hidden */
  13034. private _getEffect;
  13035. /**
  13036. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13037. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13038. */
  13039. animate(preWarmOnly?: boolean): void;
  13040. private _appendParticleVertices;
  13041. /**
  13042. * Rebuilds the particle system.
  13043. */
  13044. rebuild(): void;
  13045. /**
  13046. * Is this system ready to be used/rendered
  13047. * @return true if the system is ready
  13048. */
  13049. isReady(): boolean;
  13050. private _render;
  13051. /**
  13052. * Renders the particle system in its current state.
  13053. * @returns the current number of particles
  13054. */
  13055. render(): number;
  13056. /**
  13057. * Disposes the particle system and free the associated resources
  13058. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13059. */
  13060. dispose(disposeTexture?: boolean): void;
  13061. /**
  13062. * Clones the particle system.
  13063. * @param name The name of the cloned object
  13064. * @param newEmitter The new emitter to use
  13065. * @returns the cloned particle system
  13066. */
  13067. clone(name: string, newEmitter: any): ParticleSystem;
  13068. /**
  13069. * Serializes the particle system to a JSON object
  13070. * @param serializeTexture defines if the texture must be serialized as well
  13071. * @returns the JSON object
  13072. */
  13073. serialize(serializeTexture?: boolean): any;
  13074. /** @hidden */
  13075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13076. /** @hidden */
  13077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13078. /**
  13079. * Parses a JSON object to create a particle system.
  13080. * @param parsedParticleSystem The JSON object to parse
  13081. * @param scene The scene to create the particle system in
  13082. * @param rootUrl The root url to use to load external dependencies like texture
  13083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13084. * @returns the Parsed particle system
  13085. */
  13086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13087. }
  13088. }
  13089. declare module "babylonjs/Particles/particle" {
  13090. import { Nullable } from "babylonjs/types";
  13091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13092. import { Color4 } from "babylonjs/Maths/math.color";
  13093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13096. /**
  13097. * A particle represents one of the element emitted by a particle system.
  13098. * This is mainly define by its coordinates, direction, velocity and age.
  13099. */
  13100. export class Particle {
  13101. /**
  13102. * The particle system the particle belongs to.
  13103. */
  13104. particleSystem: ParticleSystem;
  13105. private static _Count;
  13106. /**
  13107. * Unique ID of the particle
  13108. */
  13109. id: number;
  13110. /**
  13111. * The world position of the particle in the scene.
  13112. */
  13113. position: Vector3;
  13114. /**
  13115. * The world direction of the particle in the scene.
  13116. */
  13117. direction: Vector3;
  13118. /**
  13119. * The color of the particle.
  13120. */
  13121. color: Color4;
  13122. /**
  13123. * The color change of the particle per step.
  13124. */
  13125. colorStep: Color4;
  13126. /**
  13127. * Defines how long will the life of the particle be.
  13128. */
  13129. lifeTime: number;
  13130. /**
  13131. * The current age of the particle.
  13132. */
  13133. age: number;
  13134. /**
  13135. * The current size of the particle.
  13136. */
  13137. size: number;
  13138. /**
  13139. * The current scale of the particle.
  13140. */
  13141. scale: Vector2;
  13142. /**
  13143. * The current angle of the particle.
  13144. */
  13145. angle: number;
  13146. /**
  13147. * Defines how fast is the angle changing.
  13148. */
  13149. angularSpeed: number;
  13150. /**
  13151. * Defines the cell index used by the particle to be rendered from a sprite.
  13152. */
  13153. cellIndex: number;
  13154. /**
  13155. * The information required to support color remapping
  13156. */
  13157. remapData: Vector4;
  13158. /** @hidden */
  13159. _randomCellOffset?: number;
  13160. /** @hidden */
  13161. _initialDirection: Nullable<Vector3>;
  13162. /** @hidden */
  13163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13164. /** @hidden */
  13165. _initialStartSpriteCellID: number;
  13166. /** @hidden */
  13167. _initialEndSpriteCellID: number;
  13168. /** @hidden */
  13169. _currentColorGradient: Nullable<ColorGradient>;
  13170. /** @hidden */
  13171. _currentColor1: Color4;
  13172. /** @hidden */
  13173. _currentColor2: Color4;
  13174. /** @hidden */
  13175. _currentSizeGradient: Nullable<FactorGradient>;
  13176. /** @hidden */
  13177. _currentSize1: number;
  13178. /** @hidden */
  13179. _currentSize2: number;
  13180. /** @hidden */
  13181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13182. /** @hidden */
  13183. _currentAngularSpeed1: number;
  13184. /** @hidden */
  13185. _currentAngularSpeed2: number;
  13186. /** @hidden */
  13187. _currentVelocityGradient: Nullable<FactorGradient>;
  13188. /** @hidden */
  13189. _currentVelocity1: number;
  13190. /** @hidden */
  13191. _currentVelocity2: number;
  13192. /** @hidden */
  13193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13194. /** @hidden */
  13195. _currentLimitVelocity1: number;
  13196. /** @hidden */
  13197. _currentLimitVelocity2: number;
  13198. /** @hidden */
  13199. _currentDragGradient: Nullable<FactorGradient>;
  13200. /** @hidden */
  13201. _currentDrag1: number;
  13202. /** @hidden */
  13203. _currentDrag2: number;
  13204. /** @hidden */
  13205. _randomNoiseCoordinates1: Vector3;
  13206. /** @hidden */
  13207. _randomNoiseCoordinates2: Vector3;
  13208. /** @hidden */
  13209. _localPosition?: Vector3;
  13210. /**
  13211. * Creates a new instance Particle
  13212. * @param particleSystem the particle system the particle belongs to
  13213. */
  13214. constructor(
  13215. /**
  13216. * The particle system the particle belongs to.
  13217. */
  13218. particleSystem: ParticleSystem);
  13219. private updateCellInfoFromSystem;
  13220. /**
  13221. * Defines how the sprite cell index is updated for the particle
  13222. */
  13223. updateCellIndex(): void;
  13224. /** @hidden */
  13225. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13226. /** @hidden */
  13227. _inheritParticleInfoToSubEmitters(): void;
  13228. /** @hidden */
  13229. _reset(): void;
  13230. /**
  13231. * Copy the properties of particle to another one.
  13232. * @param other the particle to copy the information to.
  13233. */
  13234. copyTo(other: Particle): void;
  13235. }
  13236. }
  13237. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13239. import { Effect } from "babylonjs/Materials/effect";
  13240. import { Particle } from "babylonjs/Particles/particle";
  13241. import { Scene } from "babylonjs/scene";
  13242. /**
  13243. * Particle emitter represents a volume emitting particles.
  13244. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13245. */
  13246. export interface IParticleEmitterType {
  13247. /**
  13248. * Called by the particle System when the direction is computed for the created particle.
  13249. * @param worldMatrix is the world matrix of the particle system
  13250. * @param directionToUpdate is the direction vector to update with the result
  13251. * @param particle is the particle we are computed the direction for
  13252. * @param isLocal defines if the direction should be set in local space
  13253. */
  13254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13255. /**
  13256. * Called by the particle System when the position is computed for the created particle.
  13257. * @param worldMatrix is the world matrix of the particle system
  13258. * @param positionToUpdate is the position vector to update with the result
  13259. * @param particle is the particle we are computed the position for
  13260. * @param isLocal defines if the position should be set in local space
  13261. */
  13262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13263. /**
  13264. * Clones the current emitter and returns a copy of it
  13265. * @returns the new emitter
  13266. */
  13267. clone(): IParticleEmitterType;
  13268. /**
  13269. * Called by the GPUParticleSystem to setup the update shader
  13270. * @param effect defines the update shader
  13271. */
  13272. applyToShader(effect: Effect): void;
  13273. /**
  13274. * Returns a string to use to update the GPU particles update shader
  13275. * @returns the effect defines string
  13276. */
  13277. getEffectDefines(): string;
  13278. /**
  13279. * Returns a string representing the class name
  13280. * @returns a string containing the class name
  13281. */
  13282. getClassName(): string;
  13283. /**
  13284. * Serializes the particle system to a JSON object.
  13285. * @returns the JSON object
  13286. */
  13287. serialize(): any;
  13288. /**
  13289. * Parse properties from a JSON object
  13290. * @param serializationObject defines the JSON object
  13291. * @param scene defines the hosting scene
  13292. */
  13293. parse(serializationObject: any, scene: Scene): void;
  13294. }
  13295. }
  13296. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13297. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import { Particle } from "babylonjs/Particles/particle";
  13300. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13301. /**
  13302. * Particle emitter emitting particles from the inside of a box.
  13303. * It emits the particles randomly between 2 given directions.
  13304. */
  13305. export class BoxParticleEmitter implements IParticleEmitterType {
  13306. /**
  13307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13308. */
  13309. direction1: Vector3;
  13310. /**
  13311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13312. */
  13313. direction2: Vector3;
  13314. /**
  13315. * 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.
  13316. */
  13317. minEmitBox: Vector3;
  13318. /**
  13319. * 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.
  13320. */
  13321. maxEmitBox: Vector3;
  13322. /**
  13323. * Creates a new instance BoxParticleEmitter
  13324. */
  13325. constructor();
  13326. /**
  13327. * Called by the particle System when the direction is computed for the created particle.
  13328. * @param worldMatrix is the world matrix of the particle system
  13329. * @param directionToUpdate is the direction vector to update with the result
  13330. * @param particle is the particle we are computed the direction for
  13331. * @param isLocal defines if the direction should be set in local space
  13332. */
  13333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13334. /**
  13335. * Called by the particle System when the position is computed for the created particle.
  13336. * @param worldMatrix is the world matrix of the particle system
  13337. * @param positionToUpdate is the position vector to update with the result
  13338. * @param particle is the particle we are computed the position for
  13339. * @param isLocal defines if the position should be set in local space
  13340. */
  13341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13342. /**
  13343. * Clones the current emitter and returns a copy of it
  13344. * @returns the new emitter
  13345. */
  13346. clone(): BoxParticleEmitter;
  13347. /**
  13348. * Called by the GPUParticleSystem to setup the update shader
  13349. * @param effect defines the update shader
  13350. */
  13351. applyToShader(effect: Effect): void;
  13352. /**
  13353. * Returns a string to use to update the GPU particles update shader
  13354. * @returns a string containng the defines string
  13355. */
  13356. getEffectDefines(): string;
  13357. /**
  13358. * Returns the string "BoxParticleEmitter"
  13359. * @returns a string containing the class name
  13360. */
  13361. getClassName(): string;
  13362. /**
  13363. * Serializes the particle system to a JSON object.
  13364. * @returns the JSON object
  13365. */
  13366. serialize(): any;
  13367. /**
  13368. * Parse properties from a JSON object
  13369. * @param serializationObject defines the JSON object
  13370. */
  13371. parse(serializationObject: any): void;
  13372. }
  13373. }
  13374. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13375. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13376. import { Effect } from "babylonjs/Materials/effect";
  13377. import { Particle } from "babylonjs/Particles/particle";
  13378. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13379. /**
  13380. * Particle emitter emitting particles from the inside of a cone.
  13381. * It emits the particles alongside the cone volume from the base to the particle.
  13382. * The emission direction might be randomized.
  13383. */
  13384. export class ConeParticleEmitter implements IParticleEmitterType {
  13385. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13386. directionRandomizer: number;
  13387. private _radius;
  13388. private _angle;
  13389. private _height;
  13390. /**
  13391. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13392. */
  13393. radiusRange: number;
  13394. /**
  13395. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13396. */
  13397. heightRange: number;
  13398. /**
  13399. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13400. */
  13401. emitFromSpawnPointOnly: boolean;
  13402. /**
  13403. * Gets or sets the radius of the emission cone
  13404. */
  13405. get radius(): number;
  13406. set radius(value: number);
  13407. /**
  13408. * Gets or sets the angle of the emission cone
  13409. */
  13410. get angle(): number;
  13411. set angle(value: number);
  13412. private _buildHeight;
  13413. /**
  13414. * Creates a new instance ConeParticleEmitter
  13415. * @param radius the radius of the emission cone (1 by default)
  13416. * @param angle the cone base angle (PI by default)
  13417. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13418. */
  13419. constructor(radius?: number, angle?: number,
  13420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13421. directionRandomizer?: number);
  13422. /**
  13423. * Called by the particle System when the direction is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param directionToUpdate is the direction vector to update with the result
  13426. * @param particle is the particle we are computed the direction for
  13427. * @param isLocal defines if the direction should be set in local space
  13428. */
  13429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Called by the particle System when the position is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param positionToUpdate is the position vector to update with the result
  13434. * @param particle is the particle we are computed the position for
  13435. * @param isLocal defines if the position should be set in local space
  13436. */
  13437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Clones the current emitter and returns a copy of it
  13440. * @returns the new emitter
  13441. */
  13442. clone(): ConeParticleEmitter;
  13443. /**
  13444. * Called by the GPUParticleSystem to setup the update shader
  13445. * @param effect defines the update shader
  13446. */
  13447. applyToShader(effect: Effect): void;
  13448. /**
  13449. * Returns a string to use to update the GPU particles update shader
  13450. * @returns a string containng the defines string
  13451. */
  13452. getEffectDefines(): string;
  13453. /**
  13454. * Returns the string "ConeParticleEmitter"
  13455. * @returns a string containing the class name
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Serializes the particle system to a JSON object.
  13460. * @returns the JSON object
  13461. */
  13462. serialize(): any;
  13463. /**
  13464. * Parse properties from a JSON object
  13465. * @param serializationObject defines the JSON object
  13466. */
  13467. parse(serializationObject: any): void;
  13468. }
  13469. }
  13470. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13471. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13472. import { Effect } from "babylonjs/Materials/effect";
  13473. import { Particle } from "babylonjs/Particles/particle";
  13474. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13475. /**
  13476. * Particle emitter emitting particles from the inside of a cylinder.
  13477. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13478. */
  13479. export class CylinderParticleEmitter implements IParticleEmitterType {
  13480. /**
  13481. * The radius of the emission cylinder.
  13482. */
  13483. radius: number;
  13484. /**
  13485. * The height of the emission cylinder.
  13486. */
  13487. height: number;
  13488. /**
  13489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13490. */
  13491. radiusRange: number;
  13492. /**
  13493. * How much to randomize the particle direction [0-1].
  13494. */
  13495. directionRandomizer: number;
  13496. /**
  13497. * Creates a new instance CylinderParticleEmitter
  13498. * @param radius the radius of the emission cylinder (1 by default)
  13499. * @param height the height of the emission cylinder (1 by default)
  13500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13502. */
  13503. constructor(
  13504. /**
  13505. * The radius of the emission cylinder.
  13506. */
  13507. radius?: number,
  13508. /**
  13509. * The height of the emission cylinder.
  13510. */
  13511. height?: number,
  13512. /**
  13513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13514. */
  13515. radiusRange?: number,
  13516. /**
  13517. * How much to randomize the particle direction [0-1].
  13518. */
  13519. directionRandomizer?: number);
  13520. /**
  13521. * Called by the particle System when the direction is computed for the created particle.
  13522. * @param worldMatrix is the world matrix of the particle system
  13523. * @param directionToUpdate is the direction vector to update with the result
  13524. * @param particle is the particle we are computed the direction for
  13525. * @param isLocal defines if the direction should be set in local space
  13526. */
  13527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13528. /**
  13529. * Called by the particle System when the position is computed for the created particle.
  13530. * @param worldMatrix is the world matrix of the particle system
  13531. * @param positionToUpdate is the position vector to update with the result
  13532. * @param particle is the particle we are computed the position for
  13533. * @param isLocal defines if the position should be set in local space
  13534. */
  13535. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13536. /**
  13537. * Clones the current emitter and returns a copy of it
  13538. * @returns the new emitter
  13539. */
  13540. clone(): CylinderParticleEmitter;
  13541. /**
  13542. * Called by the GPUParticleSystem to setup the update shader
  13543. * @param effect defines the update shader
  13544. */
  13545. applyToShader(effect: Effect): void;
  13546. /**
  13547. * Returns a string to use to update the GPU particles update shader
  13548. * @returns a string containng the defines string
  13549. */
  13550. getEffectDefines(): string;
  13551. /**
  13552. * Returns the string "CylinderParticleEmitter"
  13553. * @returns a string containing the class name
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Serializes the particle system to a JSON object.
  13558. * @returns the JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Parse properties from a JSON object
  13563. * @param serializationObject defines the JSON object
  13564. */
  13565. parse(serializationObject: any): void;
  13566. }
  13567. /**
  13568. * Particle emitter emitting particles from the inside of a cylinder.
  13569. * It emits the particles randomly between two vectors.
  13570. */
  13571. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13572. /**
  13573. * The min limit of the emission direction.
  13574. */
  13575. direction1: Vector3;
  13576. /**
  13577. * The max limit of the emission direction.
  13578. */
  13579. direction2: Vector3;
  13580. /**
  13581. * Creates a new instance CylinderDirectedParticleEmitter
  13582. * @param radius the radius of the emission cylinder (1 by default)
  13583. * @param height the height of the emission cylinder (1 by default)
  13584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13585. * @param direction1 the min limit of the emission direction (up vector by default)
  13586. * @param direction2 the max limit of the emission direction (up vector by default)
  13587. */
  13588. constructor(radius?: number, height?: number, radiusRange?: number,
  13589. /**
  13590. * The min limit of the emission direction.
  13591. */
  13592. direction1?: Vector3,
  13593. /**
  13594. * The max limit of the emission direction.
  13595. */
  13596. direction2?: Vector3);
  13597. /**
  13598. * Called by the particle System when the direction is computed for the created particle.
  13599. * @param worldMatrix is the world matrix of the particle system
  13600. * @param directionToUpdate is the direction vector to update with the result
  13601. * @param particle is the particle we are computed the direction for
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13604. /**
  13605. * Clones the current emitter and returns a copy of it
  13606. * @returns the new emitter
  13607. */
  13608. clone(): CylinderDirectedParticleEmitter;
  13609. /**
  13610. * Called by the GPUParticleSystem to setup the update shader
  13611. * @param effect defines the update shader
  13612. */
  13613. applyToShader(effect: Effect): void;
  13614. /**
  13615. * Returns a string to use to update the GPU particles update shader
  13616. * @returns a string containng the defines string
  13617. */
  13618. getEffectDefines(): string;
  13619. /**
  13620. * Returns the string "CylinderDirectedParticleEmitter"
  13621. * @returns a string containing the class name
  13622. */
  13623. getClassName(): string;
  13624. /**
  13625. * Serializes the particle system to a JSON object.
  13626. * @returns the JSON object
  13627. */
  13628. serialize(): any;
  13629. /**
  13630. * Parse properties from a JSON object
  13631. * @param serializationObject defines the JSON object
  13632. */
  13633. parse(serializationObject: any): void;
  13634. }
  13635. }
  13636. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13637. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13638. import { Effect } from "babylonjs/Materials/effect";
  13639. import { Particle } from "babylonjs/Particles/particle";
  13640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a hemisphere.
  13643. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13644. */
  13645. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13646. /**
  13647. * The radius of the emission hemisphere.
  13648. */
  13649. radius: number;
  13650. /**
  13651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13652. */
  13653. radiusRange: number;
  13654. /**
  13655. * How much to randomize the particle direction [0-1].
  13656. */
  13657. directionRandomizer: number;
  13658. /**
  13659. * Creates a new instance HemisphericParticleEmitter
  13660. * @param radius the radius of the emission hemisphere (1 by default)
  13661. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13662. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13663. */
  13664. constructor(
  13665. /**
  13666. * The radius of the emission hemisphere.
  13667. */
  13668. radius?: number,
  13669. /**
  13670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13671. */
  13672. radiusRange?: number,
  13673. /**
  13674. * How much to randomize the particle direction [0-1].
  13675. */
  13676. directionRandomizer?: number);
  13677. /**
  13678. * Called by the particle System when the direction is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param directionToUpdate is the direction vector to update with the result
  13681. * @param particle is the particle we are computed the direction for
  13682. * @param isLocal defines if the direction should be set in local space
  13683. */
  13684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Called by the particle System when the position is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param positionToUpdate is the position vector to update with the result
  13689. * @param particle is the particle we are computed the position for
  13690. * @param isLocal defines if the position should be set in local space
  13691. */
  13692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13693. /**
  13694. * Clones the current emitter and returns a copy of it
  13695. * @returns the new emitter
  13696. */
  13697. clone(): HemisphericParticleEmitter;
  13698. /**
  13699. * Called by the GPUParticleSystem to setup the update shader
  13700. * @param effect defines the update shader
  13701. */
  13702. applyToShader(effect: Effect): void;
  13703. /**
  13704. * Returns a string to use to update the GPU particles update shader
  13705. * @returns a string containng the defines string
  13706. */
  13707. getEffectDefines(): string;
  13708. /**
  13709. * Returns the string "HemisphericParticleEmitter"
  13710. * @returns a string containing the class name
  13711. */
  13712. getClassName(): string;
  13713. /**
  13714. * Serializes the particle system to a JSON object.
  13715. * @returns the JSON object
  13716. */
  13717. serialize(): any;
  13718. /**
  13719. * Parse properties from a JSON object
  13720. * @param serializationObject defines the JSON object
  13721. */
  13722. parse(serializationObject: any): void;
  13723. }
  13724. }
  13725. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13727. import { Effect } from "babylonjs/Materials/effect";
  13728. import { Particle } from "babylonjs/Particles/particle";
  13729. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13730. /**
  13731. * Particle emitter emitting particles from a point.
  13732. * It emits the particles randomly between 2 given directions.
  13733. */
  13734. export class PointParticleEmitter implements IParticleEmitterType {
  13735. /**
  13736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13737. */
  13738. direction1: Vector3;
  13739. /**
  13740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13741. */
  13742. direction2: Vector3;
  13743. /**
  13744. * Creates a new instance PointParticleEmitter
  13745. */
  13746. constructor();
  13747. /**
  13748. * Called by the particle System when the direction is computed for the created particle.
  13749. * @param worldMatrix is the world matrix of the particle system
  13750. * @param directionToUpdate is the direction vector to update with the result
  13751. * @param particle is the particle we are computed the direction for
  13752. * @param isLocal defines if the direction should be set in local space
  13753. */
  13754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13755. /**
  13756. * Called by the particle System when the position is computed for the created particle.
  13757. * @param worldMatrix is the world matrix of the particle system
  13758. * @param positionToUpdate is the position vector to update with the result
  13759. * @param particle is the particle we are computed the position for
  13760. * @param isLocal defines if the position should be set in local space
  13761. */
  13762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13763. /**
  13764. * Clones the current emitter and returns a copy of it
  13765. * @returns the new emitter
  13766. */
  13767. clone(): PointParticleEmitter;
  13768. /**
  13769. * Called by the GPUParticleSystem to setup the update shader
  13770. * @param effect defines the update shader
  13771. */
  13772. applyToShader(effect: Effect): void;
  13773. /**
  13774. * Returns a string to use to update the GPU particles update shader
  13775. * @returns a string containng the defines string
  13776. */
  13777. getEffectDefines(): string;
  13778. /**
  13779. * Returns the string "PointParticleEmitter"
  13780. * @returns a string containing the class name
  13781. */
  13782. getClassName(): string;
  13783. /**
  13784. * Serializes the particle system to a JSON object.
  13785. * @returns the JSON object
  13786. */
  13787. serialize(): any;
  13788. /**
  13789. * Parse properties from a JSON object
  13790. * @param serializationObject defines the JSON object
  13791. */
  13792. parse(serializationObject: any): void;
  13793. }
  13794. }
  13795. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13797. import { Effect } from "babylonjs/Materials/effect";
  13798. import { Particle } from "babylonjs/Particles/particle";
  13799. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13800. /**
  13801. * Particle emitter emitting particles from the inside of a sphere.
  13802. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13803. */
  13804. export class SphereParticleEmitter implements IParticleEmitterType {
  13805. /**
  13806. * The radius of the emission sphere.
  13807. */
  13808. radius: number;
  13809. /**
  13810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13811. */
  13812. radiusRange: number;
  13813. /**
  13814. * How much to randomize the particle direction [0-1].
  13815. */
  13816. directionRandomizer: number;
  13817. /**
  13818. * Creates a new instance SphereParticleEmitter
  13819. * @param radius the radius of the emission sphere (1 by default)
  13820. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13822. */
  13823. constructor(
  13824. /**
  13825. * The radius of the emission sphere.
  13826. */
  13827. radius?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): SphereParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "SphereParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a sphere.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance SphereDirectedParticleEmitter
  13898. * @param radius the radius of the emission sphere (1 by default)
  13899. * @param direction1 the min limit of the emission direction (up vector by default)
  13900. * @param direction2 the max limit of the emission direction (up vector by default)
  13901. */
  13902. constructor(radius?: number,
  13903. /**
  13904. * The min limit of the emission direction.
  13905. */
  13906. direction1?: Vector3,
  13907. /**
  13908. * The max limit of the emission direction.
  13909. */
  13910. direction2?: Vector3);
  13911. /**
  13912. * Called by the particle System when the direction is computed for the created particle.
  13913. * @param worldMatrix is the world matrix of the particle system
  13914. * @param directionToUpdate is the direction vector to update with the result
  13915. * @param particle is the particle we are computed the direction for
  13916. */
  13917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13918. /**
  13919. * Clones the current emitter and returns a copy of it
  13920. * @returns the new emitter
  13921. */
  13922. clone(): SphereDirectedParticleEmitter;
  13923. /**
  13924. * Called by the GPUParticleSystem to setup the update shader
  13925. * @param effect defines the update shader
  13926. */
  13927. applyToShader(effect: Effect): void;
  13928. /**
  13929. * Returns a string to use to update the GPU particles update shader
  13930. * @returns a string containng the defines string
  13931. */
  13932. getEffectDefines(): string;
  13933. /**
  13934. * Returns the string "SphereDirectedParticleEmitter"
  13935. * @returns a string containing the class name
  13936. */
  13937. getClassName(): string;
  13938. /**
  13939. * Serializes the particle system to a JSON object.
  13940. * @returns the JSON object
  13941. */
  13942. serialize(): any;
  13943. /**
  13944. * Parse properties from a JSON object
  13945. * @param serializationObject defines the JSON object
  13946. */
  13947. parse(serializationObject: any): void;
  13948. }
  13949. }
  13950. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13951. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13952. import { Effect } from "babylonjs/Materials/effect";
  13953. import { Particle } from "babylonjs/Particles/particle";
  13954. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13955. import { Nullable } from "babylonjs/types";
  13956. /**
  13957. * Particle emitter emitting particles from a custom list of positions.
  13958. */
  13959. export class CustomParticleEmitter implements IParticleEmitterType {
  13960. /**
  13961. * Gets or sets the position generator that will create the inital position of each particle.
  13962. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13963. */
  13964. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13965. /**
  13966. * Gets or sets the destination generator that will create the final destination of each particle.
  13967. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13968. */
  13969. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13970. /**
  13971. * Creates a new instance CustomParticleEmitter
  13972. */
  13973. constructor();
  13974. /**
  13975. * Called by the particle System when the direction is computed for the created particle.
  13976. * @param worldMatrix is the world matrix of the particle system
  13977. * @param directionToUpdate is the direction vector to update with the result
  13978. * @param particle is the particle we are computed the direction for
  13979. * @param isLocal defines if the direction should be set in local space
  13980. */
  13981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13982. /**
  13983. * Called by the particle System when the position is computed for the created particle.
  13984. * @param worldMatrix is the world matrix of the particle system
  13985. * @param positionToUpdate is the position vector to update with the result
  13986. * @param particle is the particle we are computed the position for
  13987. * @param isLocal defines if the position should be set in local space
  13988. */
  13989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13990. /**
  13991. * Clones the current emitter and returns a copy of it
  13992. * @returns the new emitter
  13993. */
  13994. clone(): CustomParticleEmitter;
  13995. /**
  13996. * Called by the GPUParticleSystem to setup the update shader
  13997. * @param effect defines the update shader
  13998. */
  13999. applyToShader(effect: Effect): void;
  14000. /**
  14001. * Returns a string to use to update the GPU particles update shader
  14002. * @returns a string containng the defines string
  14003. */
  14004. getEffectDefines(): string;
  14005. /**
  14006. * Returns the string "PointParticleEmitter"
  14007. * @returns a string containing the class name
  14008. */
  14009. getClassName(): string;
  14010. /**
  14011. * Serializes the particle system to a JSON object.
  14012. * @returns the JSON object
  14013. */
  14014. serialize(): any;
  14015. /**
  14016. * Parse properties from a JSON object
  14017. * @param serializationObject defines the JSON object
  14018. */
  14019. parse(serializationObject: any): void;
  14020. }
  14021. }
  14022. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14023. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14024. import { Effect } from "babylonjs/Materials/effect";
  14025. import { Particle } from "babylonjs/Particles/particle";
  14026. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14027. import { Nullable } from "babylonjs/types";
  14028. import { Scene } from "babylonjs/scene";
  14029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14030. /**
  14031. * Particle emitter emitting particles from the inside of a box.
  14032. * It emits the particles randomly between 2 given directions.
  14033. */
  14034. export class MeshParticleEmitter implements IParticleEmitterType {
  14035. private _indices;
  14036. private _positions;
  14037. private _normals;
  14038. private _storedNormal;
  14039. private _mesh;
  14040. /**
  14041. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14042. */
  14043. direction1: Vector3;
  14044. /**
  14045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14046. */
  14047. direction2: Vector3;
  14048. /**
  14049. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14050. */
  14051. useMeshNormalsForDirection: boolean;
  14052. /** Defines the mesh to use as source */
  14053. get mesh(): Nullable<AbstractMesh>;
  14054. set mesh(value: Nullable<AbstractMesh>);
  14055. /**
  14056. * Creates a new instance MeshParticleEmitter
  14057. * @param mesh defines the mesh to use as source
  14058. */
  14059. constructor(mesh?: Nullable<AbstractMesh>);
  14060. /**
  14061. * Called by the particle System when the direction is computed for the created particle.
  14062. * @param worldMatrix is the world matrix of the particle system
  14063. * @param directionToUpdate is the direction vector to update with the result
  14064. * @param particle is the particle we are computed the direction for
  14065. * @param isLocal defines if the direction should be set in local space
  14066. */
  14067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14068. /**
  14069. * Called by the particle System when the position is computed for the created particle.
  14070. * @param worldMatrix is the world matrix of the particle system
  14071. * @param positionToUpdate is the position vector to update with the result
  14072. * @param particle is the particle we are computed the position for
  14073. * @param isLocal defines if the position should be set in local space
  14074. */
  14075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14076. /**
  14077. * Clones the current emitter and returns a copy of it
  14078. * @returns the new emitter
  14079. */
  14080. clone(): MeshParticleEmitter;
  14081. /**
  14082. * Called by the GPUParticleSystem to setup the update shader
  14083. * @param effect defines the update shader
  14084. */
  14085. applyToShader(effect: Effect): void;
  14086. /**
  14087. * Returns a string to use to update the GPU particles update shader
  14088. * @returns a string containng the defines string
  14089. */
  14090. getEffectDefines(): string;
  14091. /**
  14092. * Returns the string "BoxParticleEmitter"
  14093. * @returns a string containing the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Serializes the particle system to a JSON object.
  14098. * @returns the JSON object
  14099. */
  14100. serialize(): any;
  14101. /**
  14102. * Parse properties from a JSON object
  14103. * @param serializationObject defines the JSON object
  14104. * @param scene defines the hosting scene
  14105. */
  14106. parse(serializationObject: any, scene: Scene): void;
  14107. }
  14108. }
  14109. declare module "babylonjs/Particles/EmitterTypes/index" {
  14110. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14111. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14112. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14113. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14114. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14115. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14116. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14117. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14118. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14119. }
  14120. declare module "babylonjs/Particles/IParticleSystem" {
  14121. import { Nullable } from "babylonjs/types";
  14122. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14123. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14126. import { Texture } from "babylonjs/Materials/Textures/texture";
  14127. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14130. import { Effect } from "babylonjs/Materials/effect";
  14131. import { Observable } from "babylonjs/Misc/observable";
  14132. import { Animation } from "babylonjs/Animations/animation";
  14133. /**
  14134. * Interface representing a particle system in Babylon.js.
  14135. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14136. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14137. */
  14138. export interface IParticleSystem {
  14139. /**
  14140. * List of animations used by the particle system.
  14141. */
  14142. animations: Animation[];
  14143. /**
  14144. * The id of the Particle system.
  14145. */
  14146. id: string;
  14147. /**
  14148. * The name of the Particle system.
  14149. */
  14150. name: string;
  14151. /**
  14152. * The emitter represents the Mesh or position we are attaching the particle system to.
  14153. */
  14154. emitter: Nullable<AbstractMesh | Vector3>;
  14155. /**
  14156. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14157. */
  14158. isBillboardBased: boolean;
  14159. /**
  14160. * The rendering group used by the Particle system to chose when to render.
  14161. */
  14162. renderingGroupId: number;
  14163. /**
  14164. * The layer mask we are rendering the particles through.
  14165. */
  14166. layerMask: number;
  14167. /**
  14168. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14169. */
  14170. updateSpeed: number;
  14171. /**
  14172. * The amount of time the particle system is running (depends of the overall update speed).
  14173. */
  14174. targetStopDuration: number;
  14175. /**
  14176. * The texture used to render each particle. (this can be a spritesheet)
  14177. */
  14178. particleTexture: Nullable<Texture>;
  14179. /**
  14180. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14181. */
  14182. blendMode: number;
  14183. /**
  14184. * Minimum life time of emitting particles.
  14185. */
  14186. minLifeTime: number;
  14187. /**
  14188. * Maximum life time of emitting particles.
  14189. */
  14190. maxLifeTime: number;
  14191. /**
  14192. * Minimum Size of emitting particles.
  14193. */
  14194. minSize: number;
  14195. /**
  14196. * Maximum Size of emitting particles.
  14197. */
  14198. maxSize: number;
  14199. /**
  14200. * Minimum scale of emitting particles on X axis.
  14201. */
  14202. minScaleX: number;
  14203. /**
  14204. * Maximum scale of emitting particles on X axis.
  14205. */
  14206. maxScaleX: number;
  14207. /**
  14208. * Minimum scale of emitting particles on Y axis.
  14209. */
  14210. minScaleY: number;
  14211. /**
  14212. * Maximum scale of emitting particles on Y axis.
  14213. */
  14214. maxScaleY: number;
  14215. /**
  14216. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14217. */
  14218. color1: Color4;
  14219. /**
  14220. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14221. */
  14222. color2: Color4;
  14223. /**
  14224. * Color the particle will have at the end of its lifetime.
  14225. */
  14226. colorDead: Color4;
  14227. /**
  14228. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14229. */
  14230. emitRate: number;
  14231. /**
  14232. * You can use gravity if you want to give an orientation to your particles.
  14233. */
  14234. gravity: Vector3;
  14235. /**
  14236. * Minimum power of emitting particles.
  14237. */
  14238. minEmitPower: number;
  14239. /**
  14240. * Maximum power of emitting particles.
  14241. */
  14242. maxEmitPower: number;
  14243. /**
  14244. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14245. */
  14246. minAngularSpeed: number;
  14247. /**
  14248. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14249. */
  14250. maxAngularSpeed: number;
  14251. /**
  14252. * Gets or sets the minimal initial rotation in radians.
  14253. */
  14254. minInitialRotation: number;
  14255. /**
  14256. * Gets or sets the maximal initial rotation in radians.
  14257. */
  14258. maxInitialRotation: number;
  14259. /**
  14260. * The particle emitter type defines the emitter used by the particle system.
  14261. * It can be for example box, sphere, or cone...
  14262. */
  14263. particleEmitterType: Nullable<IParticleEmitterType>;
  14264. /**
  14265. * Defines the delay in milliseconds before starting the system (0 by default)
  14266. */
  14267. startDelay: number;
  14268. /**
  14269. * 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
  14270. */
  14271. preWarmCycles: number;
  14272. /**
  14273. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14274. */
  14275. preWarmStepOffset: number;
  14276. /**
  14277. * 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)
  14278. */
  14279. spriteCellChangeSpeed: number;
  14280. /**
  14281. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14282. */
  14283. startSpriteCellID: number;
  14284. /**
  14285. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14286. */
  14287. endSpriteCellID: number;
  14288. /**
  14289. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14290. */
  14291. spriteCellWidth: number;
  14292. /**
  14293. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14294. */
  14295. spriteCellHeight: number;
  14296. /**
  14297. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14298. */
  14299. spriteRandomStartCell: boolean;
  14300. /**
  14301. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14302. */
  14303. isAnimationSheetEnabled: boolean;
  14304. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14305. translationPivot: Vector2;
  14306. /**
  14307. * Gets or sets a texture used to add random noise to particle positions
  14308. */
  14309. noiseTexture: Nullable<BaseTexture>;
  14310. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14311. noiseStrength: Vector3;
  14312. /**
  14313. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14314. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14315. */
  14316. billboardMode: number;
  14317. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14318. limitVelocityDamping: number;
  14319. /**
  14320. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14321. */
  14322. beginAnimationOnStart: boolean;
  14323. /**
  14324. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14325. */
  14326. beginAnimationFrom: number;
  14327. /**
  14328. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14329. */
  14330. beginAnimationTo: number;
  14331. /**
  14332. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14333. */
  14334. beginAnimationLoop: boolean;
  14335. /**
  14336. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14337. */
  14338. disposeOnStop: boolean;
  14339. /**
  14340. * Specifies if the particles are updated in emitter local space or world space
  14341. */
  14342. isLocal: boolean;
  14343. /** Snippet ID if the particle system was created from the snippet server */
  14344. snippetId: string;
  14345. /**
  14346. * Gets the maximum number of particles active at the same time.
  14347. * @returns The max number of active particles.
  14348. */
  14349. getCapacity(): number;
  14350. /**
  14351. * Gets the number of particles active at the same time.
  14352. * @returns The number of active particles.
  14353. */
  14354. getActiveCount(): number;
  14355. /**
  14356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14357. * @returns True if it has been started, otherwise false.
  14358. */
  14359. isStarted(): boolean;
  14360. /**
  14361. * Animates the particle system for this frame.
  14362. */
  14363. animate(): void;
  14364. /**
  14365. * Renders the particle system in its current state.
  14366. * @returns the current number of particles
  14367. */
  14368. render(): number;
  14369. /**
  14370. * Dispose the particle system and frees its associated resources.
  14371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14372. */
  14373. dispose(disposeTexture?: boolean): void;
  14374. /**
  14375. * An event triggered when the system is disposed
  14376. */
  14377. onDisposeObservable: Observable<IParticleSystem>;
  14378. /**
  14379. * Clones the particle system.
  14380. * @param name The name of the cloned object
  14381. * @param newEmitter The new emitter to use
  14382. * @returns the cloned particle system
  14383. */
  14384. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14385. /**
  14386. * Serializes the particle system to a JSON object
  14387. * @param serializeTexture defines if the texture must be serialized as well
  14388. * @returns the JSON object
  14389. */
  14390. serialize(serializeTexture: boolean): any;
  14391. /**
  14392. * Rebuild the particle system
  14393. */
  14394. rebuild(): void;
  14395. /** Force the system to rebuild all gradients that need to be resync */
  14396. forceRefreshGradients(): void;
  14397. /**
  14398. * Starts the particle system and begins to emit
  14399. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14400. */
  14401. start(delay?: number): void;
  14402. /**
  14403. * Stops the particle system.
  14404. */
  14405. stop(): void;
  14406. /**
  14407. * Remove all active particles
  14408. */
  14409. reset(): void;
  14410. /**
  14411. * Gets a boolean indicating that the system is stopping
  14412. * @returns true if the system is currently stopping
  14413. */
  14414. isStopping(): boolean;
  14415. /**
  14416. * Is this system ready to be used/rendered
  14417. * @return true if the system is ready
  14418. */
  14419. isReady(): boolean;
  14420. /**
  14421. * Returns the string "ParticleSystem"
  14422. * @returns a string containing the class name
  14423. */
  14424. getClassName(): string;
  14425. /**
  14426. * Gets the custom effect used to render the particles
  14427. * @param blendMode Blend mode for which the effect should be retrieved
  14428. * @returns The effect
  14429. */
  14430. getCustomEffect(blendMode: number): Nullable<Effect>;
  14431. /**
  14432. * Sets the custom effect used to render the particles
  14433. * @param effect The effect to set
  14434. * @param blendMode Blend mode for which the effect should be set
  14435. */
  14436. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14437. /**
  14438. * Fill the defines array according to the current settings of the particle system
  14439. * @param defines Array to be updated
  14440. * @param blendMode blend mode to take into account when updating the array
  14441. */
  14442. fillDefines(defines: Array<string>, blendMode: number): void;
  14443. /**
  14444. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14445. * @param uniforms Uniforms array to fill
  14446. * @param attributes Attributes array to fill
  14447. * @param samplers Samplers array to fill
  14448. */
  14449. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14450. /**
  14451. * Observable that will be called just before the particles are drawn
  14452. */
  14453. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14454. /**
  14455. * Gets the name of the particle vertex shader
  14456. */
  14457. vertexShaderName: string;
  14458. /**
  14459. * Adds a new color gradient
  14460. * @param gradient defines the gradient to use (between 0 and 1)
  14461. * @param color1 defines the color to affect to the specified gradient
  14462. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14463. * @returns the current particle system
  14464. */
  14465. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14466. /**
  14467. * Remove a specific color gradient
  14468. * @param gradient defines the gradient to remove
  14469. * @returns the current particle system
  14470. */
  14471. removeColorGradient(gradient: number): IParticleSystem;
  14472. /**
  14473. * Adds a new size gradient
  14474. * @param gradient defines the gradient to use (between 0 and 1)
  14475. * @param factor defines the size factor to affect to the specified gradient
  14476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14477. * @returns the current particle system
  14478. */
  14479. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14480. /**
  14481. * Remove a specific size gradient
  14482. * @param gradient defines the gradient to remove
  14483. * @returns the current particle system
  14484. */
  14485. removeSizeGradient(gradient: number): IParticleSystem;
  14486. /**
  14487. * Gets the current list of color gradients.
  14488. * You must use addColorGradient and removeColorGradient to udpate this list
  14489. * @returns the list of color gradients
  14490. */
  14491. getColorGradients(): Nullable<Array<ColorGradient>>;
  14492. /**
  14493. * Gets the current list of size gradients.
  14494. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14495. * @returns the list of size gradients
  14496. */
  14497. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Gets the current list of angular speed gradients.
  14500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14501. * @returns the list of angular speed gradients
  14502. */
  14503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Adds a new angular speed gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param factor defines the angular speed to affect to the specified gradient
  14508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14509. * @returns the current particle system
  14510. */
  14511. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14512. /**
  14513. * Remove a specific angular speed gradient
  14514. * @param gradient defines the gradient to remove
  14515. * @returns the current particle system
  14516. */
  14517. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14518. /**
  14519. * Gets the current list of velocity gradients.
  14520. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14521. * @returns the list of velocity gradients
  14522. */
  14523. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14524. /**
  14525. * Adds a new velocity gradient
  14526. * @param gradient defines the gradient to use (between 0 and 1)
  14527. * @param factor defines the velocity to affect to the specified gradient
  14528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14529. * @returns the current particle system
  14530. */
  14531. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14532. /**
  14533. * Remove a specific velocity gradient
  14534. * @param gradient defines the gradient to remove
  14535. * @returns the current particle system
  14536. */
  14537. removeVelocityGradient(gradient: number): IParticleSystem;
  14538. /**
  14539. * Gets the current list of limit velocity gradients.
  14540. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14541. * @returns the list of limit velocity gradients
  14542. */
  14543. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Adds a new limit velocity gradient
  14546. * @param gradient defines the gradient to use (between 0 and 1)
  14547. * @param factor defines the limit velocity to affect to the specified gradient
  14548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14549. * @returns the current particle system
  14550. */
  14551. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14552. /**
  14553. * Remove a specific limit velocity gradient
  14554. * @param gradient defines the gradient to remove
  14555. * @returns the current particle system
  14556. */
  14557. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14558. /**
  14559. * Adds a new drag gradient
  14560. * @param gradient defines the gradient to use (between 0 and 1)
  14561. * @param factor defines the drag to affect to the specified gradient
  14562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14563. * @returns the current particle system
  14564. */
  14565. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14566. /**
  14567. * Remove a specific drag gradient
  14568. * @param gradient defines the gradient to remove
  14569. * @returns the current particle system
  14570. */
  14571. removeDragGradient(gradient: number): IParticleSystem;
  14572. /**
  14573. * Gets the current list of drag gradients.
  14574. * You must use addDragGradient and removeDragGradient to udpate this list
  14575. * @returns the list of drag gradients
  14576. */
  14577. getDragGradients(): Nullable<Array<FactorGradient>>;
  14578. /**
  14579. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param factor defines the emit rate to affect to the specified gradient
  14582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14583. * @returns the current particle system
  14584. */
  14585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14586. /**
  14587. * Remove a specific emit rate gradient
  14588. * @param gradient defines the gradient to remove
  14589. * @returns the current particle system
  14590. */
  14591. removeEmitRateGradient(gradient: number): IParticleSystem;
  14592. /**
  14593. * Gets the current list of emit rate gradients.
  14594. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14595. * @returns the list of emit rate gradients
  14596. */
  14597. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14598. /**
  14599. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param factor defines the start size to affect to the specified gradient
  14602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14603. * @returns the current particle system
  14604. */
  14605. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14606. /**
  14607. * Remove a specific start size gradient
  14608. * @param gradient defines the gradient to remove
  14609. * @returns the current particle system
  14610. */
  14611. removeStartSizeGradient(gradient: number): IParticleSystem;
  14612. /**
  14613. * Gets the current list of start size gradients.
  14614. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14615. * @returns the list of start size gradients
  14616. */
  14617. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Adds a new life time gradient
  14620. * @param gradient defines the gradient to use (between 0 and 1)
  14621. * @param factor defines the life time factor to affect to the specified gradient
  14622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14623. * @returns the current particle system
  14624. */
  14625. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14626. /**
  14627. * Remove a specific life time gradient
  14628. * @param gradient defines the gradient to remove
  14629. * @returns the current particle system
  14630. */
  14631. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of life time gradients.
  14634. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14635. * @returns the list of life time gradients
  14636. */
  14637. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of color gradients.
  14640. * You must use addColorGradient and removeColorGradient to udpate this list
  14641. * @returns the list of color gradients
  14642. */
  14643. getColorGradients(): Nullable<Array<ColorGradient>>;
  14644. /**
  14645. * Adds a new ramp gradient used to remap particle colors
  14646. * @param gradient defines the gradient to use (between 0 and 1)
  14647. * @param color defines the color to affect to the specified gradient
  14648. * @returns the current particle system
  14649. */
  14650. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14651. /**
  14652. * Gets the current list of ramp gradients.
  14653. * You must use addRampGradient and removeRampGradient to udpate this list
  14654. * @returns the list of ramp gradients
  14655. */
  14656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14657. /** Gets or sets a boolean indicating that ramp gradients must be used
  14658. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14659. */
  14660. useRampGradients: boolean;
  14661. /**
  14662. * Adds a new color remap gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param min defines the color remap minimal range
  14665. * @param max defines the color remap maximal range
  14666. * @returns the current particle system
  14667. */
  14668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14669. /**
  14670. * Gets the current list of color remap gradients.
  14671. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14672. * @returns the list of color remap gradients
  14673. */
  14674. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Adds a new alpha remap gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param min defines the alpha remap minimal range
  14679. * @param max defines the alpha remap maximal range
  14680. * @returns the current particle system
  14681. */
  14682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14683. /**
  14684. * Gets the current list of alpha remap gradients.
  14685. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14686. * @returns the list of alpha remap gradients
  14687. */
  14688. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14689. /**
  14690. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14693. * @returns the emitter
  14694. */
  14695. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14696. /**
  14697. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14698. * @param radius The radius of the hemisphere to emit from
  14699. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14700. * @returns the emitter
  14701. */
  14702. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14703. /**
  14704. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14705. * @param radius The radius of the sphere to emit from
  14706. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14707. * @returns the emitter
  14708. */
  14709. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14710. /**
  14711. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14712. * @param radius The radius of the sphere to emit from
  14713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14715. * @returns the emitter
  14716. */
  14717. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14718. /**
  14719. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14720. * @param radius The radius of the emission cylinder
  14721. * @param height The height of the emission cylinder
  14722. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14723. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14724. * @returns the emitter
  14725. */
  14726. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14727. /**
  14728. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14729. * @param radius The radius of the cylinder to emit from
  14730. * @param height The height of the emission cylinder
  14731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14734. * @returns the emitter
  14735. */
  14736. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14737. /**
  14738. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14739. * @param radius The radius of the cone to emit from
  14740. * @param angle The base angle of the cone
  14741. * @returns the emitter
  14742. */
  14743. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14744. /**
  14745. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14748. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14749. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14750. * @returns the emitter
  14751. */
  14752. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14753. /**
  14754. * Get hosting scene
  14755. * @returns the scene
  14756. */
  14757. getScene(): Scene;
  14758. }
  14759. }
  14760. declare module "babylonjs/Meshes/transformNode" {
  14761. import { DeepImmutable } from "babylonjs/types";
  14762. import { Observable } from "babylonjs/Misc/observable";
  14763. import { Nullable } from "babylonjs/types";
  14764. import { Camera } from "babylonjs/Cameras/camera";
  14765. import { Scene } from "babylonjs/scene";
  14766. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14767. import { Node } from "babylonjs/node";
  14768. import { Bone } from "babylonjs/Bones/bone";
  14769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14770. import { Space } from "babylonjs/Maths/math.axis";
  14771. /**
  14772. * 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.
  14773. * @see https://doc.babylonjs.com/how_to/transformnode
  14774. */
  14775. export class TransformNode extends Node {
  14776. /**
  14777. * Object will not rotate to face the camera
  14778. */
  14779. static BILLBOARDMODE_NONE: number;
  14780. /**
  14781. * Object will rotate to face the camera but only on the x axis
  14782. */
  14783. static BILLBOARDMODE_X: number;
  14784. /**
  14785. * Object will rotate to face the camera but only on the y axis
  14786. */
  14787. static BILLBOARDMODE_Y: number;
  14788. /**
  14789. * Object will rotate to face the camera but only on the z axis
  14790. */
  14791. static BILLBOARDMODE_Z: number;
  14792. /**
  14793. * Object will rotate to face the camera
  14794. */
  14795. static BILLBOARDMODE_ALL: number;
  14796. /**
  14797. * Object will rotate to face the camera's position instead of orientation
  14798. */
  14799. static BILLBOARDMODE_USE_POSITION: number;
  14800. private static _TmpRotation;
  14801. private static _TmpScaling;
  14802. private static _TmpTranslation;
  14803. private _forward;
  14804. private _forwardInverted;
  14805. private _up;
  14806. private _right;
  14807. private _rightInverted;
  14808. private _position;
  14809. private _rotation;
  14810. private _rotationQuaternion;
  14811. protected _scaling: Vector3;
  14812. protected _isDirty: boolean;
  14813. private _transformToBoneReferal;
  14814. private _isAbsoluteSynced;
  14815. private _billboardMode;
  14816. /**
  14817. * Gets or sets the billboard mode. Default is 0.
  14818. *
  14819. * | Value | Type | Description |
  14820. * | --- | --- | --- |
  14821. * | 0 | BILLBOARDMODE_NONE | |
  14822. * | 1 | BILLBOARDMODE_X | |
  14823. * | 2 | BILLBOARDMODE_Y | |
  14824. * | 4 | BILLBOARDMODE_Z | |
  14825. * | 7 | BILLBOARDMODE_ALL | |
  14826. *
  14827. */
  14828. get billboardMode(): number;
  14829. set billboardMode(value: number);
  14830. private _preserveParentRotationForBillboard;
  14831. /**
  14832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14834. */
  14835. get preserveParentRotationForBillboard(): boolean;
  14836. set preserveParentRotationForBillboard(value: boolean);
  14837. /**
  14838. * 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
  14839. */
  14840. scalingDeterminant: number;
  14841. private _infiniteDistance;
  14842. /**
  14843. * Gets or sets the distance of the object to max, often used by skybox
  14844. */
  14845. get infiniteDistance(): boolean;
  14846. set infiniteDistance(value: boolean);
  14847. /**
  14848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14849. * By default the system will update normals to compensate
  14850. */
  14851. ignoreNonUniformScaling: boolean;
  14852. /**
  14853. * 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
  14854. */
  14855. reIntegrateRotationIntoRotationQuaternion: boolean;
  14856. /** @hidden */
  14857. _poseMatrix: Nullable<Matrix>;
  14858. /** @hidden */
  14859. _localMatrix: Matrix;
  14860. private _usePivotMatrix;
  14861. private _absolutePosition;
  14862. private _absoluteScaling;
  14863. private _absoluteRotationQuaternion;
  14864. private _pivotMatrix;
  14865. private _pivotMatrixInverse;
  14866. protected _postMultiplyPivotMatrix: boolean;
  14867. protected _isWorldMatrixFrozen: boolean;
  14868. /** @hidden */
  14869. _indexInSceneTransformNodesArray: number;
  14870. /**
  14871. * An event triggered after the world matrix is updated
  14872. */
  14873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14875. /**
  14876. * Gets a string identifying the name of the class
  14877. * @returns "TransformNode" string
  14878. */
  14879. getClassName(): string;
  14880. /**
  14881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14882. */
  14883. get position(): Vector3;
  14884. set position(newPosition: Vector3);
  14885. /**
  14886. * 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)).
  14887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14888. */
  14889. get rotation(): Vector3;
  14890. set rotation(newRotation: Vector3);
  14891. /**
  14892. * 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)).
  14893. */
  14894. get scaling(): Vector3;
  14895. set scaling(newScaling: Vector3);
  14896. /**
  14897. * 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).
  14898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14899. */
  14900. get rotationQuaternion(): Nullable<Quaternion>;
  14901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14902. /**
  14903. * The forward direction of that transform in world space.
  14904. */
  14905. get forward(): Vector3;
  14906. /**
  14907. * The up direction of that transform in world space.
  14908. */
  14909. get up(): Vector3;
  14910. /**
  14911. * The right direction of that transform in world space.
  14912. */
  14913. get right(): Vector3;
  14914. /**
  14915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14916. * @param matrix the matrix to copy the pose from
  14917. * @returns this TransformNode.
  14918. */
  14919. updatePoseMatrix(matrix: Matrix): TransformNode;
  14920. /**
  14921. * Returns the mesh Pose matrix.
  14922. * @returns the pose matrix
  14923. */
  14924. getPoseMatrix(): Matrix;
  14925. /** @hidden */
  14926. _isSynchronized(): boolean;
  14927. /** @hidden */
  14928. _initCache(): void;
  14929. /**
  14930. * Flag the transform node as dirty (Forcing it to update everything)
  14931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14932. * @returns this transform node
  14933. */
  14934. markAsDirty(property: string): TransformNode;
  14935. /**
  14936. * Returns the current mesh absolute position.
  14937. * Returns a Vector3.
  14938. */
  14939. get absolutePosition(): Vector3;
  14940. /**
  14941. * Returns the current mesh absolute scaling.
  14942. * Returns a Vector3.
  14943. */
  14944. get absoluteScaling(): Vector3;
  14945. /**
  14946. * Returns the current mesh absolute rotation.
  14947. * Returns a Quaternion.
  14948. */
  14949. get absoluteRotationQuaternion(): Quaternion;
  14950. /**
  14951. * Sets a new matrix to apply before all other transformation
  14952. * @param matrix defines the transform matrix
  14953. * @returns the current TransformNode
  14954. */
  14955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14956. /**
  14957. * Sets a new pivot matrix to the current node
  14958. * @param matrix defines the new pivot matrix to use
  14959. * @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
  14960. * @returns the current TransformNode
  14961. */
  14962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14963. /**
  14964. * Returns the mesh pivot matrix.
  14965. * Default : Identity.
  14966. * @returns the matrix
  14967. */
  14968. getPivotMatrix(): Matrix;
  14969. /**
  14970. * Instantiate (when possible) or clone that node with its hierarchy
  14971. * @param newParent defines the new parent to use for the instance (or clone)
  14972. * @param options defines options to configure how copy is done
  14973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14974. * @returns an instance (or a clone) of the current node with its hiearchy
  14975. */
  14976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14977. doNotInstantiate: boolean;
  14978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14979. /**
  14980. * Prevents the World matrix to be computed any longer
  14981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14982. * @returns the TransformNode.
  14983. */
  14984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14985. /**
  14986. * Allows back the World matrix computation.
  14987. * @returns the TransformNode.
  14988. */
  14989. unfreezeWorldMatrix(): this;
  14990. /**
  14991. * True if the World matrix has been frozen.
  14992. */
  14993. get isWorldMatrixFrozen(): boolean;
  14994. /**
  14995. * Retuns the mesh absolute position in the World.
  14996. * @returns a Vector3.
  14997. */
  14998. getAbsolutePosition(): Vector3;
  14999. /**
  15000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15001. * @param absolutePosition the absolute position to set
  15002. * @returns the TransformNode.
  15003. */
  15004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15005. /**
  15006. * Sets the mesh position in its local space.
  15007. * @param vector3 the position to set in localspace
  15008. * @returns the TransformNode.
  15009. */
  15010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15011. /**
  15012. * Returns the mesh position in the local space from the current World matrix values.
  15013. * @returns a new Vector3.
  15014. */
  15015. getPositionExpressedInLocalSpace(): Vector3;
  15016. /**
  15017. * Translates the mesh along the passed Vector3 in its local space.
  15018. * @param vector3 the distance to translate in localspace
  15019. * @returns the TransformNode.
  15020. */
  15021. locallyTranslate(vector3: Vector3): TransformNode;
  15022. private static _lookAtVectorCache;
  15023. /**
  15024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15025. * @param targetPoint the position (must be in same space as current mesh) to look at
  15026. * @param yawCor optional yaw (y-axis) correction in radians
  15027. * @param pitchCor optional pitch (x-axis) correction in radians
  15028. * @param rollCor optional roll (z-axis) correction in radians
  15029. * @param space the choosen space of the target
  15030. * @returns the TransformNode.
  15031. */
  15032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15033. /**
  15034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15035. * This Vector3 is expressed in the World space.
  15036. * @param localAxis axis to rotate
  15037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15038. */
  15039. getDirection(localAxis: Vector3): Vector3;
  15040. /**
  15041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15042. * localAxis is expressed in the mesh local space.
  15043. * result is computed in the Wordl space from the mesh World matrix.
  15044. * @param localAxis axis to rotate
  15045. * @param result the resulting transformnode
  15046. * @returns this TransformNode.
  15047. */
  15048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15049. /**
  15050. * Sets this transform node rotation to the given local axis.
  15051. * @param localAxis the axis in local space
  15052. * @param yawCor optional yaw (y-axis) correction in radians
  15053. * @param pitchCor optional pitch (x-axis) correction in radians
  15054. * @param rollCor optional roll (z-axis) correction in radians
  15055. * @returns this TransformNode
  15056. */
  15057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15058. /**
  15059. * Sets a new pivot point to the current node
  15060. * @param point defines the new pivot point to use
  15061. * @param space defines if the point is in world or local space (local by default)
  15062. * @returns the current TransformNode
  15063. */
  15064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15065. /**
  15066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15067. * @returns the pivot point
  15068. */
  15069. getPivotPoint(): Vector3;
  15070. /**
  15071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15072. * @param result the vector3 to store the result
  15073. * @returns this TransformNode.
  15074. */
  15075. getPivotPointToRef(result: Vector3): TransformNode;
  15076. /**
  15077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15079. */
  15080. getAbsolutePivotPoint(): Vector3;
  15081. /**
  15082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15083. * @param result vector3 to store the result
  15084. * @returns this TransformNode.
  15085. */
  15086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15087. /**
  15088. * Defines the passed node as the parent of the current node.
  15089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15090. * @see https://doc.babylonjs.com/how_to/parenting
  15091. * @param node the node ot set as the parent
  15092. * @returns this TransformNode.
  15093. */
  15094. setParent(node: Nullable<Node>): TransformNode;
  15095. private _nonUniformScaling;
  15096. /**
  15097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15098. */
  15099. get nonUniformScaling(): boolean;
  15100. /** @hidden */
  15101. _updateNonUniformScalingState(value: boolean): boolean;
  15102. /**
  15103. * Attach the current TransformNode to another TransformNode associated with a bone
  15104. * @param bone Bone affecting the TransformNode
  15105. * @param affectedTransformNode TransformNode associated with the bone
  15106. * @returns this object
  15107. */
  15108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15109. /**
  15110. * Detach the transform node if its associated with a bone
  15111. * @returns this object
  15112. */
  15113. detachFromBone(): TransformNode;
  15114. private static _rotationAxisCache;
  15115. /**
  15116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15119. * The passed axis is also normalized.
  15120. * @param axis the axis to rotate around
  15121. * @param amount the amount to rotate in radians
  15122. * @param space Space to rotate in (Default: local)
  15123. * @returns the TransformNode.
  15124. */
  15125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15126. /**
  15127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15129. * The passed axis is also normalized. .
  15130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15131. * @param point the point to rotate around
  15132. * @param axis the axis to rotate around
  15133. * @param amount the amount to rotate in radians
  15134. * @returns the TransformNode
  15135. */
  15136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15137. /**
  15138. * Translates the mesh along the axis vector for the passed distance in the given space.
  15139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15140. * @param axis the axis to translate in
  15141. * @param distance the distance to translate
  15142. * @param space Space to rotate in (Default: local)
  15143. * @returns the TransformNode.
  15144. */
  15145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15146. /**
  15147. * Adds a rotation step to the mesh current rotation.
  15148. * x, y, z are Euler angles expressed in radians.
  15149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15150. * This means this rotation is made in the mesh local space only.
  15151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15153. * ```javascript
  15154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15155. * ```
  15156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15157. * 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.
  15158. * @param x Rotation to add
  15159. * @param y Rotation to add
  15160. * @param z Rotation to add
  15161. * @returns the TransformNode.
  15162. */
  15163. addRotation(x: number, y: number, z: number): TransformNode;
  15164. /**
  15165. * @hidden
  15166. */
  15167. protected _getEffectiveParent(): Nullable<Node>;
  15168. /**
  15169. * Computes the world matrix of the node
  15170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15171. * @returns the world matrix
  15172. */
  15173. computeWorldMatrix(force?: boolean): Matrix;
  15174. /**
  15175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15177. */
  15178. resetLocalMatrix(independentOfChildren?: boolean): void;
  15179. protected _afterComputeWorldMatrix(): void;
  15180. /**
  15181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15182. * @param func callback function to add
  15183. *
  15184. * @returns the TransformNode.
  15185. */
  15186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15187. /**
  15188. * Removes a registered callback function.
  15189. * @param func callback function to remove
  15190. * @returns the TransformNode.
  15191. */
  15192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15193. /**
  15194. * Gets the position of the current mesh in camera space
  15195. * @param camera defines the camera to use
  15196. * @returns a position
  15197. */
  15198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15199. /**
  15200. * Returns the distance from the mesh to the active camera
  15201. * @param camera defines the camera to use
  15202. * @returns the distance
  15203. */
  15204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15205. /**
  15206. * Clone the current transform node
  15207. * @param name Name of the new clone
  15208. * @param newParent New parent for the clone
  15209. * @param doNotCloneChildren Do not clone children hierarchy
  15210. * @returns the new transform node
  15211. */
  15212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15213. /**
  15214. * Serializes the objects information.
  15215. * @param currentSerializationObject defines the object to serialize in
  15216. * @returns the serialized object
  15217. */
  15218. serialize(currentSerializationObject?: any): any;
  15219. /**
  15220. * Returns a new TransformNode object parsed from the source provided.
  15221. * @param parsedTransformNode is the source.
  15222. * @param scene the scne the object belongs to
  15223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15224. * @returns a new TransformNode object parsed from the source provided.
  15225. */
  15226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15227. /**
  15228. * Get all child-transformNodes of this node
  15229. * @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
  15230. * @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
  15231. * @returns an array of TransformNode
  15232. */
  15233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15234. /**
  15235. * Releases resources associated with this transform node.
  15236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15238. */
  15239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15240. /**
  15241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15245. * @returns the current mesh
  15246. */
  15247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15248. private _syncAbsoluteScalingAndRotation;
  15249. }
  15250. }
  15251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15252. /**
  15253. * Class used to override all child animations of a given target
  15254. */
  15255. export class AnimationPropertiesOverride {
  15256. /**
  15257. * Gets or sets a value indicating if animation blending must be used
  15258. */
  15259. enableBlending: boolean;
  15260. /**
  15261. * Gets or sets the blending speed to use when enableBlending is true
  15262. */
  15263. blendingSpeed: number;
  15264. /**
  15265. * Gets or sets the default loop mode to use
  15266. */
  15267. loopMode: number;
  15268. }
  15269. }
  15270. declare module "babylonjs/Bones/bone" {
  15271. import { Skeleton } from "babylonjs/Bones/skeleton";
  15272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15273. import { Nullable } from "babylonjs/types";
  15274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15276. import { Node } from "babylonjs/node";
  15277. import { Space } from "babylonjs/Maths/math.axis";
  15278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15279. /**
  15280. * Class used to store bone information
  15281. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15282. */
  15283. export class Bone extends Node {
  15284. /**
  15285. * defines the bone name
  15286. */
  15287. name: string;
  15288. private static _tmpVecs;
  15289. private static _tmpQuat;
  15290. private static _tmpMats;
  15291. /**
  15292. * Gets the list of child bones
  15293. */
  15294. children: Bone[];
  15295. /** Gets the animations associated with this bone */
  15296. animations: import("babylonjs/Animations/animation").Animation[];
  15297. /**
  15298. * Gets or sets bone length
  15299. */
  15300. length: number;
  15301. /**
  15302. * @hidden Internal only
  15303. * Set this value to map this bone to a different index in the transform matrices
  15304. * Set this value to -1 to exclude the bone from the transform matrices
  15305. */
  15306. _index: Nullable<number>;
  15307. private _skeleton;
  15308. private _localMatrix;
  15309. private _restPose;
  15310. private _baseMatrix;
  15311. private _absoluteTransform;
  15312. private _invertedAbsoluteTransform;
  15313. private _parent;
  15314. private _scalingDeterminant;
  15315. private _worldTransform;
  15316. private _localScaling;
  15317. private _localRotation;
  15318. private _localPosition;
  15319. private _needToDecompose;
  15320. private _needToCompose;
  15321. /** @hidden */
  15322. _linkedTransformNode: Nullable<TransformNode>;
  15323. /** @hidden */
  15324. _waitingTransformNodeId: Nullable<string>;
  15325. /** @hidden */
  15326. get _matrix(): Matrix;
  15327. /** @hidden */
  15328. set _matrix(value: Matrix);
  15329. /**
  15330. * Create a new bone
  15331. * @param name defines the bone name
  15332. * @param skeleton defines the parent skeleton
  15333. * @param parentBone defines the parent (can be null if the bone is the root)
  15334. * @param localMatrix defines the local matrix
  15335. * @param restPose defines the rest pose matrix
  15336. * @param baseMatrix defines the base matrix
  15337. * @param index defines index of the bone in the hiearchy
  15338. */
  15339. constructor(
  15340. /**
  15341. * defines the bone name
  15342. */
  15343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15344. /**
  15345. * Gets the current object class name.
  15346. * @return the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Gets the parent skeleton
  15351. * @returns a skeleton
  15352. */
  15353. getSkeleton(): Skeleton;
  15354. /**
  15355. * Gets parent bone
  15356. * @returns a bone or null if the bone is the root of the bone hierarchy
  15357. */
  15358. getParent(): Nullable<Bone>;
  15359. /**
  15360. * Returns an array containing the root bones
  15361. * @returns an array containing the root bones
  15362. */
  15363. getChildren(): Array<Bone>;
  15364. /**
  15365. * Gets the node index in matrix array generated for rendering
  15366. * @returns the node index
  15367. */
  15368. getIndex(): number;
  15369. /**
  15370. * Sets the parent bone
  15371. * @param parent defines the parent (can be null if the bone is the root)
  15372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15373. */
  15374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15375. /**
  15376. * Gets the local matrix
  15377. * @returns a matrix
  15378. */
  15379. getLocalMatrix(): Matrix;
  15380. /**
  15381. * Gets the base matrix (initial matrix which remains unchanged)
  15382. * @returns a matrix
  15383. */
  15384. getBaseMatrix(): Matrix;
  15385. /**
  15386. * Gets the rest pose matrix
  15387. * @returns a matrix
  15388. */
  15389. getRestPose(): Matrix;
  15390. /**
  15391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15392. */
  15393. getWorldMatrix(): Matrix;
  15394. /**
  15395. * Sets the local matrix to rest pose matrix
  15396. */
  15397. returnToRest(): void;
  15398. /**
  15399. * Gets the inverse of the absolute transform matrix.
  15400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15401. * @returns a matrix
  15402. */
  15403. getInvertedAbsoluteTransform(): Matrix;
  15404. /**
  15405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15406. * @returns a matrix
  15407. */
  15408. getAbsoluteTransform(): Matrix;
  15409. /**
  15410. * Links with the given transform node.
  15411. * The local matrix of this bone is copied from the transform node every frame.
  15412. * @param transformNode defines the transform node to link to
  15413. */
  15414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15415. /**
  15416. * Gets the node used to drive the bone's transformation
  15417. * @returns a transform node or null
  15418. */
  15419. getTransformNode(): Nullable<TransformNode>;
  15420. /** Gets or sets current position (in local space) */
  15421. get position(): Vector3;
  15422. set position(newPosition: Vector3);
  15423. /** Gets or sets current rotation (in local space) */
  15424. get rotation(): Vector3;
  15425. set rotation(newRotation: Vector3);
  15426. /** Gets or sets current rotation quaternion (in local space) */
  15427. get rotationQuaternion(): Quaternion;
  15428. set rotationQuaternion(newRotation: Quaternion);
  15429. /** Gets or sets current scaling (in local space) */
  15430. get scaling(): Vector3;
  15431. set scaling(newScaling: Vector3);
  15432. /**
  15433. * Gets the animation properties override
  15434. */
  15435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15436. private _decompose;
  15437. private _compose;
  15438. /**
  15439. * Update the base and local matrices
  15440. * @param matrix defines the new base or local matrix
  15441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15442. * @param updateLocalMatrix defines if the local matrix should be updated
  15443. */
  15444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15445. /** @hidden */
  15446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15447. /**
  15448. * Flag the bone as dirty (Forcing it to update everything)
  15449. */
  15450. markAsDirty(): void;
  15451. /** @hidden */
  15452. _markAsDirtyAndCompose(): void;
  15453. private _markAsDirtyAndDecompose;
  15454. /**
  15455. * Translate the bone in local or world space
  15456. * @param vec The amount to translate the bone
  15457. * @param space The space that the translation is in
  15458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15459. */
  15460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15461. /**
  15462. * Set the postion of the bone in local or world space
  15463. * @param position The position to set the bone
  15464. * @param space The space that the position is in
  15465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15466. */
  15467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Set the absolute position of the bone (world space)
  15470. * @param position The position to set the bone
  15471. * @param mesh The mesh that this bone is attached to
  15472. */
  15473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15474. /**
  15475. * Scale the bone on the x, y and z axes (in local space)
  15476. * @param x The amount to scale the bone on the x axis
  15477. * @param y The amount to scale the bone on the y axis
  15478. * @param z The amount to scale the bone on the z axis
  15479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15480. */
  15481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15482. /**
  15483. * Set the bone scaling in local space
  15484. * @param scale defines the scaling vector
  15485. */
  15486. setScale(scale: Vector3): void;
  15487. /**
  15488. * Gets the current scaling in local space
  15489. * @returns the current scaling vector
  15490. */
  15491. getScale(): Vector3;
  15492. /**
  15493. * Gets the current scaling in local space and stores it in a target vector
  15494. * @param result defines the target vector
  15495. */
  15496. getScaleToRef(result: Vector3): void;
  15497. /**
  15498. * Set the yaw, pitch, and roll of the bone in local or world space
  15499. * @param yaw The rotation of the bone on the y axis
  15500. * @param pitch The rotation of the bone on the x axis
  15501. * @param roll The rotation of the bone on the z axis
  15502. * @param space The space that the axes of rotation are in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Add a rotation to the bone on an axis in local or world space
  15508. * @param axis The axis to rotate the bone on
  15509. * @param amount The amount to rotate the bone
  15510. * @param space The space that the axis is in
  15511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15512. */
  15513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15514. /**
  15515. * Set the rotation of the bone to a particular axis angle in local or world space
  15516. * @param axis The axis to rotate the bone on
  15517. * @param angle The angle that the bone should be rotated to
  15518. * @param space The space that the axis is in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. */
  15521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15522. /**
  15523. * Set the euler rotation of the bone in local of world space
  15524. * @param rotation The euler rotation that the bone should be set to
  15525. * @param space The space that the rotation is in
  15526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15527. */
  15528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15529. /**
  15530. * Set the quaternion rotation of the bone in local of world space
  15531. * @param quat The quaternion rotation that the bone should be set to
  15532. * @param space The space that the rotation is in
  15533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15534. */
  15535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15536. /**
  15537. * Set the rotation matrix of the bone in local of world space
  15538. * @param rotMat The rotation matrix that the bone should be set to
  15539. * @param space The space that the rotation is in
  15540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15541. */
  15542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15543. private _rotateWithMatrix;
  15544. private _getNegativeRotationToRef;
  15545. /**
  15546. * Get the position of the bone in local or world space
  15547. * @param space The space that the returned position is in
  15548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15549. * @returns The position of the bone
  15550. */
  15551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15552. /**
  15553. * Copy the position of the bone to a vector3 in local or world space
  15554. * @param space The space that the returned position is in
  15555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15556. * @param result The vector3 to copy the position to
  15557. */
  15558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15559. /**
  15560. * Get the absolute position of the bone (world space)
  15561. * @param mesh The mesh that this bone is attached to
  15562. * @returns The absolute position of the bone
  15563. */
  15564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15565. /**
  15566. * Copy the absolute position of the bone (world space) to the result param
  15567. * @param mesh The mesh that this bone is attached to
  15568. * @param result The vector3 to copy the absolute position to
  15569. */
  15570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15571. /**
  15572. * Compute the absolute transforms of this bone and its children
  15573. */
  15574. computeAbsoluteTransforms(): void;
  15575. /**
  15576. * Get the world direction from an axis that is in the local space of the bone
  15577. * @param localAxis The local direction that is used to compute the world direction
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @returns The world direction
  15580. */
  15581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15582. /**
  15583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15584. * @param localAxis The local direction that is used to compute the world direction
  15585. * @param mesh The mesh that this bone is attached to
  15586. * @param result The vector3 that the world direction will be copied to
  15587. */
  15588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15589. /**
  15590. * Get the euler rotation of the bone in local or world space
  15591. * @param space The space that the rotation should be in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. * @returns The euler rotation
  15594. */
  15595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15596. /**
  15597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15598. * @param space The space that the rotation should be in
  15599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15600. * @param result The vector3 that the rotation should be copied to
  15601. */
  15602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15603. /**
  15604. * Get the quaternion rotation of the bone in either local or world space
  15605. * @param space The space that the rotation should be in
  15606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15607. * @returns The quaternion rotation
  15608. */
  15609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15610. /**
  15611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15612. * @param space The space that the rotation should be in
  15613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15614. * @param result The quaternion that the rotation should be copied to
  15615. */
  15616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15617. /**
  15618. * Get the rotation matrix of the bone in local or world space
  15619. * @param space The space that the rotation should be in
  15620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15621. * @returns The rotation matrix
  15622. */
  15623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15624. /**
  15625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15626. * @param space The space that the rotation should be in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. * @param result The quaternion that the rotation should be copied to
  15629. */
  15630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15631. /**
  15632. * Get the world position of a point that is in the local space of the bone
  15633. * @param position The local position
  15634. * @param mesh The mesh that this bone is attached to
  15635. * @returns The world position
  15636. */
  15637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15638. /**
  15639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15640. * @param position The local position
  15641. * @param mesh The mesh that this bone is attached to
  15642. * @param result The vector3 that the world position should be copied to
  15643. */
  15644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15645. /**
  15646. * Get the local position of a point that is in world space
  15647. * @param position The world position
  15648. * @param mesh The mesh that this bone is attached to
  15649. * @returns The local position
  15650. */
  15651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15652. /**
  15653. * Get the local position of a point that is in world space and copy it to the result param
  15654. * @param position The world position
  15655. * @param mesh The mesh that this bone is attached to
  15656. * @param result The vector3 that the local position should be copied to
  15657. */
  15658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Animations/runtimeAnimation" {
  15662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15663. import { Animatable } from "babylonjs/Animations/animatable";
  15664. import { Scene } from "babylonjs/scene";
  15665. /**
  15666. * Defines a runtime animation
  15667. */
  15668. export class RuntimeAnimation {
  15669. private _events;
  15670. /**
  15671. * The current frame of the runtime animation
  15672. */
  15673. private _currentFrame;
  15674. /**
  15675. * The animation used by the runtime animation
  15676. */
  15677. private _animation;
  15678. /**
  15679. * The target of the runtime animation
  15680. */
  15681. private _target;
  15682. /**
  15683. * The initiating animatable
  15684. */
  15685. private _host;
  15686. /**
  15687. * The original value of the runtime animation
  15688. */
  15689. private _originalValue;
  15690. /**
  15691. * The original blend value of the runtime animation
  15692. */
  15693. private _originalBlendValue;
  15694. /**
  15695. * The offsets cache of the runtime animation
  15696. */
  15697. private _offsetsCache;
  15698. /**
  15699. * The high limits cache of the runtime animation
  15700. */
  15701. private _highLimitsCache;
  15702. /**
  15703. * Specifies if the runtime animation has been stopped
  15704. */
  15705. private _stopped;
  15706. /**
  15707. * The blending factor of the runtime animation
  15708. */
  15709. private _blendingFactor;
  15710. /**
  15711. * The BabylonJS scene
  15712. */
  15713. private _scene;
  15714. /**
  15715. * The current value of the runtime animation
  15716. */
  15717. private _currentValue;
  15718. /** @hidden */
  15719. _animationState: _IAnimationState;
  15720. /**
  15721. * The active target of the runtime animation
  15722. */
  15723. private _activeTargets;
  15724. private _currentActiveTarget;
  15725. private _directTarget;
  15726. /**
  15727. * The target path of the runtime animation
  15728. */
  15729. private _targetPath;
  15730. /**
  15731. * The weight of the runtime animation
  15732. */
  15733. private _weight;
  15734. /**
  15735. * The ratio offset of the runtime animation
  15736. */
  15737. private _ratioOffset;
  15738. /**
  15739. * The previous delay of the runtime animation
  15740. */
  15741. private _previousDelay;
  15742. /**
  15743. * The previous ratio of the runtime animation
  15744. */
  15745. private _previousRatio;
  15746. private _enableBlending;
  15747. private _keys;
  15748. private _minFrame;
  15749. private _maxFrame;
  15750. private _minValue;
  15751. private _maxValue;
  15752. private _targetIsArray;
  15753. /**
  15754. * Gets the current frame of the runtime animation
  15755. */
  15756. get currentFrame(): number;
  15757. /**
  15758. * Gets the weight of the runtime animation
  15759. */
  15760. get weight(): number;
  15761. /**
  15762. * Gets the current value of the runtime animation
  15763. */
  15764. get currentValue(): any;
  15765. /**
  15766. * Gets the target path of the runtime animation
  15767. */
  15768. get targetPath(): string;
  15769. /**
  15770. * Gets the actual target of the runtime animation
  15771. */
  15772. get target(): any;
  15773. /**
  15774. * Gets the additive state of the runtime animation
  15775. */
  15776. get isAdditive(): boolean;
  15777. /** @hidden */
  15778. _onLoop: () => void;
  15779. /**
  15780. * Create a new RuntimeAnimation object
  15781. * @param target defines the target of the animation
  15782. * @param animation defines the source animation object
  15783. * @param scene defines the hosting scene
  15784. * @param host defines the initiating Animatable
  15785. */
  15786. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15787. private _preparePath;
  15788. /**
  15789. * Gets the animation from the runtime animation
  15790. */
  15791. get animation(): Animation;
  15792. /**
  15793. * Resets the runtime animation to the beginning
  15794. * @param restoreOriginal defines whether to restore the target property to the original value
  15795. */
  15796. reset(restoreOriginal?: boolean): void;
  15797. /**
  15798. * Specifies if the runtime animation is stopped
  15799. * @returns Boolean specifying if the runtime animation is stopped
  15800. */
  15801. isStopped(): boolean;
  15802. /**
  15803. * Disposes of the runtime animation
  15804. */
  15805. dispose(): void;
  15806. /**
  15807. * Apply the interpolated value to the target
  15808. * @param currentValue defines the value computed by the animation
  15809. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15810. */
  15811. setValue(currentValue: any, weight: number): void;
  15812. private _getOriginalValues;
  15813. private _setValue;
  15814. /**
  15815. * Gets the loop pmode of the runtime animation
  15816. * @returns Loop Mode
  15817. */
  15818. private _getCorrectLoopMode;
  15819. /**
  15820. * Move the current animation to a given frame
  15821. * @param frame defines the frame to move to
  15822. */
  15823. goToFrame(frame: number): void;
  15824. /**
  15825. * @hidden Internal use only
  15826. */
  15827. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15828. /**
  15829. * Execute the current animation
  15830. * @param delay defines the delay to add to the current frame
  15831. * @param from defines the lower bound of the animation range
  15832. * @param to defines the upper bound of the animation range
  15833. * @param loop defines if the current animation must loop
  15834. * @param speedRatio defines the current speed ratio
  15835. * @param weight defines the weight of the animation (default is -1 so no weight)
  15836. * @param onLoop optional callback called when animation loops
  15837. * @returns a boolean indicating if the animation is running
  15838. */
  15839. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15840. }
  15841. }
  15842. declare module "babylonjs/Animations/animatable" {
  15843. import { Animation } from "babylonjs/Animations/animation";
  15844. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15845. import { Nullable } from "babylonjs/types";
  15846. import { Observable } from "babylonjs/Misc/observable";
  15847. import { Scene } from "babylonjs/scene";
  15848. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15849. import { Node } from "babylonjs/node";
  15850. /**
  15851. * Class used to store an actual running animation
  15852. */
  15853. export class Animatable {
  15854. /** defines the target object */
  15855. target: any;
  15856. /** defines the starting frame number (default is 0) */
  15857. fromFrame: number;
  15858. /** defines the ending frame number (default is 100) */
  15859. toFrame: number;
  15860. /** defines if the animation must loop (default is false) */
  15861. loopAnimation: boolean;
  15862. /** defines a callback to call when animation ends if it is not looping */
  15863. onAnimationEnd?: (() => void) | null | undefined;
  15864. /** defines a callback to call when animation loops */
  15865. onAnimationLoop?: (() => void) | null | undefined;
  15866. /** defines whether the animation should be evaluated additively */
  15867. isAdditive: boolean;
  15868. private _localDelayOffset;
  15869. private _pausedDelay;
  15870. private _runtimeAnimations;
  15871. private _paused;
  15872. private _scene;
  15873. private _speedRatio;
  15874. private _weight;
  15875. private _syncRoot;
  15876. /**
  15877. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15878. * This will only apply for non looping animation (default is true)
  15879. */
  15880. disposeOnEnd: boolean;
  15881. /**
  15882. * Gets a boolean indicating if the animation has started
  15883. */
  15884. animationStarted: boolean;
  15885. /**
  15886. * Observer raised when the animation ends
  15887. */
  15888. onAnimationEndObservable: Observable<Animatable>;
  15889. /**
  15890. * Observer raised when the animation loops
  15891. */
  15892. onAnimationLoopObservable: Observable<Animatable>;
  15893. /**
  15894. * Gets the root Animatable used to synchronize and normalize animations
  15895. */
  15896. get syncRoot(): Nullable<Animatable>;
  15897. /**
  15898. * Gets the current frame of the first RuntimeAnimation
  15899. * Used to synchronize Animatables
  15900. */
  15901. get masterFrame(): number;
  15902. /**
  15903. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15904. */
  15905. get weight(): number;
  15906. set weight(value: number);
  15907. /**
  15908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15909. */
  15910. get speedRatio(): number;
  15911. set speedRatio(value: number);
  15912. /**
  15913. * Creates a new Animatable
  15914. * @param scene defines the hosting scene
  15915. * @param target defines the target object
  15916. * @param fromFrame defines the starting frame number (default is 0)
  15917. * @param toFrame defines the ending frame number (default is 100)
  15918. * @param loopAnimation defines if the animation must loop (default is false)
  15919. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15920. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15921. * @param animations defines a group of animation to add to the new Animatable
  15922. * @param onAnimationLoop defines a callback to call when animation loops
  15923. * @param isAdditive defines whether the animation should be evaluated additively
  15924. */
  15925. constructor(scene: Scene,
  15926. /** defines the target object */
  15927. target: any,
  15928. /** defines the starting frame number (default is 0) */
  15929. fromFrame?: number,
  15930. /** defines the ending frame number (default is 100) */
  15931. toFrame?: number,
  15932. /** defines if the animation must loop (default is false) */
  15933. loopAnimation?: boolean, speedRatio?: number,
  15934. /** defines a callback to call when animation ends if it is not looping */
  15935. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15936. /** defines a callback to call when animation loops */
  15937. onAnimationLoop?: (() => void) | null | undefined,
  15938. /** defines whether the animation should be evaluated additively */
  15939. isAdditive?: boolean);
  15940. /**
  15941. * Synchronize and normalize current Animatable with a source Animatable
  15942. * This is useful when using animation weights and when animations are not of the same length
  15943. * @param root defines the root Animatable to synchronize with
  15944. * @returns the current Animatable
  15945. */
  15946. syncWith(root: Animatable): Animatable;
  15947. /**
  15948. * Gets the list of runtime animations
  15949. * @returns an array of RuntimeAnimation
  15950. */
  15951. getAnimations(): RuntimeAnimation[];
  15952. /**
  15953. * Adds more animations to the current animatable
  15954. * @param target defines the target of the animations
  15955. * @param animations defines the new animations to add
  15956. */
  15957. appendAnimations(target: any, animations: Animation[]): void;
  15958. /**
  15959. * Gets the source animation for a specific property
  15960. * @param property defines the propertyu to look for
  15961. * @returns null or the source animation for the given property
  15962. */
  15963. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15964. /**
  15965. * Gets the runtime animation for a specific property
  15966. * @param property defines the propertyu to look for
  15967. * @returns null or the runtime animation for the given property
  15968. */
  15969. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15970. /**
  15971. * Resets the animatable to its original state
  15972. */
  15973. reset(): void;
  15974. /**
  15975. * Allows the animatable to blend with current running animations
  15976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15977. * @param blendingSpeed defines the blending speed to use
  15978. */
  15979. enableBlending(blendingSpeed: number): void;
  15980. /**
  15981. * Disable animation blending
  15982. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15983. */
  15984. disableBlending(): void;
  15985. /**
  15986. * Jump directly to a given frame
  15987. * @param frame defines the frame to jump to
  15988. */
  15989. goToFrame(frame: number): void;
  15990. /**
  15991. * Pause the animation
  15992. */
  15993. pause(): void;
  15994. /**
  15995. * Restart the animation
  15996. */
  15997. restart(): void;
  15998. private _raiseOnAnimationEnd;
  15999. /**
  16000. * Stop and delete the current animation
  16001. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16002. * @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)
  16003. */
  16004. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16005. /**
  16006. * Wait asynchronously for the animation to end
  16007. * @returns a promise which will be fullfilled when the animation ends
  16008. */
  16009. waitAsync(): Promise<Animatable>;
  16010. /** @hidden */
  16011. _animate(delay: number): boolean;
  16012. }
  16013. module "babylonjs/scene" {
  16014. interface Scene {
  16015. /** @hidden */
  16016. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16017. /** @hidden */
  16018. _processLateAnimationBindingsForMatrices(holder: {
  16019. totalWeight: number;
  16020. totalAdditiveWeight: number;
  16021. animations: RuntimeAnimation[];
  16022. additiveAnimations: RuntimeAnimation[];
  16023. originalValue: Matrix;
  16024. }): any;
  16025. /** @hidden */
  16026. _processLateAnimationBindingsForQuaternions(holder: {
  16027. totalWeight: number;
  16028. totalAdditiveWeight: number;
  16029. animations: RuntimeAnimation[];
  16030. additiveAnimations: RuntimeAnimation[];
  16031. originalValue: Quaternion;
  16032. }, refQuaternion: Quaternion): Quaternion;
  16033. /** @hidden */
  16034. _processLateAnimationBindings(): void;
  16035. /**
  16036. * Will start the animation sequence of a given target
  16037. * @param target defines the target
  16038. * @param from defines from which frame should animation start
  16039. * @param to defines until which frame should animation run.
  16040. * @param weight defines the weight to apply to the animation (1.0 by default)
  16041. * @param loop defines if the animation loops
  16042. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16043. * @param onAnimationEnd defines the function to be executed when the animation ends
  16044. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16045. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16046. * @param onAnimationLoop defines the callback to call when an animation loops
  16047. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16048. * @returns the animatable object created for this animation
  16049. */
  16050. 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;
  16051. /**
  16052. * Will start the animation sequence of a given target
  16053. * @param target defines the target
  16054. * @param from defines from which frame should animation start
  16055. * @param to defines until which frame should animation run.
  16056. * @param loop defines if the animation loops
  16057. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16058. * @param onAnimationEnd defines the function to be executed when the animation ends
  16059. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16060. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16061. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16062. * @param onAnimationLoop defines the callback to call when an animation loops
  16063. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16064. * @returns the animatable object created for this animation
  16065. */
  16066. 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;
  16067. /**
  16068. * Will start the animation sequence of a given target and its hierarchy
  16069. * @param target defines the target
  16070. * @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.
  16071. * @param from defines from which frame should animation start
  16072. * @param to defines until which frame should animation run.
  16073. * @param loop defines if the animation loops
  16074. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16075. * @param onAnimationEnd defines the function to be executed when the animation ends
  16076. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16077. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16078. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16079. * @param onAnimationLoop defines the callback to call when an animation loops
  16080. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16081. * @returns the list of created animatables
  16082. */
  16083. 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[];
  16084. /**
  16085. * Begin a new animation on a given node
  16086. * @param target defines the target where the animation will take place
  16087. * @param animations defines the list of animations to start
  16088. * @param from defines the initial value
  16089. * @param to defines the final value
  16090. * @param loop defines if you want animation to loop (off by default)
  16091. * @param speedRatio defines the speed ratio to apply to all animations
  16092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16093. * @param onAnimationLoop defines the callback to call when an animation loops
  16094. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16095. * @returns the list of created animatables
  16096. */
  16097. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16098. /**
  16099. * Begin a new animation on a given node and its hierarchy
  16100. * @param target defines the root node where the animation will take place
  16101. * @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.
  16102. * @param animations defines the list of animations to start
  16103. * @param from defines the initial value
  16104. * @param to defines the final value
  16105. * @param loop defines if you want animation to loop (off by default)
  16106. * @param speedRatio defines the speed ratio to apply to all animations
  16107. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16108. * @param onAnimationLoop defines the callback to call when an animation loops
  16109. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16110. * @returns the list of animatables created for all nodes
  16111. */
  16112. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16113. /**
  16114. * Gets the animatable associated with a specific target
  16115. * @param target defines the target of the animatable
  16116. * @returns the required animatable if found
  16117. */
  16118. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16119. /**
  16120. * Gets all animatables associated with a given target
  16121. * @param target defines the target to look animatables for
  16122. * @returns an array of Animatables
  16123. */
  16124. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16125. /**
  16126. * Stops and removes all animations that have been applied to the scene
  16127. */
  16128. stopAllAnimations(): void;
  16129. /**
  16130. * Gets the current delta time used by animation engine
  16131. */
  16132. deltaTime: number;
  16133. }
  16134. }
  16135. module "babylonjs/Bones/bone" {
  16136. interface Bone {
  16137. /**
  16138. * Copy an animation range from another bone
  16139. * @param source defines the source bone
  16140. * @param rangeName defines the range name to copy
  16141. * @param frameOffset defines the frame offset
  16142. * @param rescaleAsRequired defines if rescaling must be applied if required
  16143. * @param skelDimensionsRatio defines the scaling ratio
  16144. * @returns true if operation was successful
  16145. */
  16146. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16147. }
  16148. }
  16149. }
  16150. declare module "babylonjs/Bones/skeleton" {
  16151. import { Bone } from "babylonjs/Bones/bone";
  16152. import { Observable } from "babylonjs/Misc/observable";
  16153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16154. import { Scene } from "babylonjs/scene";
  16155. import { Nullable } from "babylonjs/types";
  16156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16157. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16158. import { Animatable } from "babylonjs/Animations/animatable";
  16159. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16160. import { Animation } from "babylonjs/Animations/animation";
  16161. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16162. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16163. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16164. /**
  16165. * Class used to handle skinning animations
  16166. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16167. */
  16168. export class Skeleton implements IAnimatable {
  16169. /** defines the skeleton name */
  16170. name: string;
  16171. /** defines the skeleton Id */
  16172. id: string;
  16173. /**
  16174. * Defines the list of child bones
  16175. */
  16176. bones: Bone[];
  16177. /**
  16178. * Defines an estimate of the dimension of the skeleton at rest
  16179. */
  16180. dimensionsAtRest: Vector3;
  16181. /**
  16182. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16183. */
  16184. needInitialSkinMatrix: boolean;
  16185. /**
  16186. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16187. */
  16188. overrideMesh: Nullable<AbstractMesh>;
  16189. /**
  16190. * Gets the list of animations attached to this skeleton
  16191. */
  16192. animations: Array<Animation>;
  16193. private _scene;
  16194. private _isDirty;
  16195. private _transformMatrices;
  16196. private _transformMatrixTexture;
  16197. private _meshesWithPoseMatrix;
  16198. private _animatables;
  16199. private _identity;
  16200. private _synchronizedWithMesh;
  16201. private _ranges;
  16202. private _lastAbsoluteTransformsUpdateId;
  16203. private _canUseTextureForBones;
  16204. private _uniqueId;
  16205. /** @hidden */
  16206. _numBonesWithLinkedTransformNode: number;
  16207. /** @hidden */
  16208. _hasWaitingData: Nullable<boolean>;
  16209. /**
  16210. * Specifies if the skeleton should be serialized
  16211. */
  16212. doNotSerialize: boolean;
  16213. private _useTextureToStoreBoneMatrices;
  16214. /**
  16215. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16216. * Please note that this option is not available if the hardware does not support it
  16217. */
  16218. get useTextureToStoreBoneMatrices(): boolean;
  16219. set useTextureToStoreBoneMatrices(value: boolean);
  16220. private _animationPropertiesOverride;
  16221. /**
  16222. * Gets or sets the animation properties override
  16223. */
  16224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16226. /**
  16227. * List of inspectable custom properties (used by the Inspector)
  16228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16229. */
  16230. inspectableCustomProperties: IInspectable[];
  16231. /**
  16232. * An observable triggered before computing the skeleton's matrices
  16233. */
  16234. onBeforeComputeObservable: Observable<Skeleton>;
  16235. /**
  16236. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16237. */
  16238. get isUsingTextureForMatrices(): boolean;
  16239. /**
  16240. * Gets the unique ID of this skeleton
  16241. */
  16242. get uniqueId(): number;
  16243. /**
  16244. * Creates a new skeleton
  16245. * @param name defines the skeleton name
  16246. * @param id defines the skeleton Id
  16247. * @param scene defines the hosting scene
  16248. */
  16249. constructor(
  16250. /** defines the skeleton name */
  16251. name: string,
  16252. /** defines the skeleton Id */
  16253. id: string, scene: Scene);
  16254. /**
  16255. * Gets the current object class name.
  16256. * @return the class name
  16257. */
  16258. getClassName(): string;
  16259. /**
  16260. * Returns an array containing the root bones
  16261. * @returns an array containing the root bones
  16262. */
  16263. getChildren(): Array<Bone>;
  16264. /**
  16265. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16266. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16267. * @returns a Float32Array containing matrices data
  16268. */
  16269. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16270. /**
  16271. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16272. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16273. * @returns a raw texture containing the data
  16274. */
  16275. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16276. /**
  16277. * Gets the current hosting scene
  16278. * @returns a scene object
  16279. */
  16280. getScene(): Scene;
  16281. /**
  16282. * Gets a string representing the current skeleton data
  16283. * @param fullDetails defines a boolean indicating if we want a verbose version
  16284. * @returns a string representing the current skeleton data
  16285. */
  16286. toString(fullDetails?: boolean): string;
  16287. /**
  16288. * Get bone's index searching by name
  16289. * @param name defines bone's name to search for
  16290. * @return the indice of the bone. Returns -1 if not found
  16291. */
  16292. getBoneIndexByName(name: string): number;
  16293. /**
  16294. * Creater a new animation range
  16295. * @param name defines the name of the range
  16296. * @param from defines the start key
  16297. * @param to defines the end key
  16298. */
  16299. createAnimationRange(name: string, from: number, to: number): void;
  16300. /**
  16301. * Delete a specific animation range
  16302. * @param name defines the name of the range
  16303. * @param deleteFrames defines if frames must be removed as well
  16304. */
  16305. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16306. /**
  16307. * Gets a specific animation range
  16308. * @param name defines the name of the range to look for
  16309. * @returns the requested animation range or null if not found
  16310. */
  16311. getAnimationRange(name: string): Nullable<AnimationRange>;
  16312. /**
  16313. * Gets the list of all animation ranges defined on this skeleton
  16314. * @returns an array
  16315. */
  16316. getAnimationRanges(): Nullable<AnimationRange>[];
  16317. /**
  16318. * Copy animation range from a source skeleton.
  16319. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16320. * @param source defines the source skeleton
  16321. * @param name defines the name of the range to copy
  16322. * @param rescaleAsRequired defines if rescaling must be applied if required
  16323. * @returns true if operation was successful
  16324. */
  16325. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16326. /**
  16327. * Forces the skeleton to go to rest pose
  16328. */
  16329. returnToRest(): void;
  16330. private _getHighestAnimationFrame;
  16331. /**
  16332. * Begin a specific animation range
  16333. * @param name defines the name of the range to start
  16334. * @param loop defines if looping must be turned on (false by default)
  16335. * @param speedRatio defines the speed ratio to apply (1 by default)
  16336. * @param onAnimationEnd defines a callback which will be called when animation will end
  16337. * @returns a new animatable
  16338. */
  16339. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16340. /**
  16341. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16342. * @param skeleton defines the Skeleton containing the animation range to convert
  16343. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16344. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16345. * @returns the original skeleton
  16346. */
  16347. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16348. /** @hidden */
  16349. _markAsDirty(): void;
  16350. /** @hidden */
  16351. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16352. /** @hidden */
  16353. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16354. private _computeTransformMatrices;
  16355. /**
  16356. * Build all resources required to render a skeleton
  16357. */
  16358. prepare(): void;
  16359. /**
  16360. * Gets the list of animatables currently running for this skeleton
  16361. * @returns an array of animatables
  16362. */
  16363. getAnimatables(): IAnimatable[];
  16364. /**
  16365. * Clone the current skeleton
  16366. * @param name defines the name of the new skeleton
  16367. * @param id defines the id of the new skeleton
  16368. * @returns the new skeleton
  16369. */
  16370. clone(name: string, id?: string): Skeleton;
  16371. /**
  16372. * Enable animation blending for this skeleton
  16373. * @param blendingSpeed defines the blending speed to apply
  16374. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16375. */
  16376. enableBlending(blendingSpeed?: number): void;
  16377. /**
  16378. * Releases all resources associated with the current skeleton
  16379. */
  16380. dispose(): void;
  16381. /**
  16382. * Serialize the skeleton in a JSON object
  16383. * @returns a JSON object
  16384. */
  16385. serialize(): any;
  16386. /**
  16387. * Creates a new skeleton from serialized data
  16388. * @param parsedSkeleton defines the serialized data
  16389. * @param scene defines the hosting scene
  16390. * @returns a new skeleton
  16391. */
  16392. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16393. /**
  16394. * Compute all node absolute transforms
  16395. * @param forceUpdate defines if computation must be done even if cache is up to date
  16396. */
  16397. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16398. /**
  16399. * Gets the root pose matrix
  16400. * @returns a matrix
  16401. */
  16402. getPoseMatrix(): Nullable<Matrix>;
  16403. /**
  16404. * Sorts bones per internal index
  16405. */
  16406. sortBones(): void;
  16407. private _sortBones;
  16408. }
  16409. }
  16410. declare module "babylonjs/Meshes/instancedMesh" {
  16411. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16412. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16413. import { Camera } from "babylonjs/Cameras/camera";
  16414. import { Node } from "babylonjs/node";
  16415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16416. import { Mesh } from "babylonjs/Meshes/mesh";
  16417. import { Material } from "babylonjs/Materials/material";
  16418. import { Skeleton } from "babylonjs/Bones/skeleton";
  16419. import { Light } from "babylonjs/Lights/light";
  16420. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16421. /**
  16422. * Creates an instance based on a source mesh.
  16423. */
  16424. export class InstancedMesh extends AbstractMesh {
  16425. private _sourceMesh;
  16426. private _currentLOD;
  16427. /** @hidden */
  16428. _indexInSourceMeshInstanceArray: number;
  16429. constructor(name: string, source: Mesh);
  16430. /**
  16431. * Returns the string "InstancedMesh".
  16432. */
  16433. getClassName(): string;
  16434. /** Gets the list of lights affecting that mesh */
  16435. get lightSources(): Light[];
  16436. _resyncLightSources(): void;
  16437. _resyncLightSource(light: Light): void;
  16438. _removeLightSource(light: Light, dispose: boolean): void;
  16439. /**
  16440. * If the source mesh receives shadows
  16441. */
  16442. get receiveShadows(): boolean;
  16443. /**
  16444. * The material of the source mesh
  16445. */
  16446. get material(): Nullable<Material>;
  16447. /**
  16448. * Visibility of the source mesh
  16449. */
  16450. get visibility(): number;
  16451. /**
  16452. * Skeleton of the source mesh
  16453. */
  16454. get skeleton(): Nullable<Skeleton>;
  16455. /**
  16456. * Rendering ground id of the source mesh
  16457. */
  16458. get renderingGroupId(): number;
  16459. set renderingGroupId(value: number);
  16460. /**
  16461. * Returns the total number of vertices (integer).
  16462. */
  16463. getTotalVertices(): number;
  16464. /**
  16465. * Returns a positive integer : the total number of indices in this mesh geometry.
  16466. * @returns the numner of indices or zero if the mesh has no geometry.
  16467. */
  16468. getTotalIndices(): number;
  16469. /**
  16470. * The source mesh of the instance
  16471. */
  16472. get sourceMesh(): Mesh;
  16473. /**
  16474. * Creates a new InstancedMesh object from the mesh model.
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16476. * @param name defines the name of the new instance
  16477. * @returns a new InstancedMesh
  16478. */
  16479. createInstance(name: string): InstancedMesh;
  16480. /**
  16481. * Is this node ready to be used/rendered
  16482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16483. * @return {boolean} is it ready
  16484. */
  16485. isReady(completeCheck?: boolean): boolean;
  16486. /**
  16487. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16488. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16489. * @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.
  16490. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16491. */
  16492. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16493. /**
  16494. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16495. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16496. * The `data` are either a numeric array either a Float32Array.
  16497. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16498. * 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).
  16499. * Note that a new underlying VertexBuffer object is created each call.
  16500. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16501. *
  16502. * Possible `kind` values :
  16503. * - VertexBuffer.PositionKind
  16504. * - VertexBuffer.UVKind
  16505. * - VertexBuffer.UV2Kind
  16506. * - VertexBuffer.UV3Kind
  16507. * - VertexBuffer.UV4Kind
  16508. * - VertexBuffer.UV5Kind
  16509. * - VertexBuffer.UV6Kind
  16510. * - VertexBuffer.ColorKind
  16511. * - VertexBuffer.MatricesIndicesKind
  16512. * - VertexBuffer.MatricesIndicesExtraKind
  16513. * - VertexBuffer.MatricesWeightsKind
  16514. * - VertexBuffer.MatricesWeightsExtraKind
  16515. *
  16516. * Returns the Mesh.
  16517. */
  16518. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16519. /**
  16520. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16521. * If the mesh has no geometry, it is simply returned as it is.
  16522. * The `data` are either a numeric array either a Float32Array.
  16523. * No new underlying VertexBuffer object is created.
  16524. * 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.
  16525. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16526. *
  16527. * Possible `kind` values :
  16528. * - VertexBuffer.PositionKind
  16529. * - VertexBuffer.UVKind
  16530. * - VertexBuffer.UV2Kind
  16531. * - VertexBuffer.UV3Kind
  16532. * - VertexBuffer.UV4Kind
  16533. * - VertexBuffer.UV5Kind
  16534. * - VertexBuffer.UV6Kind
  16535. * - VertexBuffer.ColorKind
  16536. * - VertexBuffer.MatricesIndicesKind
  16537. * - VertexBuffer.MatricesIndicesExtraKind
  16538. * - VertexBuffer.MatricesWeightsKind
  16539. * - VertexBuffer.MatricesWeightsExtraKind
  16540. *
  16541. * Returns the Mesh.
  16542. */
  16543. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16544. /**
  16545. * Sets the mesh indices.
  16546. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16547. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16548. * This method creates a new index buffer each call.
  16549. * Returns the Mesh.
  16550. */
  16551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16552. /**
  16553. * Boolean : True if the mesh owns the requested kind of data.
  16554. */
  16555. isVerticesDataPresent(kind: string): boolean;
  16556. /**
  16557. * Returns an array of indices (IndicesArray).
  16558. */
  16559. getIndices(): Nullable<IndicesArray>;
  16560. get _positions(): Nullable<Vector3[]>;
  16561. /**
  16562. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16563. * This means the mesh underlying bounding box and sphere are recomputed.
  16564. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16565. * @returns the current mesh
  16566. */
  16567. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16568. /** @hidden */
  16569. _preActivate(): InstancedMesh;
  16570. /** @hidden */
  16571. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16572. /** @hidden */
  16573. _postActivate(): void;
  16574. getWorldMatrix(): Matrix;
  16575. get isAnInstance(): boolean;
  16576. /**
  16577. * Returns the current associated LOD AbstractMesh.
  16578. */
  16579. getLOD(camera: Camera): AbstractMesh;
  16580. /** @hidden */
  16581. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16582. /** @hidden */
  16583. _syncSubMeshes(): InstancedMesh;
  16584. /** @hidden */
  16585. _generatePointsArray(): boolean;
  16586. /**
  16587. * Creates a new InstancedMesh from the current mesh.
  16588. * - name (string) : the cloned mesh name
  16589. * - newParent (optional Node) : the optional Node to parent the clone to.
  16590. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16591. *
  16592. * Returns the clone.
  16593. */
  16594. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16595. /**
  16596. * Disposes the InstancedMesh.
  16597. * Returns nothing.
  16598. */
  16599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16600. }
  16601. module "babylonjs/Meshes/mesh" {
  16602. interface Mesh {
  16603. /**
  16604. * Register a custom buffer that will be instanced
  16605. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16606. * @param kind defines the buffer kind
  16607. * @param stride defines the stride in floats
  16608. */
  16609. registerInstancedBuffer(kind: string, stride: number): void;
  16610. /**
  16611. * true to use the edge renderer for all instances of this mesh
  16612. */
  16613. edgesShareWithInstances: boolean;
  16614. /** @hidden */
  16615. _userInstancedBuffersStorage: {
  16616. data: {
  16617. [key: string]: Float32Array;
  16618. };
  16619. sizes: {
  16620. [key: string]: number;
  16621. };
  16622. vertexBuffers: {
  16623. [key: string]: Nullable<VertexBuffer>;
  16624. };
  16625. strides: {
  16626. [key: string]: number;
  16627. };
  16628. };
  16629. }
  16630. }
  16631. module "babylonjs/Meshes/abstractMesh" {
  16632. interface AbstractMesh {
  16633. /**
  16634. * Object used to store instanced buffers defined by user
  16635. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16636. */
  16637. instancedBuffers: {
  16638. [key: string]: any;
  16639. };
  16640. }
  16641. }
  16642. }
  16643. declare module "babylonjs/Materials/shaderMaterial" {
  16644. import { Nullable } from "babylonjs/types";
  16645. import { Scene } from "babylonjs/scene";
  16646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16648. import { Mesh } from "babylonjs/Meshes/mesh";
  16649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16651. import { Effect } from "babylonjs/Materials/effect";
  16652. import { Material } from "babylonjs/Materials/material";
  16653. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16654. /**
  16655. * Defines the options associated with the creation of a shader material.
  16656. */
  16657. export interface IShaderMaterialOptions {
  16658. /**
  16659. * Does the material work in alpha blend mode
  16660. */
  16661. needAlphaBlending: boolean;
  16662. /**
  16663. * Does the material work in alpha test mode
  16664. */
  16665. needAlphaTesting: boolean;
  16666. /**
  16667. * The list of attribute names used in the shader
  16668. */
  16669. attributes: string[];
  16670. /**
  16671. * The list of unifrom names used in the shader
  16672. */
  16673. uniforms: string[];
  16674. /**
  16675. * The list of UBO names used in the shader
  16676. */
  16677. uniformBuffers: string[];
  16678. /**
  16679. * The list of sampler names used in the shader
  16680. */
  16681. samplers: string[];
  16682. /**
  16683. * The list of defines used in the shader
  16684. */
  16685. defines: string[];
  16686. }
  16687. /**
  16688. * 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.
  16689. *
  16690. * This returned material effects how the mesh will look based on the code in the shaders.
  16691. *
  16692. * @see https://doc.babylonjs.com/how_to/shader_material
  16693. */
  16694. export class ShaderMaterial extends Material {
  16695. private _shaderPath;
  16696. private _options;
  16697. private _textures;
  16698. private _textureArrays;
  16699. private _floats;
  16700. private _ints;
  16701. private _floatsArrays;
  16702. private _colors3;
  16703. private _colors3Arrays;
  16704. private _colors4;
  16705. private _colors4Arrays;
  16706. private _vectors2;
  16707. private _vectors3;
  16708. private _vectors4;
  16709. private _matrices;
  16710. private _matrixArrays;
  16711. private _matrices3x3;
  16712. private _matrices2x2;
  16713. private _vectors2Arrays;
  16714. private _vectors3Arrays;
  16715. private _vectors4Arrays;
  16716. private _cachedWorldViewMatrix;
  16717. private _cachedWorldViewProjectionMatrix;
  16718. private _renderId;
  16719. private _multiview;
  16720. private _cachedDefines;
  16721. /** Define the Url to load snippets */
  16722. static SnippetUrl: string;
  16723. /** Snippet ID if the material was created from the snippet server */
  16724. snippetId: string;
  16725. /**
  16726. * Instantiate a new shader material.
  16727. * 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.
  16728. * This returned material effects how the mesh will look based on the code in the shaders.
  16729. * @see https://doc.babylonjs.com/how_to/shader_material
  16730. * @param name Define the name of the material in the scene
  16731. * @param scene Define the scene the material belongs to
  16732. * @param shaderPath Defines the route to the shader code in one of three ways:
  16733. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16734. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16735. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16736. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16737. * @param options Define the options used to create the shader
  16738. */
  16739. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16740. /**
  16741. * Gets the shader path used to define the shader code
  16742. * It can be modified to trigger a new compilation
  16743. */
  16744. get shaderPath(): any;
  16745. /**
  16746. * Sets the shader path used to define the shader code
  16747. * It can be modified to trigger a new compilation
  16748. */
  16749. set shaderPath(shaderPath: any);
  16750. /**
  16751. * Gets the options used to compile the shader.
  16752. * They can be modified to trigger a new compilation
  16753. */
  16754. get options(): IShaderMaterialOptions;
  16755. /**
  16756. * Gets the current class name of the material e.g. "ShaderMaterial"
  16757. * Mainly use in serialization.
  16758. * @returns the class name
  16759. */
  16760. getClassName(): string;
  16761. /**
  16762. * Specifies if the material will require alpha blending
  16763. * @returns a boolean specifying if alpha blending is needed
  16764. */
  16765. needAlphaBlending(): boolean;
  16766. /**
  16767. * Specifies if this material should be rendered in alpha test mode
  16768. * @returns a boolean specifying if an alpha test is needed.
  16769. */
  16770. needAlphaTesting(): boolean;
  16771. private _checkUniform;
  16772. /**
  16773. * Set a texture in the shader.
  16774. * @param name Define the name of the uniform samplers as defined in the shader
  16775. * @param texture Define the texture to bind to this sampler
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16779. /**
  16780. * Set a texture array in the shader.
  16781. * @param name Define the name of the uniform sampler array as defined in the shader
  16782. * @param textures Define the list of textures to bind to this sampler
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16786. /**
  16787. * Set a float in the shader.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setFloat(name: string, value: number): ShaderMaterial;
  16793. /**
  16794. * Set a int in the shader.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setInt(name: string, value: number): ShaderMaterial;
  16800. /**
  16801. * Set an array of floats in the shader.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setFloats(name: string, value: number[]): ShaderMaterial;
  16807. /**
  16808. * Set a vec3 in the shader from a Color3.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setColor3(name: string, value: Color3): ShaderMaterial;
  16814. /**
  16815. * Set a vec3 array in the shader from a Color3 array.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 in the shader from a Color4.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setColor4(name: string, value: Color4): ShaderMaterial;
  16828. /**
  16829. * Set a vec4 array in the shader from a Color4 array.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16835. /**
  16836. * Set a vec2 in the shader from a Vector2.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setVector2(name: string, value: Vector2): ShaderMaterial;
  16842. /**
  16843. * Set a vec3 in the shader from a Vector3.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setVector3(name: string, value: Vector3): ShaderMaterial;
  16849. /**
  16850. * Set a vec4 in the shader from a Vector4.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setVector4(name: string, value: Vector4): ShaderMaterial;
  16856. /**
  16857. * Set a mat4 in the shader from a Matrix.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the material itself allowing "fluent" like uniform updates
  16861. */
  16862. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16863. /**
  16864. * Set a float32Array in the shader from a matrix array.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the material itself allowing "fluent" like uniform updates
  16868. */
  16869. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16870. /**
  16871. * Set a mat3 in the shader from a Float32Array.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the material itself allowing "fluent" like uniform updates
  16875. */
  16876. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16877. /**
  16878. * Set a mat2 in the shader from a Float32Array.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the material itself allowing "fluent" like uniform updates
  16882. */
  16883. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16884. /**
  16885. * Set a vec2 array in the shader from a number array.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the material itself allowing "fluent" like uniform updates
  16889. */
  16890. setArray2(name: string, value: number[]): ShaderMaterial;
  16891. /**
  16892. * Set a vec3 array in the shader from a number array.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setArray3(name: string, value: number[]): ShaderMaterial;
  16898. /**
  16899. * Set a vec4 array in the shader from a number array.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the material itself allowing "fluent" like uniform updates
  16903. */
  16904. setArray4(name: string, value: number[]): ShaderMaterial;
  16905. private _checkCache;
  16906. /**
  16907. * Specifies that the submesh is ready to be used
  16908. * @param mesh defines the mesh to check
  16909. * @param subMesh defines which submesh to check
  16910. * @param useInstances specifies that instances should be used
  16911. * @returns a boolean indicating that the submesh is ready or not
  16912. */
  16913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16914. /**
  16915. * Checks if the material is ready to render the requested mesh
  16916. * @param mesh Define the mesh to render
  16917. * @param useInstances Define whether or not the material is used with instances
  16918. * @returns true if ready, otherwise false
  16919. */
  16920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16921. /**
  16922. * Binds the world matrix to the material
  16923. * @param world defines the world transformation matrix
  16924. * @param effectOverride - If provided, use this effect instead of internal effect
  16925. */
  16926. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16927. /**
  16928. * Binds the submesh to this material by preparing the effect and shader to draw
  16929. * @param world defines the world transformation matrix
  16930. * @param mesh defines the mesh containing the submesh
  16931. * @param subMesh defines the submesh to bind the material to
  16932. */
  16933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16934. /**
  16935. * Binds the material to the mesh
  16936. * @param world defines the world transformation matrix
  16937. * @param mesh defines the mesh to bind the material to
  16938. * @param effectOverride - If provided, use this effect instead of internal effect
  16939. */
  16940. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16941. protected _afterBind(mesh?: Mesh): void;
  16942. /**
  16943. * Gets the active textures from the material
  16944. * @returns an array of textures
  16945. */
  16946. getActiveTextures(): BaseTexture[];
  16947. /**
  16948. * Specifies if the material uses a texture
  16949. * @param texture defines the texture to check against the material
  16950. * @returns a boolean specifying if the material uses the texture
  16951. */
  16952. hasTexture(texture: BaseTexture): boolean;
  16953. /**
  16954. * Makes a duplicate of the material, and gives it a new name
  16955. * @param name defines the new name for the duplicated material
  16956. * @returns the cloned material
  16957. */
  16958. clone(name: string): ShaderMaterial;
  16959. /**
  16960. * Disposes the material
  16961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16964. */
  16965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16966. /**
  16967. * Serializes this material in a JSON representation
  16968. * @returns the serialized material object
  16969. */
  16970. serialize(): any;
  16971. /**
  16972. * Creates a shader material from parsed shader material data
  16973. * @param source defines the JSON represnetation of the material
  16974. * @param scene defines the hosting scene
  16975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16976. * @returns a new material
  16977. */
  16978. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16979. /**
  16980. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16981. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16982. * @param url defines the url to load from
  16983. * @param scene defines the hosting scene
  16984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16985. * @returns a promise that will resolve to the new ShaderMaterial
  16986. */
  16987. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16988. /**
  16989. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16990. * @param snippetId defines the snippet to load
  16991. * @param scene defines the hosting scene
  16992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16993. * @returns a promise that will resolve to the new ShaderMaterial
  16994. */
  16995. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16996. }
  16997. }
  16998. declare module "babylonjs/Shaders/color.fragment" {
  16999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17000. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17001. /** @hidden */
  17002. export var colorPixelShader: {
  17003. name: string;
  17004. shader: string;
  17005. };
  17006. }
  17007. declare module "babylonjs/Shaders/color.vertex" {
  17008. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17010. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17013. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17014. /** @hidden */
  17015. export var colorVertexShader: {
  17016. name: string;
  17017. shader: string;
  17018. };
  17019. }
  17020. declare module "babylonjs/Meshes/linesMesh" {
  17021. import { Nullable } from "babylonjs/types";
  17022. import { Scene } from "babylonjs/scene";
  17023. import { Color3 } from "babylonjs/Maths/math.color";
  17024. import { Node } from "babylonjs/node";
  17025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17026. import { Mesh } from "babylonjs/Meshes/mesh";
  17027. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17028. import { Effect } from "babylonjs/Materials/effect";
  17029. import { Material } from "babylonjs/Materials/material";
  17030. import "babylonjs/Shaders/color.fragment";
  17031. import "babylonjs/Shaders/color.vertex";
  17032. /**
  17033. * Line mesh
  17034. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17035. */
  17036. export class LinesMesh extends Mesh {
  17037. /**
  17038. * If vertex color should be applied to the mesh
  17039. */
  17040. readonly useVertexColor?: boolean | undefined;
  17041. /**
  17042. * If vertex alpha should be applied to the mesh
  17043. */
  17044. readonly useVertexAlpha?: boolean | undefined;
  17045. /**
  17046. * Color of the line (Default: White)
  17047. */
  17048. color: Color3;
  17049. /**
  17050. * Alpha of the line (Default: 1)
  17051. */
  17052. alpha: number;
  17053. /**
  17054. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17055. * This margin is expressed in world space coordinates, so its value may vary.
  17056. * Default value is 0.1
  17057. */
  17058. intersectionThreshold: number;
  17059. private _colorShader;
  17060. private color4;
  17061. /**
  17062. * Creates a new LinesMesh
  17063. * @param name defines the name
  17064. * @param scene defines the hosting scene
  17065. * @param parent defines the parent mesh if any
  17066. * @param source defines the optional source LinesMesh used to clone data from
  17067. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17068. * When false, achieved by calling a clone(), also passing False.
  17069. * This will make creation of children, recursive.
  17070. * @param useVertexColor defines if this LinesMesh supports vertex color
  17071. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17072. */
  17073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17074. /**
  17075. * If vertex color should be applied to the mesh
  17076. */
  17077. useVertexColor?: boolean | undefined,
  17078. /**
  17079. * If vertex alpha should be applied to the mesh
  17080. */
  17081. useVertexAlpha?: boolean | undefined);
  17082. private _addClipPlaneDefine;
  17083. private _removeClipPlaneDefine;
  17084. isReady(): boolean;
  17085. /**
  17086. * Returns the string "LineMesh"
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * @hidden
  17091. */
  17092. get material(): Material;
  17093. /**
  17094. * @hidden
  17095. */
  17096. set material(value: Material);
  17097. /**
  17098. * @hidden
  17099. */
  17100. get checkCollisions(): boolean;
  17101. /** @hidden */
  17102. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17103. /** @hidden */
  17104. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17105. /**
  17106. * Disposes of the line mesh
  17107. * @param doNotRecurse If children should be disposed
  17108. */
  17109. dispose(doNotRecurse?: boolean): void;
  17110. /**
  17111. * Returns a new LineMesh object cloned from the current one.
  17112. */
  17113. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17114. /**
  17115. * Creates a new InstancedLinesMesh object from the mesh model.
  17116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17117. * @param name defines the name of the new instance
  17118. * @returns a new InstancedLinesMesh
  17119. */
  17120. createInstance(name: string): InstancedLinesMesh;
  17121. }
  17122. /**
  17123. * Creates an instance based on a source LinesMesh
  17124. */
  17125. export class InstancedLinesMesh extends InstancedMesh {
  17126. /**
  17127. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17128. * This margin is expressed in world space coordinates, so its value may vary.
  17129. * Initilized with the intersectionThreshold value of the source LinesMesh
  17130. */
  17131. intersectionThreshold: number;
  17132. constructor(name: string, source: LinesMesh);
  17133. /**
  17134. * Returns the string "InstancedLinesMesh".
  17135. */
  17136. getClassName(): string;
  17137. }
  17138. }
  17139. declare module "babylonjs/Shaders/line.fragment" {
  17140. /** @hidden */
  17141. export var linePixelShader: {
  17142. name: string;
  17143. shader: string;
  17144. };
  17145. }
  17146. declare module "babylonjs/Shaders/line.vertex" {
  17147. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17149. /** @hidden */
  17150. export var lineVertexShader: {
  17151. name: string;
  17152. shader: string;
  17153. };
  17154. }
  17155. declare module "babylonjs/Rendering/edgesRenderer" {
  17156. import { Nullable } from "babylonjs/types";
  17157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17159. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17160. import { IDisposable } from "babylonjs/scene";
  17161. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17162. import "babylonjs/Shaders/line.fragment";
  17163. import "babylonjs/Shaders/line.vertex";
  17164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17165. import { SmartArray } from "babylonjs/Misc/smartArray";
  17166. module "babylonjs/scene" {
  17167. interface Scene {
  17168. /** @hidden */
  17169. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/abstractMesh" {
  17173. interface AbstractMesh {
  17174. /**
  17175. * Gets the edgesRenderer associated with the mesh
  17176. */
  17177. edgesRenderer: Nullable<EdgesRenderer>;
  17178. }
  17179. }
  17180. module "babylonjs/Meshes/linesMesh" {
  17181. interface LinesMesh {
  17182. /**
  17183. * Enables the edge rendering mode on the mesh.
  17184. * This mode makes the mesh edges visible
  17185. * @param epsilon defines the maximal distance between two angles to detect a face
  17186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17187. * @returns the currentAbstractMesh
  17188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17189. */
  17190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17191. }
  17192. }
  17193. module "babylonjs/Meshes/linesMesh" {
  17194. interface InstancedLinesMesh {
  17195. /**
  17196. * Enables the edge rendering mode on the mesh.
  17197. * This mode makes the mesh edges visible
  17198. * @param epsilon defines the maximal distance between two angles to detect a face
  17199. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17200. * @returns the current InstancedLinesMesh
  17201. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17202. */
  17203. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17204. }
  17205. }
  17206. /**
  17207. * Defines the minimum contract an Edges renderer should follow.
  17208. */
  17209. export interface IEdgesRenderer extends IDisposable {
  17210. /**
  17211. * Gets or sets a boolean indicating if the edgesRenderer is active
  17212. */
  17213. isEnabled: boolean;
  17214. /**
  17215. * Renders the edges of the attached mesh,
  17216. */
  17217. render(): void;
  17218. /**
  17219. * Checks wether or not the edges renderer is ready to render.
  17220. * @return true if ready, otherwise false.
  17221. */
  17222. isReady(): boolean;
  17223. /**
  17224. * List of instances to render in case the source mesh has instances
  17225. */
  17226. customInstances: SmartArray<Matrix>;
  17227. }
  17228. /**
  17229. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17230. */
  17231. export class EdgesRenderer implements IEdgesRenderer {
  17232. /**
  17233. * Define the size of the edges with an orthographic camera
  17234. */
  17235. edgesWidthScalerForOrthographic: number;
  17236. /**
  17237. * Define the size of the edges with a perspective camera
  17238. */
  17239. edgesWidthScalerForPerspective: number;
  17240. protected _source: AbstractMesh;
  17241. protected _linesPositions: number[];
  17242. protected _linesNormals: number[];
  17243. protected _linesIndices: number[];
  17244. protected _epsilon: number;
  17245. protected _indicesCount: number;
  17246. protected _lineShader: ShaderMaterial;
  17247. protected _ib: DataBuffer;
  17248. protected _buffers: {
  17249. [key: string]: Nullable<VertexBuffer>;
  17250. };
  17251. protected _buffersForInstances: {
  17252. [key: string]: Nullable<VertexBuffer>;
  17253. };
  17254. protected _checkVerticesInsteadOfIndices: boolean;
  17255. private _meshRebuildObserver;
  17256. private _meshDisposeObserver;
  17257. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17258. isEnabled: boolean;
  17259. /**
  17260. * List of instances to render in case the source mesh has instances
  17261. */
  17262. customInstances: SmartArray<Matrix>;
  17263. private static GetShader;
  17264. /**
  17265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17267. * @param source Mesh used to create edges
  17268. * @param epsilon sum of angles in adjacency to check for edge
  17269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17271. */
  17272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17273. protected _prepareRessources(): void;
  17274. /** @hidden */
  17275. _rebuild(): void;
  17276. /**
  17277. * Releases the required resources for the edges renderer
  17278. */
  17279. dispose(): void;
  17280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17282. /**
  17283. * Checks if the pair of p0 and p1 is en edge
  17284. * @param faceIndex
  17285. * @param edge
  17286. * @param faceNormals
  17287. * @param p0
  17288. * @param p1
  17289. * @private
  17290. */
  17291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17292. /**
  17293. * push line into the position, normal and index buffer
  17294. * @protected
  17295. */
  17296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17297. /**
  17298. * Generates lines edges from adjacencjes
  17299. * @private
  17300. */
  17301. _generateEdgesLines(): void;
  17302. /**
  17303. * Checks wether or not the edges renderer is ready to render.
  17304. * @return true if ready, otherwise false.
  17305. */
  17306. isReady(): boolean;
  17307. /**
  17308. * Renders the edges of the attached mesh,
  17309. */
  17310. render(): void;
  17311. }
  17312. /**
  17313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17314. */
  17315. export class LineEdgesRenderer extends EdgesRenderer {
  17316. /**
  17317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17318. * @param source LineMesh used to generate edges
  17319. * @param epsilon not important (specified angle for edge detection)
  17320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17321. */
  17322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17323. /**
  17324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17325. */
  17326. _generateEdgesLines(): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Rendering/renderingGroup" {
  17330. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Nullable } from "babylonjs/types";
  17334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17335. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17336. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. import { Scene } from "babylonjs/scene";
  17339. /**
  17340. * This represents the object necessary to create a rendering group.
  17341. * This is exclusively used and created by the rendering manager.
  17342. * To modify the behavior, you use the available helpers in your scene or meshes.
  17343. * @hidden
  17344. */
  17345. export class RenderingGroup {
  17346. index: number;
  17347. private static _zeroVector;
  17348. private _scene;
  17349. private _opaqueSubMeshes;
  17350. private _transparentSubMeshes;
  17351. private _alphaTestSubMeshes;
  17352. private _depthOnlySubMeshes;
  17353. private _particleSystems;
  17354. private _spriteManagers;
  17355. private _opaqueSortCompareFn;
  17356. private _alphaTestSortCompareFn;
  17357. private _transparentSortCompareFn;
  17358. private _renderOpaque;
  17359. private _renderAlphaTest;
  17360. private _renderTransparent;
  17361. /** @hidden */
  17362. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17363. onBeforeTransparentRendering: () => void;
  17364. /**
  17365. * Set the opaque sort comparison function.
  17366. * If null the sub meshes will be render in the order they were created
  17367. */
  17368. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17369. /**
  17370. * Set the alpha test sort comparison function.
  17371. * If null the sub meshes will be render in the order they were created
  17372. */
  17373. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17374. /**
  17375. * Set the transparent sort comparison function.
  17376. * If null the sub meshes will be render in the order they were created
  17377. */
  17378. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17379. /**
  17380. * Creates a new rendering group.
  17381. * @param index The rendering group index
  17382. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17383. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17384. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17385. */
  17386. 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>);
  17387. /**
  17388. * Render all the sub meshes contained in the group.
  17389. * @param customRenderFunction Used to override the default render behaviour of the group.
  17390. * @returns true if rendered some submeshes.
  17391. */
  17392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17393. /**
  17394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private renderOpaqueSorted;
  17398. /**
  17399. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17400. * @param subMeshes The submeshes to render
  17401. */
  17402. private renderAlphaTestSorted;
  17403. /**
  17404. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17405. * @param subMeshes The submeshes to render
  17406. */
  17407. private renderTransparentSorted;
  17408. /**
  17409. * Renders the submeshes in a specified order.
  17410. * @param subMeshes The submeshes to sort before render
  17411. * @param sortCompareFn The comparison function use to sort
  17412. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17413. * @param transparent Specifies to activate blending if true
  17414. */
  17415. private static renderSorted;
  17416. /**
  17417. * Renders the submeshes in the order they were dispatched (no sort applied).
  17418. * @param subMeshes The submeshes to render
  17419. */
  17420. private static renderUnsorted;
  17421. /**
  17422. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17423. * are rendered back to front if in the same alpha index.
  17424. *
  17425. * @param a The first submesh
  17426. * @param b The second submesh
  17427. * @returns The result of the comparison
  17428. */
  17429. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17430. /**
  17431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17432. * are rendered back to front.
  17433. *
  17434. * @param a The first submesh
  17435. * @param b The second submesh
  17436. * @returns The result of the comparison
  17437. */
  17438. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17439. /**
  17440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17441. * are rendered front to back (prevent overdraw).
  17442. *
  17443. * @param a The first submesh
  17444. * @param b The second submesh
  17445. * @returns The result of the comparison
  17446. */
  17447. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17448. /**
  17449. * Resets the different lists of submeshes to prepare a new frame.
  17450. */
  17451. prepare(): void;
  17452. dispose(): void;
  17453. /**
  17454. * Inserts the submesh in its correct queue depending on its material.
  17455. * @param subMesh The submesh to dispatch
  17456. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17457. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17458. */
  17459. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17460. dispatchSprites(spriteManager: ISpriteManager): void;
  17461. dispatchParticles(particleSystem: IParticleSystem): void;
  17462. private _renderParticles;
  17463. private _renderSprites;
  17464. }
  17465. }
  17466. declare module "babylonjs/Rendering/renderingManager" {
  17467. import { Nullable } from "babylonjs/types";
  17468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17470. import { SmartArray } from "babylonjs/Misc/smartArray";
  17471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17473. import { Material } from "babylonjs/Materials/material";
  17474. import { Scene } from "babylonjs/scene";
  17475. import { Camera } from "babylonjs/Cameras/camera";
  17476. /**
  17477. * Interface describing the different options available in the rendering manager
  17478. * regarding Auto Clear between groups.
  17479. */
  17480. export interface IRenderingManagerAutoClearSetup {
  17481. /**
  17482. * Defines whether or not autoclear is enable.
  17483. */
  17484. autoClear: boolean;
  17485. /**
  17486. * Defines whether or not to autoclear the depth buffer.
  17487. */
  17488. depth: boolean;
  17489. /**
  17490. * Defines whether or not to autoclear the stencil buffer.
  17491. */
  17492. stencil: boolean;
  17493. }
  17494. /**
  17495. * This class is used by the onRenderingGroupObservable
  17496. */
  17497. export class RenderingGroupInfo {
  17498. /**
  17499. * The Scene that being rendered
  17500. */
  17501. scene: Scene;
  17502. /**
  17503. * The camera currently used for the rendering pass
  17504. */
  17505. camera: Nullable<Camera>;
  17506. /**
  17507. * The ID of the renderingGroup being processed
  17508. */
  17509. renderingGroupId: number;
  17510. }
  17511. /**
  17512. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17513. * It is enable to manage the different groups as well as the different necessary sort functions.
  17514. * This should not be used directly aside of the few static configurations
  17515. */
  17516. export class RenderingManager {
  17517. /**
  17518. * The max id used for rendering groups (not included)
  17519. */
  17520. static MAX_RENDERINGGROUPS: number;
  17521. /**
  17522. * The min id used for rendering groups (included)
  17523. */
  17524. static MIN_RENDERINGGROUPS: number;
  17525. /**
  17526. * Used to globally prevent autoclearing scenes.
  17527. */
  17528. static AUTOCLEAR: boolean;
  17529. /**
  17530. * @hidden
  17531. */
  17532. _useSceneAutoClearSetup: boolean;
  17533. private _scene;
  17534. private _renderingGroups;
  17535. private _depthStencilBufferAlreadyCleaned;
  17536. private _autoClearDepthStencil;
  17537. private _customOpaqueSortCompareFn;
  17538. private _customAlphaTestSortCompareFn;
  17539. private _customTransparentSortCompareFn;
  17540. private _renderingGroupInfo;
  17541. /**
  17542. * Instantiates a new rendering group for a particular scene
  17543. * @param scene Defines the scene the groups belongs to
  17544. */
  17545. constructor(scene: Scene);
  17546. private _clearDepthStencilBuffer;
  17547. /**
  17548. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17549. * @hidden
  17550. */
  17551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17552. /**
  17553. * Resets the different information of the group to prepare a new frame
  17554. * @hidden
  17555. */
  17556. reset(): void;
  17557. /**
  17558. * Dispose and release the group and its associated resources.
  17559. * @hidden
  17560. */
  17561. dispose(): void;
  17562. /**
  17563. * Clear the info related to rendering groups preventing retention points during dispose.
  17564. */
  17565. freeRenderingGroups(): void;
  17566. private _prepareRenderingGroup;
  17567. /**
  17568. * Add a sprite manager to the rendering manager in order to render it this frame.
  17569. * @param spriteManager Define the sprite manager to render
  17570. */
  17571. dispatchSprites(spriteManager: ISpriteManager): void;
  17572. /**
  17573. * Add a particle system to the rendering manager in order to render it this frame.
  17574. * @param particleSystem Define the particle system to render
  17575. */
  17576. dispatchParticles(particleSystem: IParticleSystem): void;
  17577. /**
  17578. * Add a submesh to the manager in order to render it this frame
  17579. * @param subMesh The submesh to dispatch
  17580. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17581. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17582. */
  17583. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17584. /**
  17585. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17586. * This allowed control for front to back rendering or reversly depending of the special needs.
  17587. *
  17588. * @param renderingGroupId The rendering group id corresponding to its index
  17589. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17590. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17591. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17592. */
  17593. 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;
  17594. /**
  17595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17596. *
  17597. * @param renderingGroupId The rendering group id corresponding to its index
  17598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17599. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17600. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17601. */
  17602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17603. /**
  17604. * Gets the current auto clear configuration for one rendering group of the rendering
  17605. * manager.
  17606. * @param index the rendering group index to get the information for
  17607. * @returns The auto clear setup for the requested rendering group
  17608. */
  17609. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17610. }
  17611. }
  17612. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17613. import { SmartArray } from "babylonjs/Misc/smartArray";
  17614. import { Nullable } from "babylonjs/types";
  17615. import { Scene } from "babylonjs/scene";
  17616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17619. import { Mesh } from "babylonjs/Meshes/mesh";
  17620. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17621. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17622. import { Effect } from "babylonjs/Materials/effect";
  17623. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17625. import "babylonjs/Shaders/shadowMap.fragment";
  17626. import "babylonjs/Shaders/shadowMap.vertex";
  17627. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17628. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17629. import { Observable } from "babylonjs/Misc/observable";
  17630. /**
  17631. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17632. */
  17633. export interface ICustomShaderOptions {
  17634. /**
  17635. * Gets or sets the custom shader name to use
  17636. */
  17637. shaderName: string;
  17638. /**
  17639. * The list of attribute names used in the shader
  17640. */
  17641. attributes?: string[];
  17642. /**
  17643. * The list of unifrom names used in the shader
  17644. */
  17645. uniforms?: string[];
  17646. /**
  17647. * The list of sampler names used in the shader
  17648. */
  17649. samplers?: string[];
  17650. /**
  17651. * The list of defines used in the shader
  17652. */
  17653. defines?: string[];
  17654. }
  17655. /**
  17656. * Interface to implement to create a shadow generator compatible with BJS.
  17657. */
  17658. export interface IShadowGenerator {
  17659. /**
  17660. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17661. * @returns The render target texture if present otherwise, null
  17662. */
  17663. getShadowMap(): Nullable<RenderTargetTexture>;
  17664. /**
  17665. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17666. * @param subMesh The submesh we want to render in the shadow map
  17667. * @param useInstances Defines wether will draw in the map using instances
  17668. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17669. * @returns true if ready otherwise, false
  17670. */
  17671. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17672. /**
  17673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17674. * @param defines Defines of the material we want to update
  17675. * @param lightIndex Index of the light in the enabled light list of the material
  17676. */
  17677. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17678. /**
  17679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17680. * defined in the generator but impacting the effect).
  17681. * It implies the unifroms available on the materials are the standard BJS ones.
  17682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17683. * @param effect The effect we are binfing the information for
  17684. */
  17685. bindShadowLight(lightIndex: string, effect: Effect): void;
  17686. /**
  17687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17688. * (eq to shadow prjection matrix * light transform matrix)
  17689. * @returns The transform matrix used to create the shadow map
  17690. */
  17691. getTransformMatrix(): Matrix;
  17692. /**
  17693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17694. * Cube and 2D textures for instance.
  17695. */
  17696. recreateShadowMap(): void;
  17697. /**
  17698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17699. * @param onCompiled Callback triggered at the and of the effects compilation
  17700. * @param options Sets of optional options forcing the compilation with different modes
  17701. */
  17702. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17703. useInstances: boolean;
  17704. }>): void;
  17705. /**
  17706. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17707. * @param options Sets of optional options forcing the compilation with different modes
  17708. * @returns A promise that resolves when the compilation completes
  17709. */
  17710. forceCompilationAsync(options?: Partial<{
  17711. useInstances: boolean;
  17712. }>): Promise<void>;
  17713. /**
  17714. * Serializes the shadow generator setup to a json object.
  17715. * @returns The serialized JSON object
  17716. */
  17717. serialize(): any;
  17718. /**
  17719. * Disposes the Shadow map and related Textures and effects.
  17720. */
  17721. dispose(): void;
  17722. }
  17723. /**
  17724. * Default implementation IShadowGenerator.
  17725. * This is the main object responsible of generating shadows in the framework.
  17726. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17727. */
  17728. export class ShadowGenerator implements IShadowGenerator {
  17729. /**
  17730. * Name of the shadow generator class
  17731. */
  17732. static CLASSNAME: string;
  17733. /**
  17734. * Shadow generator mode None: no filtering applied.
  17735. */
  17736. static readonly FILTER_NONE: number;
  17737. /**
  17738. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17740. */
  17741. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17742. /**
  17743. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17744. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17745. */
  17746. static readonly FILTER_POISSONSAMPLING: number;
  17747. /**
  17748. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17750. */
  17751. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17752. /**
  17753. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17754. * edge artifacts on steep falloff.
  17755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17756. */
  17757. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17758. /**
  17759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17760. * edge artifacts on steep falloff.
  17761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17762. */
  17763. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17764. /**
  17765. * Shadow generator mode PCF: Percentage Closer Filtering
  17766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17767. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17768. */
  17769. static readonly FILTER_PCF: number;
  17770. /**
  17771. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17773. * Contact Hardening
  17774. */
  17775. static readonly FILTER_PCSS: number;
  17776. /**
  17777. * Reserved for PCF and PCSS
  17778. * Highest Quality.
  17779. *
  17780. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17781. *
  17782. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17783. */
  17784. static readonly QUALITY_HIGH: number;
  17785. /**
  17786. * Reserved for PCF and PCSS
  17787. * Good tradeoff for quality/perf cross devices
  17788. *
  17789. * Execute PCF on a 3*3 kernel.
  17790. *
  17791. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17792. */
  17793. static readonly QUALITY_MEDIUM: number;
  17794. /**
  17795. * Reserved for PCF and PCSS
  17796. * The lowest quality but the fastest.
  17797. *
  17798. * Execute PCF on a 1*1 kernel.
  17799. *
  17800. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17801. */
  17802. static readonly QUALITY_LOW: number;
  17803. /** Gets or sets the custom shader name to use */
  17804. customShaderOptions: ICustomShaderOptions;
  17805. /**
  17806. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17807. */
  17808. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17809. /**
  17810. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17811. */
  17812. onAfterShadowMapRenderObservable: Observable<Effect>;
  17813. /**
  17814. * Observable triggered before a mesh is rendered in the shadow map.
  17815. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17816. */
  17817. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17818. /**
  17819. * Observable triggered after a mesh is rendered in the shadow map.
  17820. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17821. */
  17822. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17823. protected _bias: number;
  17824. /**
  17825. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17826. */
  17827. get bias(): number;
  17828. /**
  17829. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17830. */
  17831. set bias(bias: number);
  17832. protected _normalBias: number;
  17833. /**
  17834. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17835. */
  17836. get normalBias(): number;
  17837. /**
  17838. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17839. */
  17840. set normalBias(normalBias: number);
  17841. protected _blurBoxOffset: number;
  17842. /**
  17843. * Gets the blur box offset: offset applied during the blur pass.
  17844. * Only useful if useKernelBlur = false
  17845. */
  17846. get blurBoxOffset(): number;
  17847. /**
  17848. * Sets the blur box offset: offset applied during the blur pass.
  17849. * Only useful if useKernelBlur = false
  17850. */
  17851. set blurBoxOffset(value: number);
  17852. protected _blurScale: number;
  17853. /**
  17854. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17855. * 2 means half of the size.
  17856. */
  17857. get blurScale(): number;
  17858. /**
  17859. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17860. * 2 means half of the size.
  17861. */
  17862. set blurScale(value: number);
  17863. protected _blurKernel: number;
  17864. /**
  17865. * Gets the blur kernel: kernel size of the blur pass.
  17866. * Only useful if useKernelBlur = true
  17867. */
  17868. get blurKernel(): number;
  17869. /**
  17870. * Sets the blur kernel: kernel size of the blur pass.
  17871. * Only useful if useKernelBlur = true
  17872. */
  17873. set blurKernel(value: number);
  17874. protected _useKernelBlur: boolean;
  17875. /**
  17876. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17877. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17878. */
  17879. get useKernelBlur(): boolean;
  17880. /**
  17881. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17882. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17883. */
  17884. set useKernelBlur(value: boolean);
  17885. protected _depthScale: number;
  17886. /**
  17887. * Gets the depth scale used in ESM mode.
  17888. */
  17889. get depthScale(): number;
  17890. /**
  17891. * Sets the depth scale used in ESM mode.
  17892. * This can override the scale stored on the light.
  17893. */
  17894. set depthScale(value: number);
  17895. protected _validateFilter(filter: number): number;
  17896. protected _filter: number;
  17897. /**
  17898. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17899. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17900. */
  17901. get filter(): number;
  17902. /**
  17903. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17904. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17905. */
  17906. set filter(value: number);
  17907. /**
  17908. * Gets if the current filter is set to Poisson Sampling.
  17909. */
  17910. get usePoissonSampling(): boolean;
  17911. /**
  17912. * Sets the current filter to Poisson Sampling.
  17913. */
  17914. set usePoissonSampling(value: boolean);
  17915. /**
  17916. * Gets if the current filter is set to ESM.
  17917. */
  17918. get useExponentialShadowMap(): boolean;
  17919. /**
  17920. * Sets the current filter is to ESM.
  17921. */
  17922. set useExponentialShadowMap(value: boolean);
  17923. /**
  17924. * Gets if the current filter is set to filtered ESM.
  17925. */
  17926. get useBlurExponentialShadowMap(): boolean;
  17927. /**
  17928. * Gets if the current filter is set to filtered ESM.
  17929. */
  17930. set useBlurExponentialShadowMap(value: boolean);
  17931. /**
  17932. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17933. * exponential to prevent steep falloff artifacts).
  17934. */
  17935. get useCloseExponentialShadowMap(): boolean;
  17936. /**
  17937. * Sets the current filter to "close ESM" (using the inverse of the
  17938. * exponential to prevent steep falloff artifacts).
  17939. */
  17940. set useCloseExponentialShadowMap(value: boolean);
  17941. /**
  17942. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17943. * exponential to prevent steep falloff artifacts).
  17944. */
  17945. get useBlurCloseExponentialShadowMap(): boolean;
  17946. /**
  17947. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17948. * exponential to prevent steep falloff artifacts).
  17949. */
  17950. set useBlurCloseExponentialShadowMap(value: boolean);
  17951. /**
  17952. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17953. */
  17954. get usePercentageCloserFiltering(): boolean;
  17955. /**
  17956. * Sets the current filter to "PCF" (percentage closer filtering).
  17957. */
  17958. set usePercentageCloserFiltering(value: boolean);
  17959. protected _filteringQuality: number;
  17960. /**
  17961. * Gets the PCF or PCSS Quality.
  17962. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17963. */
  17964. get filteringQuality(): number;
  17965. /**
  17966. * Sets the PCF or PCSS Quality.
  17967. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17968. */
  17969. set filteringQuality(filteringQuality: number);
  17970. /**
  17971. * Gets if the current filter is set to "PCSS" (contact hardening).
  17972. */
  17973. get useContactHardeningShadow(): boolean;
  17974. /**
  17975. * Sets the current filter to "PCSS" (contact hardening).
  17976. */
  17977. set useContactHardeningShadow(value: boolean);
  17978. protected _contactHardeningLightSizeUVRatio: number;
  17979. /**
  17980. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17981. * Using a ratio helps keeping shape stability independently of the map size.
  17982. *
  17983. * It does not account for the light projection as it was having too much
  17984. * instability during the light setup or during light position changes.
  17985. *
  17986. * Only valid if useContactHardeningShadow is true.
  17987. */
  17988. get contactHardeningLightSizeUVRatio(): number;
  17989. /**
  17990. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17991. * Using a ratio helps keeping shape stability independently of the map size.
  17992. *
  17993. * It does not account for the light projection as it was having too much
  17994. * instability during the light setup or during light position changes.
  17995. *
  17996. * Only valid if useContactHardeningShadow is true.
  17997. */
  17998. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17999. protected _darkness: number;
  18000. /** Gets or sets the actual darkness of a shadow */
  18001. get darkness(): number;
  18002. set darkness(value: number);
  18003. /**
  18004. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18005. * 0 means strongest and 1 would means no shadow.
  18006. * @returns the darkness.
  18007. */
  18008. getDarkness(): number;
  18009. /**
  18010. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18011. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18012. * @returns the shadow generator allowing fluent coding.
  18013. */
  18014. setDarkness(darkness: number): ShadowGenerator;
  18015. protected _transparencyShadow: boolean;
  18016. /** Gets or sets the ability to have transparent shadow */
  18017. get transparencyShadow(): boolean;
  18018. set transparencyShadow(value: boolean);
  18019. /**
  18020. * Sets the ability to have transparent shadow (boolean).
  18021. * @param transparent True if transparent else False
  18022. * @returns the shadow generator allowing fluent coding
  18023. */
  18024. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18025. /**
  18026. * Enables or disables shadows with varying strength based on the transparency
  18027. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18028. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18029. * mesh.visibility * alphaTexture.a
  18030. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18031. */
  18032. enableSoftTransparentShadow: boolean;
  18033. protected _shadowMap: Nullable<RenderTargetTexture>;
  18034. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18035. /**
  18036. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18037. * @returns The render target texture if present otherwise, null
  18038. */
  18039. getShadowMap(): Nullable<RenderTargetTexture>;
  18040. /**
  18041. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18042. * @returns The render target texture if the shadow map is present otherwise, null
  18043. */
  18044. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18045. /**
  18046. * Gets the class name of that object
  18047. * @returns "ShadowGenerator"
  18048. */
  18049. getClassName(): string;
  18050. /**
  18051. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18052. * @param mesh Mesh to add
  18053. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18054. * @returns the Shadow Generator itself
  18055. */
  18056. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18057. /**
  18058. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18059. * @param mesh Mesh to remove
  18060. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18061. * @returns the Shadow Generator itself
  18062. */
  18063. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18064. /**
  18065. * Controls the extent to which the shadows fade out at the edge of the frustum
  18066. */
  18067. frustumEdgeFalloff: number;
  18068. protected _light: IShadowLight;
  18069. /**
  18070. * Returns the associated light object.
  18071. * @returns the light generating the shadow
  18072. */
  18073. getLight(): IShadowLight;
  18074. /**
  18075. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18076. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18077. * It might on the other hand introduce peter panning.
  18078. */
  18079. forceBackFacesOnly: boolean;
  18080. protected _scene: Scene;
  18081. protected _lightDirection: Vector3;
  18082. protected _effect: Effect;
  18083. protected _viewMatrix: Matrix;
  18084. protected _projectionMatrix: Matrix;
  18085. protected _transformMatrix: Matrix;
  18086. protected _cachedPosition: Vector3;
  18087. protected _cachedDirection: Vector3;
  18088. protected _cachedDefines: string;
  18089. protected _currentRenderID: number;
  18090. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18091. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18092. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18093. protected _blurPostProcesses: PostProcess[];
  18094. protected _mapSize: number;
  18095. protected _currentFaceIndex: number;
  18096. protected _currentFaceIndexCache: number;
  18097. protected _textureType: number;
  18098. protected _defaultTextureMatrix: Matrix;
  18099. protected _storedUniqueId: Nullable<number>;
  18100. /** @hidden */
  18101. static _SceneComponentInitialization: (scene: Scene) => void;
  18102. /**
  18103. * Creates a ShadowGenerator object.
  18104. * A ShadowGenerator is the required tool to use the shadows.
  18105. * Each light casting shadows needs to use its own ShadowGenerator.
  18106. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18107. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18108. * @param light The light object generating the shadows.
  18109. * @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.
  18110. */
  18111. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18112. protected _initializeGenerator(): void;
  18113. protected _createTargetRenderTexture(): void;
  18114. protected _initializeShadowMap(): void;
  18115. protected _initializeBlurRTTAndPostProcesses(): void;
  18116. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18117. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18118. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18119. protected _applyFilterValues(): void;
  18120. /**
  18121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18122. * @param onCompiled Callback triggered at the and of the effects compilation
  18123. * @param options Sets of optional options forcing the compilation with different modes
  18124. */
  18125. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18126. useInstances: boolean;
  18127. }>): void;
  18128. /**
  18129. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18130. * @param options Sets of optional options forcing the compilation with different modes
  18131. * @returns A promise that resolves when the compilation completes
  18132. */
  18133. forceCompilationAsync(options?: Partial<{
  18134. useInstances: boolean;
  18135. }>): Promise<void>;
  18136. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18137. private _prepareShadowDefines;
  18138. /**
  18139. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18140. * @param subMesh The submesh we want to render in the shadow map
  18141. * @param useInstances Defines wether will draw in the map using instances
  18142. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18143. * @returns true if ready otherwise, false
  18144. */
  18145. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18146. /**
  18147. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18148. * @param defines Defines of the material we want to update
  18149. * @param lightIndex Index of the light in the enabled light list of the material
  18150. */
  18151. prepareDefines(defines: any, lightIndex: number): void;
  18152. /**
  18153. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18154. * defined in the generator but impacting the effect).
  18155. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18156. * @param effect The effect we are binfing the information for
  18157. */
  18158. bindShadowLight(lightIndex: string, effect: Effect): void;
  18159. /**
  18160. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18161. * (eq to shadow prjection matrix * light transform matrix)
  18162. * @returns The transform matrix used to create the shadow map
  18163. */
  18164. getTransformMatrix(): Matrix;
  18165. /**
  18166. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18167. * Cube and 2D textures for instance.
  18168. */
  18169. recreateShadowMap(): void;
  18170. protected _disposeBlurPostProcesses(): void;
  18171. protected _disposeRTTandPostProcesses(): void;
  18172. /**
  18173. * Disposes the ShadowGenerator.
  18174. * Returns nothing.
  18175. */
  18176. dispose(): void;
  18177. /**
  18178. * Serializes the shadow generator setup to a json object.
  18179. * @returns The serialized JSON object
  18180. */
  18181. serialize(): any;
  18182. /**
  18183. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18184. * @param parsedShadowGenerator The JSON object to parse
  18185. * @param scene The scene to create the shadow map for
  18186. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18187. * @returns The parsed shadow generator
  18188. */
  18189. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18190. }
  18191. }
  18192. declare module "babylonjs/Lights/light" {
  18193. import { Nullable } from "babylonjs/types";
  18194. import { Scene } from "babylonjs/scene";
  18195. import { Vector3 } from "babylonjs/Maths/math.vector";
  18196. import { Color3 } from "babylonjs/Maths/math.color";
  18197. import { Node } from "babylonjs/node";
  18198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18199. import { Effect } from "babylonjs/Materials/effect";
  18200. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18201. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18202. /**
  18203. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18204. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18205. * 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.
  18206. */
  18207. export abstract class Light extends Node {
  18208. /**
  18209. * Falloff Default: light is falling off following the material specification:
  18210. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18211. */
  18212. static readonly FALLOFF_DEFAULT: number;
  18213. /**
  18214. * Falloff Physical: light is falling off following the inverse squared distance law.
  18215. */
  18216. static readonly FALLOFF_PHYSICAL: number;
  18217. /**
  18218. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18219. * to enhance interoperability with other engines.
  18220. */
  18221. static readonly FALLOFF_GLTF: number;
  18222. /**
  18223. * Falloff Standard: light is falling off like in the standard material
  18224. * to enhance interoperability with other materials.
  18225. */
  18226. static readonly FALLOFF_STANDARD: number;
  18227. /**
  18228. * If every light affecting the material is in this lightmapMode,
  18229. * material.lightmapTexture adds or multiplies
  18230. * (depends on material.useLightmapAsShadowmap)
  18231. * after every other light calculations.
  18232. */
  18233. static readonly LIGHTMAP_DEFAULT: number;
  18234. /**
  18235. * material.lightmapTexture as only diffuse lighting from this light
  18236. * adds only specular lighting from this light
  18237. * adds dynamic shadows
  18238. */
  18239. static readonly LIGHTMAP_SPECULAR: number;
  18240. /**
  18241. * material.lightmapTexture as only lighting
  18242. * no light calculation from this light
  18243. * only adds dynamic shadows from this light
  18244. */
  18245. static readonly LIGHTMAP_SHADOWSONLY: number;
  18246. /**
  18247. * Each light type uses the default quantity according to its type:
  18248. * point/spot lights use luminous intensity
  18249. * directional lights use illuminance
  18250. */
  18251. static readonly INTENSITYMODE_AUTOMATIC: number;
  18252. /**
  18253. * lumen (lm)
  18254. */
  18255. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18256. /**
  18257. * candela (lm/sr)
  18258. */
  18259. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18260. /**
  18261. * lux (lm/m^2)
  18262. */
  18263. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18264. /**
  18265. * nit (cd/m^2)
  18266. */
  18267. static readonly INTENSITYMODE_LUMINANCE: number;
  18268. /**
  18269. * Light type const id of the point light.
  18270. */
  18271. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18272. /**
  18273. * Light type const id of the directional light.
  18274. */
  18275. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18276. /**
  18277. * Light type const id of the spot light.
  18278. */
  18279. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18280. /**
  18281. * Light type const id of the hemispheric light.
  18282. */
  18283. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18284. /**
  18285. * Diffuse gives the basic color to an object.
  18286. */
  18287. diffuse: Color3;
  18288. /**
  18289. * Specular produces a highlight color on an object.
  18290. * Note: This is note affecting PBR materials.
  18291. */
  18292. specular: Color3;
  18293. /**
  18294. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18295. * falling off base on range or angle.
  18296. * This can be set to any values in Light.FALLOFF_x.
  18297. *
  18298. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18299. * other types of materials.
  18300. */
  18301. falloffType: number;
  18302. /**
  18303. * Strength of the light.
  18304. * Note: By default it is define in the framework own unit.
  18305. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18306. */
  18307. intensity: number;
  18308. private _range;
  18309. protected _inverseSquaredRange: number;
  18310. /**
  18311. * Defines how far from the source the light is impacting in scene units.
  18312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18313. */
  18314. get range(): number;
  18315. /**
  18316. * Defines how far from the source the light is impacting in scene units.
  18317. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18318. */
  18319. set range(value: number);
  18320. /**
  18321. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18322. * of light.
  18323. */
  18324. private _photometricScale;
  18325. private _intensityMode;
  18326. /**
  18327. * Gets the photometric scale used to interpret the intensity.
  18328. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18329. */
  18330. get intensityMode(): number;
  18331. /**
  18332. * Sets the photometric scale used to interpret the intensity.
  18333. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18334. */
  18335. set intensityMode(value: number);
  18336. private _radius;
  18337. /**
  18338. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18339. */
  18340. get radius(): number;
  18341. /**
  18342. * sets the light radius used by PBR Materials to simulate soft area lights.
  18343. */
  18344. set radius(value: number);
  18345. private _renderPriority;
  18346. /**
  18347. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18348. * exceeding the number allowed of the materials.
  18349. */
  18350. renderPriority: number;
  18351. private _shadowEnabled;
  18352. /**
  18353. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18354. * the current shadow generator.
  18355. */
  18356. get shadowEnabled(): boolean;
  18357. /**
  18358. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18359. * the current shadow generator.
  18360. */
  18361. set shadowEnabled(value: boolean);
  18362. private _includedOnlyMeshes;
  18363. /**
  18364. * Gets the only meshes impacted by this light.
  18365. */
  18366. get includedOnlyMeshes(): AbstractMesh[];
  18367. /**
  18368. * Sets the only meshes impacted by this light.
  18369. */
  18370. set includedOnlyMeshes(value: AbstractMesh[]);
  18371. private _excludedMeshes;
  18372. /**
  18373. * Gets the meshes not impacted by this light.
  18374. */
  18375. get excludedMeshes(): AbstractMesh[];
  18376. /**
  18377. * Sets the meshes not impacted by this light.
  18378. */
  18379. set excludedMeshes(value: AbstractMesh[]);
  18380. private _excludeWithLayerMask;
  18381. /**
  18382. * Gets the layer id use to find what meshes are not impacted by the light.
  18383. * Inactive if 0
  18384. */
  18385. get excludeWithLayerMask(): number;
  18386. /**
  18387. * Sets the layer id use to find what meshes are not impacted by the light.
  18388. * Inactive if 0
  18389. */
  18390. set excludeWithLayerMask(value: number);
  18391. private _includeOnlyWithLayerMask;
  18392. /**
  18393. * Gets the layer id use to find what meshes are impacted by the light.
  18394. * Inactive if 0
  18395. */
  18396. get includeOnlyWithLayerMask(): number;
  18397. /**
  18398. * Sets the layer id use to find what meshes are impacted by the light.
  18399. * Inactive if 0
  18400. */
  18401. set includeOnlyWithLayerMask(value: number);
  18402. private _lightmapMode;
  18403. /**
  18404. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18405. */
  18406. get lightmapMode(): number;
  18407. /**
  18408. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18409. */
  18410. set lightmapMode(value: number);
  18411. /**
  18412. * Shadow generator associted to the light.
  18413. * @hidden Internal use only.
  18414. */
  18415. _shadowGenerator: Nullable<IShadowGenerator>;
  18416. /**
  18417. * @hidden Internal use only.
  18418. */
  18419. _excludedMeshesIds: string[];
  18420. /**
  18421. * @hidden Internal use only.
  18422. */
  18423. _includedOnlyMeshesIds: string[];
  18424. /**
  18425. * The current light unifom buffer.
  18426. * @hidden Internal use only.
  18427. */
  18428. _uniformBuffer: UniformBuffer;
  18429. /** @hidden */
  18430. _renderId: number;
  18431. /**
  18432. * Creates a Light object in the scene.
  18433. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18434. * @param name The firendly name of the light
  18435. * @param scene The scene the light belongs too
  18436. */
  18437. constructor(name: string, scene: Scene);
  18438. protected abstract _buildUniformLayout(): void;
  18439. /**
  18440. * Sets the passed Effect "effect" with the Light information.
  18441. * @param effect The effect to update
  18442. * @param lightIndex The index of the light in the effect to update
  18443. * @returns The light
  18444. */
  18445. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18446. /**
  18447. * Sets the passed Effect "effect" with the Light textures.
  18448. * @param effect The effect to update
  18449. * @param lightIndex The index of the light in the effect to update
  18450. * @returns The light
  18451. */
  18452. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18453. /**
  18454. * Binds the lights information from the scene to the effect for the given mesh.
  18455. * @param lightIndex Light index
  18456. * @param scene The scene where the light belongs to
  18457. * @param effect The effect we are binding the data to
  18458. * @param useSpecular Defines if specular is supported
  18459. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18460. */
  18461. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18462. /**
  18463. * Sets the passed Effect "effect" with the Light information.
  18464. * @param effect The effect to update
  18465. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18466. * @returns The light
  18467. */
  18468. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18469. /**
  18470. * Returns the string "Light".
  18471. * @returns the class name
  18472. */
  18473. getClassName(): string;
  18474. /** @hidden */
  18475. readonly _isLight: boolean;
  18476. /**
  18477. * Converts the light information to a readable string for debug purpose.
  18478. * @param fullDetails Supports for multiple levels of logging within scene loading
  18479. * @returns the human readable light info
  18480. */
  18481. toString(fullDetails?: boolean): string;
  18482. /** @hidden */
  18483. protected _syncParentEnabledState(): void;
  18484. /**
  18485. * Set the enabled state of this node.
  18486. * @param value - the new enabled state
  18487. */
  18488. setEnabled(value: boolean): void;
  18489. /**
  18490. * Returns the Light associated shadow generator if any.
  18491. * @return the associated shadow generator.
  18492. */
  18493. getShadowGenerator(): Nullable<IShadowGenerator>;
  18494. /**
  18495. * Returns a Vector3, the absolute light position in the World.
  18496. * @returns the world space position of the light
  18497. */
  18498. getAbsolutePosition(): Vector3;
  18499. /**
  18500. * Specifies if the light will affect the passed mesh.
  18501. * @param mesh The mesh to test against the light
  18502. * @return true the mesh is affected otherwise, false.
  18503. */
  18504. canAffectMesh(mesh: AbstractMesh): boolean;
  18505. /**
  18506. * Sort function to order lights for rendering.
  18507. * @param a First Light object to compare to second.
  18508. * @param b Second Light object to compare first.
  18509. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18510. */
  18511. static CompareLightsPriority(a: Light, b: Light): number;
  18512. /**
  18513. * Releases resources associated with this node.
  18514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18516. */
  18517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18518. /**
  18519. * Returns the light type ID (integer).
  18520. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18521. */
  18522. getTypeID(): number;
  18523. /**
  18524. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18525. * @returns the scaled intensity in intensity mode unit
  18526. */
  18527. getScaledIntensity(): number;
  18528. /**
  18529. * Returns a new Light object, named "name", from the current one.
  18530. * @param name The name of the cloned light
  18531. * @param newParent The parent of this light, if it has one
  18532. * @returns the new created light
  18533. */
  18534. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18535. /**
  18536. * Serializes the current light into a Serialization object.
  18537. * @returns the serialized object.
  18538. */
  18539. serialize(): any;
  18540. /**
  18541. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18542. * This new light is named "name" and added to the passed scene.
  18543. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18544. * @param name The friendly name of the light
  18545. * @param scene The scene the new light will belong to
  18546. * @returns the constructor function
  18547. */
  18548. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18549. /**
  18550. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18551. * @param parsedLight The JSON representation of the light
  18552. * @param scene The scene to create the parsed light in
  18553. * @returns the created light after parsing
  18554. */
  18555. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18556. private _hookArrayForExcluded;
  18557. private _hookArrayForIncludedOnly;
  18558. private _resyncMeshes;
  18559. /**
  18560. * Forces the meshes to update their light related information in their rendering used effects
  18561. * @hidden Internal Use Only
  18562. */
  18563. _markMeshesAsLightDirty(): void;
  18564. /**
  18565. * Recomputes the cached photometric scale if needed.
  18566. */
  18567. private _computePhotometricScale;
  18568. /**
  18569. * Returns the Photometric Scale according to the light type and intensity mode.
  18570. */
  18571. private _getPhotometricScale;
  18572. /**
  18573. * Reorder the light in the scene according to their defined priority.
  18574. * @hidden Internal Use Only
  18575. */
  18576. _reorderLightsInScene(): void;
  18577. /**
  18578. * Prepares the list of defines specific to the light type.
  18579. * @param defines the list of defines
  18580. * @param lightIndex defines the index of the light for the effect
  18581. */
  18582. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Cameras/targetCamera" {
  18586. import { Nullable } from "babylonjs/types";
  18587. import { Camera } from "babylonjs/Cameras/camera";
  18588. import { Scene } from "babylonjs/scene";
  18589. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18590. /**
  18591. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18592. * This is the base of the follow, arc rotate cameras and Free camera
  18593. * @see https://doc.babylonjs.com/features/cameras
  18594. */
  18595. export class TargetCamera extends Camera {
  18596. private static _RigCamTransformMatrix;
  18597. private static _TargetTransformMatrix;
  18598. private static _TargetFocalPoint;
  18599. private _tmpUpVector;
  18600. private _tmpTargetVector;
  18601. /**
  18602. * Define the current direction the camera is moving to
  18603. */
  18604. cameraDirection: Vector3;
  18605. /**
  18606. * Define the current rotation the camera is rotating to
  18607. */
  18608. cameraRotation: Vector2;
  18609. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18610. ignoreParentScaling: boolean;
  18611. /**
  18612. * When set, the up vector of the camera will be updated by the rotation of the camera
  18613. */
  18614. updateUpVectorFromRotation: boolean;
  18615. private _tmpQuaternion;
  18616. /**
  18617. * Define the current rotation of the camera
  18618. */
  18619. rotation: Vector3;
  18620. /**
  18621. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18622. */
  18623. rotationQuaternion: Quaternion;
  18624. /**
  18625. * Define the current speed of the camera
  18626. */
  18627. speed: number;
  18628. /**
  18629. * Add constraint to the camera to prevent it to move freely in all directions and
  18630. * around all axis.
  18631. */
  18632. noRotationConstraint: boolean;
  18633. /**
  18634. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18635. * panning
  18636. */
  18637. invertRotation: boolean;
  18638. /**
  18639. * Speed multiplier for inverse camera panning
  18640. */
  18641. inverseRotationSpeed: number;
  18642. /**
  18643. * Define the current target of the camera as an object or a position.
  18644. */
  18645. lockedTarget: any;
  18646. /** @hidden */
  18647. _currentTarget: Vector3;
  18648. /** @hidden */
  18649. _initialFocalDistance: number;
  18650. /** @hidden */
  18651. _viewMatrix: Matrix;
  18652. /** @hidden */
  18653. _camMatrix: Matrix;
  18654. /** @hidden */
  18655. _cameraTransformMatrix: Matrix;
  18656. /** @hidden */
  18657. _cameraRotationMatrix: Matrix;
  18658. /** @hidden */
  18659. _referencePoint: Vector3;
  18660. /** @hidden */
  18661. _transformedReferencePoint: Vector3;
  18662. /** @hidden */
  18663. _reset: () => void;
  18664. private _defaultUp;
  18665. /**
  18666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18667. * This is the base of the follow, arc rotate cameras and Free camera
  18668. * @see https://doc.babylonjs.com/features/cameras
  18669. * @param name Defines the name of the camera in the scene
  18670. * @param position Defines the start position of the camera in the scene
  18671. * @param scene Defines the scene the camera belongs to
  18672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18673. */
  18674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18675. /**
  18676. * Gets the position in front of the camera at a given distance.
  18677. * @param distance The distance from the camera we want the position to be
  18678. * @returns the position
  18679. */
  18680. getFrontPosition(distance: number): Vector3;
  18681. /** @hidden */
  18682. _getLockedTargetPosition(): Nullable<Vector3>;
  18683. private _storedPosition;
  18684. private _storedRotation;
  18685. private _storedRotationQuaternion;
  18686. /**
  18687. * Store current camera state of the camera (fov, position, rotation, etc..)
  18688. * @returns the camera
  18689. */
  18690. storeState(): Camera;
  18691. /**
  18692. * Restored camera state. You must call storeState() first
  18693. * @returns whether it was successful or not
  18694. * @hidden
  18695. */
  18696. _restoreStateValues(): boolean;
  18697. /** @hidden */
  18698. _initCache(): void;
  18699. /** @hidden */
  18700. _updateCache(ignoreParentClass?: boolean): void;
  18701. /** @hidden */
  18702. _isSynchronizedViewMatrix(): boolean;
  18703. /** @hidden */
  18704. _computeLocalCameraSpeed(): number;
  18705. /**
  18706. * Defines the target the camera should look at.
  18707. * @param target Defines the new target as a Vector or a mesh
  18708. */
  18709. setTarget(target: Vector3): void;
  18710. /**
  18711. * Return the current target position of the camera. This value is expressed in local space.
  18712. * @returns the target position
  18713. */
  18714. getTarget(): Vector3;
  18715. /** @hidden */
  18716. _decideIfNeedsToMove(): boolean;
  18717. /** @hidden */
  18718. _updatePosition(): void;
  18719. /** @hidden */
  18720. _checkInputs(): void;
  18721. protected _updateCameraRotationMatrix(): void;
  18722. /**
  18723. * 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)
  18724. * @returns the current camera
  18725. */
  18726. private _rotateUpVectorWithCameraRotationMatrix;
  18727. private _cachedRotationZ;
  18728. private _cachedQuaternionRotationZ;
  18729. /** @hidden */
  18730. _getViewMatrix(): Matrix;
  18731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18732. /**
  18733. * @hidden
  18734. */
  18735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18736. /**
  18737. * @hidden
  18738. */
  18739. _updateRigCameras(): void;
  18740. private _getRigCamPositionAndTarget;
  18741. /**
  18742. * Gets the current object class name.
  18743. * @return the class name
  18744. */
  18745. getClassName(): string;
  18746. }
  18747. }
  18748. declare module "babylonjs/Events/keyboardEvents" {
  18749. /**
  18750. * Gather the list of keyboard event types as constants.
  18751. */
  18752. export class KeyboardEventTypes {
  18753. /**
  18754. * The keydown event is fired when a key becomes active (pressed).
  18755. */
  18756. static readonly KEYDOWN: number;
  18757. /**
  18758. * The keyup event is fired when a key has been released.
  18759. */
  18760. static readonly KEYUP: number;
  18761. }
  18762. /**
  18763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18764. */
  18765. export class KeyboardInfo {
  18766. /**
  18767. * Defines the type of event (KeyboardEventTypes)
  18768. */
  18769. type: number;
  18770. /**
  18771. * Defines the related dom event
  18772. */
  18773. event: KeyboardEvent;
  18774. /**
  18775. * Instantiates a new keyboard info.
  18776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18777. * @param type Defines the type of event (KeyboardEventTypes)
  18778. * @param event Defines the related dom event
  18779. */
  18780. constructor(
  18781. /**
  18782. * Defines the type of event (KeyboardEventTypes)
  18783. */
  18784. type: number,
  18785. /**
  18786. * Defines the related dom event
  18787. */
  18788. event: KeyboardEvent);
  18789. }
  18790. /**
  18791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18793. */
  18794. export class KeyboardInfoPre extends KeyboardInfo {
  18795. /**
  18796. * Defines the type of event (KeyboardEventTypes)
  18797. */
  18798. type: number;
  18799. /**
  18800. * Defines the related dom event
  18801. */
  18802. event: KeyboardEvent;
  18803. /**
  18804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18805. */
  18806. skipOnPointerObservable: boolean;
  18807. /**
  18808. * Instantiates a new keyboard pre info.
  18809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18810. * @param type Defines the type of event (KeyboardEventTypes)
  18811. * @param event Defines the related dom event
  18812. */
  18813. constructor(
  18814. /**
  18815. * Defines the type of event (KeyboardEventTypes)
  18816. */
  18817. type: number,
  18818. /**
  18819. * Defines the related dom event
  18820. */
  18821. event: KeyboardEvent);
  18822. }
  18823. }
  18824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18825. import { Nullable } from "babylonjs/types";
  18826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18828. /**
  18829. * Manage the keyboard inputs to control the movement of a free camera.
  18830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18831. */
  18832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18833. /**
  18834. * Defines the camera the input is attached to.
  18835. */
  18836. camera: FreeCamera;
  18837. /**
  18838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18839. */
  18840. keysUp: number[];
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18843. */
  18844. keysUpward: number[];
  18845. /**
  18846. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18847. */
  18848. keysDown: number[];
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18851. */
  18852. keysDownward: number[];
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. keysLeft: number[];
  18857. /**
  18858. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18859. */
  18860. keysRight: number[];
  18861. private _keys;
  18862. private _onCanvasBlurObserver;
  18863. private _onKeyboardObserver;
  18864. private _engine;
  18865. private _scene;
  18866. /**
  18867. * Attach the input controls to a specific dom element to get the input from.
  18868. * @param element Defines the element the controls should be listened from
  18869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18870. */
  18871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18872. /**
  18873. * Detach the current controls from the specified dom element.
  18874. * @param element Defines the element to stop listening the inputs from
  18875. */
  18876. detachControl(element: Nullable<HTMLElement>): void;
  18877. /**
  18878. * Update the current camera state depending on the inputs that have been used this frame.
  18879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18880. */
  18881. checkInputs(): void;
  18882. /**
  18883. * Gets the class name of the current intput.
  18884. * @returns the class name
  18885. */
  18886. getClassName(): string;
  18887. /** @hidden */
  18888. _onLostFocus(): void;
  18889. /**
  18890. * Get the friendly name associated with the input class.
  18891. * @returns the input friendly name
  18892. */
  18893. getSimpleName(): string;
  18894. }
  18895. }
  18896. declare module "babylonjs/Events/pointerEvents" {
  18897. import { Nullable } from "babylonjs/types";
  18898. import { Vector2 } from "babylonjs/Maths/math.vector";
  18899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18900. import { Ray } from "babylonjs/Culling/ray";
  18901. /**
  18902. * Gather the list of pointer event types as constants.
  18903. */
  18904. export class PointerEventTypes {
  18905. /**
  18906. * 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.
  18907. */
  18908. static readonly POINTERDOWN: number;
  18909. /**
  18910. * The pointerup event is fired when a pointer is no longer active.
  18911. */
  18912. static readonly POINTERUP: number;
  18913. /**
  18914. * The pointermove event is fired when a pointer changes coordinates.
  18915. */
  18916. static readonly POINTERMOVE: number;
  18917. /**
  18918. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18919. */
  18920. static readonly POINTERWHEEL: number;
  18921. /**
  18922. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18923. */
  18924. static readonly POINTERPICK: number;
  18925. /**
  18926. * The pointertap event is fired when a the object has been touched and released without drag.
  18927. */
  18928. static readonly POINTERTAP: number;
  18929. /**
  18930. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18931. */
  18932. static readonly POINTERDOUBLETAP: number;
  18933. }
  18934. /**
  18935. * Base class of pointer info types.
  18936. */
  18937. export class PointerInfoBase {
  18938. /**
  18939. * Defines the type of event (PointerEventTypes)
  18940. */
  18941. type: number;
  18942. /**
  18943. * Defines the related dom event
  18944. */
  18945. event: PointerEvent | MouseWheelEvent;
  18946. /**
  18947. * Instantiates the base class of pointers info.
  18948. * @param type Defines the type of event (PointerEventTypes)
  18949. * @param event Defines the related dom event
  18950. */
  18951. constructor(
  18952. /**
  18953. * Defines the type of event (PointerEventTypes)
  18954. */
  18955. type: number,
  18956. /**
  18957. * Defines the related dom event
  18958. */
  18959. event: PointerEvent | MouseWheelEvent);
  18960. }
  18961. /**
  18962. * This class is used to store pointer related info for the onPrePointerObservable event.
  18963. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18964. */
  18965. export class PointerInfoPre extends PointerInfoBase {
  18966. /**
  18967. * Ray from a pointer if availible (eg. 6dof controller)
  18968. */
  18969. ray: Nullable<Ray>;
  18970. /**
  18971. * Defines the local position of the pointer on the canvas.
  18972. */
  18973. localPosition: Vector2;
  18974. /**
  18975. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18976. */
  18977. skipOnPointerObservable: boolean;
  18978. /**
  18979. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18980. * @param type Defines the type of event (PointerEventTypes)
  18981. * @param event Defines the related dom event
  18982. * @param localX Defines the local x coordinates of the pointer when the event occured
  18983. * @param localY Defines the local y coordinates of the pointer when the event occured
  18984. */
  18985. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18986. }
  18987. /**
  18988. * This type contains all the data related to a pointer event in Babylon.js.
  18989. * 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.
  18990. */
  18991. export class PointerInfo extends PointerInfoBase {
  18992. /**
  18993. * Defines the picking info associated to the info (if any)\
  18994. */
  18995. pickInfo: Nullable<PickingInfo>;
  18996. /**
  18997. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18998. * @param type Defines the type of event (PointerEventTypes)
  18999. * @param event Defines the related dom event
  19000. * @param pickInfo Defines the picking info associated to the info (if any)\
  19001. */
  19002. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19003. /**
  19004. * Defines the picking info associated to the info (if any)\
  19005. */
  19006. pickInfo: Nullable<PickingInfo>);
  19007. }
  19008. /**
  19009. * Data relating to a touch event on the screen.
  19010. */
  19011. export interface PointerTouch {
  19012. /**
  19013. * X coordinate of touch.
  19014. */
  19015. x: number;
  19016. /**
  19017. * Y coordinate of touch.
  19018. */
  19019. y: number;
  19020. /**
  19021. * Id of touch. Unique for each finger.
  19022. */
  19023. pointerId: number;
  19024. /**
  19025. * Event type passed from DOM.
  19026. */
  19027. type: any;
  19028. }
  19029. }
  19030. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19031. import { Observable } from "babylonjs/Misc/observable";
  19032. import { Nullable } from "babylonjs/types";
  19033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19034. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19035. /**
  19036. * Manage the mouse inputs to control the movement of a free camera.
  19037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19038. */
  19039. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19040. /**
  19041. * Define if touch is enabled in the mouse input
  19042. */
  19043. touchEnabled: boolean;
  19044. /**
  19045. * Defines the camera the input is attached to.
  19046. */
  19047. camera: FreeCamera;
  19048. /**
  19049. * Defines the buttons associated with the input to handle camera move.
  19050. */
  19051. buttons: number[];
  19052. /**
  19053. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19054. */
  19055. angularSensibility: number;
  19056. private _pointerInput;
  19057. private _onMouseMove;
  19058. private _observer;
  19059. private previousPosition;
  19060. /**
  19061. * Observable for when a pointer move event occurs containing the move offset
  19062. */
  19063. onPointerMovedObservable: Observable<{
  19064. offsetX: number;
  19065. offsetY: number;
  19066. }>;
  19067. /**
  19068. * @hidden
  19069. * If the camera should be rotated automatically based on pointer movement
  19070. */
  19071. _allowCameraRotation: boolean;
  19072. /**
  19073. * Manage the mouse inputs to control the movement of a free camera.
  19074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19075. * @param touchEnabled Defines if touch is enabled or not
  19076. */
  19077. constructor(
  19078. /**
  19079. * Define if touch is enabled in the mouse input
  19080. */
  19081. touchEnabled?: boolean);
  19082. /**
  19083. * Attach the input controls to a specific dom element to get the input from.
  19084. * @param element Defines the element the controls should be listened from
  19085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19086. */
  19087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19088. /**
  19089. * Called on JS contextmenu event.
  19090. * Override this method to provide functionality.
  19091. */
  19092. protected onContextMenu(evt: PointerEvent): void;
  19093. /**
  19094. * Detach the current controls from the specified dom element.
  19095. * @param element Defines the element to stop listening the inputs from
  19096. */
  19097. detachControl(element: Nullable<HTMLElement>): void;
  19098. /**
  19099. * Gets the class name of the current intput.
  19100. * @returns the class name
  19101. */
  19102. getClassName(): string;
  19103. /**
  19104. * Get the friendly name associated with the input class.
  19105. * @returns the input friendly name
  19106. */
  19107. getSimpleName(): string;
  19108. }
  19109. }
  19110. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19111. import { Nullable } from "babylonjs/types";
  19112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19114. /**
  19115. * Manage the touch inputs to control the movement of a free camera.
  19116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19117. */
  19118. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19119. /**
  19120. * Defines the camera the input is attached to.
  19121. */
  19122. camera: FreeCamera;
  19123. /**
  19124. * Defines the touch sensibility for rotation.
  19125. * The higher the faster.
  19126. */
  19127. touchAngularSensibility: number;
  19128. /**
  19129. * Defines the touch sensibility for move.
  19130. * The higher the faster.
  19131. */
  19132. touchMoveSensibility: number;
  19133. private _offsetX;
  19134. private _offsetY;
  19135. private _pointerPressed;
  19136. private _pointerInput;
  19137. private _observer;
  19138. private _onLostFocus;
  19139. /**
  19140. * Attach the input controls to a specific dom element to get the input from.
  19141. * @param element Defines the element the controls should be listened from
  19142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19143. */
  19144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19145. /**
  19146. * Detach the current controls from the specified dom element.
  19147. * @param element Defines the element to stop listening the inputs from
  19148. */
  19149. detachControl(element: Nullable<HTMLElement>): void;
  19150. /**
  19151. * Update the current camera state depending on the inputs that have been used this frame.
  19152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19153. */
  19154. checkInputs(): void;
  19155. /**
  19156. * Gets the class name of the current intput.
  19157. * @returns the class name
  19158. */
  19159. getClassName(): string;
  19160. /**
  19161. * Get the friendly name associated with the input class.
  19162. * @returns the input friendly name
  19163. */
  19164. getSimpleName(): string;
  19165. }
  19166. }
  19167. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19170. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19171. import { Nullable } from "babylonjs/types";
  19172. /**
  19173. * Default Inputs manager for the FreeCamera.
  19174. * It groups all the default supported inputs for ease of use.
  19175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19176. */
  19177. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19178. /**
  19179. * @hidden
  19180. */
  19181. _mouseInput: Nullable<FreeCameraMouseInput>;
  19182. /**
  19183. * Instantiates a new FreeCameraInputsManager.
  19184. * @param camera Defines the camera the inputs belong to
  19185. */
  19186. constructor(camera: FreeCamera);
  19187. /**
  19188. * Add keyboard input support to the input manager.
  19189. * @returns the current input manager
  19190. */
  19191. addKeyboard(): FreeCameraInputsManager;
  19192. /**
  19193. * Add mouse input support to the input manager.
  19194. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19195. * @returns the current input manager
  19196. */
  19197. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19198. /**
  19199. * Removes the mouse input support from the manager
  19200. * @returns the current input manager
  19201. */
  19202. removeMouse(): FreeCameraInputsManager;
  19203. /**
  19204. * Add touch input support to the input manager.
  19205. * @returns the current input manager
  19206. */
  19207. addTouch(): FreeCameraInputsManager;
  19208. /**
  19209. * Remove all attached input methods from a camera
  19210. */
  19211. clear(): void;
  19212. }
  19213. }
  19214. declare module "babylonjs/Cameras/freeCamera" {
  19215. import { Vector3 } from "babylonjs/Maths/math.vector";
  19216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19217. import { Scene } from "babylonjs/scene";
  19218. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19219. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19220. /**
  19221. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19222. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19223. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19224. */
  19225. export class FreeCamera extends TargetCamera {
  19226. /**
  19227. * Define the collision ellipsoid of the camera.
  19228. * This is helpful to simulate a camera body like the player body around the camera
  19229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19230. */
  19231. ellipsoid: Vector3;
  19232. /**
  19233. * Define an offset for the position of the ellipsoid around the camera.
  19234. * This can be helpful to determine the center of the body near the gravity center of the body
  19235. * instead of its head.
  19236. */
  19237. ellipsoidOffset: Vector3;
  19238. /**
  19239. * Enable or disable collisions of the camera with the rest of the scene objects.
  19240. */
  19241. checkCollisions: boolean;
  19242. /**
  19243. * Enable or disable gravity on the camera.
  19244. */
  19245. applyGravity: boolean;
  19246. /**
  19247. * Define the input manager associated to the camera.
  19248. */
  19249. inputs: FreeCameraInputsManager;
  19250. /**
  19251. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19252. * Higher values reduce sensitivity.
  19253. */
  19254. get angularSensibility(): number;
  19255. /**
  19256. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19257. * Higher values reduce sensitivity.
  19258. */
  19259. set angularSensibility(value: number);
  19260. /**
  19261. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19262. */
  19263. get keysUp(): number[];
  19264. set keysUp(value: number[]);
  19265. /**
  19266. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19267. */
  19268. get keysUpward(): number[];
  19269. set keysUpward(value: number[]);
  19270. /**
  19271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19272. */
  19273. get keysDown(): number[];
  19274. set keysDown(value: number[]);
  19275. /**
  19276. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19277. */
  19278. get keysDownward(): number[];
  19279. set keysDownward(value: number[]);
  19280. /**
  19281. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19282. */
  19283. get keysLeft(): number[];
  19284. set keysLeft(value: number[]);
  19285. /**
  19286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19287. */
  19288. get keysRight(): number[];
  19289. set keysRight(value: number[]);
  19290. /**
  19291. * Event raised when the camera collide with a mesh in the scene.
  19292. */
  19293. onCollide: (collidedMesh: AbstractMesh) => void;
  19294. private _collider;
  19295. private _needMoveForGravity;
  19296. private _oldPosition;
  19297. private _diffPosition;
  19298. private _newPosition;
  19299. /** @hidden */
  19300. _localDirection: Vector3;
  19301. /** @hidden */
  19302. _transformedDirection: Vector3;
  19303. /**
  19304. * Instantiates a Free Camera.
  19305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19307. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19308. * @param name Define the name of the camera in the scene
  19309. * @param position Define the start position of the camera in the scene
  19310. * @param scene Define the scene the camera belongs to
  19311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19312. */
  19313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19314. /**
  19315. * Attached controls to the current camera.
  19316. * @param element Defines the element the controls should be listened from
  19317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19318. */
  19319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19320. /**
  19321. * Detach the current controls from the camera.
  19322. * The camera will stop reacting to inputs.
  19323. * @param element Defines the element to stop listening the inputs from
  19324. */
  19325. detachControl(element: HTMLElement): void;
  19326. private _collisionMask;
  19327. /**
  19328. * Define a collision mask to limit the list of object the camera can collide with
  19329. */
  19330. get collisionMask(): number;
  19331. set collisionMask(mask: number);
  19332. /** @hidden */
  19333. _collideWithWorld(displacement: Vector3): void;
  19334. private _onCollisionPositionChange;
  19335. /** @hidden */
  19336. _checkInputs(): void;
  19337. /** @hidden */
  19338. _decideIfNeedsToMove(): boolean;
  19339. /** @hidden */
  19340. _updatePosition(): void;
  19341. /**
  19342. * Destroy the camera and release the current resources hold by it.
  19343. */
  19344. dispose(): void;
  19345. /**
  19346. * Gets the current object class name.
  19347. * @return the class name
  19348. */
  19349. getClassName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Gamepads/gamepad" {
  19353. import { Observable } from "babylonjs/Misc/observable";
  19354. /**
  19355. * Represents a gamepad control stick position
  19356. */
  19357. export class StickValues {
  19358. /**
  19359. * The x component of the control stick
  19360. */
  19361. x: number;
  19362. /**
  19363. * The y component of the control stick
  19364. */
  19365. y: number;
  19366. /**
  19367. * Initializes the gamepad x and y control stick values
  19368. * @param x The x component of the gamepad control stick value
  19369. * @param y The y component of the gamepad control stick value
  19370. */
  19371. constructor(
  19372. /**
  19373. * The x component of the control stick
  19374. */
  19375. x: number,
  19376. /**
  19377. * The y component of the control stick
  19378. */
  19379. y: number);
  19380. }
  19381. /**
  19382. * An interface which manages callbacks for gamepad button changes
  19383. */
  19384. export interface GamepadButtonChanges {
  19385. /**
  19386. * Called when a gamepad has been changed
  19387. */
  19388. changed: boolean;
  19389. /**
  19390. * Called when a gamepad press event has been triggered
  19391. */
  19392. pressChanged: boolean;
  19393. /**
  19394. * Called when a touch event has been triggered
  19395. */
  19396. touchChanged: boolean;
  19397. /**
  19398. * Called when a value has changed
  19399. */
  19400. valueChanged: boolean;
  19401. }
  19402. /**
  19403. * Represents a gamepad
  19404. */
  19405. export class Gamepad {
  19406. /**
  19407. * The id of the gamepad
  19408. */
  19409. id: string;
  19410. /**
  19411. * The index of the gamepad
  19412. */
  19413. index: number;
  19414. /**
  19415. * The browser gamepad
  19416. */
  19417. browserGamepad: any;
  19418. /**
  19419. * Specifies what type of gamepad this represents
  19420. */
  19421. type: number;
  19422. private _leftStick;
  19423. private _rightStick;
  19424. /** @hidden */
  19425. _isConnected: boolean;
  19426. private _leftStickAxisX;
  19427. private _leftStickAxisY;
  19428. private _rightStickAxisX;
  19429. private _rightStickAxisY;
  19430. /**
  19431. * Triggered when the left control stick has been changed
  19432. */
  19433. private _onleftstickchanged;
  19434. /**
  19435. * Triggered when the right control stick has been changed
  19436. */
  19437. private _onrightstickchanged;
  19438. /**
  19439. * Represents a gamepad controller
  19440. */
  19441. static GAMEPAD: number;
  19442. /**
  19443. * Represents a generic controller
  19444. */
  19445. static GENERIC: number;
  19446. /**
  19447. * Represents an XBox controller
  19448. */
  19449. static XBOX: number;
  19450. /**
  19451. * Represents a pose-enabled controller
  19452. */
  19453. static POSE_ENABLED: number;
  19454. /**
  19455. * Represents an Dual Shock controller
  19456. */
  19457. static DUALSHOCK: number;
  19458. /**
  19459. * Specifies whether the left control stick should be Y-inverted
  19460. */
  19461. protected _invertLeftStickY: boolean;
  19462. /**
  19463. * Specifies if the gamepad has been connected
  19464. */
  19465. get isConnected(): boolean;
  19466. /**
  19467. * Initializes the gamepad
  19468. * @param id The id of the gamepad
  19469. * @param index The index of the gamepad
  19470. * @param browserGamepad The browser gamepad
  19471. * @param leftStickX The x component of the left joystick
  19472. * @param leftStickY The y component of the left joystick
  19473. * @param rightStickX The x component of the right joystick
  19474. * @param rightStickY The y component of the right joystick
  19475. */
  19476. constructor(
  19477. /**
  19478. * The id of the gamepad
  19479. */
  19480. id: string,
  19481. /**
  19482. * The index of the gamepad
  19483. */
  19484. index: number,
  19485. /**
  19486. * The browser gamepad
  19487. */
  19488. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19489. /**
  19490. * Callback triggered when the left joystick has changed
  19491. * @param callback
  19492. */
  19493. onleftstickchanged(callback: (values: StickValues) => void): void;
  19494. /**
  19495. * Callback triggered when the right joystick has changed
  19496. * @param callback
  19497. */
  19498. onrightstickchanged(callback: (values: StickValues) => void): void;
  19499. /**
  19500. * Gets the left joystick
  19501. */
  19502. get leftStick(): StickValues;
  19503. /**
  19504. * Sets the left joystick values
  19505. */
  19506. set leftStick(newValues: StickValues);
  19507. /**
  19508. * Gets the right joystick
  19509. */
  19510. get rightStick(): StickValues;
  19511. /**
  19512. * Sets the right joystick value
  19513. */
  19514. set rightStick(newValues: StickValues);
  19515. /**
  19516. * Updates the gamepad joystick positions
  19517. */
  19518. update(): void;
  19519. /**
  19520. * Disposes the gamepad
  19521. */
  19522. dispose(): void;
  19523. }
  19524. /**
  19525. * Represents a generic gamepad
  19526. */
  19527. export class GenericPad extends Gamepad {
  19528. private _buttons;
  19529. private _onbuttondown;
  19530. private _onbuttonup;
  19531. /**
  19532. * Observable triggered when a button has been pressed
  19533. */
  19534. onButtonDownObservable: Observable<number>;
  19535. /**
  19536. * Observable triggered when a button has been released
  19537. */
  19538. onButtonUpObservable: Observable<number>;
  19539. /**
  19540. * Callback triggered when a button has been pressed
  19541. * @param callback Called when a button has been pressed
  19542. */
  19543. onbuttondown(callback: (buttonPressed: number) => void): void;
  19544. /**
  19545. * Callback triggered when a button has been released
  19546. * @param callback Called when a button has been released
  19547. */
  19548. onbuttonup(callback: (buttonReleased: number) => void): void;
  19549. /**
  19550. * Initializes the generic gamepad
  19551. * @param id The id of the generic gamepad
  19552. * @param index The index of the generic gamepad
  19553. * @param browserGamepad The browser gamepad
  19554. */
  19555. constructor(id: string, index: number, browserGamepad: any);
  19556. private _setButtonValue;
  19557. /**
  19558. * Updates the generic gamepad
  19559. */
  19560. update(): void;
  19561. /**
  19562. * Disposes the generic gamepad
  19563. */
  19564. dispose(): void;
  19565. }
  19566. }
  19567. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19568. import { Observable } from "babylonjs/Misc/observable";
  19569. import { Nullable } from "babylonjs/types";
  19570. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19573. import { Ray } from "babylonjs/Culling/ray";
  19574. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19575. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19576. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19577. /**
  19578. * Defines the types of pose enabled controllers that are supported
  19579. */
  19580. export enum PoseEnabledControllerType {
  19581. /**
  19582. * HTC Vive
  19583. */
  19584. VIVE = 0,
  19585. /**
  19586. * Oculus Rift
  19587. */
  19588. OCULUS = 1,
  19589. /**
  19590. * Windows mixed reality
  19591. */
  19592. WINDOWS = 2,
  19593. /**
  19594. * Samsung gear VR
  19595. */
  19596. GEAR_VR = 3,
  19597. /**
  19598. * Google Daydream
  19599. */
  19600. DAYDREAM = 4,
  19601. /**
  19602. * Generic
  19603. */
  19604. GENERIC = 5
  19605. }
  19606. /**
  19607. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19608. */
  19609. export interface MutableGamepadButton {
  19610. /**
  19611. * Value of the button/trigger
  19612. */
  19613. value: number;
  19614. /**
  19615. * If the button/trigger is currently touched
  19616. */
  19617. touched: boolean;
  19618. /**
  19619. * If the button/trigger is currently pressed
  19620. */
  19621. pressed: boolean;
  19622. }
  19623. /**
  19624. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19625. * @hidden
  19626. */
  19627. export interface ExtendedGamepadButton extends GamepadButton {
  19628. /**
  19629. * If the button/trigger is currently pressed
  19630. */
  19631. readonly pressed: boolean;
  19632. /**
  19633. * If the button/trigger is currently touched
  19634. */
  19635. readonly touched: boolean;
  19636. /**
  19637. * Value of the button/trigger
  19638. */
  19639. readonly value: number;
  19640. }
  19641. /** @hidden */
  19642. export interface _GamePadFactory {
  19643. /**
  19644. * Returns whether or not the current gamepad can be created for this type of controller.
  19645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19646. * @returns true if it can be created, otherwise false
  19647. */
  19648. canCreate(gamepadInfo: any): boolean;
  19649. /**
  19650. * Creates a new instance of the Gamepad.
  19651. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19652. * @returns the new gamepad instance
  19653. */
  19654. create(gamepadInfo: any): Gamepad;
  19655. }
  19656. /**
  19657. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19658. */
  19659. export class PoseEnabledControllerHelper {
  19660. /** @hidden */
  19661. static _ControllerFactories: _GamePadFactory[];
  19662. /** @hidden */
  19663. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19664. /**
  19665. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19666. * @param vrGamepad the gamepad to initialized
  19667. * @returns a vr controller of the type the gamepad identified as
  19668. */
  19669. static InitiateController(vrGamepad: any): Gamepad;
  19670. }
  19671. /**
  19672. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19673. */
  19674. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19675. /**
  19676. * If the controller is used in a webXR session
  19677. */
  19678. isXR: boolean;
  19679. private _deviceRoomPosition;
  19680. private _deviceRoomRotationQuaternion;
  19681. /**
  19682. * The device position in babylon space
  19683. */
  19684. devicePosition: Vector3;
  19685. /**
  19686. * The device rotation in babylon space
  19687. */
  19688. deviceRotationQuaternion: Quaternion;
  19689. /**
  19690. * The scale factor of the device in babylon space
  19691. */
  19692. deviceScaleFactor: number;
  19693. /**
  19694. * (Likely devicePosition should be used instead) The device position in its room space
  19695. */
  19696. position: Vector3;
  19697. /**
  19698. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19699. */
  19700. rotationQuaternion: Quaternion;
  19701. /**
  19702. * The type of controller (Eg. Windows mixed reality)
  19703. */
  19704. controllerType: PoseEnabledControllerType;
  19705. protected _calculatedPosition: Vector3;
  19706. private _calculatedRotation;
  19707. /**
  19708. * The raw pose from the device
  19709. */
  19710. rawPose: DevicePose;
  19711. private _trackPosition;
  19712. private _maxRotationDistFromHeadset;
  19713. private _draggedRoomRotation;
  19714. /**
  19715. * @hidden
  19716. */
  19717. _disableTrackPosition(fixedPosition: Vector3): void;
  19718. /**
  19719. * Internal, the mesh attached to the controller
  19720. * @hidden
  19721. */
  19722. _mesh: Nullable<AbstractMesh>;
  19723. private _poseControlledCamera;
  19724. private _leftHandSystemQuaternion;
  19725. /**
  19726. * Internal, matrix used to convert room space to babylon space
  19727. * @hidden
  19728. */
  19729. _deviceToWorld: Matrix;
  19730. /**
  19731. * Node to be used when casting a ray from the controller
  19732. * @hidden
  19733. */
  19734. _pointingPoseNode: Nullable<TransformNode>;
  19735. /**
  19736. * Name of the child mesh that can be used to cast a ray from the controller
  19737. */
  19738. static readonly POINTING_POSE: string;
  19739. /**
  19740. * Creates a new PoseEnabledController from a gamepad
  19741. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19742. */
  19743. constructor(browserGamepad: any);
  19744. private _workingMatrix;
  19745. /**
  19746. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Updates only the pose device and mesh without doing any button event checking
  19751. */
  19752. protected _updatePoseAndMesh(): void;
  19753. /**
  19754. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19755. * @param poseData raw pose fromthe device
  19756. */
  19757. updateFromDevice(poseData: DevicePose): void;
  19758. /**
  19759. * @hidden
  19760. */
  19761. _meshAttachedObservable: Observable<AbstractMesh>;
  19762. /**
  19763. * Attaches a mesh to the controller
  19764. * @param mesh the mesh to be attached
  19765. */
  19766. attachToMesh(mesh: AbstractMesh): void;
  19767. /**
  19768. * Attaches the controllers mesh to a camera
  19769. * @param camera the camera the mesh should be attached to
  19770. */
  19771. attachToPoseControlledCamera(camera: TargetCamera): void;
  19772. /**
  19773. * Disposes of the controller
  19774. */
  19775. dispose(): void;
  19776. /**
  19777. * The mesh that is attached to the controller
  19778. */
  19779. get mesh(): Nullable<AbstractMesh>;
  19780. /**
  19781. * Gets the ray of the controller in the direction the controller is pointing
  19782. * @param length the length the resulting ray should be
  19783. * @returns a ray in the direction the controller is pointing
  19784. */
  19785. getForwardRay(length?: number): Ray;
  19786. }
  19787. }
  19788. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19789. import { Observable } from "babylonjs/Misc/observable";
  19790. import { Scene } from "babylonjs/scene";
  19791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19792. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19793. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19794. import { Nullable } from "babylonjs/types";
  19795. /**
  19796. * Defines the WebVRController object that represents controllers tracked in 3D space
  19797. */
  19798. export abstract class WebVRController extends PoseEnabledController {
  19799. /**
  19800. * Internal, the default controller model for the controller
  19801. */
  19802. protected _defaultModel: Nullable<AbstractMesh>;
  19803. /**
  19804. * Fired when the trigger state has changed
  19805. */
  19806. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19807. /**
  19808. * Fired when the main button state has changed
  19809. */
  19810. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19811. /**
  19812. * Fired when the secondary button state has changed
  19813. */
  19814. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19815. /**
  19816. * Fired when the pad state has changed
  19817. */
  19818. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19819. /**
  19820. * Fired when controllers stick values have changed
  19821. */
  19822. onPadValuesChangedObservable: Observable<StickValues>;
  19823. /**
  19824. * Array of button availible on the controller
  19825. */
  19826. protected _buttons: Array<MutableGamepadButton>;
  19827. private _onButtonStateChange;
  19828. /**
  19829. * Fired when a controller button's state has changed
  19830. * @param callback the callback containing the button that was modified
  19831. */
  19832. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19833. /**
  19834. * X and Y axis corresponding to the controllers joystick
  19835. */
  19836. pad: StickValues;
  19837. /**
  19838. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19839. */
  19840. hand: string;
  19841. /**
  19842. * The default controller model for the controller
  19843. */
  19844. get defaultModel(): Nullable<AbstractMesh>;
  19845. /**
  19846. * Creates a new WebVRController from a gamepad
  19847. * @param vrGamepad the gamepad that the WebVRController should be created from
  19848. */
  19849. constructor(vrGamepad: any);
  19850. /**
  19851. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19852. */
  19853. update(): void;
  19854. /**
  19855. * Function to be called when a button is modified
  19856. */
  19857. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19858. /**
  19859. * Loads a mesh and attaches it to the controller
  19860. * @param scene the scene the mesh should be added to
  19861. * @param meshLoaded callback for when the mesh has been loaded
  19862. */
  19863. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19864. private _setButtonValue;
  19865. private _changes;
  19866. private _checkChanges;
  19867. /**
  19868. * Disposes of th webVRCOntroller
  19869. */
  19870. dispose(): void;
  19871. }
  19872. }
  19873. declare module "babylonjs/Lights/hemisphericLight" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19877. import { Color3 } from "babylonjs/Maths/math.color";
  19878. import { Effect } from "babylonjs/Materials/effect";
  19879. import { Light } from "babylonjs/Lights/light";
  19880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19881. /**
  19882. * The HemisphericLight simulates the ambient environment light,
  19883. * so the passed direction is the light reflection direction, not the incoming direction.
  19884. */
  19885. export class HemisphericLight extends Light {
  19886. /**
  19887. * The groundColor is the light in the opposite direction to the one specified during creation.
  19888. * 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.
  19889. */
  19890. groundColor: Color3;
  19891. /**
  19892. * The light reflection direction, not the incoming direction.
  19893. */
  19894. direction: Vector3;
  19895. /**
  19896. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19897. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19898. * The HemisphericLight can't cast shadows.
  19899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19900. * @param name The friendly name of the light
  19901. * @param direction The direction of the light reflection
  19902. * @param scene The scene the light belongs to
  19903. */
  19904. constructor(name: string, direction: Vector3, scene: Scene);
  19905. protected _buildUniformLayout(): void;
  19906. /**
  19907. * Returns the string "HemisphericLight".
  19908. * @return The class name
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19913. * Returns the updated direction.
  19914. * @param target The target the direction should point to
  19915. * @return The computed direction
  19916. */
  19917. setDirectionToTarget(target: Vector3): Vector3;
  19918. /**
  19919. * Returns the shadow generator associated to the light.
  19920. * @returns Always null for hemispheric lights because it does not support shadows.
  19921. */
  19922. getShadowGenerator(): Nullable<IShadowGenerator>;
  19923. /**
  19924. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19925. * @param effect The effect to update
  19926. * @param lightIndex The index of the light in the effect to update
  19927. * @returns The hemispheric light
  19928. */
  19929. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19931. /**
  19932. * Computes the world matrix of the node
  19933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19934. * @param useWasUpdatedFlag defines a reserved property
  19935. * @returns the world matrix
  19936. */
  19937. computeWorldMatrix(): Matrix;
  19938. /**
  19939. * Returns the integer 3.
  19940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19941. */
  19942. getTypeID(): number;
  19943. /**
  19944. * Prepares the list of defines specific to the light type.
  19945. * @param defines the list of defines
  19946. * @param lightIndex defines the index of the light for the effect
  19947. */
  19948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19949. }
  19950. }
  19951. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19952. /** @hidden */
  19953. export var vrMultiviewToSingleviewPixelShader: {
  19954. name: string;
  19955. shader: string;
  19956. };
  19957. }
  19958. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19960. import { Scene } from "babylonjs/scene";
  19961. /**
  19962. * Renders to multiple views with a single draw call
  19963. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19964. */
  19965. export class MultiviewRenderTarget extends RenderTargetTexture {
  19966. /**
  19967. * Creates a multiview render target
  19968. * @param scene scene used with the render target
  19969. * @param size the size of the render target (used for each view)
  19970. */
  19971. constructor(scene: Scene, size?: number | {
  19972. width: number;
  19973. height: number;
  19974. } | {
  19975. ratio: number;
  19976. });
  19977. /**
  19978. * @hidden
  19979. * @param faceIndex the face index, if its a cube texture
  19980. */
  19981. _bindFrameBuffer(faceIndex?: number): void;
  19982. /**
  19983. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19984. * @returns the view count
  19985. */
  19986. getViewCount(): number;
  19987. }
  19988. }
  19989. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19990. import { Camera } from "babylonjs/Cameras/camera";
  19991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19992. import { Nullable } from "babylonjs/types";
  19993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19994. import { Matrix } from "babylonjs/Maths/math.vector";
  19995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19996. module "babylonjs/Engines/engine" {
  19997. interface Engine {
  19998. /**
  19999. * Creates a new multiview render target
  20000. * @param width defines the width of the texture
  20001. * @param height defines the height of the texture
  20002. * @returns the created multiview texture
  20003. */
  20004. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20005. /**
  20006. * Binds a multiview framebuffer to be drawn to
  20007. * @param multiviewTexture texture to bind
  20008. */
  20009. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20010. }
  20011. }
  20012. module "babylonjs/Cameras/camera" {
  20013. interface Camera {
  20014. /**
  20015. * @hidden
  20016. * 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)
  20017. */
  20018. _useMultiviewToSingleView: boolean;
  20019. /**
  20020. * @hidden
  20021. * 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)
  20022. */
  20023. _multiviewTexture: Nullable<RenderTargetTexture>;
  20024. /**
  20025. * @hidden
  20026. * ensures the multiview texture of the camera exists and has the specified width/height
  20027. * @param width height to set on the multiview texture
  20028. * @param height width to set on the multiview texture
  20029. */
  20030. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20031. }
  20032. }
  20033. module "babylonjs/scene" {
  20034. interface Scene {
  20035. /** @hidden */
  20036. _transformMatrixR: Matrix;
  20037. /** @hidden */
  20038. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20039. /** @hidden */
  20040. _createMultiviewUbo(): void;
  20041. /** @hidden */
  20042. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20043. /** @hidden */
  20044. _renderMultiviewToSingleView(camera: Camera): void;
  20045. }
  20046. }
  20047. }
  20048. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20049. import { Camera } from "babylonjs/Cameras/camera";
  20050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20051. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20052. import "babylonjs/Engines/Extensions/engine.multiview";
  20053. /**
  20054. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20055. * This will not be used for webXR as it supports displaying texture arrays directly
  20056. */
  20057. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20058. /**
  20059. * Initializes a VRMultiviewToSingleview
  20060. * @param name name of the post process
  20061. * @param camera camera to be applied to
  20062. * @param scaleFactor scaling factor to the size of the output texture
  20063. */
  20064. constructor(name: string, camera: Camera, scaleFactor: number);
  20065. }
  20066. }
  20067. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20068. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20069. import { Nullable } from "babylonjs/types";
  20070. import { Size } from "babylonjs/Maths/math.size";
  20071. import { Observable } from "babylonjs/Misc/observable";
  20072. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20073. /**
  20074. * Interface used to define additional presentation attributes
  20075. */
  20076. export interface IVRPresentationAttributes {
  20077. /**
  20078. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20079. */
  20080. highRefreshRate: boolean;
  20081. /**
  20082. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20083. */
  20084. foveationLevel: number;
  20085. }
  20086. module "babylonjs/Engines/engine" {
  20087. interface Engine {
  20088. /** @hidden */
  20089. _vrDisplay: any;
  20090. /** @hidden */
  20091. _vrSupported: boolean;
  20092. /** @hidden */
  20093. _oldSize: Size;
  20094. /** @hidden */
  20095. _oldHardwareScaleFactor: number;
  20096. /** @hidden */
  20097. _vrExclusivePointerMode: boolean;
  20098. /** @hidden */
  20099. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20100. /** @hidden */
  20101. _onVRDisplayPointerRestricted: () => void;
  20102. /** @hidden */
  20103. _onVRDisplayPointerUnrestricted: () => void;
  20104. /** @hidden */
  20105. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20106. /** @hidden */
  20107. _onVrDisplayDisconnect: Nullable<() => void>;
  20108. /** @hidden */
  20109. _onVrDisplayPresentChange: Nullable<() => void>;
  20110. /**
  20111. * Observable signaled when VR display mode changes
  20112. */
  20113. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20114. /**
  20115. * Observable signaled when VR request present is complete
  20116. */
  20117. onVRRequestPresentComplete: Observable<boolean>;
  20118. /**
  20119. * Observable signaled when VR request present starts
  20120. */
  20121. onVRRequestPresentStart: Observable<Engine>;
  20122. /**
  20123. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20124. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20125. */
  20126. isInVRExclusivePointerMode: boolean;
  20127. /**
  20128. * Gets a boolean indicating if a webVR device was detected
  20129. * @returns true if a webVR device was detected
  20130. */
  20131. isVRDevicePresent(): boolean;
  20132. /**
  20133. * Gets the current webVR device
  20134. * @returns the current webVR device (or null)
  20135. */
  20136. getVRDevice(): any;
  20137. /**
  20138. * Initializes a webVR display and starts listening to display change events
  20139. * The onVRDisplayChangedObservable will be notified upon these changes
  20140. * @returns A promise containing a VRDisplay and if vr is supported
  20141. */
  20142. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20143. /** @hidden */
  20144. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20145. /**
  20146. * Gets or sets the presentation attributes used to configure VR rendering
  20147. */
  20148. vrPresentationAttributes?: IVRPresentationAttributes;
  20149. /**
  20150. * Call this function to switch to webVR mode
  20151. * Will do nothing if webVR is not supported or if there is no webVR device
  20152. * @param options the webvr options provided to the camera. mainly used for multiview
  20153. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20154. */
  20155. enableVR(options: WebVROptions): void;
  20156. /** @hidden */
  20157. _onVRFullScreenTriggered(): void;
  20158. }
  20159. }
  20160. }
  20161. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20162. import { Nullable } from "babylonjs/types";
  20163. import { Observable } from "babylonjs/Misc/observable";
  20164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20165. import { Scene } from "babylonjs/scene";
  20166. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20168. import { Node } from "babylonjs/node";
  20169. import { Ray } from "babylonjs/Culling/ray";
  20170. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20171. import "babylonjs/Engines/Extensions/engine.webVR";
  20172. /**
  20173. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20174. * IMPORTANT!! The data is right-hand data.
  20175. * @export
  20176. * @interface DevicePose
  20177. */
  20178. export interface DevicePose {
  20179. /**
  20180. * The position of the device, values in array are [x,y,z].
  20181. */
  20182. readonly position: Nullable<Float32Array>;
  20183. /**
  20184. * The linearVelocity of the device, values in array are [x,y,z].
  20185. */
  20186. readonly linearVelocity: Nullable<Float32Array>;
  20187. /**
  20188. * The linearAcceleration of the device, values in array are [x,y,z].
  20189. */
  20190. readonly linearAcceleration: Nullable<Float32Array>;
  20191. /**
  20192. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20193. */
  20194. readonly orientation: Nullable<Float32Array>;
  20195. /**
  20196. * The angularVelocity of the device, values in array are [x,y,z].
  20197. */
  20198. readonly angularVelocity: Nullable<Float32Array>;
  20199. /**
  20200. * The angularAcceleration of the device, values in array are [x,y,z].
  20201. */
  20202. readonly angularAcceleration: Nullable<Float32Array>;
  20203. }
  20204. /**
  20205. * Interface representing a pose controlled object in Babylon.
  20206. * A pose controlled object has both regular pose values as well as pose values
  20207. * from an external device such as a VR head mounted display
  20208. */
  20209. export interface PoseControlled {
  20210. /**
  20211. * The position of the object in babylon space.
  20212. */
  20213. position: Vector3;
  20214. /**
  20215. * The rotation quaternion of the object in babylon space.
  20216. */
  20217. rotationQuaternion: Quaternion;
  20218. /**
  20219. * The position of the device in babylon space.
  20220. */
  20221. devicePosition?: Vector3;
  20222. /**
  20223. * The rotation quaternion of the device in babylon space.
  20224. */
  20225. deviceRotationQuaternion: Quaternion;
  20226. /**
  20227. * The raw pose coming from the device.
  20228. */
  20229. rawPose: Nullable<DevicePose>;
  20230. /**
  20231. * The scale of the device to be used when translating from device space to babylon space.
  20232. */
  20233. deviceScaleFactor: number;
  20234. /**
  20235. * Updates the poseControlled values based on the input device pose.
  20236. * @param poseData the pose data to update the object with
  20237. */
  20238. updateFromDevice(poseData: DevicePose): void;
  20239. }
  20240. /**
  20241. * Set of options to customize the webVRCamera
  20242. */
  20243. export interface WebVROptions {
  20244. /**
  20245. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20246. */
  20247. trackPosition?: boolean;
  20248. /**
  20249. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20250. */
  20251. positionScale?: number;
  20252. /**
  20253. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20254. */
  20255. displayName?: string;
  20256. /**
  20257. * Should the native controller meshes be initialized. (default: true)
  20258. */
  20259. controllerMeshes?: boolean;
  20260. /**
  20261. * Creating a default HemiLight only on controllers. (default: true)
  20262. */
  20263. defaultLightingOnControllers?: boolean;
  20264. /**
  20265. * If you don't want to use the default VR button of the helper. (default: false)
  20266. */
  20267. useCustomVRButton?: boolean;
  20268. /**
  20269. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20270. */
  20271. customVRButton?: HTMLButtonElement;
  20272. /**
  20273. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20274. */
  20275. rayLength?: number;
  20276. /**
  20277. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20278. */
  20279. defaultHeight?: number;
  20280. /**
  20281. * If multiview should be used if availible (default: false)
  20282. */
  20283. useMultiview?: boolean;
  20284. }
  20285. /**
  20286. * This represents a WebVR camera.
  20287. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20288. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20289. */
  20290. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20291. private webVROptions;
  20292. /**
  20293. * @hidden
  20294. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20295. */
  20296. _vrDevice: any;
  20297. /**
  20298. * The rawPose of the vrDevice.
  20299. */
  20300. rawPose: Nullable<DevicePose>;
  20301. private _onVREnabled;
  20302. private _specsVersion;
  20303. private _attached;
  20304. private _frameData;
  20305. protected _descendants: Array<Node>;
  20306. private _deviceRoomPosition;
  20307. /** @hidden */
  20308. _deviceRoomRotationQuaternion: Quaternion;
  20309. private _standingMatrix;
  20310. /**
  20311. * Represents device position in babylon space.
  20312. */
  20313. devicePosition: Vector3;
  20314. /**
  20315. * Represents device rotation in babylon space.
  20316. */
  20317. deviceRotationQuaternion: Quaternion;
  20318. /**
  20319. * The scale of the device to be used when translating from device space to babylon space.
  20320. */
  20321. deviceScaleFactor: number;
  20322. private _deviceToWorld;
  20323. private _worldToDevice;
  20324. /**
  20325. * References to the webVR controllers for the vrDevice.
  20326. */
  20327. controllers: Array<WebVRController>;
  20328. /**
  20329. * Emits an event when a controller is attached.
  20330. */
  20331. onControllersAttachedObservable: Observable<WebVRController[]>;
  20332. /**
  20333. * Emits an event when a controller's mesh has been loaded;
  20334. */
  20335. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20336. /**
  20337. * Emits an event when the HMD's pose has been updated.
  20338. */
  20339. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20340. private _poseSet;
  20341. /**
  20342. * If the rig cameras be used as parent instead of this camera.
  20343. */
  20344. rigParenting: boolean;
  20345. private _lightOnControllers;
  20346. private _defaultHeight?;
  20347. /**
  20348. * Instantiates a WebVRFreeCamera.
  20349. * @param name The name of the WebVRFreeCamera
  20350. * @param position The starting anchor position for the camera
  20351. * @param scene The scene the camera belongs to
  20352. * @param webVROptions a set of customizable options for the webVRCamera
  20353. */
  20354. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20355. /**
  20356. * Gets the device distance from the ground in meters.
  20357. * @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.
  20358. */
  20359. deviceDistanceToRoomGround(): number;
  20360. /**
  20361. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20362. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20363. */
  20364. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20365. /**
  20366. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20367. * @returns A promise with a boolean set to if the standing matrix is supported.
  20368. */
  20369. useStandingMatrixAsync(): Promise<boolean>;
  20370. /**
  20371. * Disposes the camera
  20372. */
  20373. dispose(): void;
  20374. /**
  20375. * Gets a vrController by name.
  20376. * @param name The name of the controller to retreive
  20377. * @returns the controller matching the name specified or null if not found
  20378. */
  20379. getControllerByName(name: string): Nullable<WebVRController>;
  20380. private _leftController;
  20381. /**
  20382. * The controller corresponding to the users left hand.
  20383. */
  20384. get leftController(): Nullable<WebVRController>;
  20385. private _rightController;
  20386. /**
  20387. * The controller corresponding to the users right hand.
  20388. */
  20389. get rightController(): Nullable<WebVRController>;
  20390. /**
  20391. * Casts a ray forward from the vrCamera's gaze.
  20392. * @param length Length of the ray (default: 100)
  20393. * @returns the ray corresponding to the gaze
  20394. */
  20395. getForwardRay(length?: number): Ray;
  20396. /**
  20397. * @hidden
  20398. * Updates the camera based on device's frame data
  20399. */
  20400. _checkInputs(): void;
  20401. /**
  20402. * Updates the poseControlled values based on the input device pose.
  20403. * @param poseData Pose coming from the device
  20404. */
  20405. updateFromDevice(poseData: DevicePose): void;
  20406. private _htmlElementAttached;
  20407. private _detachIfAttached;
  20408. /**
  20409. * WebVR's attach control will start broadcasting frames to the device.
  20410. * Note that in certain browsers (chrome for example) this function must be called
  20411. * within a user-interaction callback. Example:
  20412. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20413. *
  20414. * @param element html element to attach the vrDevice to
  20415. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20416. */
  20417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20418. /**
  20419. * Detaches the camera from the html element and disables VR
  20420. *
  20421. * @param element html element to detach from
  20422. */
  20423. detachControl(element: HTMLElement): void;
  20424. /**
  20425. * @returns the name of this class
  20426. */
  20427. getClassName(): string;
  20428. /**
  20429. * Calls resetPose on the vrDisplay
  20430. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20431. */
  20432. resetToCurrentRotation(): void;
  20433. /**
  20434. * @hidden
  20435. * Updates the rig cameras (left and right eye)
  20436. */
  20437. _updateRigCameras(): void;
  20438. private _workingVector;
  20439. private _oneVector;
  20440. private _workingMatrix;
  20441. private updateCacheCalled;
  20442. private _correctPositionIfNotTrackPosition;
  20443. /**
  20444. * @hidden
  20445. * Updates the cached values of the camera
  20446. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20447. */
  20448. _updateCache(ignoreParentClass?: boolean): void;
  20449. /**
  20450. * @hidden
  20451. * Get current device position in babylon world
  20452. */
  20453. _computeDevicePosition(): void;
  20454. /**
  20455. * Updates the current device position and rotation in the babylon world
  20456. */
  20457. update(): void;
  20458. /**
  20459. * @hidden
  20460. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20461. * @returns an identity matrix
  20462. */
  20463. _getViewMatrix(): Matrix;
  20464. private _tmpMatrix;
  20465. /**
  20466. * This function is called by the two RIG cameras.
  20467. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20468. * @hidden
  20469. */
  20470. _getWebVRViewMatrix(): Matrix;
  20471. /** @hidden */
  20472. _getWebVRProjectionMatrix(): Matrix;
  20473. private _onGamepadConnectedObserver;
  20474. private _onGamepadDisconnectedObserver;
  20475. private _updateCacheWhenTrackingDisabledObserver;
  20476. /**
  20477. * Initializes the controllers and their meshes
  20478. */
  20479. initControllers(): void;
  20480. }
  20481. }
  20482. declare module "babylonjs/Materials/materialHelper" {
  20483. import { Nullable } from "babylonjs/types";
  20484. import { Scene } from "babylonjs/scene";
  20485. import { Engine } from "babylonjs/Engines/engine";
  20486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20487. import { Light } from "babylonjs/Lights/light";
  20488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20489. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20491. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20492. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20493. /**
  20494. * "Static Class" containing the most commonly used helper while dealing with material for
  20495. * rendering purpose.
  20496. *
  20497. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20498. *
  20499. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20500. */
  20501. export class MaterialHelper {
  20502. /**
  20503. * Bind the current view position to an effect.
  20504. * @param effect The effect to be bound
  20505. * @param scene The scene the eyes position is used from
  20506. * @param variableName name of the shader variable that will hold the eye position
  20507. */
  20508. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20509. /**
  20510. * Helps preparing the defines values about the UVs in used in the effect.
  20511. * UVs are shared as much as we can accross channels in the shaders.
  20512. * @param texture The texture we are preparing the UVs for
  20513. * @param defines The defines to update
  20514. * @param key The channel key "diffuse", "specular"... used in the shader
  20515. */
  20516. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20517. /**
  20518. * Binds a texture matrix value to its corrsponding uniform
  20519. * @param texture The texture to bind the matrix for
  20520. * @param uniformBuffer The uniform buffer receivin the data
  20521. * @param key The channel key "diffuse", "specular"... used in the shader
  20522. */
  20523. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20524. /**
  20525. * Gets the current status of the fog (should it be enabled?)
  20526. * @param mesh defines the mesh to evaluate for fog support
  20527. * @param scene defines the hosting scene
  20528. * @returns true if fog must be enabled
  20529. */
  20530. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20531. /**
  20532. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20533. * @param mesh defines the current mesh
  20534. * @param scene defines the current scene
  20535. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20536. * @param pointsCloud defines if point cloud rendering has to be turned on
  20537. * @param fogEnabled defines if fog has to be turned on
  20538. * @param alphaTest defines if alpha testing has to be turned on
  20539. * @param defines defines the current list of defines
  20540. */
  20541. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20542. /**
  20543. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20544. * @param scene defines the current scene
  20545. * @param engine defines the current engine
  20546. * @param defines specifies the list of active defines
  20547. * @param useInstances defines if instances have to be turned on
  20548. * @param useClipPlane defines if clip plane have to be turned on
  20549. * @param useInstances defines if instances have to be turned on
  20550. * @param useThinInstances defines if thin instances have to be turned on
  20551. */
  20552. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20553. /**
  20554. * Prepares the defines for bones
  20555. * @param mesh The mesh containing the geometry data we will draw
  20556. * @param defines The defines to update
  20557. */
  20558. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20559. /**
  20560. * Prepares the defines for morph targets
  20561. * @param mesh The mesh containing the geometry data we will draw
  20562. * @param defines The defines to update
  20563. */
  20564. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20565. /**
  20566. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20567. * @param mesh The mesh containing the geometry data we will draw
  20568. * @param defines The defines to update
  20569. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20570. * @param useBones Precise whether bones should be used or not (override mesh info)
  20571. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20572. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20573. * @returns false if defines are considered not dirty and have not been checked
  20574. */
  20575. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20576. /**
  20577. * Prepares the defines related to multiview
  20578. * @param scene The scene we are intending to draw
  20579. * @param defines The defines to update
  20580. */
  20581. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20582. /**
  20583. * Prepares the defines related to the prepass
  20584. * @param scene The scene we are intending to draw
  20585. * @param defines The defines to update
  20586. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20587. */
  20588. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20589. /**
  20590. * Prepares the defines related to the light information passed in parameter
  20591. * @param scene The scene we are intending to draw
  20592. * @param mesh The mesh the effect is compiling for
  20593. * @param light The light the effect is compiling for
  20594. * @param lightIndex The index of the light
  20595. * @param defines The defines to update
  20596. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20597. * @param state Defines the current state regarding what is needed (normals, etc...)
  20598. */
  20599. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20600. needNormals: boolean;
  20601. needRebuild: boolean;
  20602. shadowEnabled: boolean;
  20603. specularEnabled: boolean;
  20604. lightmapMode: boolean;
  20605. }): void;
  20606. /**
  20607. * Prepares the defines related to the light information passed in parameter
  20608. * @param scene The scene we are intending to draw
  20609. * @param mesh The mesh the effect is compiling for
  20610. * @param defines The defines to update
  20611. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20612. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20613. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20614. * @returns true if normals will be required for the rest of the effect
  20615. */
  20616. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20617. /**
  20618. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20619. * @param lightIndex defines the light index
  20620. * @param uniformsList The uniform list
  20621. * @param samplersList The sampler list
  20622. * @param projectedLightTexture defines if projected texture must be used
  20623. * @param uniformBuffersList defines an optional list of uniform buffers
  20624. */
  20625. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20626. /**
  20627. * Prepares the uniforms and samplers list to be used in the effect
  20628. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20629. * @param samplersList The sampler list
  20630. * @param defines The defines helping in the list generation
  20631. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20632. */
  20633. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20634. /**
  20635. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20636. * @param defines The defines to update while falling back
  20637. * @param fallbacks The authorized effect fallbacks
  20638. * @param maxSimultaneousLights The maximum number of lights allowed
  20639. * @param rank the current rank of the Effect
  20640. * @returns The newly affected rank
  20641. */
  20642. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20643. private static _TmpMorphInfluencers;
  20644. /**
  20645. * Prepares the list of attributes required for morph targets according to the effect defines.
  20646. * @param attribs The current list of supported attribs
  20647. * @param mesh The mesh to prepare the morph targets attributes for
  20648. * @param influencers The number of influencers
  20649. */
  20650. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20651. /**
  20652. * Prepares the list of attributes required for morph targets according to the effect defines.
  20653. * @param attribs The current list of supported attribs
  20654. * @param mesh The mesh to prepare the morph targets attributes for
  20655. * @param defines The current Defines of the effect
  20656. */
  20657. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20658. /**
  20659. * Prepares the list of attributes required for bones according to the effect defines.
  20660. * @param attribs The current list of supported attribs
  20661. * @param mesh The mesh to prepare the bones attributes for
  20662. * @param defines The current Defines of the effect
  20663. * @param fallbacks The current efffect fallback strategy
  20664. */
  20665. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20666. /**
  20667. * Check and prepare the list of attributes required for instances according to the effect defines.
  20668. * @param attribs The current list of supported attribs
  20669. * @param defines The current MaterialDefines of the effect
  20670. */
  20671. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20672. /**
  20673. * Add the list of attributes required for instances to the attribs array.
  20674. * @param attribs The current list of supported attribs
  20675. */
  20676. static PushAttributesForInstances(attribs: string[]): void;
  20677. /**
  20678. * Binds the light information to the effect.
  20679. * @param light The light containing the generator
  20680. * @param effect The effect we are binding the data to
  20681. * @param lightIndex The light index in the effect used to render
  20682. */
  20683. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20684. /**
  20685. * Binds the lights information from the scene to the effect for the given mesh.
  20686. * @param light Light to bind
  20687. * @param lightIndex Light index
  20688. * @param scene The scene where the light belongs to
  20689. * @param effect The effect we are binding the data to
  20690. * @param useSpecular Defines if specular is supported
  20691. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20692. */
  20693. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20694. /**
  20695. * Binds the lights information from the scene to the effect for the given mesh.
  20696. * @param scene The scene the lights belongs to
  20697. * @param mesh The mesh we are binding the information to render
  20698. * @param effect The effect we are binding the data to
  20699. * @param defines The generated defines for the effect
  20700. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20701. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20702. */
  20703. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20704. private static _tempFogColor;
  20705. /**
  20706. * Binds the fog information from the scene to the effect for the given mesh.
  20707. * @param scene The scene the lights belongs to
  20708. * @param mesh The mesh we are binding the information to render
  20709. * @param effect The effect we are binding the data to
  20710. * @param linearSpace Defines if the fog effect is applied in linear space
  20711. */
  20712. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20713. /**
  20714. * Binds the bones information from the mesh to the effect.
  20715. * @param mesh The mesh we are binding the information to render
  20716. * @param effect The effect we are binding the data to
  20717. */
  20718. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20719. /**
  20720. * Binds the morph targets information from the mesh to the effect.
  20721. * @param abstractMesh The mesh we are binding the information to render
  20722. * @param effect The effect we are binding the data to
  20723. */
  20724. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20725. /**
  20726. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20727. * @param defines The generated defines used in the effect
  20728. * @param effect The effect we are binding the data to
  20729. * @param scene The scene we are willing to render with logarithmic scale for
  20730. */
  20731. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20732. /**
  20733. * Binds the clip plane information from the scene to the effect.
  20734. * @param scene The scene the clip plane information are extracted from
  20735. * @param effect The effect we are binding the data to
  20736. */
  20737. static BindClipPlane(effect: Effect, scene: Scene): void;
  20738. }
  20739. }
  20740. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20742. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20743. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20744. import { Nullable } from "babylonjs/types";
  20745. import { Effect } from "babylonjs/Materials/effect";
  20746. import { Matrix } from "babylonjs/Maths/math.vector";
  20747. import { Scene } from "babylonjs/scene";
  20748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20750. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20751. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20752. import { Observable } from "babylonjs/Misc/observable";
  20753. /**
  20754. * Block used to expose an input value
  20755. */
  20756. export class InputBlock extends NodeMaterialBlock {
  20757. private _mode;
  20758. private _associatedVariableName;
  20759. private _storedValue;
  20760. private _valueCallback;
  20761. private _type;
  20762. private _animationType;
  20763. /** Gets or set a value used to limit the range of float values */
  20764. min: number;
  20765. /** Gets or set a value used to limit the range of float values */
  20766. max: number;
  20767. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20768. isBoolean: boolean;
  20769. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20770. matrixMode: number;
  20771. /** @hidden */
  20772. _systemValue: Nullable<NodeMaterialSystemValues>;
  20773. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20774. visibleInInspector: boolean;
  20775. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20776. isConstant: boolean;
  20777. /** Gets or sets the group to use to display this block in the Inspector */
  20778. groupInInspector: string;
  20779. /** Gets an observable raised when the value is changed */
  20780. onValueChangedObservable: Observable<InputBlock>;
  20781. /**
  20782. * Gets or sets the connection point type (default is float)
  20783. */
  20784. get type(): NodeMaterialBlockConnectionPointTypes;
  20785. /**
  20786. * Creates a new InputBlock
  20787. * @param name defines the block name
  20788. * @param target defines the target of that block (Vertex by default)
  20789. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20790. */
  20791. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20792. /**
  20793. * Gets the output component
  20794. */
  20795. get output(): NodeMaterialConnectionPoint;
  20796. /**
  20797. * Set the source of this connection point to a vertex attribute
  20798. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20799. * @returns the current connection point
  20800. */
  20801. setAsAttribute(attributeName?: string): InputBlock;
  20802. /**
  20803. * Set the source of this connection point to a system value
  20804. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20805. * @returns the current connection point
  20806. */
  20807. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20808. /**
  20809. * Gets or sets the value of that point.
  20810. * Please note that this value will be ignored if valueCallback is defined
  20811. */
  20812. get value(): any;
  20813. set value(value: any);
  20814. /**
  20815. * Gets or sets a callback used to get the value of that point.
  20816. * Please note that setting this value will force the connection point to ignore the value property
  20817. */
  20818. get valueCallback(): () => any;
  20819. set valueCallback(value: () => any);
  20820. /**
  20821. * Gets or sets the associated variable name in the shader
  20822. */
  20823. get associatedVariableName(): string;
  20824. set associatedVariableName(value: string);
  20825. /** Gets or sets the type of animation applied to the input */
  20826. get animationType(): AnimatedInputBlockTypes;
  20827. set animationType(value: AnimatedInputBlockTypes);
  20828. /**
  20829. * Gets a boolean indicating that this connection point not defined yet
  20830. */
  20831. get isUndefined(): boolean;
  20832. /**
  20833. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20834. * In this case the connection point name must be the name of the uniform to use.
  20835. * Can only be set on inputs
  20836. */
  20837. get isUniform(): boolean;
  20838. set isUniform(value: boolean);
  20839. /**
  20840. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20841. * In this case the connection point name must be the name of the attribute to use
  20842. * Can only be set on inputs
  20843. */
  20844. get isAttribute(): boolean;
  20845. set isAttribute(value: boolean);
  20846. /**
  20847. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20848. * Can only be set on exit points
  20849. */
  20850. get isVarying(): boolean;
  20851. set isVarying(value: boolean);
  20852. /**
  20853. * Gets a boolean indicating that the current connection point is a system value
  20854. */
  20855. get isSystemValue(): boolean;
  20856. /**
  20857. * Gets or sets the current well known value or null if not defined as a system value
  20858. */
  20859. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20860. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20861. /**
  20862. * Gets the current class name
  20863. * @returns the class name
  20864. */
  20865. getClassName(): string;
  20866. /**
  20867. * Animate the input if animationType !== None
  20868. * @param scene defines the rendering scene
  20869. */
  20870. animate(scene: Scene): void;
  20871. private _emitDefine;
  20872. initialize(state: NodeMaterialBuildState): void;
  20873. /**
  20874. * Set the input block to its default value (based on its type)
  20875. */
  20876. setDefaultValue(): void;
  20877. private _emitConstant;
  20878. /** @hidden */
  20879. get _noContextSwitch(): boolean;
  20880. private _emit;
  20881. /** @hidden */
  20882. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20883. /** @hidden */
  20884. _transmit(effect: Effect, scene: Scene): void;
  20885. protected _buildBlock(state: NodeMaterialBuildState): void;
  20886. protected _dumpPropertiesCode(): string;
  20887. dispose(): void;
  20888. serialize(): any;
  20889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20890. }
  20891. }
  20892. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20893. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20894. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20895. import { Nullable } from "babylonjs/types";
  20896. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20897. import { Observable } from "babylonjs/Misc/observable";
  20898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20899. /**
  20900. * Enum used to define the compatibility state between two connection points
  20901. */
  20902. export enum NodeMaterialConnectionPointCompatibilityStates {
  20903. /** Points are compatibles */
  20904. Compatible = 0,
  20905. /** Points are incompatible because of their types */
  20906. TypeIncompatible = 1,
  20907. /** Points are incompatible because of their targets (vertex vs fragment) */
  20908. TargetIncompatible = 2
  20909. }
  20910. /**
  20911. * Defines the direction of a connection point
  20912. */
  20913. export enum NodeMaterialConnectionPointDirection {
  20914. /** Input */
  20915. Input = 0,
  20916. /** Output */
  20917. Output = 1
  20918. }
  20919. /**
  20920. * Defines a connection point for a block
  20921. */
  20922. export class NodeMaterialConnectionPoint {
  20923. /** @hidden */
  20924. _ownerBlock: NodeMaterialBlock;
  20925. /** @hidden */
  20926. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20927. private _endpoints;
  20928. private _associatedVariableName;
  20929. private _direction;
  20930. /** @hidden */
  20931. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20932. /** @hidden */
  20933. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20934. private _type;
  20935. /** @hidden */
  20936. _enforceAssociatedVariableName: boolean;
  20937. /** Gets the direction of the point */
  20938. get direction(): NodeMaterialConnectionPointDirection;
  20939. /** Indicates that this connection point needs dual validation before being connected to another point */
  20940. needDualDirectionValidation: boolean;
  20941. /**
  20942. * Gets or sets the additional types supported by this connection point
  20943. */
  20944. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20945. /**
  20946. * Gets or sets the additional types excluded by this connection point
  20947. */
  20948. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20949. /**
  20950. * Observable triggered when this point is connected
  20951. */
  20952. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20953. /**
  20954. * Gets or sets the associated variable name in the shader
  20955. */
  20956. get associatedVariableName(): string;
  20957. set associatedVariableName(value: string);
  20958. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20959. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20960. /**
  20961. * Gets or sets the connection point type (default is float)
  20962. */
  20963. get type(): NodeMaterialBlockConnectionPointTypes;
  20964. set type(value: NodeMaterialBlockConnectionPointTypes);
  20965. /**
  20966. * Gets or sets the connection point name
  20967. */
  20968. name: string;
  20969. /**
  20970. * Gets or sets the connection point name
  20971. */
  20972. displayName: string;
  20973. /**
  20974. * Gets or sets a boolean indicating that this connection point can be omitted
  20975. */
  20976. isOptional: boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20979. */
  20980. isExposedOnFrame: boolean;
  20981. /**
  20982. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20983. */
  20984. define: string;
  20985. /** @hidden */
  20986. _prioritizeVertex: boolean;
  20987. private _target;
  20988. /** Gets or sets the target of that connection point */
  20989. get target(): NodeMaterialBlockTargets;
  20990. set target(value: NodeMaterialBlockTargets);
  20991. /**
  20992. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20993. */
  20994. get isConnected(): boolean;
  20995. /**
  20996. * Gets a boolean indicating that the current point is connected to an input block
  20997. */
  20998. get isConnectedToInputBlock(): boolean;
  20999. /**
  21000. * Gets a the connected input block (if any)
  21001. */
  21002. get connectInputBlock(): Nullable<InputBlock>;
  21003. /** Get the other side of the connection (if any) */
  21004. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21005. /** Get the block that owns this connection point */
  21006. get ownerBlock(): NodeMaterialBlock;
  21007. /** Get the block connected on the other side of this connection (if any) */
  21008. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21009. /** Get the block connected on the endpoints of this connection (if any) */
  21010. get connectedBlocks(): Array<NodeMaterialBlock>;
  21011. /** Gets the list of connected endpoints */
  21012. get endpoints(): NodeMaterialConnectionPoint[];
  21013. /** Gets a boolean indicating if that output point is connected to at least one input */
  21014. get hasEndpoints(): boolean;
  21015. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21016. get isConnectedInVertexShader(): boolean;
  21017. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21018. get isConnectedInFragmentShader(): boolean;
  21019. /**
  21020. * Creates a block suitable to be used as an input for this input point.
  21021. * If null is returned, a block based on the point type will be created.
  21022. * @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
  21023. */
  21024. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21025. /**
  21026. * Creates a new connection point
  21027. * @param name defines the connection point name
  21028. * @param ownerBlock defines the block hosting this connection point
  21029. * @param direction defines the direction of the connection point
  21030. */
  21031. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21032. /**
  21033. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21034. * @returns the class name
  21035. */
  21036. getClassName(): string;
  21037. /**
  21038. * Gets a boolean indicating if the current point can be connected to another point
  21039. * @param connectionPoint defines the other connection point
  21040. * @returns a boolean
  21041. */
  21042. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21043. /**
  21044. * Gets a number indicating if the current point can be connected to another point
  21045. * @param connectionPoint defines the other connection point
  21046. * @returns a number defining the compatibility state
  21047. */
  21048. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21049. /**
  21050. * Connect this point to another connection point
  21051. * @param connectionPoint defines the other connection point
  21052. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21053. * @returns the current connection point
  21054. */
  21055. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21056. /**
  21057. * Disconnect this point from one of his endpoint
  21058. * @param endpoint defines the other connection point
  21059. * @returns the current connection point
  21060. */
  21061. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21062. /**
  21063. * Serializes this point in a JSON representation
  21064. * @param isInput defines if the connection point is an input (default is true)
  21065. * @returns the serialized point object
  21066. */
  21067. serialize(isInput?: boolean): any;
  21068. /**
  21069. * Release resources
  21070. */
  21071. dispose(): void;
  21072. }
  21073. }
  21074. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21075. /**
  21076. * Enum used to define the material modes
  21077. */
  21078. export enum NodeMaterialModes {
  21079. /** Regular material */
  21080. Material = 0,
  21081. /** For post process */
  21082. PostProcess = 1,
  21083. /** For particle system */
  21084. Particle = 2
  21085. }
  21086. }
  21087. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21090. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21094. import { Effect } from "babylonjs/Materials/effect";
  21095. import { Mesh } from "babylonjs/Meshes/mesh";
  21096. import { Nullable } from "babylonjs/types";
  21097. import { Texture } from "babylonjs/Materials/Textures/texture";
  21098. import { Scene } from "babylonjs/scene";
  21099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21100. /**
  21101. * Block used to read a texture from a sampler
  21102. */
  21103. export class TextureBlock extends NodeMaterialBlock {
  21104. private _defineName;
  21105. private _linearDefineName;
  21106. private _gammaDefineName;
  21107. private _tempTextureRead;
  21108. private _samplerName;
  21109. private _transformedUVName;
  21110. private _textureTransformName;
  21111. private _textureInfoName;
  21112. private _mainUVName;
  21113. private _mainUVDefineName;
  21114. private _fragmentOnly;
  21115. /**
  21116. * Gets or sets the texture associated with the node
  21117. */
  21118. texture: Nullable<Texture>;
  21119. /**
  21120. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21121. */
  21122. convertToGammaSpace: boolean;
  21123. /**
  21124. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21125. */
  21126. convertToLinearSpace: boolean;
  21127. /**
  21128. * Create a new TextureBlock
  21129. * @param name defines the block name
  21130. */
  21131. constructor(name: string, fragmentOnly?: boolean);
  21132. /**
  21133. * Gets the current class name
  21134. * @returns the class name
  21135. */
  21136. getClassName(): string;
  21137. /**
  21138. * Gets the uv input component
  21139. */
  21140. get uv(): NodeMaterialConnectionPoint;
  21141. /**
  21142. * Gets the rgba output component
  21143. */
  21144. get rgba(): NodeMaterialConnectionPoint;
  21145. /**
  21146. * Gets the rgb output component
  21147. */
  21148. get rgb(): NodeMaterialConnectionPoint;
  21149. /**
  21150. * Gets the r output component
  21151. */
  21152. get r(): NodeMaterialConnectionPoint;
  21153. /**
  21154. * Gets the g output component
  21155. */
  21156. get g(): NodeMaterialConnectionPoint;
  21157. /**
  21158. * Gets the b output component
  21159. */
  21160. get b(): NodeMaterialConnectionPoint;
  21161. /**
  21162. * Gets the a output component
  21163. */
  21164. get a(): NodeMaterialConnectionPoint;
  21165. get target(): NodeMaterialBlockTargets;
  21166. autoConfigure(material: NodeMaterial): void;
  21167. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21169. isReady(): boolean;
  21170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21171. private get _isMixed();
  21172. private _injectVertexCode;
  21173. private _writeTextureRead;
  21174. private _writeOutput;
  21175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21176. protected _dumpPropertiesCode(): string;
  21177. serialize(): any;
  21178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21179. }
  21180. }
  21181. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21182. /** @hidden */
  21183. export var reflectionFunction: {
  21184. name: string;
  21185. shader: string;
  21186. };
  21187. }
  21188. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21195. import { Effect } from "babylonjs/Materials/effect";
  21196. import { Mesh } from "babylonjs/Meshes/mesh";
  21197. import { Nullable } from "babylonjs/types";
  21198. import { Scene } from "babylonjs/scene";
  21199. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21200. /**
  21201. * Base block used to read a reflection texture from a sampler
  21202. */
  21203. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21204. /** @hidden */
  21205. _define3DName: string;
  21206. /** @hidden */
  21207. _defineCubicName: string;
  21208. /** @hidden */
  21209. _defineExplicitName: string;
  21210. /** @hidden */
  21211. _defineProjectionName: string;
  21212. /** @hidden */
  21213. _defineLocalCubicName: string;
  21214. /** @hidden */
  21215. _defineSphericalName: string;
  21216. /** @hidden */
  21217. _definePlanarName: string;
  21218. /** @hidden */
  21219. _defineEquirectangularName: string;
  21220. /** @hidden */
  21221. _defineMirroredEquirectangularFixedName: string;
  21222. /** @hidden */
  21223. _defineEquirectangularFixedName: string;
  21224. /** @hidden */
  21225. _defineSkyboxName: string;
  21226. /** @hidden */
  21227. _defineOppositeZ: string;
  21228. /** @hidden */
  21229. _cubeSamplerName: string;
  21230. /** @hidden */
  21231. _2DSamplerName: string;
  21232. protected _positionUVWName: string;
  21233. protected _directionWName: string;
  21234. protected _reflectionVectorName: string;
  21235. /** @hidden */
  21236. _reflectionCoordsName: string;
  21237. /** @hidden */
  21238. _reflectionMatrixName: string;
  21239. protected _reflectionColorName: string;
  21240. /**
  21241. * Gets or sets the texture associated with the node
  21242. */
  21243. texture: Nullable<BaseTexture>;
  21244. /**
  21245. * Create a new ReflectionTextureBaseBlock
  21246. * @param name defines the block name
  21247. */
  21248. constructor(name: string);
  21249. /**
  21250. * Gets the current class name
  21251. * @returns the class name
  21252. */
  21253. getClassName(): string;
  21254. /**
  21255. * Gets the world position input component
  21256. */
  21257. abstract get position(): NodeMaterialConnectionPoint;
  21258. /**
  21259. * Gets the world position input component
  21260. */
  21261. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the world normal input component
  21264. */
  21265. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the world input component
  21268. */
  21269. abstract get world(): NodeMaterialConnectionPoint;
  21270. /**
  21271. * Gets the camera (or eye) position component
  21272. */
  21273. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the view input component
  21276. */
  21277. abstract get view(): NodeMaterialConnectionPoint;
  21278. protected _getTexture(): Nullable<BaseTexture>;
  21279. autoConfigure(material: NodeMaterial): void;
  21280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21281. isReady(): boolean;
  21282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21283. /**
  21284. * Gets the code to inject in the vertex shader
  21285. * @param state current state of the node material building
  21286. * @returns the shader code
  21287. */
  21288. handleVertexSide(state: NodeMaterialBuildState): string;
  21289. /**
  21290. * Handles the inits for the fragment code path
  21291. * @param state node material build state
  21292. */
  21293. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21294. /**
  21295. * Generates the reflection coords code for the fragment code path
  21296. * @param worldNormalVarName name of the world normal variable
  21297. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21298. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21299. * @returns the shader code
  21300. */
  21301. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21302. /**
  21303. * Generates the reflection color code for the fragment code path
  21304. * @param lodVarName name of the lod variable
  21305. * @param swizzleLookupTexture swizzle to use for the final color variable
  21306. * @returns the shader code
  21307. */
  21308. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21309. /**
  21310. * Generates the code corresponding to the connected output points
  21311. * @param state node material build state
  21312. * @param varName name of the variable to output
  21313. * @returns the shader code
  21314. */
  21315. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21316. protected _buildBlock(state: NodeMaterialBuildState): this;
  21317. protected _dumpPropertiesCode(): string;
  21318. serialize(): any;
  21319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21320. }
  21321. }
  21322. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21324. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21325. import { Nullable } from "babylonjs/types";
  21326. /**
  21327. * Defines a connection point to be used for points with a custom object type
  21328. */
  21329. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21330. private _blockType;
  21331. private _blockName;
  21332. private _nameForCheking?;
  21333. /**
  21334. * Creates a new connection point
  21335. * @param name defines the connection point name
  21336. * @param ownerBlock defines the block hosting this connection point
  21337. * @param direction defines the direction of the connection point
  21338. */
  21339. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21340. /**
  21341. * Gets a number indicating if the current point can be connected to another point
  21342. * @param connectionPoint defines the other connection point
  21343. * @returns a number defining the compatibility state
  21344. */
  21345. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21346. /**
  21347. * Creates a block suitable to be used as an input for this input point.
  21348. * If null is returned, a block based on the point type will be created.
  21349. * @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
  21350. */
  21351. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21352. }
  21353. }
  21354. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21355. /**
  21356. * Enum defining the type of properties that can be edited in the property pages in the NME
  21357. */
  21358. export enum PropertyTypeForEdition {
  21359. /** property is a boolean */
  21360. Boolean = 0,
  21361. /** property is a float */
  21362. Float = 1,
  21363. /** property is a Vector2 */
  21364. Vector2 = 2,
  21365. /** property is a list of values */
  21366. List = 3
  21367. }
  21368. /**
  21369. * Interface that defines an option in a variable of type list
  21370. */
  21371. export interface IEditablePropertyListOption {
  21372. /** label of the option */
  21373. "label": string;
  21374. /** value of the option */
  21375. "value": number;
  21376. }
  21377. /**
  21378. * Interface that defines the options available for an editable property
  21379. */
  21380. export interface IEditablePropertyOption {
  21381. /** min value */
  21382. "min"?: number;
  21383. /** max value */
  21384. "max"?: number;
  21385. /** notifiers: indicates which actions to take when the property is changed */
  21386. "notifiers"?: {
  21387. /** the material should be rebuilt */
  21388. "rebuild"?: boolean;
  21389. /** the preview should be updated */
  21390. "update"?: boolean;
  21391. };
  21392. /** list of the options for a variable of type list */
  21393. "options"?: IEditablePropertyListOption[];
  21394. }
  21395. /**
  21396. * Interface that describes an editable property
  21397. */
  21398. export interface IPropertyDescriptionForEdition {
  21399. /** name of the property */
  21400. "propertyName": string;
  21401. /** display name of the property */
  21402. "displayName": string;
  21403. /** type of the property */
  21404. "type": PropertyTypeForEdition;
  21405. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21406. "groupName": string;
  21407. /** options for the property */
  21408. "options": IEditablePropertyOption;
  21409. }
  21410. /**
  21411. * Decorator that flags a property in a node material block as being editable
  21412. */
  21413. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21414. }
  21415. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21418. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21420. import { Nullable } from "babylonjs/types";
  21421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21422. import { Mesh } from "babylonjs/Meshes/mesh";
  21423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21424. import { Effect } from "babylonjs/Materials/effect";
  21425. import { Scene } from "babylonjs/scene";
  21426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21427. /**
  21428. * Block used to implement the refraction part of the sub surface module of the PBR material
  21429. */
  21430. export class RefractionBlock extends NodeMaterialBlock {
  21431. /** @hidden */
  21432. _define3DName: string;
  21433. /** @hidden */
  21434. _refractionMatrixName: string;
  21435. /** @hidden */
  21436. _defineLODRefractionAlpha: string;
  21437. /** @hidden */
  21438. _defineLinearSpecularRefraction: string;
  21439. /** @hidden */
  21440. _defineOppositeZ: string;
  21441. /** @hidden */
  21442. _cubeSamplerName: string;
  21443. /** @hidden */
  21444. _2DSamplerName: string;
  21445. /** @hidden */
  21446. _vRefractionMicrosurfaceInfosName: string;
  21447. /** @hidden */
  21448. _vRefractionInfosName: string;
  21449. private _scene;
  21450. /**
  21451. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21452. * Materials half opaque for instance using refraction could benefit from this control.
  21453. */
  21454. linkRefractionWithTransparency: boolean;
  21455. /**
  21456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21457. */
  21458. invertRefractionY: boolean;
  21459. /**
  21460. * Gets or sets the texture associated with the node
  21461. */
  21462. texture: Nullable<BaseTexture>;
  21463. /**
  21464. * Create a new RefractionBlock
  21465. * @param name defines the block name
  21466. */
  21467. constructor(name: string);
  21468. /**
  21469. * Gets the current class name
  21470. * @returns the class name
  21471. */
  21472. getClassName(): string;
  21473. /**
  21474. * Gets the intensity input component
  21475. */
  21476. get intensity(): NodeMaterialConnectionPoint;
  21477. /**
  21478. * Gets the index of refraction input component
  21479. */
  21480. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21481. /**
  21482. * Gets the tint at distance input component
  21483. */
  21484. get tintAtDistance(): NodeMaterialConnectionPoint;
  21485. /**
  21486. * Gets the view input component
  21487. */
  21488. get view(): NodeMaterialConnectionPoint;
  21489. /**
  21490. * Gets the refraction object output component
  21491. */
  21492. get refraction(): NodeMaterialConnectionPoint;
  21493. /**
  21494. * Returns true if the block has a texture
  21495. */
  21496. get hasTexture(): boolean;
  21497. protected _getTexture(): Nullable<BaseTexture>;
  21498. autoConfigure(material: NodeMaterial): void;
  21499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21500. isReady(): boolean;
  21501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21502. /**
  21503. * Gets the main code of the block (fragment side)
  21504. * @param state current state of the node material building
  21505. * @returns the shader code
  21506. */
  21507. getCode(state: NodeMaterialBuildState): string;
  21508. protected _buildBlock(state: NodeMaterialBuildState): this;
  21509. protected _dumpPropertiesCode(): string;
  21510. serialize(): any;
  21511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21512. }
  21513. }
  21514. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21517. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21520. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21522. import { Nullable } from "babylonjs/types";
  21523. import { Scene } from "babylonjs/scene";
  21524. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21525. /**
  21526. * Base block used as input for post process
  21527. */
  21528. export class CurrentScreenBlock extends NodeMaterialBlock {
  21529. private _samplerName;
  21530. private _linearDefineName;
  21531. private _gammaDefineName;
  21532. private _mainUVName;
  21533. private _tempTextureRead;
  21534. /**
  21535. * Gets or sets the texture associated with the node
  21536. */
  21537. texture: Nullable<BaseTexture>;
  21538. /**
  21539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21540. */
  21541. convertToGammaSpace: boolean;
  21542. /**
  21543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21544. */
  21545. convertToLinearSpace: boolean;
  21546. /**
  21547. * Create a new CurrentScreenBlock
  21548. * @param name defines the block name
  21549. */
  21550. constructor(name: string);
  21551. /**
  21552. * Gets the current class name
  21553. * @returns the class name
  21554. */
  21555. getClassName(): string;
  21556. /**
  21557. * Gets the uv input component
  21558. */
  21559. get uv(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the rgba output component
  21562. */
  21563. get rgba(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the rgb output component
  21566. */
  21567. get rgb(): NodeMaterialConnectionPoint;
  21568. /**
  21569. * Gets the r output component
  21570. */
  21571. get r(): NodeMaterialConnectionPoint;
  21572. /**
  21573. * Gets the g output component
  21574. */
  21575. get g(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Gets the b output component
  21578. */
  21579. get b(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Gets the a output component
  21582. */
  21583. get a(): NodeMaterialConnectionPoint;
  21584. /**
  21585. * Initialize the block and prepare the context for build
  21586. * @param state defines the state that will be used for the build
  21587. */
  21588. initialize(state: NodeMaterialBuildState): void;
  21589. get target(): NodeMaterialBlockTargets;
  21590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21591. isReady(): boolean;
  21592. private _injectVertexCode;
  21593. private _writeTextureRead;
  21594. private _writeOutput;
  21595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21596. serialize(): any;
  21597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21598. }
  21599. }
  21600. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Nullable } from "babylonjs/types";
  21608. import { Scene } from "babylonjs/scene";
  21609. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21610. /**
  21611. * Base block used for the particle texture
  21612. */
  21613. export class ParticleTextureBlock extends NodeMaterialBlock {
  21614. private _samplerName;
  21615. private _linearDefineName;
  21616. private _gammaDefineName;
  21617. private _tempTextureRead;
  21618. /**
  21619. * Gets or sets the texture associated with the node
  21620. */
  21621. texture: Nullable<BaseTexture>;
  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 ParticleTextureBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string);
  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. /**
  21669. * Initialize the block and prepare the context for build
  21670. * @param state defines the state that will be used for the build
  21671. */
  21672. initialize(state: NodeMaterialBuildState): void;
  21673. autoConfigure(material: NodeMaterial): void;
  21674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21675. isReady(): boolean;
  21676. private _writeOutput;
  21677. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21678. serialize(): any;
  21679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21680. }
  21681. }
  21682. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21685. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21686. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21687. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21688. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21689. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21690. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21691. import { Scene } from "babylonjs/scene";
  21692. /**
  21693. * Class used to store shared data between 2 NodeMaterialBuildState
  21694. */
  21695. export class NodeMaterialBuildStateSharedData {
  21696. /**
  21697. * Gets the list of emitted varyings
  21698. */
  21699. temps: string[];
  21700. /**
  21701. * Gets the list of emitted varyings
  21702. */
  21703. varyings: string[];
  21704. /**
  21705. * Gets the varying declaration string
  21706. */
  21707. varyingDeclaration: string;
  21708. /**
  21709. * Input blocks
  21710. */
  21711. inputBlocks: InputBlock[];
  21712. /**
  21713. * Input blocks
  21714. */
  21715. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21716. /**
  21717. * Bindable blocks (Blocks that need to set data to the effect)
  21718. */
  21719. bindableBlocks: NodeMaterialBlock[];
  21720. /**
  21721. * List of blocks that can provide a compilation fallback
  21722. */
  21723. blocksWithFallbacks: NodeMaterialBlock[];
  21724. /**
  21725. * List of blocks that can provide a define update
  21726. */
  21727. blocksWithDefines: NodeMaterialBlock[];
  21728. /**
  21729. * List of blocks that can provide a repeatable content
  21730. */
  21731. repeatableContentBlocks: NodeMaterialBlock[];
  21732. /**
  21733. * List of blocks that can provide a dynamic list of uniforms
  21734. */
  21735. dynamicUniformBlocks: NodeMaterialBlock[];
  21736. /**
  21737. * List of blocks that can block the isReady function for the material
  21738. */
  21739. blockingBlocks: NodeMaterialBlock[];
  21740. /**
  21741. * Gets the list of animated inputs
  21742. */
  21743. animatedInputs: InputBlock[];
  21744. /**
  21745. * Build Id used to avoid multiple recompilations
  21746. */
  21747. buildId: number;
  21748. /** List of emitted variables */
  21749. variableNames: {
  21750. [key: string]: number;
  21751. };
  21752. /** List of emitted defines */
  21753. defineNames: {
  21754. [key: string]: number;
  21755. };
  21756. /** Should emit comments? */
  21757. emitComments: boolean;
  21758. /** Emit build activity */
  21759. verbose: boolean;
  21760. /** Gets or sets the hosting scene */
  21761. scene: Scene;
  21762. /**
  21763. * Gets the compilation hints emitted at compilation time
  21764. */
  21765. hints: {
  21766. needWorldViewMatrix: boolean;
  21767. needWorldViewProjectionMatrix: boolean;
  21768. needAlphaBlending: boolean;
  21769. needAlphaTesting: boolean;
  21770. };
  21771. /**
  21772. * List of compilation checks
  21773. */
  21774. checks: {
  21775. emitVertex: boolean;
  21776. emitFragment: boolean;
  21777. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21778. };
  21779. /**
  21780. * Is vertex program allowed to be empty?
  21781. */
  21782. allowEmptyVertexProgram: boolean;
  21783. /** Creates a new shared data */
  21784. constructor();
  21785. /**
  21786. * Emits console errors and exceptions if there is a failing check
  21787. */
  21788. emitErrors(): void;
  21789. }
  21790. }
  21791. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21792. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21793. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21794. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21795. /**
  21796. * Class used to store node based material build state
  21797. */
  21798. export class NodeMaterialBuildState {
  21799. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21800. supportUniformBuffers: boolean;
  21801. /**
  21802. * Gets the list of emitted attributes
  21803. */
  21804. attributes: string[];
  21805. /**
  21806. * Gets the list of emitted uniforms
  21807. */
  21808. uniforms: string[];
  21809. /**
  21810. * Gets the list of emitted constants
  21811. */
  21812. constants: string[];
  21813. /**
  21814. * Gets the list of emitted samplers
  21815. */
  21816. samplers: string[];
  21817. /**
  21818. * Gets the list of emitted functions
  21819. */
  21820. functions: {
  21821. [key: string]: string;
  21822. };
  21823. /**
  21824. * Gets the list of emitted extensions
  21825. */
  21826. extensions: {
  21827. [key: string]: string;
  21828. };
  21829. /**
  21830. * Gets the target of the compilation state
  21831. */
  21832. target: NodeMaterialBlockTargets;
  21833. /**
  21834. * Gets the list of emitted counters
  21835. */
  21836. counters: {
  21837. [key: string]: number;
  21838. };
  21839. /**
  21840. * Shared data between multiple NodeMaterialBuildState instances
  21841. */
  21842. sharedData: NodeMaterialBuildStateSharedData;
  21843. /** @hidden */
  21844. _vertexState: NodeMaterialBuildState;
  21845. /** @hidden */
  21846. _attributeDeclaration: string;
  21847. /** @hidden */
  21848. _uniformDeclaration: string;
  21849. /** @hidden */
  21850. _constantDeclaration: string;
  21851. /** @hidden */
  21852. _samplerDeclaration: string;
  21853. /** @hidden */
  21854. _varyingTransfer: string;
  21855. /** @hidden */
  21856. _injectAtEnd: string;
  21857. private _repeatableContentAnchorIndex;
  21858. /** @hidden */
  21859. _builtCompilationString: string;
  21860. /**
  21861. * Gets the emitted compilation strings
  21862. */
  21863. compilationString: string;
  21864. /**
  21865. * Finalize the compilation strings
  21866. * @param state defines the current compilation state
  21867. */
  21868. finalize(state: NodeMaterialBuildState): void;
  21869. /** @hidden */
  21870. get _repeatableContentAnchor(): string;
  21871. /** @hidden */
  21872. _getFreeVariableName(prefix: string): string;
  21873. /** @hidden */
  21874. _getFreeDefineName(prefix: string): string;
  21875. /** @hidden */
  21876. _excludeVariableName(name: string): void;
  21877. /** @hidden */
  21878. _emit2DSampler(name: string): void;
  21879. /** @hidden */
  21880. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21881. /** @hidden */
  21882. _emitExtension(name: string, extension: string, define?: string): void;
  21883. /** @hidden */
  21884. _emitFunction(name: string, code: string, comments: string): void;
  21885. /** @hidden */
  21886. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21887. replaceStrings?: {
  21888. search: RegExp;
  21889. replace: string;
  21890. }[];
  21891. repeatKey?: string;
  21892. }): string;
  21893. /** @hidden */
  21894. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21895. repeatKey?: string;
  21896. removeAttributes?: boolean;
  21897. removeUniforms?: boolean;
  21898. removeVaryings?: boolean;
  21899. removeIfDef?: boolean;
  21900. replaceStrings?: {
  21901. search: RegExp;
  21902. replace: string;
  21903. }[];
  21904. }, storeKey?: string): void;
  21905. /** @hidden */
  21906. _registerTempVariable(name: string): boolean;
  21907. /** @hidden */
  21908. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21909. /** @hidden */
  21910. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21911. /** @hidden */
  21912. _emitFloat(value: number): string;
  21913. }
  21914. }
  21915. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21916. /**
  21917. * Helper class used to generate session unique ID
  21918. */
  21919. export class UniqueIdGenerator {
  21920. private static _UniqueIdCounter;
  21921. /**
  21922. * Gets an unique (relatively to the current scene) Id
  21923. */
  21924. static get UniqueId(): number;
  21925. }
  21926. }
  21927. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21928. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21930. import { Nullable } from "babylonjs/types";
  21931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21932. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21933. import { Effect } from "babylonjs/Materials/effect";
  21934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21938. import { Scene } from "babylonjs/scene";
  21939. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21940. /**
  21941. * Defines a block that can be used inside a node based material
  21942. */
  21943. export class NodeMaterialBlock {
  21944. private _buildId;
  21945. private _buildTarget;
  21946. private _target;
  21947. private _isFinalMerger;
  21948. private _isInput;
  21949. protected _isUnique: boolean;
  21950. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21951. inputsAreExclusive: boolean;
  21952. /** @hidden */
  21953. _codeVariableName: string;
  21954. /** @hidden */
  21955. _inputs: NodeMaterialConnectionPoint[];
  21956. /** @hidden */
  21957. _outputs: NodeMaterialConnectionPoint[];
  21958. /** @hidden */
  21959. _preparationId: number;
  21960. /**
  21961. * Gets or sets the name of the block
  21962. */
  21963. name: string;
  21964. /**
  21965. * Gets or sets the unique id of the node
  21966. */
  21967. uniqueId: number;
  21968. /**
  21969. * Gets or sets the comments associated with this block
  21970. */
  21971. comments: string;
  21972. /**
  21973. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21974. */
  21975. get isUnique(): boolean;
  21976. /**
  21977. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21978. */
  21979. get isFinalMerger(): boolean;
  21980. /**
  21981. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21982. */
  21983. get isInput(): boolean;
  21984. /**
  21985. * Gets or sets the build Id
  21986. */
  21987. get buildId(): number;
  21988. set buildId(value: number);
  21989. /**
  21990. * Gets or sets the target of the block
  21991. */
  21992. get target(): NodeMaterialBlockTargets;
  21993. set target(value: NodeMaterialBlockTargets);
  21994. /**
  21995. * Gets the list of input points
  21996. */
  21997. get inputs(): NodeMaterialConnectionPoint[];
  21998. /** Gets the list of output points */
  21999. get outputs(): NodeMaterialConnectionPoint[];
  22000. /**
  22001. * Find an input by its name
  22002. * @param name defines the name of the input to look for
  22003. * @returns the input or null if not found
  22004. */
  22005. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22006. /**
  22007. * Find an output by its name
  22008. * @param name defines the name of the outputto look for
  22009. * @returns the output or null if not found
  22010. */
  22011. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22012. /**
  22013. * Creates a new NodeMaterialBlock
  22014. * @param name defines the block name
  22015. * @param target defines the target of that block (Vertex by default)
  22016. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22017. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22018. */
  22019. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22020. /**
  22021. * Initialize the block and prepare the context for build
  22022. * @param state defines the state that will be used for the build
  22023. */
  22024. initialize(state: NodeMaterialBuildState): void;
  22025. /**
  22026. * Bind data to effect. Will only be called for blocks with isBindable === true
  22027. * @param effect defines the effect to bind data to
  22028. * @param nodeMaterial defines the hosting NodeMaterial
  22029. * @param mesh defines the mesh that will be rendered
  22030. * @param subMesh defines the submesh that will be rendered
  22031. */
  22032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22033. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22034. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22035. protected _writeFloat(value: number): string;
  22036. /**
  22037. * Gets the current class name e.g. "NodeMaterialBlock"
  22038. * @returns the class name
  22039. */
  22040. getClassName(): string;
  22041. /**
  22042. * Register a new input. Must be called inside a block constructor
  22043. * @param name defines the connection point name
  22044. * @param type defines the connection point type
  22045. * @param isOptional defines a boolean indicating that this input can be omitted
  22046. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22047. * @param point an already created connection point. If not provided, create a new one
  22048. * @returns the current block
  22049. */
  22050. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22051. /**
  22052. * Register a new output. Must be called inside a block constructor
  22053. * @param name defines the connection point name
  22054. * @param type defines the connection point type
  22055. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22056. * @param point an already created connection point. If not provided, create a new one
  22057. * @returns the current block
  22058. */
  22059. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22060. /**
  22061. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22062. * @param forOutput defines an optional connection point to check compatibility with
  22063. * @returns the first available input or null
  22064. */
  22065. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22066. /**
  22067. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22068. * @param forBlock defines an optional block to check compatibility with
  22069. * @returns the first available input or null
  22070. */
  22071. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22072. /**
  22073. * Gets the sibling of the given output
  22074. * @param current defines the current output
  22075. * @returns the next output in the list or null
  22076. */
  22077. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22078. /**
  22079. * Connect current block with another block
  22080. * @param other defines the block to connect with
  22081. * @param options define the various options to help pick the right connections
  22082. * @returns the current block
  22083. */
  22084. connectTo(other: NodeMaterialBlock, options?: {
  22085. input?: string;
  22086. output?: string;
  22087. outputSwizzle?: string;
  22088. }): this | undefined;
  22089. protected _buildBlock(state: NodeMaterialBuildState): void;
  22090. /**
  22091. * Add uniforms, samplers and uniform buffers at compilation time
  22092. * @param state defines the state to update
  22093. * @param nodeMaterial defines the node material requesting the update
  22094. * @param defines defines the material defines to update
  22095. * @param uniformBuffers defines the list of uniform buffer names
  22096. */
  22097. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22098. /**
  22099. * Add potential fallbacks if shader compilation fails
  22100. * @param mesh defines the mesh to be rendered
  22101. * @param fallbacks defines the current prioritized list of fallbacks
  22102. */
  22103. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22104. /**
  22105. * Initialize defines for shader compilation
  22106. * @param mesh defines the mesh to be rendered
  22107. * @param nodeMaterial defines the node material requesting the update
  22108. * @param defines defines the material defines to update
  22109. * @param useInstances specifies that instances should be used
  22110. */
  22111. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22112. /**
  22113. * Update defines for shader compilation
  22114. * @param mesh defines the mesh to be rendered
  22115. * @param nodeMaterial defines the node material requesting the update
  22116. * @param defines defines the material defines to update
  22117. * @param useInstances specifies that instances should be used
  22118. * @param subMesh defines which submesh to render
  22119. */
  22120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22121. /**
  22122. * Lets the block try to connect some inputs automatically
  22123. * @param material defines the hosting NodeMaterial
  22124. */
  22125. autoConfigure(material: NodeMaterial): void;
  22126. /**
  22127. * Function called when a block is declared as repeatable content generator
  22128. * @param vertexShaderState defines the current compilation state for the vertex shader
  22129. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22130. * @param mesh defines the mesh to be rendered
  22131. * @param defines defines the material defines to update
  22132. */
  22133. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22134. /**
  22135. * Checks if the block is ready
  22136. * @param mesh defines the mesh to be rendered
  22137. * @param nodeMaterial defines the node material requesting the update
  22138. * @param defines defines the material defines to update
  22139. * @param useInstances specifies that instances should be used
  22140. * @returns true if the block is ready
  22141. */
  22142. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22143. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22144. private _processBuild;
  22145. /**
  22146. * Compile the current node and generate the shader code
  22147. * @param state defines the current compilation state (uniforms, samplers, current string)
  22148. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22149. * @returns true if already built
  22150. */
  22151. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22152. protected _inputRename(name: string): string;
  22153. protected _outputRename(name: string): string;
  22154. protected _dumpPropertiesCode(): string;
  22155. /** @hidden */
  22156. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22157. /** @hidden */
  22158. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22159. /**
  22160. * Clone the current block to a new identical block
  22161. * @param scene defines the hosting scene
  22162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22163. * @returns a copy of the current block
  22164. */
  22165. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22166. /**
  22167. * Serializes this block in a JSON representation
  22168. * @returns the serialized block object
  22169. */
  22170. serialize(): any;
  22171. /** @hidden */
  22172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22173. private _deserializePortDisplayNamesAndExposedOnFrame;
  22174. /**
  22175. * Release resources
  22176. */
  22177. dispose(): void;
  22178. }
  22179. }
  22180. declare module "babylonjs/Materials/pushMaterial" {
  22181. import { Nullable } from "babylonjs/types";
  22182. import { Scene } from "babylonjs/scene";
  22183. import { Matrix } from "babylonjs/Maths/math.vector";
  22184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22185. import { Mesh } from "babylonjs/Meshes/mesh";
  22186. import { Material } from "babylonjs/Materials/material";
  22187. import { Effect } from "babylonjs/Materials/effect";
  22188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22189. /**
  22190. * Base class of materials working in push mode in babylon JS
  22191. * @hidden
  22192. */
  22193. export class PushMaterial extends Material {
  22194. protected _activeEffect: Effect;
  22195. protected _normalMatrix: Matrix;
  22196. constructor(name: string, scene: Scene);
  22197. getEffect(): Effect;
  22198. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22199. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22200. /**
  22201. * Binds the given world matrix to the active effect
  22202. *
  22203. * @param world the matrix to bind
  22204. */
  22205. bindOnlyWorldMatrix(world: Matrix): void;
  22206. /**
  22207. * Binds the given normal matrix to the active effect
  22208. *
  22209. * @param normalMatrix the matrix to bind
  22210. */
  22211. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22212. bind(world: Matrix, mesh?: Mesh): void;
  22213. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22214. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22215. }
  22216. }
  22217. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22219. /**
  22220. * Root class for all node material optimizers
  22221. */
  22222. export class NodeMaterialOptimizer {
  22223. /**
  22224. * Function used to optimize a NodeMaterial graph
  22225. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22226. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22227. */
  22228. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22229. }
  22230. }
  22231. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22235. import { Scene } from "babylonjs/scene";
  22236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22239. /**
  22240. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22241. */
  22242. export class TransformBlock extends NodeMaterialBlock {
  22243. /**
  22244. * Defines the value to use to complement W value to transform it to a Vector4
  22245. */
  22246. complementW: number;
  22247. /**
  22248. * Defines the value to use to complement z value to transform it to a Vector4
  22249. */
  22250. complementZ: number;
  22251. /**
  22252. * Creates a new TransformBlock
  22253. * @param name defines the block name
  22254. */
  22255. constructor(name: string);
  22256. /**
  22257. * Gets the current class name
  22258. * @returns the class name
  22259. */
  22260. getClassName(): string;
  22261. /**
  22262. * Gets the vector input
  22263. */
  22264. get vector(): NodeMaterialConnectionPoint;
  22265. /**
  22266. * Gets the output component
  22267. */
  22268. get output(): NodeMaterialConnectionPoint;
  22269. /**
  22270. * Gets the xyz output component
  22271. */
  22272. get xyz(): NodeMaterialConnectionPoint;
  22273. /**
  22274. * Gets the matrix transform input
  22275. */
  22276. get transform(): NodeMaterialConnectionPoint;
  22277. protected _buildBlock(state: NodeMaterialBuildState): this;
  22278. /**
  22279. * Update defines for shader compilation
  22280. * @param mesh defines the mesh to be rendered
  22281. * @param nodeMaterial defines the node material requesting the update
  22282. * @param defines defines the material defines to update
  22283. * @param useInstances specifies that instances should be used
  22284. * @param subMesh defines which submesh to render
  22285. */
  22286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22287. serialize(): any;
  22288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22289. protected _dumpPropertiesCode(): string;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. /**
  22297. * Block used to output the vertex position
  22298. */
  22299. export class VertexOutputBlock extends NodeMaterialBlock {
  22300. /**
  22301. * Creates a new VertexOutputBlock
  22302. * @param name defines the block name
  22303. */
  22304. constructor(name: string);
  22305. /**
  22306. * Gets the current class name
  22307. * @returns the class name
  22308. */
  22309. getClassName(): string;
  22310. /**
  22311. * Gets the vector input component
  22312. */
  22313. get vector(): NodeMaterialConnectionPoint;
  22314. protected _buildBlock(state: NodeMaterialBuildState): this;
  22315. }
  22316. }
  22317. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22321. /**
  22322. * Block used to output the final color
  22323. */
  22324. export class FragmentOutputBlock extends NodeMaterialBlock {
  22325. /**
  22326. * Create a new FragmentOutputBlock
  22327. * @param name defines the block name
  22328. */
  22329. constructor(name: string);
  22330. /**
  22331. * Gets the current class name
  22332. * @returns the class name
  22333. */
  22334. getClassName(): string;
  22335. /**
  22336. * Gets the rgba input component
  22337. */
  22338. get rgba(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the rgb input component
  22341. */
  22342. get rgb(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the a input component
  22345. */
  22346. get a(): NodeMaterialConnectionPoint;
  22347. protected _buildBlock(state: NodeMaterialBuildState): this;
  22348. }
  22349. }
  22350. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22354. /**
  22355. * Block used for the particle ramp gradient section
  22356. */
  22357. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22358. /**
  22359. * Create a new ParticleRampGradientBlock
  22360. * @param name defines the block name
  22361. */
  22362. constructor(name: string);
  22363. /**
  22364. * Gets the current class name
  22365. * @returns the class name
  22366. */
  22367. getClassName(): string;
  22368. /**
  22369. * Gets the color input component
  22370. */
  22371. get color(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the rampColor output component
  22374. */
  22375. get rampColor(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Initialize the block and prepare the context for build
  22378. * @param state defines the state that will be used for the build
  22379. */
  22380. initialize(state: NodeMaterialBuildState): void;
  22381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22382. }
  22383. }
  22384. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22388. /**
  22389. * Block used for the particle blend multiply section
  22390. */
  22391. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22392. /**
  22393. * Create a new ParticleBlendMultiplyBlock
  22394. * @param name defines the block name
  22395. */
  22396. constructor(name: string);
  22397. /**
  22398. * Gets the current class name
  22399. * @returns the class name
  22400. */
  22401. getClassName(): string;
  22402. /**
  22403. * Gets the color input component
  22404. */
  22405. get color(): NodeMaterialConnectionPoint;
  22406. /**
  22407. * Gets the alphaTexture input component
  22408. */
  22409. get alphaTexture(): NodeMaterialConnectionPoint;
  22410. /**
  22411. * Gets the alphaColor input component
  22412. */
  22413. get alphaColor(): NodeMaterialConnectionPoint;
  22414. /**
  22415. * Gets the blendColor output component
  22416. */
  22417. get blendColor(): NodeMaterialConnectionPoint;
  22418. /**
  22419. * Initialize the block and prepare the context for build
  22420. * @param state defines the state that will be used for the build
  22421. */
  22422. initialize(state: NodeMaterialBuildState): void;
  22423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22424. }
  22425. }
  22426. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22430. /**
  22431. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22432. */
  22433. export class VectorMergerBlock extends NodeMaterialBlock {
  22434. /**
  22435. * Create a new VectorMergerBlock
  22436. * @param name defines the block name
  22437. */
  22438. constructor(name: string);
  22439. /**
  22440. * Gets the current class name
  22441. * @returns the class name
  22442. */
  22443. getClassName(): string;
  22444. /**
  22445. * Gets the xyz component (input)
  22446. */
  22447. get xyzIn(): NodeMaterialConnectionPoint;
  22448. /**
  22449. * Gets the xy component (input)
  22450. */
  22451. get xyIn(): NodeMaterialConnectionPoint;
  22452. /**
  22453. * Gets the x component (input)
  22454. */
  22455. get x(): NodeMaterialConnectionPoint;
  22456. /**
  22457. * Gets the y component (input)
  22458. */
  22459. get y(): NodeMaterialConnectionPoint;
  22460. /**
  22461. * Gets the z component (input)
  22462. */
  22463. get z(): NodeMaterialConnectionPoint;
  22464. /**
  22465. * Gets the w component (input)
  22466. */
  22467. get w(): NodeMaterialConnectionPoint;
  22468. /**
  22469. * Gets the xyzw component (output)
  22470. */
  22471. get xyzw(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the xyz component (output)
  22474. */
  22475. get xyzOut(): NodeMaterialConnectionPoint;
  22476. /**
  22477. * Gets the xy component (output)
  22478. */
  22479. get xyOut(): NodeMaterialConnectionPoint;
  22480. /**
  22481. * Gets the xy component (output)
  22482. * @deprecated Please use xyOut instead.
  22483. */
  22484. get xy(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyz component (output)
  22487. * @deprecated Please use xyzOut instead.
  22488. */
  22489. get xyz(): NodeMaterialConnectionPoint;
  22490. protected _buildBlock(state: NodeMaterialBuildState): this;
  22491. }
  22492. }
  22493. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22497. import { Vector2 } from "babylonjs/Maths/math.vector";
  22498. import { Scene } from "babylonjs/scene";
  22499. /**
  22500. * Block used to remap a float from a range to a new one
  22501. */
  22502. export class RemapBlock extends NodeMaterialBlock {
  22503. /**
  22504. * Gets or sets the source range
  22505. */
  22506. sourceRange: Vector2;
  22507. /**
  22508. * Gets or sets the target range
  22509. */
  22510. targetRange: Vector2;
  22511. /**
  22512. * Creates a new RemapBlock
  22513. * @param name defines the block name
  22514. */
  22515. constructor(name: string);
  22516. /**
  22517. * Gets the current class name
  22518. * @returns the class name
  22519. */
  22520. getClassName(): string;
  22521. /**
  22522. * Gets the input component
  22523. */
  22524. get input(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the source min input component
  22527. */
  22528. get sourceMin(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the source max input component
  22531. */
  22532. get sourceMax(): NodeMaterialConnectionPoint;
  22533. /**
  22534. * Gets the target min input component
  22535. */
  22536. get targetMin(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the target max input component
  22539. */
  22540. get targetMax(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the output component
  22543. */
  22544. get output(): NodeMaterialConnectionPoint;
  22545. protected _buildBlock(state: NodeMaterialBuildState): this;
  22546. protected _dumpPropertiesCode(): string;
  22547. serialize(): any;
  22548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22555. /**
  22556. * Block used to multiply 2 values
  22557. */
  22558. export class MultiplyBlock extends NodeMaterialBlock {
  22559. /**
  22560. * Creates a new MultiplyBlock
  22561. * @param name defines the block name
  22562. */
  22563. constructor(name: string);
  22564. /**
  22565. * Gets the current class name
  22566. * @returns the class name
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets the left operand input component
  22571. */
  22572. get left(): NodeMaterialConnectionPoint;
  22573. /**
  22574. * Gets the right operand input component
  22575. */
  22576. get right(): NodeMaterialConnectionPoint;
  22577. /**
  22578. * Gets the output component
  22579. */
  22580. get output(): NodeMaterialConnectionPoint;
  22581. protected _buildBlock(state: NodeMaterialBuildState): this;
  22582. }
  22583. }
  22584. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22588. /**
  22589. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22590. */
  22591. export class ColorSplitterBlock extends NodeMaterialBlock {
  22592. /**
  22593. * Create a new ColorSplitterBlock
  22594. * @param name defines the block name
  22595. */
  22596. constructor(name: string);
  22597. /**
  22598. * Gets the current class name
  22599. * @returns the class name
  22600. */
  22601. getClassName(): string;
  22602. /**
  22603. * Gets the rgba component (input)
  22604. */
  22605. get rgba(): NodeMaterialConnectionPoint;
  22606. /**
  22607. * Gets the rgb component (input)
  22608. */
  22609. get rgbIn(): NodeMaterialConnectionPoint;
  22610. /**
  22611. * Gets the rgb component (output)
  22612. */
  22613. get rgbOut(): NodeMaterialConnectionPoint;
  22614. /**
  22615. * Gets the r component (output)
  22616. */
  22617. get r(): NodeMaterialConnectionPoint;
  22618. /**
  22619. * Gets the g component (output)
  22620. */
  22621. get g(): NodeMaterialConnectionPoint;
  22622. /**
  22623. * Gets the b component (output)
  22624. */
  22625. get b(): NodeMaterialConnectionPoint;
  22626. /**
  22627. * Gets the a component (output)
  22628. */
  22629. get a(): NodeMaterialConnectionPoint;
  22630. protected _inputRename(name: string): string;
  22631. protected _outputRename(name: string): string;
  22632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22633. }
  22634. }
  22635. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22637. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22638. import { Scene } from "babylonjs/scene";
  22639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22640. import { Matrix } from "babylonjs/Maths/math.vector";
  22641. import { Mesh } from "babylonjs/Meshes/mesh";
  22642. import { Engine } from "babylonjs/Engines/engine";
  22643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22644. import { Observable } from "babylonjs/Misc/observable";
  22645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22646. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22647. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22648. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22649. import { Nullable } from "babylonjs/types";
  22650. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22651. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22652. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22653. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22654. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22655. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22656. import { Effect } from "babylonjs/Materials/effect";
  22657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22658. import { Camera } from "babylonjs/Cameras/camera";
  22659. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22660. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22661. /**
  22662. * Interface used to configure the node material editor
  22663. */
  22664. export interface INodeMaterialEditorOptions {
  22665. /** Define the URl to load node editor script */
  22666. editorURL?: string;
  22667. }
  22668. /** @hidden */
  22669. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22670. NORMAL: boolean;
  22671. TANGENT: boolean;
  22672. UV1: boolean;
  22673. /** BONES */
  22674. NUM_BONE_INFLUENCERS: number;
  22675. BonesPerMesh: number;
  22676. BONETEXTURE: boolean;
  22677. /** MORPH TARGETS */
  22678. MORPHTARGETS: boolean;
  22679. MORPHTARGETS_NORMAL: boolean;
  22680. MORPHTARGETS_TANGENT: boolean;
  22681. MORPHTARGETS_UV: boolean;
  22682. NUM_MORPH_INFLUENCERS: number;
  22683. /** IMAGE PROCESSING */
  22684. IMAGEPROCESSING: boolean;
  22685. VIGNETTE: boolean;
  22686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22687. VIGNETTEBLENDMODEOPAQUE: boolean;
  22688. TONEMAPPING: boolean;
  22689. TONEMAPPING_ACES: boolean;
  22690. CONTRAST: boolean;
  22691. EXPOSURE: boolean;
  22692. COLORCURVES: boolean;
  22693. COLORGRADING: boolean;
  22694. COLORGRADING3D: boolean;
  22695. SAMPLER3DGREENDEPTH: boolean;
  22696. SAMPLER3DBGRMAP: boolean;
  22697. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22698. /** MISC. */
  22699. BUMPDIRECTUV: number;
  22700. constructor();
  22701. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22702. }
  22703. /**
  22704. * Class used to configure NodeMaterial
  22705. */
  22706. export interface INodeMaterialOptions {
  22707. /**
  22708. * Defines if blocks should emit comments
  22709. */
  22710. emitComments: boolean;
  22711. }
  22712. /**
  22713. * Class used to create a node based material built by assembling shader blocks
  22714. */
  22715. export class NodeMaterial extends PushMaterial {
  22716. private static _BuildIdGenerator;
  22717. private _options;
  22718. private _vertexCompilationState;
  22719. private _fragmentCompilationState;
  22720. private _sharedData;
  22721. private _buildId;
  22722. private _buildWasSuccessful;
  22723. private _cachedWorldViewMatrix;
  22724. private _cachedWorldViewProjectionMatrix;
  22725. private _optimizers;
  22726. private _animationFrame;
  22727. /** Define the Url to load node editor script */
  22728. static EditorURL: string;
  22729. /** Define the Url to load snippets */
  22730. static SnippetUrl: string;
  22731. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22732. static IgnoreTexturesAtLoadTime: boolean;
  22733. private BJSNODEMATERIALEDITOR;
  22734. /** Get the inspector from bundle or global */
  22735. private _getGlobalNodeMaterialEditor;
  22736. /**
  22737. * Snippet ID if the material was created from the snippet server
  22738. */
  22739. snippetId: string;
  22740. /**
  22741. * Gets or sets data used by visual editor
  22742. * @see https://nme.babylonjs.com
  22743. */
  22744. editorData: any;
  22745. /**
  22746. * 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)
  22747. */
  22748. ignoreAlpha: boolean;
  22749. /**
  22750. * Defines the maximum number of lights that can be used in the material
  22751. */
  22752. maxSimultaneousLights: number;
  22753. /**
  22754. * Observable raised when the material is built
  22755. */
  22756. onBuildObservable: Observable<NodeMaterial>;
  22757. /**
  22758. * Gets or sets the root nodes of the material vertex shader
  22759. */
  22760. _vertexOutputNodes: NodeMaterialBlock[];
  22761. /**
  22762. * Gets or sets the root nodes of the material fragment (pixel) shader
  22763. */
  22764. _fragmentOutputNodes: NodeMaterialBlock[];
  22765. /** Gets or sets options to control the node material overall behavior */
  22766. get options(): INodeMaterialOptions;
  22767. set options(options: INodeMaterialOptions);
  22768. /**
  22769. * Default configuration related to image processing available in the standard Material.
  22770. */
  22771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22772. /**
  22773. * Gets the image processing configuration used either in this material.
  22774. */
  22775. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22776. /**
  22777. * Sets the Default image processing configuration used either in the this material.
  22778. *
  22779. * If sets to null, the scene one is in use.
  22780. */
  22781. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22782. /**
  22783. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22784. */
  22785. attachedBlocks: NodeMaterialBlock[];
  22786. /**
  22787. * Specifies the mode of the node material
  22788. * @hidden
  22789. */
  22790. _mode: NodeMaterialModes;
  22791. /**
  22792. * Gets the mode property
  22793. */
  22794. get mode(): NodeMaterialModes;
  22795. /**
  22796. * Create a new node based material
  22797. * @param name defines the material name
  22798. * @param scene defines the hosting scene
  22799. * @param options defines creation option
  22800. */
  22801. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22802. /**
  22803. * Gets the current class name of the material e.g. "NodeMaterial"
  22804. * @returns the class name
  22805. */
  22806. getClassName(): string;
  22807. /**
  22808. * Keep track of the image processing observer to allow dispose and replace.
  22809. */
  22810. private _imageProcessingObserver;
  22811. /**
  22812. * Attaches a new image processing configuration to the Standard Material.
  22813. * @param configuration
  22814. */
  22815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22816. /**
  22817. * Get a block by its name
  22818. * @param name defines the name of the block to retrieve
  22819. * @returns the required block or null if not found
  22820. */
  22821. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22822. /**
  22823. * Get a block by its name
  22824. * @param predicate defines the predicate used to find the good candidate
  22825. * @returns the required block or null if not found
  22826. */
  22827. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22828. /**
  22829. * Get an input block by its name
  22830. * @param predicate defines the predicate used to find the good candidate
  22831. * @returns the required input block or null if not found
  22832. */
  22833. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22834. /**
  22835. * Gets the list of input blocks attached to this material
  22836. * @returns an array of InputBlocks
  22837. */
  22838. getInputBlocks(): InputBlock[];
  22839. /**
  22840. * Adds a new optimizer to the list of optimizers
  22841. * @param optimizer defines the optimizers to add
  22842. * @returns the current material
  22843. */
  22844. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22845. /**
  22846. * Remove an optimizer from the list of optimizers
  22847. * @param optimizer defines the optimizers to remove
  22848. * @returns the current material
  22849. */
  22850. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22851. /**
  22852. * Add a new block to the list of output nodes
  22853. * @param node defines the node to add
  22854. * @returns the current material
  22855. */
  22856. addOutputNode(node: NodeMaterialBlock): this;
  22857. /**
  22858. * Remove a block from the list of root nodes
  22859. * @param node defines the node to remove
  22860. * @returns the current material
  22861. */
  22862. removeOutputNode(node: NodeMaterialBlock): this;
  22863. private _addVertexOutputNode;
  22864. private _removeVertexOutputNode;
  22865. private _addFragmentOutputNode;
  22866. private _removeFragmentOutputNode;
  22867. /**
  22868. * Specifies if the material will require alpha blending
  22869. * @returns a boolean specifying if alpha blending is needed
  22870. */
  22871. needAlphaBlending(): boolean;
  22872. /**
  22873. * Specifies if this material should be rendered in alpha test mode
  22874. * @returns a boolean specifying if an alpha test is needed.
  22875. */
  22876. needAlphaTesting(): boolean;
  22877. private _initializeBlock;
  22878. private _resetDualBlocks;
  22879. /**
  22880. * Remove a block from the current node material
  22881. * @param block defines the block to remove
  22882. */
  22883. removeBlock(block: NodeMaterialBlock): void;
  22884. /**
  22885. * Build the material and generates the inner effect
  22886. * @param verbose defines if the build should log activity
  22887. */
  22888. build(verbose?: boolean): void;
  22889. /**
  22890. * Runs an otpimization phase to try to improve the shader code
  22891. */
  22892. optimize(): void;
  22893. private _prepareDefinesForAttributes;
  22894. /**
  22895. * Create a post process from the material
  22896. * @param camera The camera to apply the render pass to.
  22897. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22899. * @param engine The engine which the post process will be applied. (default: current engine)
  22900. * @param reusable If the post process can be reused on the same frame. (default: false)
  22901. * @param textureType Type of textures used when performing the post process. (default: 0)
  22902. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22903. * @returns the post process created
  22904. */
  22905. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22906. /**
  22907. * Create the post process effect from the material
  22908. * @param postProcess The post process to create the effect for
  22909. */
  22910. createEffectForPostProcess(postProcess: PostProcess): void;
  22911. private _createEffectOrPostProcess;
  22912. private _createEffectForParticles;
  22913. /**
  22914. * Create the effect to be used as the custom effect for a particle system
  22915. * @param particleSystem Particle system to create the effect for
  22916. * @param onCompiled defines a function to call when the effect creation is successful
  22917. * @param onError defines a function to call when the effect creation has failed
  22918. */
  22919. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22920. private _processDefines;
  22921. /**
  22922. * Get if the submesh is ready to be used and all its information available.
  22923. * Child classes can use it to update shaders
  22924. * @param mesh defines the mesh to check
  22925. * @param subMesh defines which submesh to check
  22926. * @param useInstances specifies that instances should be used
  22927. * @returns a boolean indicating that the submesh is ready or not
  22928. */
  22929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22930. /**
  22931. * Get a string representing the shaders built by the current node graph
  22932. */
  22933. get compiledShaders(): string;
  22934. /**
  22935. * Binds the world matrix to the material
  22936. * @param world defines the world transformation matrix
  22937. */
  22938. bindOnlyWorldMatrix(world: Matrix): void;
  22939. /**
  22940. * Binds the submesh to this material by preparing the effect and shader to draw
  22941. * @param world defines the world transformation matrix
  22942. * @param mesh defines the mesh containing the submesh
  22943. * @param subMesh defines the submesh to bind the material to
  22944. */
  22945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22946. /**
  22947. * Gets the active textures from the material
  22948. * @returns an array of textures
  22949. */
  22950. getActiveTextures(): BaseTexture[];
  22951. /**
  22952. * Gets the list of texture blocks
  22953. * @returns an array of texture blocks
  22954. */
  22955. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22956. /**
  22957. * Specifies if the material uses a texture
  22958. * @param texture defines the texture to check against the material
  22959. * @returns a boolean specifying if the material uses the texture
  22960. */
  22961. hasTexture(texture: BaseTexture): boolean;
  22962. /**
  22963. * Disposes the material
  22964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22967. */
  22968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22969. /** Creates the node editor window. */
  22970. private _createNodeEditor;
  22971. /**
  22972. * Launch the node material editor
  22973. * @param config Define the configuration of the editor
  22974. * @return a promise fulfilled when the node editor is visible
  22975. */
  22976. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22977. /**
  22978. * Clear the current material
  22979. */
  22980. clear(): void;
  22981. /**
  22982. * Clear the current material and set it to a default state
  22983. */
  22984. setToDefault(): void;
  22985. /**
  22986. * Clear the current material and set it to a default state for post process
  22987. */
  22988. setToDefaultPostProcess(): void;
  22989. /**
  22990. * Clear the current material and set it to a default state for particle
  22991. */
  22992. setToDefaultParticle(): void;
  22993. /**
  22994. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22995. * @param url defines the url to load from
  22996. * @returns a promise that will fullfil when the material is fully loaded
  22997. */
  22998. loadAsync(url: string): Promise<void>;
  22999. private _gatherBlocks;
  23000. /**
  23001. * Generate a string containing the code declaration required to create an equivalent of this material
  23002. * @returns a string
  23003. */
  23004. generateCode(): string;
  23005. /**
  23006. * Serializes this material in a JSON representation
  23007. * @returns the serialized material object
  23008. */
  23009. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23010. private _restoreConnections;
  23011. /**
  23012. * Clear the current graph and load a new one from a serialization object
  23013. * @param source defines the JSON representation of the material
  23014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23015. * @param merge defines whether or not the source must be merged or replace the current content
  23016. */
  23017. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23018. /**
  23019. * Makes a duplicate of the current material.
  23020. * @param name - name to use for the new material.
  23021. */
  23022. clone(name: string): NodeMaterial;
  23023. /**
  23024. * Creates a node material from parsed material data
  23025. * @param source defines the JSON representation of the material
  23026. * @param scene defines the hosting scene
  23027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23028. * @returns a new node material
  23029. */
  23030. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23031. /**
  23032. * Creates a node material from a snippet saved in a remote file
  23033. * @param name defines the name of the material to create
  23034. * @param url defines the url to load from
  23035. * @param scene defines the hosting scene
  23036. * @returns a promise that will resolve to the new node material
  23037. */
  23038. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23039. /**
  23040. * Creates a node material from a snippet saved by the node material editor
  23041. * @param snippetId defines the snippet to load
  23042. * @param scene defines the hosting scene
  23043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23044. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23045. * @returns a promise that will resolve to the new node material
  23046. */
  23047. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23048. /**
  23049. * Creates a new node material set to default basic configuration
  23050. * @param name defines the name of the material
  23051. * @param scene defines the hosting scene
  23052. * @returns a new NodeMaterial
  23053. */
  23054. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23055. }
  23056. }
  23057. declare module "babylonjs/PostProcesses/postProcess" {
  23058. import { Nullable } from "babylonjs/types";
  23059. import { SmartArray } from "babylonjs/Misc/smartArray";
  23060. import { Observable } from "babylonjs/Misc/observable";
  23061. import { Vector2 } from "babylonjs/Maths/math.vector";
  23062. import { Camera } from "babylonjs/Cameras/camera";
  23063. import { Effect } from "babylonjs/Materials/effect";
  23064. import "babylonjs/Shaders/postprocess.vertex";
  23065. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23066. import { Engine } from "babylonjs/Engines/engine";
  23067. import { Color4 } from "babylonjs/Maths/math.color";
  23068. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23069. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23070. import { Scene } from "babylonjs/scene";
  23071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23072. /**
  23073. * Size options for a post process
  23074. */
  23075. export type PostProcessOptions = {
  23076. width: number;
  23077. height: number;
  23078. };
  23079. /**
  23080. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23081. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23082. */
  23083. export class PostProcess {
  23084. /** Name of the PostProcess. */
  23085. name: string;
  23086. /**
  23087. * Gets or sets the unique id of the post process
  23088. */
  23089. uniqueId: number;
  23090. /**
  23091. * Width of the texture to apply the post process on
  23092. */
  23093. width: number;
  23094. /**
  23095. * Height of the texture to apply the post process on
  23096. */
  23097. height: number;
  23098. /**
  23099. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23100. */
  23101. nodeMaterialSource: Nullable<NodeMaterial>;
  23102. /**
  23103. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23104. * @hidden
  23105. */
  23106. _outputTexture: Nullable<InternalTexture>;
  23107. /**
  23108. * Sampling mode used by the shader
  23109. * See https://doc.babylonjs.com/classes/3.1/texture
  23110. */
  23111. renderTargetSamplingMode: number;
  23112. /**
  23113. * Clear color to use when screen clearing
  23114. */
  23115. clearColor: Color4;
  23116. /**
  23117. * If the buffer needs to be cleared before applying the post process. (default: true)
  23118. * Should be set to false if shader will overwrite all previous pixels.
  23119. */
  23120. autoClear: boolean;
  23121. /**
  23122. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23123. */
  23124. alphaMode: number;
  23125. /**
  23126. * Sets the setAlphaBlendConstants of the babylon engine
  23127. */
  23128. alphaConstants: Color4;
  23129. /**
  23130. * Animations to be used for the post processing
  23131. */
  23132. animations: import("babylonjs/Animations/animation").Animation[];
  23133. /**
  23134. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23135. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23136. */
  23137. enablePixelPerfectMode: boolean;
  23138. /**
  23139. * Force the postprocess to be applied without taking in account viewport
  23140. */
  23141. forceFullscreenViewport: boolean;
  23142. /**
  23143. * List of inspectable custom properties (used by the Inspector)
  23144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23145. */
  23146. inspectableCustomProperties: IInspectable[];
  23147. /**
  23148. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23149. *
  23150. * | Value | Type | Description |
  23151. * | ----- | ----------------------------------- | ----------- |
  23152. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23153. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23154. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23155. *
  23156. */
  23157. scaleMode: number;
  23158. /**
  23159. * Force textures to be a power of two (default: false)
  23160. */
  23161. alwaysForcePOT: boolean;
  23162. private _samples;
  23163. /**
  23164. * Number of sample textures (default: 1)
  23165. */
  23166. get samples(): number;
  23167. set samples(n: number);
  23168. /**
  23169. * Modify the scale of the post process to be the same as the viewport (default: false)
  23170. */
  23171. adaptScaleToCurrentViewport: boolean;
  23172. private _camera;
  23173. protected _scene: Scene;
  23174. private _engine;
  23175. private _options;
  23176. private _reusable;
  23177. private _textureType;
  23178. private _textureFormat;
  23179. /**
  23180. * Smart array of input and output textures for the post process.
  23181. * @hidden
  23182. */
  23183. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23184. /**
  23185. * The index in _textures that corresponds to the output texture.
  23186. * @hidden
  23187. */
  23188. _currentRenderTextureInd: number;
  23189. private _effect;
  23190. private _samplers;
  23191. private _fragmentUrl;
  23192. private _vertexUrl;
  23193. private _parameters;
  23194. private _scaleRatio;
  23195. protected _indexParameters: any;
  23196. private _shareOutputWithPostProcess;
  23197. private _texelSize;
  23198. private _forcedOutputTexture;
  23199. /**
  23200. * Returns the fragment url or shader name used in the post process.
  23201. * @returns the fragment url or name in the shader store.
  23202. */
  23203. getEffectName(): string;
  23204. /**
  23205. * An event triggered when the postprocess is activated.
  23206. */
  23207. onActivateObservable: Observable<Camera>;
  23208. private _onActivateObserver;
  23209. /**
  23210. * A function that is added to the onActivateObservable
  23211. */
  23212. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23213. /**
  23214. * An event triggered when the postprocess changes its size.
  23215. */
  23216. onSizeChangedObservable: Observable<PostProcess>;
  23217. private _onSizeChangedObserver;
  23218. /**
  23219. * A function that is added to the onSizeChangedObservable
  23220. */
  23221. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23222. /**
  23223. * An event triggered when the postprocess applies its effect.
  23224. */
  23225. onApplyObservable: Observable<Effect>;
  23226. private _onApplyObserver;
  23227. /**
  23228. * A function that is added to the onApplyObservable
  23229. */
  23230. set onApply(callback: (effect: Effect) => void);
  23231. /**
  23232. * An event triggered before rendering the postprocess
  23233. */
  23234. onBeforeRenderObservable: Observable<Effect>;
  23235. private _onBeforeRenderObserver;
  23236. /**
  23237. * A function that is added to the onBeforeRenderObservable
  23238. */
  23239. set onBeforeRender(callback: (effect: Effect) => void);
  23240. /**
  23241. * An event triggered after rendering the postprocess
  23242. */
  23243. onAfterRenderObservable: Observable<Effect>;
  23244. private _onAfterRenderObserver;
  23245. /**
  23246. * A function that is added to the onAfterRenderObservable
  23247. */
  23248. set onAfterRender(callback: (efect: Effect) => void);
  23249. /**
  23250. * 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
  23251. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23252. */
  23253. get inputTexture(): InternalTexture;
  23254. set inputTexture(value: InternalTexture);
  23255. /**
  23256. * Gets the camera which post process is applied to.
  23257. * @returns The camera the post process is applied to.
  23258. */
  23259. getCamera(): Camera;
  23260. /**
  23261. * Gets the texel size of the postprocess.
  23262. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23263. */
  23264. get texelSize(): Vector2;
  23265. /**
  23266. * Creates a new instance PostProcess
  23267. * @param name The name of the PostProcess.
  23268. * @param fragmentUrl The url of the fragment shader to be used.
  23269. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23270. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23271. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23272. * @param camera The camera to apply the render pass to.
  23273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23274. * @param engine The engine which the post process will be applied. (default: current engine)
  23275. * @param reusable If the post process can be reused on the same frame. (default: false)
  23276. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23277. * @param textureType Type of textures used when performing the post process. (default: 0)
  23278. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23279. * @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
  23280. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23281. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23282. */
  23283. constructor(
  23284. /** Name of the PostProcess. */
  23285. 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);
  23286. /**
  23287. * Gets a string idenfifying the name of the class
  23288. * @returns "PostProcess" string
  23289. */
  23290. getClassName(): string;
  23291. /**
  23292. * Gets the engine which this post process belongs to.
  23293. * @returns The engine the post process was enabled with.
  23294. */
  23295. getEngine(): Engine;
  23296. /**
  23297. * The effect that is created when initializing the post process.
  23298. * @returns The created effect corresponding the the postprocess.
  23299. */
  23300. getEffect(): Effect;
  23301. /**
  23302. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23303. * @param postProcess The post process to share the output with.
  23304. * @returns This post process.
  23305. */
  23306. shareOutputWith(postProcess: PostProcess): PostProcess;
  23307. /**
  23308. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23309. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23310. */
  23311. useOwnOutput(): void;
  23312. /**
  23313. * Updates the effect with the current post process compile time values and recompiles the shader.
  23314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23317. * @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
  23318. * @param onCompiled Called when the shader has been compiled.
  23319. * @param onError Called if there is an error when compiling a shader.
  23320. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23321. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23322. */
  23323. 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;
  23324. /**
  23325. * The post process is reusable if it can be used multiple times within one frame.
  23326. * @returns If the post process is reusable
  23327. */
  23328. isReusable(): boolean;
  23329. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23330. markTextureDirty(): void;
  23331. /**
  23332. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23333. * 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.
  23334. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23335. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23336. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23337. * @returns The target texture that was bound to be written to.
  23338. */
  23339. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23340. /**
  23341. * If the post process is supported.
  23342. */
  23343. get isSupported(): boolean;
  23344. /**
  23345. * The aspect ratio of the output texture.
  23346. */
  23347. get aspectRatio(): number;
  23348. /**
  23349. * Get a value indicating if the post-process is ready to be used
  23350. * @returns true if the post-process is ready (shader is compiled)
  23351. */
  23352. isReady(): boolean;
  23353. /**
  23354. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23355. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23356. */
  23357. apply(): Nullable<Effect>;
  23358. private _disposeTextures;
  23359. /**
  23360. * Disposes the post process.
  23361. * @param camera The camera to dispose the post process on.
  23362. */
  23363. dispose(camera?: Camera): void;
  23364. }
  23365. }
  23366. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23367. /** @hidden */
  23368. export var kernelBlurVaryingDeclaration: {
  23369. name: string;
  23370. shader: string;
  23371. };
  23372. }
  23373. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23374. /** @hidden */
  23375. export var kernelBlurFragment: {
  23376. name: string;
  23377. shader: string;
  23378. };
  23379. }
  23380. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23381. /** @hidden */
  23382. export var kernelBlurFragment2: {
  23383. name: string;
  23384. shader: string;
  23385. };
  23386. }
  23387. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23388. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23389. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23390. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23391. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23392. /** @hidden */
  23393. export var kernelBlurPixelShader: {
  23394. name: string;
  23395. shader: string;
  23396. };
  23397. }
  23398. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23399. /** @hidden */
  23400. export var kernelBlurVertex: {
  23401. name: string;
  23402. shader: string;
  23403. };
  23404. }
  23405. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23406. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23407. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23408. /** @hidden */
  23409. export var kernelBlurVertexShader: {
  23410. name: string;
  23411. shader: string;
  23412. };
  23413. }
  23414. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23415. import { Vector2 } from "babylonjs/Maths/math.vector";
  23416. import { Nullable } from "babylonjs/types";
  23417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23418. import { Camera } from "babylonjs/Cameras/camera";
  23419. import { Effect } from "babylonjs/Materials/effect";
  23420. import { Engine } from "babylonjs/Engines/engine";
  23421. import "babylonjs/Shaders/kernelBlur.fragment";
  23422. import "babylonjs/Shaders/kernelBlur.vertex";
  23423. /**
  23424. * The Blur Post Process which blurs an image based on a kernel and direction.
  23425. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23426. */
  23427. export class BlurPostProcess extends PostProcess {
  23428. /** The direction in which to blur the image. */
  23429. direction: Vector2;
  23430. private blockCompilation;
  23431. protected _kernel: number;
  23432. protected _idealKernel: number;
  23433. protected _packedFloat: boolean;
  23434. private _staticDefines;
  23435. /**
  23436. * Sets the length in pixels of the blur sample region
  23437. */
  23438. set kernel(v: number);
  23439. /**
  23440. * Gets the length in pixels of the blur sample region
  23441. */
  23442. get kernel(): number;
  23443. /**
  23444. * Sets wether or not the blur needs to unpack/repack floats
  23445. */
  23446. set packedFloat(v: boolean);
  23447. /**
  23448. * Gets wether or not the blur is unpacking/repacking floats
  23449. */
  23450. get packedFloat(): boolean;
  23451. /**
  23452. * Creates a new instance BlurPostProcess
  23453. * @param name The name of the effect.
  23454. * @param direction The direction in which to blur the image.
  23455. * @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.
  23456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23457. * @param camera The camera to apply the render pass to.
  23458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23459. * @param engine The engine which the post process will be applied. (default: current engine)
  23460. * @param reusable If the post process can be reused on the same frame. (default: false)
  23461. * @param textureType Type of textures used when performing the post process. (default: 0)
  23462. * @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)
  23463. */
  23464. constructor(name: string,
  23465. /** The direction in which to blur the image. */
  23466. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23467. /**
  23468. * Updates the effect with the current post process compile time values and recompiles the shader.
  23469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23472. * @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
  23473. * @param onCompiled Called when the shader has been compiled.
  23474. * @param onError Called if there is an error when compiling a shader.
  23475. */
  23476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23477. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23478. /**
  23479. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23480. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23481. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23482. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23483. * The gaps between physical kernels are compensated for in the weighting of the samples
  23484. * @param idealKernel Ideal blur kernel.
  23485. * @return Nearest best kernel.
  23486. */
  23487. protected _nearestBestKernel(idealKernel: number): number;
  23488. /**
  23489. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23490. * @param x The point on the Gaussian distribution to sample.
  23491. * @return the value of the Gaussian function at x.
  23492. */
  23493. protected _gaussianWeight(x: number): number;
  23494. /**
  23495. * Generates a string that can be used as a floating point number in GLSL.
  23496. * @param x Value to print.
  23497. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23498. * @return GLSL float string.
  23499. */
  23500. protected _glslFloat(x: number, decimalFigures?: number): string;
  23501. }
  23502. }
  23503. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23504. import { Scene } from "babylonjs/scene";
  23505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23506. import { Plane } from "babylonjs/Maths/math.plane";
  23507. /**
  23508. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23509. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23510. * You can then easily use it as a reflectionTexture on a flat surface.
  23511. * In case the surface is not a plane, please consider relying on reflection probes.
  23512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23513. */
  23514. export class MirrorTexture extends RenderTargetTexture {
  23515. private scene;
  23516. /**
  23517. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23518. * 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.
  23519. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23520. */
  23521. mirrorPlane: Plane;
  23522. /**
  23523. * Define the blur ratio used to blur the reflection if needed.
  23524. */
  23525. set blurRatio(value: number);
  23526. get blurRatio(): number;
  23527. /**
  23528. * Define the adaptive blur kernel used to blur the reflection if needed.
  23529. * This will autocompute the closest best match for the `blurKernel`
  23530. */
  23531. set adaptiveBlurKernel(value: number);
  23532. /**
  23533. * Define the blur kernel used to blur the reflection if needed.
  23534. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23535. */
  23536. set blurKernel(value: number);
  23537. /**
  23538. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23539. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23540. */
  23541. set blurKernelX(value: number);
  23542. get blurKernelX(): number;
  23543. /**
  23544. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23546. */
  23547. set blurKernelY(value: number);
  23548. get blurKernelY(): number;
  23549. private _autoComputeBlurKernel;
  23550. protected _onRatioRescale(): void;
  23551. private _updateGammaSpace;
  23552. private _imageProcessingConfigChangeObserver;
  23553. private _transformMatrix;
  23554. private _mirrorMatrix;
  23555. private _savedViewMatrix;
  23556. private _blurX;
  23557. private _blurY;
  23558. private _adaptiveBlurKernel;
  23559. private _blurKernelX;
  23560. private _blurKernelY;
  23561. private _blurRatio;
  23562. /**
  23563. * Instantiates a Mirror Texture.
  23564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23566. * You can then easily use it as a reflectionTexture on a flat surface.
  23567. * In case the surface is not a plane, please consider relying on reflection probes.
  23568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23569. * @param name
  23570. * @param size
  23571. * @param scene
  23572. * @param generateMipMaps
  23573. * @param type
  23574. * @param samplingMode
  23575. * @param generateDepthBuffer
  23576. */
  23577. constructor(name: string, size: number | {
  23578. width: number;
  23579. height: number;
  23580. } | {
  23581. ratio: number;
  23582. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23583. private _preparePostProcesses;
  23584. /**
  23585. * Clone the mirror texture.
  23586. * @returns the cloned texture
  23587. */
  23588. clone(): MirrorTexture;
  23589. /**
  23590. * Serialize the texture to a JSON representation you could use in Parse later on
  23591. * @returns the serialized JSON representation
  23592. */
  23593. serialize(): any;
  23594. /**
  23595. * Dispose the texture and release its associated resources.
  23596. */
  23597. dispose(): void;
  23598. }
  23599. }
  23600. declare module "babylonjs/Materials/Textures/texture" {
  23601. import { Observable } from "babylonjs/Misc/observable";
  23602. import { Nullable } from "babylonjs/types";
  23603. import { Matrix } from "babylonjs/Maths/math.vector";
  23604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23605. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23606. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23607. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23608. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23610. import { Scene } from "babylonjs/scene";
  23611. /**
  23612. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23613. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23614. */
  23615. export class Texture extends BaseTexture {
  23616. /**
  23617. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23618. */
  23619. static SerializeBuffers: boolean;
  23620. /** @hidden */
  23621. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23622. /** @hidden */
  23623. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23624. /** @hidden */
  23625. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23626. /** nearest is mag = nearest and min = nearest and mip = linear */
  23627. static readonly NEAREST_SAMPLINGMODE: number;
  23628. /** nearest is mag = nearest and min = nearest and mip = linear */
  23629. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23631. static readonly BILINEAR_SAMPLINGMODE: number;
  23632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23633. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23634. /** Trilinear is mag = linear and min = linear and mip = linear */
  23635. static readonly TRILINEAR_SAMPLINGMODE: number;
  23636. /** Trilinear is mag = linear and min = linear and mip = linear */
  23637. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23638. /** mag = nearest and min = nearest and mip = nearest */
  23639. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23640. /** mag = nearest and min = linear and mip = nearest */
  23641. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23642. /** mag = nearest and min = linear and mip = linear */
  23643. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23644. /** mag = nearest and min = linear and mip = none */
  23645. static readonly NEAREST_LINEAR: number;
  23646. /** mag = nearest and min = nearest and mip = none */
  23647. static readonly NEAREST_NEAREST: number;
  23648. /** mag = linear and min = nearest and mip = nearest */
  23649. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23650. /** mag = linear and min = nearest and mip = linear */
  23651. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23652. /** mag = linear and min = linear and mip = none */
  23653. static readonly LINEAR_LINEAR: number;
  23654. /** mag = linear and min = nearest and mip = none */
  23655. static readonly LINEAR_NEAREST: number;
  23656. /** Explicit coordinates mode */
  23657. static readonly EXPLICIT_MODE: number;
  23658. /** Spherical coordinates mode */
  23659. static readonly SPHERICAL_MODE: number;
  23660. /** Planar coordinates mode */
  23661. static readonly PLANAR_MODE: number;
  23662. /** Cubic coordinates mode */
  23663. static readonly CUBIC_MODE: number;
  23664. /** Projection coordinates mode */
  23665. static readonly PROJECTION_MODE: number;
  23666. /** Inverse Cubic coordinates mode */
  23667. static readonly SKYBOX_MODE: number;
  23668. /** Inverse Cubic coordinates mode */
  23669. static readonly INVCUBIC_MODE: number;
  23670. /** Equirectangular coordinates mode */
  23671. static readonly EQUIRECTANGULAR_MODE: number;
  23672. /** Equirectangular Fixed coordinates mode */
  23673. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23674. /** Equirectangular Fixed Mirrored coordinates mode */
  23675. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23676. /** Texture is not repeating outside of 0..1 UVs */
  23677. static readonly CLAMP_ADDRESSMODE: number;
  23678. /** Texture is repeating outside of 0..1 UVs */
  23679. static readonly WRAP_ADDRESSMODE: number;
  23680. /** Texture is repeating and mirrored */
  23681. static readonly MIRROR_ADDRESSMODE: number;
  23682. /**
  23683. * 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
  23684. */
  23685. static UseSerializedUrlIfAny: boolean;
  23686. /**
  23687. * Define the url of the texture.
  23688. */
  23689. url: Nullable<string>;
  23690. /**
  23691. * Define an offset on the texture to offset the u coordinates of the UVs
  23692. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23693. */
  23694. uOffset: number;
  23695. /**
  23696. * Define an offset on the texture to offset the v coordinates of the UVs
  23697. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23698. */
  23699. vOffset: number;
  23700. /**
  23701. * Define an offset on the texture to scale the u coordinates of the UVs
  23702. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23703. */
  23704. uScale: number;
  23705. /**
  23706. * Define an offset on the texture to scale the v coordinates of the UVs
  23707. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23708. */
  23709. vScale: number;
  23710. /**
  23711. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23712. * @see https://doc.babylonjs.com/how_to/more_materials
  23713. */
  23714. uAng: number;
  23715. /**
  23716. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23717. * @see https://doc.babylonjs.com/how_to/more_materials
  23718. */
  23719. vAng: number;
  23720. /**
  23721. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23722. * @see https://doc.babylonjs.com/how_to/more_materials
  23723. */
  23724. wAng: number;
  23725. /**
  23726. * Defines the center of rotation (U)
  23727. */
  23728. uRotationCenter: number;
  23729. /**
  23730. * Defines the center of rotation (V)
  23731. */
  23732. vRotationCenter: number;
  23733. /**
  23734. * Defines the center of rotation (W)
  23735. */
  23736. wRotationCenter: number;
  23737. /**
  23738. * Are mip maps generated for this texture or not.
  23739. */
  23740. get noMipmap(): boolean;
  23741. /**
  23742. * List of inspectable custom properties (used by the Inspector)
  23743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23744. */
  23745. inspectableCustomProperties: Nullable<IInspectable[]>;
  23746. private _noMipmap;
  23747. /** @hidden */
  23748. _invertY: boolean;
  23749. private _rowGenerationMatrix;
  23750. private _cachedTextureMatrix;
  23751. private _projectionModeMatrix;
  23752. private _t0;
  23753. private _t1;
  23754. private _t2;
  23755. private _cachedUOffset;
  23756. private _cachedVOffset;
  23757. private _cachedUScale;
  23758. private _cachedVScale;
  23759. private _cachedUAng;
  23760. private _cachedVAng;
  23761. private _cachedWAng;
  23762. private _cachedProjectionMatrixId;
  23763. private _cachedCoordinatesMode;
  23764. /** @hidden */
  23765. protected _initialSamplingMode: number;
  23766. /** @hidden */
  23767. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23768. private _deleteBuffer;
  23769. protected _format: Nullable<number>;
  23770. private _delayedOnLoad;
  23771. private _delayedOnError;
  23772. private _mimeType?;
  23773. /**
  23774. * Observable triggered once the texture has been loaded.
  23775. */
  23776. onLoadObservable: Observable<Texture>;
  23777. protected _isBlocking: boolean;
  23778. /**
  23779. * Is the texture preventing material to render while loading.
  23780. * If false, a default texture will be used instead of the loading one during the preparation step.
  23781. */
  23782. set isBlocking(value: boolean);
  23783. get isBlocking(): boolean;
  23784. /**
  23785. * Get the current sampling mode associated with the texture.
  23786. */
  23787. get samplingMode(): number;
  23788. /**
  23789. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23790. */
  23791. get invertY(): boolean;
  23792. /**
  23793. * Instantiates a new texture.
  23794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23795. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23796. * @param url defines the url of the picture to load as a texture
  23797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23798. * @param noMipmap defines if the texture will require mip maps or not
  23799. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23800. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23801. * @param onLoad defines a callback triggered when the texture has been loaded
  23802. * @param onError defines a callback triggered when an error occurred during the loading session
  23803. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23804. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23805. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23806. * @param mimeType defines an optional mime type information
  23807. */
  23808. 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);
  23809. /**
  23810. * Update the url (and optional buffer) of this texture if url was null during construction.
  23811. * @param url the url of the texture
  23812. * @param buffer the buffer of the texture (defaults to null)
  23813. * @param onLoad callback called when the texture is loaded (defaults to null)
  23814. */
  23815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23816. /**
  23817. * Finish the loading sequence of a texture flagged as delayed load.
  23818. * @hidden
  23819. */
  23820. delayLoad(): void;
  23821. private _prepareRowForTextureGeneration;
  23822. /**
  23823. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23824. * @returns the transform matrix of the texture.
  23825. */
  23826. getTextureMatrix(uBase?: number): Matrix;
  23827. /**
  23828. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23829. * @returns The reflection texture transform
  23830. */
  23831. getReflectionTextureMatrix(): Matrix;
  23832. /**
  23833. * Clones the texture.
  23834. * @returns the cloned texture
  23835. */
  23836. clone(): Texture;
  23837. /**
  23838. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23839. * @returns The JSON representation of the texture
  23840. */
  23841. serialize(): any;
  23842. /**
  23843. * Get the current class name of the texture useful for serialization or dynamic coding.
  23844. * @returns "Texture"
  23845. */
  23846. getClassName(): string;
  23847. /**
  23848. * Dispose the texture and release its associated resources.
  23849. */
  23850. dispose(): void;
  23851. /**
  23852. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23853. * @param parsedTexture Define the JSON representation of the texture
  23854. * @param scene Define the scene the parsed texture should be instantiated in
  23855. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23856. * @returns The parsed texture if successful
  23857. */
  23858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23859. /**
  23860. * Creates a texture from its base 64 representation.
  23861. * @param data Define the base64 payload without the data: prefix
  23862. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23863. * @param scene Define the scene the texture should belong to
  23864. * @param noMipmap Forces the texture to not create mip map information if true
  23865. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23866. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23867. * @param onLoad define a callback triggered when the texture has been loaded
  23868. * @param onError define a callback triggered when an error occurred during the loading session
  23869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23870. * @returns the created texture
  23871. */
  23872. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23873. /**
  23874. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23875. * @param data Define the base64 payload without the data: prefix
  23876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23877. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23878. * @param scene Define the scene the texture should belong to
  23879. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23880. * @param noMipmap Forces the texture to not create mip map information if true
  23881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23883. * @param onLoad define a callback triggered when the texture has been loaded
  23884. * @param onError define a callback triggered when an error occurred during the loading session
  23885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23886. * @returns the created texture
  23887. */
  23888. 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;
  23889. }
  23890. }
  23891. declare module "babylonjs/PostProcesses/postProcessManager" {
  23892. import { Nullable } from "babylonjs/types";
  23893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23895. import { Scene } from "babylonjs/scene";
  23896. /**
  23897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23899. */
  23900. export class PostProcessManager {
  23901. private _scene;
  23902. private _indexBuffer;
  23903. private _vertexBuffers;
  23904. /**
  23905. * Creates a new instance PostProcess
  23906. * @param scene The scene that the post process is associated with.
  23907. */
  23908. constructor(scene: Scene);
  23909. private _prepareBuffers;
  23910. private _buildIndexBuffer;
  23911. /**
  23912. * Rebuilds the vertex buffers of the manager.
  23913. * @hidden
  23914. */
  23915. _rebuild(): void;
  23916. /**
  23917. * Prepares a frame to be run through a post process.
  23918. * @param sourceTexture The input texture to the post procesess. (default: null)
  23919. * @param postProcesses An array of post processes to be run. (default: null)
  23920. * @returns True if the post processes were able to be run.
  23921. * @hidden
  23922. */
  23923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23924. /**
  23925. * Manually render a set of post processes to a texture.
  23926. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23927. * @param postProcesses An array of post processes to be run.
  23928. * @param targetTexture The target texture to render to.
  23929. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23930. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23931. * @param lodLevel defines which lod of the texture to render to
  23932. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23933. */
  23934. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23935. /**
  23936. * Finalize the result of the output of the postprocesses.
  23937. * @param doNotPresent If true the result will not be displayed to the screen.
  23938. * @param targetTexture The target texture to render to.
  23939. * @param faceIndex The index of the face to bind the target texture to.
  23940. * @param postProcesses The array of post processes to render.
  23941. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23942. * @hidden
  23943. */
  23944. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23945. /**
  23946. * Disposes of the post process manager.
  23947. */
  23948. dispose(): void;
  23949. }
  23950. }
  23951. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23952. import { Observable } from "babylonjs/Misc/observable";
  23953. import { SmartArray } from "babylonjs/Misc/smartArray";
  23954. import { Nullable, Immutable } from "babylonjs/types";
  23955. import { Camera } from "babylonjs/Cameras/camera";
  23956. import { Scene } from "babylonjs/scene";
  23957. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23958. import { Color4 } from "babylonjs/Maths/math.color";
  23959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23963. import { Texture } from "babylonjs/Materials/Textures/texture";
  23964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23965. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23966. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23967. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23968. import { Engine } from "babylonjs/Engines/engine";
  23969. /**
  23970. * This Helps creating a texture that will be created from a camera in your scene.
  23971. * It is basically a dynamic texture that could be used to create special effects for instance.
  23972. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23973. */
  23974. export class RenderTargetTexture extends Texture {
  23975. isCube: boolean;
  23976. /**
  23977. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23978. */
  23979. static readonly REFRESHRATE_RENDER_ONCE: number;
  23980. /**
  23981. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23982. */
  23983. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23984. /**
  23985. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23986. * the central point of your effect and can save a lot of performances.
  23987. */
  23988. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23989. /**
  23990. * Use this predicate to dynamically define the list of mesh you want to render.
  23991. * If set, the renderList property will be overwritten.
  23992. */
  23993. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23994. private _renderList;
  23995. /**
  23996. * Use this list to define the list of mesh you want to render.
  23997. */
  23998. get renderList(): Nullable<Array<AbstractMesh>>;
  23999. set renderList(value: Nullable<Array<AbstractMesh>>);
  24000. /**
  24001. * Use this function to overload the renderList array at rendering time.
  24002. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24003. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24004. * the cube (if the RTT is a cube, else layerOrFace=0).
  24005. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24006. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24007. * hold dummy elements!
  24008. */
  24009. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24010. private _hookArray;
  24011. /**
  24012. * Define if particles should be rendered in your texture.
  24013. */
  24014. renderParticles: boolean;
  24015. /**
  24016. * Define if sprites should be rendered in your texture.
  24017. */
  24018. renderSprites: boolean;
  24019. /**
  24020. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24021. */
  24022. coordinatesMode: number;
  24023. /**
  24024. * Define the camera used to render the texture.
  24025. */
  24026. activeCamera: Nullable<Camera>;
  24027. /**
  24028. * Override the mesh isReady function with your own one.
  24029. */
  24030. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24031. /**
  24032. * Override the render function of the texture with your own one.
  24033. */
  24034. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24035. /**
  24036. * Define if camera post processes should be use while rendering the texture.
  24037. */
  24038. useCameraPostProcesses: boolean;
  24039. /**
  24040. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24041. */
  24042. ignoreCameraViewport: boolean;
  24043. private _postProcessManager;
  24044. private _postProcesses;
  24045. private _resizeObserver;
  24046. /**
  24047. * An event triggered when the texture is unbind.
  24048. */
  24049. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24050. /**
  24051. * An event triggered when the texture is unbind.
  24052. */
  24053. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24054. private _onAfterUnbindObserver;
  24055. /**
  24056. * Set a after unbind callback in the texture.
  24057. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24058. */
  24059. set onAfterUnbind(callback: () => void);
  24060. /**
  24061. * An event triggered before rendering the texture
  24062. */
  24063. onBeforeRenderObservable: Observable<number>;
  24064. private _onBeforeRenderObserver;
  24065. /**
  24066. * Set a before render callback in the texture.
  24067. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24068. */
  24069. set onBeforeRender(callback: (faceIndex: number) => void);
  24070. /**
  24071. * An event triggered after rendering the texture
  24072. */
  24073. onAfterRenderObservable: Observable<number>;
  24074. private _onAfterRenderObserver;
  24075. /**
  24076. * Set a after render callback in the texture.
  24077. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24078. */
  24079. set onAfterRender(callback: (faceIndex: number) => void);
  24080. /**
  24081. * An event triggered after the texture clear
  24082. */
  24083. onClearObservable: Observable<Engine>;
  24084. private _onClearObserver;
  24085. /**
  24086. * Set a clear callback in the texture.
  24087. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24088. */
  24089. set onClear(callback: (Engine: Engine) => void);
  24090. /**
  24091. * An event triggered when the texture is resized.
  24092. */
  24093. onResizeObservable: Observable<RenderTargetTexture>;
  24094. /**
  24095. * Define the clear color of the Render Target if it should be different from the scene.
  24096. */
  24097. clearColor: Color4;
  24098. protected _size: number | {
  24099. width: number;
  24100. height: number;
  24101. layers?: number;
  24102. };
  24103. protected _initialSizeParameter: number | {
  24104. width: number;
  24105. height: number;
  24106. } | {
  24107. ratio: number;
  24108. };
  24109. protected _sizeRatio: Nullable<number>;
  24110. /** @hidden */
  24111. _generateMipMaps: boolean;
  24112. protected _renderingManager: RenderingManager;
  24113. /** @hidden */
  24114. _waitingRenderList: string[];
  24115. protected _doNotChangeAspectRatio: boolean;
  24116. protected _currentRefreshId: number;
  24117. protected _refreshRate: number;
  24118. protected _textureMatrix: Matrix;
  24119. protected _samples: number;
  24120. protected _renderTargetOptions: RenderTargetCreationOptions;
  24121. /**
  24122. * Gets render target creation options that were used.
  24123. */
  24124. get renderTargetOptions(): RenderTargetCreationOptions;
  24125. protected _onRatioRescale(): void;
  24126. /**
  24127. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24128. * It must define where the camera used to render the texture is set
  24129. */
  24130. boundingBoxPosition: Vector3;
  24131. private _boundingBoxSize;
  24132. /**
  24133. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24134. * When defined, the cubemap will switch to local mode
  24135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24136. * @example https://www.babylonjs-playground.com/#RNASML
  24137. */
  24138. set boundingBoxSize(value: Vector3);
  24139. get boundingBoxSize(): Vector3;
  24140. /**
  24141. * In case the RTT has been created with a depth texture, get the associated
  24142. * depth texture.
  24143. * Otherwise, return null.
  24144. */
  24145. get depthStencilTexture(): Nullable<InternalTexture>;
  24146. /**
  24147. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24148. * or used a shadow, depth texture...
  24149. * @param name The friendly name of the texture
  24150. * @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)
  24151. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24152. * @param generateMipMaps True if mip maps need to be generated after render.
  24153. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24154. * @param type The type of the buffer in the RTT (int, half float, float...)
  24155. * @param isCube True if a cube texture needs to be created
  24156. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24157. * @param generateDepthBuffer True to generate a depth buffer
  24158. * @param generateStencilBuffer True to generate a stencil buffer
  24159. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24160. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24161. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24162. */
  24163. constructor(name: string, size: number | {
  24164. width: number;
  24165. height: number;
  24166. layers?: number;
  24167. } | {
  24168. ratio: number;
  24169. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24170. /**
  24171. * Creates a depth stencil texture.
  24172. * This is only available in WebGL 2 or with the depth texture extension available.
  24173. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24174. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24175. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24176. */
  24177. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24178. private _processSizeParameter;
  24179. /**
  24180. * Define the number of samples to use in case of MSAA.
  24181. * It defaults to one meaning no MSAA has been enabled.
  24182. */
  24183. get samples(): number;
  24184. set samples(value: number);
  24185. /**
  24186. * Resets the refresh counter of the texture and start bak from scratch.
  24187. * Could be useful to regenerate the texture if it is setup to render only once.
  24188. */
  24189. resetRefreshCounter(): void;
  24190. /**
  24191. * Define the refresh rate of the texture or the rendering frequency.
  24192. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24193. */
  24194. get refreshRate(): number;
  24195. set refreshRate(value: number);
  24196. /**
  24197. * Adds a post process to the render target rendering passes.
  24198. * @param postProcess define the post process to add
  24199. */
  24200. addPostProcess(postProcess: PostProcess): void;
  24201. /**
  24202. * Clear all the post processes attached to the render target
  24203. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24204. */
  24205. clearPostProcesses(dispose?: boolean): void;
  24206. /**
  24207. * Remove one of the post process from the list of attached post processes to the texture
  24208. * @param postProcess define the post process to remove from the list
  24209. */
  24210. removePostProcess(postProcess: PostProcess): void;
  24211. /** @hidden */
  24212. _shouldRender(): boolean;
  24213. /**
  24214. * Gets the actual render size of the texture.
  24215. * @returns the width of the render size
  24216. */
  24217. getRenderSize(): number;
  24218. /**
  24219. * Gets the actual render width of the texture.
  24220. * @returns the width of the render size
  24221. */
  24222. getRenderWidth(): number;
  24223. /**
  24224. * Gets the actual render height of the texture.
  24225. * @returns the height of the render size
  24226. */
  24227. getRenderHeight(): number;
  24228. /**
  24229. * Gets the actual number of layers of the texture.
  24230. * @returns the number of layers
  24231. */
  24232. getRenderLayers(): number;
  24233. /**
  24234. * Get if the texture can be rescaled or not.
  24235. */
  24236. get canRescale(): boolean;
  24237. /**
  24238. * Resize the texture using a ratio.
  24239. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24240. */
  24241. scale(ratio: number): void;
  24242. /**
  24243. * Get the texture reflection matrix used to rotate/transform the reflection.
  24244. * @returns the reflection matrix
  24245. */
  24246. getReflectionTextureMatrix(): Matrix;
  24247. /**
  24248. * Resize the texture to a new desired size.
  24249. * Be carrefull as it will recreate all the data in the new texture.
  24250. * @param size Define the new size. It can be:
  24251. * - a number for squared texture,
  24252. * - an object containing { width: number, height: number }
  24253. * - or an object containing a ratio { ratio: number }
  24254. */
  24255. resize(size: number | {
  24256. width: number;
  24257. height: number;
  24258. } | {
  24259. ratio: number;
  24260. }): void;
  24261. private _defaultRenderListPrepared;
  24262. /**
  24263. * Renders all the objects from the render list into the texture.
  24264. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24265. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24266. */
  24267. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24268. private _bestReflectionRenderTargetDimension;
  24269. private _prepareRenderingManager;
  24270. /**
  24271. * @hidden
  24272. * @param faceIndex face index to bind to if this is a cubetexture
  24273. * @param layer defines the index of the texture to bind in the array
  24274. */
  24275. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24276. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24277. private renderToTarget;
  24278. /**
  24279. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24280. * This allowed control for front to back rendering or reversly depending of the special needs.
  24281. *
  24282. * @param renderingGroupId The rendering group id corresponding to its index
  24283. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24284. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24285. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24286. */
  24287. 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;
  24288. /**
  24289. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24290. *
  24291. * @param renderingGroupId The rendering group id corresponding to its index
  24292. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24293. */
  24294. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24295. /**
  24296. * Clones the texture.
  24297. * @returns the cloned texture
  24298. */
  24299. clone(): RenderTargetTexture;
  24300. /**
  24301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24302. * @returns The JSON representation of the texture
  24303. */
  24304. serialize(): any;
  24305. /**
  24306. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24307. */
  24308. disposeFramebufferObjects(): void;
  24309. /**
  24310. * Dispose the texture and release its associated resources.
  24311. */
  24312. dispose(): void;
  24313. /** @hidden */
  24314. _rebuild(): void;
  24315. /**
  24316. * Clear the info related to rendering groups preventing retention point in material dispose.
  24317. */
  24318. freeRenderingGroups(): void;
  24319. /**
  24320. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24321. * @returns the view count
  24322. */
  24323. getViewCount(): number;
  24324. }
  24325. }
  24326. declare module "babylonjs/Misc/guid" {
  24327. /**
  24328. * Class used to manipulate GUIDs
  24329. */
  24330. export class GUID {
  24331. /**
  24332. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24333. * Be aware Math.random() could cause collisions, but:
  24334. * "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"
  24335. * @returns a pseudo random id
  24336. */
  24337. static RandomId(): string;
  24338. }
  24339. }
  24340. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24341. import { Nullable } from "babylonjs/types";
  24342. import { Scene } from "babylonjs/scene";
  24343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24344. import { Material } from "babylonjs/Materials/material";
  24345. import { Effect } from "babylonjs/Materials/effect";
  24346. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24347. /**
  24348. * Options to be used when creating a shadow depth material
  24349. */
  24350. export interface IIOptionShadowDepthMaterial {
  24351. /** Variables in the vertex shader code that need to have their names remapped.
  24352. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24353. * "var_name" should be either: worldPos or vNormalW
  24354. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24355. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24356. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24357. */
  24358. remappedVariables?: string[];
  24359. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24360. standalone?: boolean;
  24361. }
  24362. /**
  24363. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24364. */
  24365. export class ShadowDepthWrapper {
  24366. private _scene;
  24367. private _options?;
  24368. private _baseMaterial;
  24369. private _onEffectCreatedObserver;
  24370. private _subMeshToEffect;
  24371. private _subMeshToDepthEffect;
  24372. private _meshes;
  24373. /** @hidden */
  24374. _matriceNames: any;
  24375. /** Gets the standalone status of the wrapper */
  24376. get standalone(): boolean;
  24377. /** Gets the base material the wrapper is built upon */
  24378. get baseMaterial(): Material;
  24379. /**
  24380. * Instantiate a new shadow depth wrapper.
  24381. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24382. * generate the shadow depth map. For more information, please refer to the documentation:
  24383. * https://doc.babylonjs.com/babylon101/shadows
  24384. * @param baseMaterial Material to wrap
  24385. * @param scene Define the scene the material belongs to
  24386. * @param options Options used to create the wrapper
  24387. */
  24388. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24389. /**
  24390. * Gets the effect to use to generate the depth map
  24391. * @param subMesh subMesh to get the effect for
  24392. * @param shadowGenerator shadow generator to get the effect for
  24393. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24394. */
  24395. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24396. /**
  24397. * Specifies that the submesh is ready to be used for depth rendering
  24398. * @param subMesh submesh to check
  24399. * @param defines the list of defines to take into account when checking the effect
  24400. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24401. * @param useInstances specifies that instances should be used
  24402. * @returns a boolean indicating that the submesh is ready or not
  24403. */
  24404. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24405. /**
  24406. * Disposes the resources
  24407. */
  24408. dispose(): void;
  24409. private _makeEffect;
  24410. }
  24411. }
  24412. declare module "babylonjs/Materials/material" {
  24413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24414. import { SmartArray } from "babylonjs/Misc/smartArray";
  24415. import { Observable } from "babylonjs/Misc/observable";
  24416. import { Nullable } from "babylonjs/types";
  24417. import { Scene } from "babylonjs/scene";
  24418. import { Matrix } from "babylonjs/Maths/math.vector";
  24419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24422. import { Effect } from "babylonjs/Materials/effect";
  24423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24425. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24426. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24427. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24428. import { Mesh } from "babylonjs/Meshes/mesh";
  24429. import { Animation } from "babylonjs/Animations/animation";
  24430. /**
  24431. * Options for compiling materials.
  24432. */
  24433. export interface IMaterialCompilationOptions {
  24434. /**
  24435. * Defines whether clip planes are enabled.
  24436. */
  24437. clipPlane: boolean;
  24438. /**
  24439. * Defines whether instances are enabled.
  24440. */
  24441. useInstances: boolean;
  24442. }
  24443. /**
  24444. * Options passed when calling customShaderNameResolve
  24445. */
  24446. export interface ICustomShaderNameResolveOptions {
  24447. /**
  24448. * 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
  24449. */
  24450. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24451. }
  24452. /**
  24453. * Base class for the main features of a material in Babylon.js
  24454. */
  24455. export class Material implements IAnimatable {
  24456. /**
  24457. * Returns the triangle fill mode
  24458. */
  24459. static readonly TriangleFillMode: number;
  24460. /**
  24461. * Returns the wireframe mode
  24462. */
  24463. static readonly WireFrameFillMode: number;
  24464. /**
  24465. * Returns the point fill mode
  24466. */
  24467. static readonly PointFillMode: number;
  24468. /**
  24469. * Returns the point list draw mode
  24470. */
  24471. static readonly PointListDrawMode: number;
  24472. /**
  24473. * Returns the line list draw mode
  24474. */
  24475. static readonly LineListDrawMode: number;
  24476. /**
  24477. * Returns the line loop draw mode
  24478. */
  24479. static readonly LineLoopDrawMode: number;
  24480. /**
  24481. * Returns the line strip draw mode
  24482. */
  24483. static readonly LineStripDrawMode: number;
  24484. /**
  24485. * Returns the triangle strip draw mode
  24486. */
  24487. static readonly TriangleStripDrawMode: number;
  24488. /**
  24489. * Returns the triangle fan draw mode
  24490. */
  24491. static readonly TriangleFanDrawMode: number;
  24492. /**
  24493. * Stores the clock-wise side orientation
  24494. */
  24495. static readonly ClockWiseSideOrientation: number;
  24496. /**
  24497. * Stores the counter clock-wise side orientation
  24498. */
  24499. static readonly CounterClockWiseSideOrientation: number;
  24500. /**
  24501. * The dirty texture flag value
  24502. */
  24503. static readonly TextureDirtyFlag: number;
  24504. /**
  24505. * The dirty light flag value
  24506. */
  24507. static readonly LightDirtyFlag: number;
  24508. /**
  24509. * The dirty fresnel flag value
  24510. */
  24511. static readonly FresnelDirtyFlag: number;
  24512. /**
  24513. * The dirty attribute flag value
  24514. */
  24515. static readonly AttributesDirtyFlag: number;
  24516. /**
  24517. * The dirty misc flag value
  24518. */
  24519. static readonly MiscDirtyFlag: number;
  24520. /**
  24521. * The all dirty flag value
  24522. */
  24523. static readonly AllDirtyFlag: number;
  24524. /**
  24525. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24526. */
  24527. static readonly MATERIAL_OPAQUE: number;
  24528. /**
  24529. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24530. */
  24531. static readonly MATERIAL_ALPHATEST: number;
  24532. /**
  24533. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24534. */
  24535. static readonly MATERIAL_ALPHABLEND: number;
  24536. /**
  24537. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24538. * They are also discarded below the alpha cutoff threshold to improve performances.
  24539. */
  24540. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24541. /**
  24542. * The Whiteout method is used to blend normals.
  24543. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24544. */
  24545. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24546. /**
  24547. * The Reoriented Normal Mapping method is used to blend normals.
  24548. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24549. */
  24550. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24551. /**
  24552. * Custom callback helping to override the default shader used in the material.
  24553. */
  24554. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24555. /**
  24556. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24557. */
  24558. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24559. /**
  24560. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24561. * This means that the material can keep using a previous shader while a new one is being compiled.
  24562. * This is mostly used when shader parallel compilation is supported (true by default)
  24563. */
  24564. allowShaderHotSwapping: boolean;
  24565. /**
  24566. * The ID of the material
  24567. */
  24568. id: string;
  24569. /**
  24570. * Gets or sets the unique id of the material
  24571. */
  24572. uniqueId: number;
  24573. /**
  24574. * The name of the material
  24575. */
  24576. name: string;
  24577. /**
  24578. * Gets or sets user defined metadata
  24579. */
  24580. metadata: any;
  24581. /**
  24582. * For internal use only. Please do not use.
  24583. */
  24584. reservedDataStore: any;
  24585. /**
  24586. * Specifies if the ready state should be checked on each call
  24587. */
  24588. checkReadyOnEveryCall: boolean;
  24589. /**
  24590. * Specifies if the ready state should be checked once
  24591. */
  24592. checkReadyOnlyOnce: boolean;
  24593. /**
  24594. * The state of the material
  24595. */
  24596. state: string;
  24597. /**
  24598. * If the material should be rendered to several textures with MRT extension
  24599. */
  24600. get shouldRenderToMRT(): boolean;
  24601. /**
  24602. * The alpha value of the material
  24603. */
  24604. protected _alpha: number;
  24605. /**
  24606. * List of inspectable custom properties (used by the Inspector)
  24607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24608. */
  24609. inspectableCustomProperties: IInspectable[];
  24610. /**
  24611. * Sets the alpha value of the material
  24612. */
  24613. set alpha(value: number);
  24614. /**
  24615. * Gets the alpha value of the material
  24616. */
  24617. get alpha(): number;
  24618. /**
  24619. * Specifies if back face culling is enabled
  24620. */
  24621. protected _backFaceCulling: boolean;
  24622. /**
  24623. * Sets the back-face culling state
  24624. */
  24625. set backFaceCulling(value: boolean);
  24626. /**
  24627. * Gets the back-face culling state
  24628. */
  24629. get backFaceCulling(): boolean;
  24630. /**
  24631. * Stores the value for side orientation
  24632. */
  24633. sideOrientation: number;
  24634. /**
  24635. * Callback triggered when the material is compiled
  24636. */
  24637. onCompiled: Nullable<(effect: Effect) => void>;
  24638. /**
  24639. * Callback triggered when an error occurs
  24640. */
  24641. onError: Nullable<(effect: Effect, errors: string) => void>;
  24642. /**
  24643. * Callback triggered to get the render target textures
  24644. */
  24645. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24646. /**
  24647. * Gets a boolean indicating that current material needs to register RTT
  24648. */
  24649. get hasRenderTargetTextures(): boolean;
  24650. /**
  24651. * Specifies if the material should be serialized
  24652. */
  24653. doNotSerialize: boolean;
  24654. /**
  24655. * @hidden
  24656. */
  24657. _storeEffectOnSubMeshes: boolean;
  24658. /**
  24659. * Stores the animations for the material
  24660. */
  24661. animations: Nullable<Array<Animation>>;
  24662. /**
  24663. * An event triggered when the material is disposed
  24664. */
  24665. onDisposeObservable: Observable<Material>;
  24666. /**
  24667. * An observer which watches for dispose events
  24668. */
  24669. private _onDisposeObserver;
  24670. private _onUnBindObservable;
  24671. /**
  24672. * Called during a dispose event
  24673. */
  24674. set onDispose(callback: () => void);
  24675. private _onBindObservable;
  24676. /**
  24677. * An event triggered when the material is bound
  24678. */
  24679. get onBindObservable(): Observable<AbstractMesh>;
  24680. /**
  24681. * An observer which watches for bind events
  24682. */
  24683. private _onBindObserver;
  24684. /**
  24685. * Called during a bind event
  24686. */
  24687. set onBind(callback: (Mesh: AbstractMesh) => void);
  24688. /**
  24689. * An event triggered when the material is unbound
  24690. */
  24691. get onUnBindObservable(): Observable<Material>;
  24692. protected _onEffectCreatedObservable: Nullable<Observable<{
  24693. effect: Effect;
  24694. subMesh: Nullable<SubMesh>;
  24695. }>>;
  24696. /**
  24697. * An event triggered when the effect is (re)created
  24698. */
  24699. get onEffectCreatedObservable(): Observable<{
  24700. effect: Effect;
  24701. subMesh: Nullable<SubMesh>;
  24702. }>;
  24703. /**
  24704. * Stores the value of the alpha mode
  24705. */
  24706. private _alphaMode;
  24707. /**
  24708. * Sets the value of the alpha mode.
  24709. *
  24710. * | Value | Type | Description |
  24711. * | --- | --- | --- |
  24712. * | 0 | ALPHA_DISABLE | |
  24713. * | 1 | ALPHA_ADD | |
  24714. * | 2 | ALPHA_COMBINE | |
  24715. * | 3 | ALPHA_SUBTRACT | |
  24716. * | 4 | ALPHA_MULTIPLY | |
  24717. * | 5 | ALPHA_MAXIMIZED | |
  24718. * | 6 | ALPHA_ONEONE | |
  24719. * | 7 | ALPHA_PREMULTIPLIED | |
  24720. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24721. * | 9 | ALPHA_INTERPOLATE | |
  24722. * | 10 | ALPHA_SCREENMODE | |
  24723. *
  24724. */
  24725. set alphaMode(value: number);
  24726. /**
  24727. * Gets the value of the alpha mode
  24728. */
  24729. get alphaMode(): number;
  24730. /**
  24731. * Stores the state of the need depth pre-pass value
  24732. */
  24733. private _needDepthPrePass;
  24734. /**
  24735. * Sets the need depth pre-pass value
  24736. */
  24737. set needDepthPrePass(value: boolean);
  24738. /**
  24739. * Gets the depth pre-pass value
  24740. */
  24741. get needDepthPrePass(): boolean;
  24742. /**
  24743. * Specifies if depth writing should be disabled
  24744. */
  24745. disableDepthWrite: boolean;
  24746. /**
  24747. * Specifies if color writing should be disabled
  24748. */
  24749. disableColorWrite: boolean;
  24750. /**
  24751. * Specifies if depth writing should be forced
  24752. */
  24753. forceDepthWrite: boolean;
  24754. /**
  24755. * Specifies the depth function that should be used. 0 means the default engine function
  24756. */
  24757. depthFunction: number;
  24758. /**
  24759. * Specifies if there should be a separate pass for culling
  24760. */
  24761. separateCullingPass: boolean;
  24762. /**
  24763. * Stores the state specifing if fog should be enabled
  24764. */
  24765. private _fogEnabled;
  24766. /**
  24767. * Sets the state for enabling fog
  24768. */
  24769. set fogEnabled(value: boolean);
  24770. /**
  24771. * Gets the value of the fog enabled state
  24772. */
  24773. get fogEnabled(): boolean;
  24774. /**
  24775. * Stores the size of points
  24776. */
  24777. pointSize: number;
  24778. /**
  24779. * Stores the z offset value
  24780. */
  24781. zOffset: number;
  24782. get wireframe(): boolean;
  24783. /**
  24784. * Sets the state of wireframe mode
  24785. */
  24786. set wireframe(value: boolean);
  24787. /**
  24788. * Gets the value specifying if point clouds are enabled
  24789. */
  24790. get pointsCloud(): boolean;
  24791. /**
  24792. * Sets the state of point cloud mode
  24793. */
  24794. set pointsCloud(value: boolean);
  24795. /**
  24796. * Gets the material fill mode
  24797. */
  24798. get fillMode(): number;
  24799. /**
  24800. * Sets the material fill mode
  24801. */
  24802. set fillMode(value: number);
  24803. /**
  24804. * @hidden
  24805. * Stores the effects for the material
  24806. */
  24807. _effect: Nullable<Effect>;
  24808. /**
  24809. * Specifies if uniform buffers should be used
  24810. */
  24811. private _useUBO;
  24812. /**
  24813. * Stores a reference to the scene
  24814. */
  24815. private _scene;
  24816. /**
  24817. * Stores the fill mode state
  24818. */
  24819. private _fillMode;
  24820. /**
  24821. * Specifies if the depth write state should be cached
  24822. */
  24823. private _cachedDepthWriteState;
  24824. /**
  24825. * Specifies if the color write state should be cached
  24826. */
  24827. private _cachedColorWriteState;
  24828. /**
  24829. * Specifies if the depth function state should be cached
  24830. */
  24831. private _cachedDepthFunctionState;
  24832. /**
  24833. * Stores the uniform buffer
  24834. */
  24835. protected _uniformBuffer: UniformBuffer;
  24836. /** @hidden */
  24837. _indexInSceneMaterialArray: number;
  24838. /** @hidden */
  24839. meshMap: Nullable<{
  24840. [id: string]: AbstractMesh | undefined;
  24841. }>;
  24842. /**
  24843. * Creates a material instance
  24844. * @param name defines the name of the material
  24845. * @param scene defines the scene to reference
  24846. * @param doNotAdd specifies if the material should be added to the scene
  24847. */
  24848. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24849. /**
  24850. * Returns a string representation of the current material
  24851. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24852. * @returns a string with material information
  24853. */
  24854. toString(fullDetails?: boolean): string;
  24855. /**
  24856. * Gets the class name of the material
  24857. * @returns a string with the class name of the material
  24858. */
  24859. getClassName(): string;
  24860. /**
  24861. * Specifies if updates for the material been locked
  24862. */
  24863. get isFrozen(): boolean;
  24864. /**
  24865. * Locks updates for the material
  24866. */
  24867. freeze(): void;
  24868. /**
  24869. * Unlocks updates for the material
  24870. */
  24871. unfreeze(): void;
  24872. /**
  24873. * Specifies if the material is ready to be used
  24874. * @param mesh defines the mesh to check
  24875. * @param useInstances specifies if instances should be used
  24876. * @returns a boolean indicating if the material is ready to be used
  24877. */
  24878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24879. /**
  24880. * Specifies that the submesh is ready to be used
  24881. * @param mesh defines the mesh to check
  24882. * @param subMesh defines which submesh to check
  24883. * @param useInstances specifies that instances should be used
  24884. * @returns a boolean indicating that the submesh is ready or not
  24885. */
  24886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24887. /**
  24888. * Returns the material effect
  24889. * @returns the effect associated with the material
  24890. */
  24891. getEffect(): Nullable<Effect>;
  24892. /**
  24893. * Returns the current scene
  24894. * @returns a Scene
  24895. */
  24896. getScene(): Scene;
  24897. /**
  24898. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24899. */
  24900. protected _forceAlphaTest: boolean;
  24901. /**
  24902. * The transparency mode of the material.
  24903. */
  24904. protected _transparencyMode: Nullable<number>;
  24905. /**
  24906. * Gets the current transparency mode.
  24907. */
  24908. get transparencyMode(): Nullable<number>;
  24909. /**
  24910. * Sets the transparency mode of the material.
  24911. *
  24912. * | Value | Type | Description |
  24913. * | ----- | ----------------------------------- | ----------- |
  24914. * | 0 | OPAQUE | |
  24915. * | 1 | ALPHATEST | |
  24916. * | 2 | ALPHABLEND | |
  24917. * | 3 | ALPHATESTANDBLEND | |
  24918. *
  24919. */
  24920. set transparencyMode(value: Nullable<number>);
  24921. /**
  24922. * Returns true if alpha blending should be disabled.
  24923. */
  24924. protected get _disableAlphaBlending(): boolean;
  24925. /**
  24926. * Specifies whether or not this material should be rendered in alpha blend mode.
  24927. * @returns a boolean specifying if alpha blending is needed
  24928. */
  24929. needAlphaBlending(): boolean;
  24930. /**
  24931. * Specifies if the mesh will require alpha blending
  24932. * @param mesh defines the mesh to check
  24933. * @returns a boolean specifying if alpha blending is needed for the mesh
  24934. */
  24935. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24936. /**
  24937. * Specifies whether or not this material should be rendered in alpha test mode.
  24938. * @returns a boolean specifying if an alpha test is needed.
  24939. */
  24940. needAlphaTesting(): boolean;
  24941. /**
  24942. * Specifies if material alpha testing should be turned on for the mesh
  24943. * @param mesh defines the mesh to check
  24944. */
  24945. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24946. /**
  24947. * Gets the texture used for the alpha test
  24948. * @returns the texture to use for alpha testing
  24949. */
  24950. getAlphaTestTexture(): Nullable<BaseTexture>;
  24951. /**
  24952. * Marks the material to indicate that it needs to be re-calculated
  24953. */
  24954. markDirty(): void;
  24955. /** @hidden */
  24956. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24957. /**
  24958. * Binds the material to the mesh
  24959. * @param world defines the world transformation matrix
  24960. * @param mesh defines the mesh to bind the material to
  24961. */
  24962. bind(world: Matrix, mesh?: Mesh): void;
  24963. /**
  24964. * Binds the submesh to the material
  24965. * @param world defines the world transformation matrix
  24966. * @param mesh defines the mesh containing the submesh
  24967. * @param subMesh defines the submesh to bind the material to
  24968. */
  24969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24970. /**
  24971. * Binds the world matrix to the material
  24972. * @param world defines the world transformation matrix
  24973. */
  24974. bindOnlyWorldMatrix(world: Matrix): void;
  24975. /**
  24976. * Binds the scene's uniform buffer to the effect.
  24977. * @param effect defines the effect to bind to the scene uniform buffer
  24978. * @param sceneUbo defines the uniform buffer storing scene data
  24979. */
  24980. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24981. /**
  24982. * Binds the view matrix to the effect
  24983. * @param effect defines the effect to bind the view matrix to
  24984. */
  24985. bindView(effect: Effect): void;
  24986. /**
  24987. * Binds the view projection matrix to the effect
  24988. * @param effect defines the effect to bind the view projection matrix to
  24989. */
  24990. bindViewProjection(effect: Effect): void;
  24991. /**
  24992. * Processes to execute after binding the material to a mesh
  24993. * @param mesh defines the rendered mesh
  24994. */
  24995. protected _afterBind(mesh?: Mesh): void;
  24996. /**
  24997. * Unbinds the material from the mesh
  24998. */
  24999. unbind(): void;
  25000. /**
  25001. * Gets the active textures from the material
  25002. * @returns an array of textures
  25003. */
  25004. getActiveTextures(): BaseTexture[];
  25005. /**
  25006. * Specifies if the material uses a texture
  25007. * @param texture defines the texture to check against the material
  25008. * @returns a boolean specifying if the material uses the texture
  25009. */
  25010. hasTexture(texture: BaseTexture): boolean;
  25011. /**
  25012. * Makes a duplicate of the material, and gives it a new name
  25013. * @param name defines the new name for the duplicated material
  25014. * @returns the cloned material
  25015. */
  25016. clone(name: string): Nullable<Material>;
  25017. /**
  25018. * Gets the meshes bound to the material
  25019. * @returns an array of meshes bound to the material
  25020. */
  25021. getBindedMeshes(): AbstractMesh[];
  25022. /**
  25023. * Force shader compilation
  25024. * @param mesh defines the mesh associated with this material
  25025. * @param onCompiled defines a function to execute once the material is compiled
  25026. * @param options defines the options to configure the compilation
  25027. * @param onError defines a function to execute if the material fails compiling
  25028. */
  25029. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25030. /**
  25031. * Force shader compilation
  25032. * @param mesh defines the mesh that will use this material
  25033. * @param options defines additional options for compiling the shaders
  25034. * @returns a promise that resolves when the compilation completes
  25035. */
  25036. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25037. private static readonly _AllDirtyCallBack;
  25038. private static readonly _ImageProcessingDirtyCallBack;
  25039. private static readonly _TextureDirtyCallBack;
  25040. private static readonly _FresnelDirtyCallBack;
  25041. private static readonly _MiscDirtyCallBack;
  25042. private static readonly _LightsDirtyCallBack;
  25043. private static readonly _AttributeDirtyCallBack;
  25044. private static _FresnelAndMiscDirtyCallBack;
  25045. private static _TextureAndMiscDirtyCallBack;
  25046. private static readonly _DirtyCallbackArray;
  25047. private static readonly _RunDirtyCallBacks;
  25048. /**
  25049. * Marks a define in the material to indicate that it needs to be re-computed
  25050. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25051. */
  25052. markAsDirty(flag: number): void;
  25053. /**
  25054. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25055. * @param func defines a function which checks material defines against the submeshes
  25056. */
  25057. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25058. /**
  25059. * Indicates that the scene should check if the rendering now needs a prepass
  25060. */
  25061. protected _markScenePrePassDirty(): void;
  25062. /**
  25063. * Indicates that we need to re-calculated for all submeshes
  25064. */
  25065. protected _markAllSubMeshesAsAllDirty(): void;
  25066. /**
  25067. * Indicates that image processing needs to be re-calculated for all submeshes
  25068. */
  25069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25070. /**
  25071. * Indicates that textures need to be re-calculated for all submeshes
  25072. */
  25073. protected _markAllSubMeshesAsTexturesDirty(): void;
  25074. /**
  25075. * Indicates that fresnel needs to be re-calculated for all submeshes
  25076. */
  25077. protected _markAllSubMeshesAsFresnelDirty(): void;
  25078. /**
  25079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25080. */
  25081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25082. /**
  25083. * Indicates that lights need to be re-calculated for all submeshes
  25084. */
  25085. protected _markAllSubMeshesAsLightsDirty(): void;
  25086. /**
  25087. * Indicates that attributes need to be re-calculated for all submeshes
  25088. */
  25089. protected _markAllSubMeshesAsAttributesDirty(): void;
  25090. /**
  25091. * Indicates that misc needs to be re-calculated for all submeshes
  25092. */
  25093. protected _markAllSubMeshesAsMiscDirty(): void;
  25094. /**
  25095. * Indicates that textures and misc need to be re-calculated for all submeshes
  25096. */
  25097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25098. /**
  25099. * Disposes the material
  25100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25103. */
  25104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25105. /** @hidden */
  25106. private releaseVertexArrayObject;
  25107. /**
  25108. * Serializes this material
  25109. * @returns the serialized material object
  25110. */
  25111. serialize(): any;
  25112. /**
  25113. * Creates a material from parsed material data
  25114. * @param parsedMaterial defines parsed material data
  25115. * @param scene defines the hosting scene
  25116. * @param rootUrl defines the root URL to use to load textures
  25117. * @returns a new material
  25118. */
  25119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25120. }
  25121. }
  25122. declare module "babylonjs/Materials/multiMaterial" {
  25123. import { Nullable } from "babylonjs/types";
  25124. import { Scene } from "babylonjs/scene";
  25125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25128. import { Material } from "babylonjs/Materials/material";
  25129. /**
  25130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25131. * separate meshes. This can be use to improve performances.
  25132. * @see https://doc.babylonjs.com/how_to/multi_materials
  25133. */
  25134. export class MultiMaterial extends Material {
  25135. private _subMaterials;
  25136. /**
  25137. * Gets or Sets the list of Materials used within the multi material.
  25138. * They need to be ordered according to the submeshes order in the associated mesh
  25139. */
  25140. get subMaterials(): Nullable<Material>[];
  25141. set subMaterials(value: Nullable<Material>[]);
  25142. /**
  25143. * Function used to align with Node.getChildren()
  25144. * @returns the list of Materials used within the multi material
  25145. */
  25146. getChildren(): Nullable<Material>[];
  25147. /**
  25148. * Instantiates a new Multi Material
  25149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25150. * separate meshes. This can be use to improve performances.
  25151. * @see https://doc.babylonjs.com/how_to/multi_materials
  25152. * @param name Define the name in the scene
  25153. * @param scene Define the scene the material belongs to
  25154. */
  25155. constructor(name: string, scene: Scene);
  25156. private _hookArray;
  25157. /**
  25158. * Get one of the submaterial by its index in the submaterials array
  25159. * @param index The index to look the sub material at
  25160. * @returns The Material if the index has been defined
  25161. */
  25162. getSubMaterial(index: number): Nullable<Material>;
  25163. /**
  25164. * Get the list of active textures for the whole sub materials list.
  25165. * @returns All the textures that will be used during the rendering
  25166. */
  25167. getActiveTextures(): BaseTexture[];
  25168. /**
  25169. * Gets the current class name of the material e.g. "MultiMaterial"
  25170. * Mainly use in serialization.
  25171. * @returns the class name
  25172. */
  25173. getClassName(): string;
  25174. /**
  25175. * Checks if the material is ready to render the requested sub mesh
  25176. * @param mesh Define the mesh the submesh belongs to
  25177. * @param subMesh Define the sub mesh to look readyness for
  25178. * @param useInstances Define whether or not the material is used with instances
  25179. * @returns true if ready, otherwise false
  25180. */
  25181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25182. /**
  25183. * Clones the current material and its related sub materials
  25184. * @param name Define the name of the newly cloned material
  25185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25186. * @returns the cloned material
  25187. */
  25188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25189. /**
  25190. * Serializes the materials into a JSON representation.
  25191. * @returns the JSON representation
  25192. */
  25193. serialize(): any;
  25194. /**
  25195. * Dispose the material and release its associated resources
  25196. * @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)
  25197. * @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)
  25198. * @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)
  25199. */
  25200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25201. /**
  25202. * Creates a MultiMaterial from parsed MultiMaterial data.
  25203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25204. * @param scene defines the hosting scene
  25205. * @returns a new MultiMaterial
  25206. */
  25207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25208. }
  25209. }
  25210. declare module "babylonjs/Meshes/subMesh" {
  25211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25213. import { Engine } from "babylonjs/Engines/engine";
  25214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25216. import { Effect } from "babylonjs/Materials/effect";
  25217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25218. import { Plane } from "babylonjs/Maths/math.plane";
  25219. import { Collider } from "babylonjs/Collisions/collider";
  25220. import { Material } from "babylonjs/Materials/material";
  25221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25223. import { Mesh } from "babylonjs/Meshes/mesh";
  25224. import { Ray } from "babylonjs/Culling/ray";
  25225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25226. /**
  25227. * Defines a subdivision inside a mesh
  25228. */
  25229. export class SubMesh implements ICullable {
  25230. /** the material index to use */
  25231. materialIndex: number;
  25232. /** vertex index start */
  25233. verticesStart: number;
  25234. /** vertices count */
  25235. verticesCount: number;
  25236. /** index start */
  25237. indexStart: number;
  25238. /** indices count */
  25239. indexCount: number;
  25240. /** @hidden */
  25241. _materialDefines: Nullable<MaterialDefines>;
  25242. /** @hidden */
  25243. _materialEffect: Nullable<Effect>;
  25244. /** @hidden */
  25245. _effectOverride: Nullable<Effect>;
  25246. /**
  25247. * Gets material defines used by the effect associated to the sub mesh
  25248. */
  25249. get materialDefines(): Nullable<MaterialDefines>;
  25250. /**
  25251. * Sets material defines used by the effect associated to the sub mesh
  25252. */
  25253. set materialDefines(defines: Nullable<MaterialDefines>);
  25254. /**
  25255. * Gets associated effect
  25256. */
  25257. get effect(): Nullable<Effect>;
  25258. /**
  25259. * Sets associated effect (effect used to render this submesh)
  25260. * @param effect defines the effect to associate with
  25261. * @param defines defines the set of defines used to compile this effect
  25262. */
  25263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25264. /** @hidden */
  25265. _linesIndexCount: number;
  25266. private _mesh;
  25267. private _renderingMesh;
  25268. private _boundingInfo;
  25269. private _linesIndexBuffer;
  25270. /** @hidden */
  25271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25272. /** @hidden */
  25273. _trianglePlanes: Plane[];
  25274. /** @hidden */
  25275. _lastColliderTransformMatrix: Nullable<Matrix>;
  25276. /** @hidden */
  25277. _renderId: number;
  25278. /** @hidden */
  25279. _alphaIndex: number;
  25280. /** @hidden */
  25281. _distanceToCamera: number;
  25282. /** @hidden */
  25283. _id: number;
  25284. private _currentMaterial;
  25285. /**
  25286. * Add a new submesh to a mesh
  25287. * @param materialIndex defines the material index to use
  25288. * @param verticesStart defines vertex index start
  25289. * @param verticesCount defines vertices count
  25290. * @param indexStart defines index start
  25291. * @param indexCount defines indices count
  25292. * @param mesh defines the parent mesh
  25293. * @param renderingMesh defines an optional rendering mesh
  25294. * @param createBoundingBox defines if bounding box should be created for this submesh
  25295. * @returns the new submesh
  25296. */
  25297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25298. /**
  25299. * Creates a new submesh
  25300. * @param materialIndex defines the material index to use
  25301. * @param verticesStart defines vertex index start
  25302. * @param verticesCount defines vertices count
  25303. * @param indexStart defines index start
  25304. * @param indexCount defines indices count
  25305. * @param mesh defines the parent mesh
  25306. * @param renderingMesh defines an optional rendering mesh
  25307. * @param createBoundingBox defines if bounding box should be created for this submesh
  25308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25309. */
  25310. constructor(
  25311. /** the material index to use */
  25312. materialIndex: number,
  25313. /** vertex index start */
  25314. verticesStart: number,
  25315. /** vertices count */
  25316. verticesCount: number,
  25317. /** index start */
  25318. indexStart: number,
  25319. /** indices count */
  25320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25321. /**
  25322. * Returns true if this submesh covers the entire parent mesh
  25323. * @ignorenaming
  25324. */
  25325. get IsGlobal(): boolean;
  25326. /**
  25327. * Returns the submesh BoudingInfo object
  25328. * @returns current bounding info (or mesh's one if the submesh is global)
  25329. */
  25330. getBoundingInfo(): BoundingInfo;
  25331. /**
  25332. * Sets the submesh BoundingInfo
  25333. * @param boundingInfo defines the new bounding info to use
  25334. * @returns the SubMesh
  25335. */
  25336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25337. /**
  25338. * Returns the mesh of the current submesh
  25339. * @return the parent mesh
  25340. */
  25341. getMesh(): AbstractMesh;
  25342. /**
  25343. * Returns the rendering mesh of the submesh
  25344. * @returns the rendering mesh (could be different from parent mesh)
  25345. */
  25346. getRenderingMesh(): Mesh;
  25347. /**
  25348. * Returns the replacement mesh of the submesh
  25349. * @returns the replacement mesh (could be different from parent mesh)
  25350. */
  25351. getReplacementMesh(): Nullable<AbstractMesh>;
  25352. /**
  25353. * Returns the effective mesh of the submesh
  25354. * @returns the effective mesh (could be different from parent mesh)
  25355. */
  25356. getEffectiveMesh(): AbstractMesh;
  25357. /**
  25358. * Returns the submesh material
  25359. * @returns null or the current material
  25360. */
  25361. getMaterial(): Nullable<Material>;
  25362. private _IsMultiMaterial;
  25363. /**
  25364. * Sets a new updated BoundingInfo object to the submesh
  25365. * @param data defines an optional position array to use to determine the bounding info
  25366. * @returns the SubMesh
  25367. */
  25368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25369. /** @hidden */
  25370. _checkCollision(collider: Collider): boolean;
  25371. /**
  25372. * Updates the submesh BoundingInfo
  25373. * @param world defines the world matrix to use to update the bounding info
  25374. * @returns the submesh
  25375. */
  25376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25377. /**
  25378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25379. * @param frustumPlanes defines the frustum planes
  25380. * @returns true if the submesh is intersecting with the frustum
  25381. */
  25382. isInFrustum(frustumPlanes: Plane[]): boolean;
  25383. /**
  25384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25385. * @param frustumPlanes defines the frustum planes
  25386. * @returns true if the submesh is inside the frustum
  25387. */
  25388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25389. /**
  25390. * Renders the submesh
  25391. * @param enableAlphaMode defines if alpha needs to be used
  25392. * @returns the submesh
  25393. */
  25394. render(enableAlphaMode: boolean): SubMesh;
  25395. /**
  25396. * @hidden
  25397. */
  25398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25399. /**
  25400. * Checks if the submesh intersects with a ray
  25401. * @param ray defines the ray to test
  25402. * @returns true is the passed ray intersects the submesh bounding box
  25403. */
  25404. canIntersects(ray: Ray): boolean;
  25405. /**
  25406. * Intersects current submesh with a ray
  25407. * @param ray defines the ray to test
  25408. * @param positions defines mesh's positions array
  25409. * @param indices defines mesh's indices array
  25410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25412. * @returns intersection info or null if no intersection
  25413. */
  25414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25415. /** @hidden */
  25416. private _intersectLines;
  25417. /** @hidden */
  25418. private _intersectUnIndexedLines;
  25419. /** @hidden */
  25420. private _intersectTriangles;
  25421. /** @hidden */
  25422. private _intersectUnIndexedTriangles;
  25423. /** @hidden */
  25424. _rebuild(): void;
  25425. /**
  25426. * Creates a new submesh from the passed mesh
  25427. * @param newMesh defines the new hosting mesh
  25428. * @param newRenderingMesh defines an optional rendering mesh
  25429. * @returns the new submesh
  25430. */
  25431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25432. /**
  25433. * Release associated resources
  25434. */
  25435. dispose(): void;
  25436. /**
  25437. * Gets the class name
  25438. * @returns the string "SubMesh".
  25439. */
  25440. getClassName(): string;
  25441. /**
  25442. * Creates a new submesh from indices data
  25443. * @param materialIndex the index of the main mesh material
  25444. * @param startIndex the index where to start the copy in the mesh indices array
  25445. * @param indexCount the number of indices to copy then from the startIndex
  25446. * @param mesh the main mesh to create the submesh from
  25447. * @param renderingMesh the optional rendering mesh
  25448. * @returns a new submesh
  25449. */
  25450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25451. }
  25452. }
  25453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25454. /**
  25455. * Class used to represent data loading progression
  25456. */
  25457. export class SceneLoaderFlags {
  25458. private static _ForceFullSceneLoadingForIncremental;
  25459. private static _ShowLoadingScreen;
  25460. private static _CleanBoneMatrixWeights;
  25461. private static _loggingLevel;
  25462. /**
  25463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25464. */
  25465. static get ForceFullSceneLoadingForIncremental(): boolean;
  25466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25467. /**
  25468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25469. */
  25470. static get ShowLoadingScreen(): boolean;
  25471. static set ShowLoadingScreen(value: boolean);
  25472. /**
  25473. * Defines the current logging level (while loading the scene)
  25474. * @ignorenaming
  25475. */
  25476. static get loggingLevel(): number;
  25477. static set loggingLevel(value: number);
  25478. /**
  25479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25480. */
  25481. static get CleanBoneMatrixWeights(): boolean;
  25482. static set CleanBoneMatrixWeights(value: boolean);
  25483. }
  25484. }
  25485. declare module "babylonjs/Meshes/geometry" {
  25486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25487. import { Scene } from "babylonjs/scene";
  25488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25489. import { Engine } from "babylonjs/Engines/engine";
  25490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25492. import { Effect } from "babylonjs/Materials/effect";
  25493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25495. import { Mesh } from "babylonjs/Meshes/mesh";
  25496. /**
  25497. * Class used to store geometry data (vertex buffers + index buffer)
  25498. */
  25499. export class Geometry implements IGetSetVerticesData {
  25500. /**
  25501. * Gets or sets the ID of the geometry
  25502. */
  25503. id: string;
  25504. /**
  25505. * Gets or sets the unique ID of the geometry
  25506. */
  25507. uniqueId: number;
  25508. /**
  25509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25510. */
  25511. delayLoadState: number;
  25512. /**
  25513. * Gets the file containing the data to load when running in delay load state
  25514. */
  25515. delayLoadingFile: Nullable<string>;
  25516. /**
  25517. * Callback called when the geometry is updated
  25518. */
  25519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25520. private _scene;
  25521. private _engine;
  25522. private _meshes;
  25523. private _totalVertices;
  25524. /** @hidden */
  25525. _indices: IndicesArray;
  25526. /** @hidden */
  25527. _vertexBuffers: {
  25528. [key: string]: VertexBuffer;
  25529. };
  25530. private _isDisposed;
  25531. private _extend;
  25532. private _boundingBias;
  25533. /** @hidden */
  25534. _delayInfo: Array<string>;
  25535. private _indexBuffer;
  25536. private _indexBufferIsUpdatable;
  25537. /** @hidden */
  25538. _boundingInfo: Nullable<BoundingInfo>;
  25539. /** @hidden */
  25540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25541. /** @hidden */
  25542. _softwareSkinningFrameId: number;
  25543. private _vertexArrayObjects;
  25544. private _updatable;
  25545. /** @hidden */
  25546. _positions: Nullable<Vector3[]>;
  25547. /**
  25548. * 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
  25549. */
  25550. get boundingBias(): Vector2;
  25551. /**
  25552. * 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
  25553. */
  25554. set boundingBias(value: Vector2);
  25555. /**
  25556. * Static function used to attach a new empty geometry to a mesh
  25557. * @param mesh defines the mesh to attach the geometry to
  25558. * @returns the new Geometry
  25559. */
  25560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25561. /** Get the list of meshes using this geometry */
  25562. get meshes(): Mesh[];
  25563. /**
  25564. * 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
  25565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25566. */
  25567. useBoundingInfoFromGeometry: boolean;
  25568. /**
  25569. * Creates a new geometry
  25570. * @param id defines the unique ID
  25571. * @param scene defines the hosting scene
  25572. * @param vertexData defines the VertexData used to get geometry data
  25573. * @param updatable defines if geometry must be updatable (false by default)
  25574. * @param mesh defines the mesh that will be associated with the geometry
  25575. */
  25576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25577. /**
  25578. * Gets the current extend of the geometry
  25579. */
  25580. get extend(): {
  25581. minimum: Vector3;
  25582. maximum: Vector3;
  25583. };
  25584. /**
  25585. * Gets the hosting scene
  25586. * @returns the hosting Scene
  25587. */
  25588. getScene(): Scene;
  25589. /**
  25590. * Gets the hosting engine
  25591. * @returns the hosting Engine
  25592. */
  25593. getEngine(): Engine;
  25594. /**
  25595. * Defines if the geometry is ready to use
  25596. * @returns true if the geometry is ready to be used
  25597. */
  25598. isReady(): boolean;
  25599. /**
  25600. * Gets a value indicating that the geometry should not be serialized
  25601. */
  25602. get doNotSerialize(): boolean;
  25603. /** @hidden */
  25604. _rebuild(): void;
  25605. /**
  25606. * Affects all geometry data in one call
  25607. * @param vertexData defines the geometry data
  25608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25609. */
  25610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25611. /**
  25612. * Set specific vertex data
  25613. * @param kind defines the data kind (Position, normal, etc...)
  25614. * @param data defines the vertex data to use
  25615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25617. */
  25618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25619. /**
  25620. * Removes a specific vertex data
  25621. * @param kind defines the data kind (Position, normal, etc...)
  25622. */
  25623. removeVerticesData(kind: string): void;
  25624. /**
  25625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25626. * @param buffer defines the vertex buffer to use
  25627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25628. */
  25629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25630. /**
  25631. * Update a specific vertex buffer
  25632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25633. * It will do nothing if the buffer is not updatable
  25634. * @param kind defines the data kind (Position, normal, etc...)
  25635. * @param data defines the data to use
  25636. * @param offset defines the offset in the target buffer where to store the data
  25637. * @param useBytes set to true if the offset is in bytes
  25638. */
  25639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25640. /**
  25641. * Update a specific vertex buffer
  25642. * This function will create a new buffer if the current one is not updatable
  25643. * @param kind defines the data kind (Position, normal, etc...)
  25644. * @param data defines the data to use
  25645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25646. */
  25647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25648. private _updateBoundingInfo;
  25649. /** @hidden */
  25650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25651. /**
  25652. * Gets total number of vertices
  25653. * @returns the total number of vertices
  25654. */
  25655. getTotalVertices(): number;
  25656. /**
  25657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25661. * @returns a float array containing vertex data
  25662. */
  25663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25664. /**
  25665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25666. * @param kind defines the data kind (Position, normal, etc...)
  25667. * @returns true if the vertex buffer with the specified kind is updatable
  25668. */
  25669. isVertexBufferUpdatable(kind: string): boolean;
  25670. /**
  25671. * Gets a specific vertex buffer
  25672. * @param kind defines the data kind (Position, normal, etc...)
  25673. * @returns a VertexBuffer
  25674. */
  25675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25676. /**
  25677. * Returns all vertex buffers
  25678. * @return an object holding all vertex buffers indexed by kind
  25679. */
  25680. getVertexBuffers(): Nullable<{
  25681. [key: string]: VertexBuffer;
  25682. }>;
  25683. /**
  25684. * Gets a boolean indicating if specific vertex buffer is present
  25685. * @param kind defines the data kind (Position, normal, etc...)
  25686. * @returns true if data is present
  25687. */
  25688. isVerticesDataPresent(kind: string): boolean;
  25689. /**
  25690. * Gets a list of all attached data kinds (Position, normal, etc...)
  25691. * @returns a list of string containing all kinds
  25692. */
  25693. getVerticesDataKinds(): string[];
  25694. /**
  25695. * Update index buffer
  25696. * @param indices defines the indices to store in the index buffer
  25697. * @param offset defines the offset in the target buffer where to store the data
  25698. * @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)
  25699. */
  25700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25701. /**
  25702. * Creates a new index buffer
  25703. * @param indices defines the indices to store in the index buffer
  25704. * @param totalVertices defines the total number of vertices (could be null)
  25705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25706. */
  25707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25708. /**
  25709. * Return the total number of indices
  25710. * @returns the total number of indices
  25711. */
  25712. getTotalIndices(): number;
  25713. /**
  25714. * Gets the index buffer array
  25715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25717. * @returns the index buffer array
  25718. */
  25719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25720. /**
  25721. * Gets the index buffer
  25722. * @return the index buffer
  25723. */
  25724. getIndexBuffer(): Nullable<DataBuffer>;
  25725. /** @hidden */
  25726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25727. /**
  25728. * Release the associated resources for a specific mesh
  25729. * @param mesh defines the source mesh
  25730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25731. */
  25732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25733. /**
  25734. * Apply current geometry to a given mesh
  25735. * @param mesh defines the mesh to apply geometry to
  25736. */
  25737. applyToMesh(mesh: Mesh): void;
  25738. private _updateExtend;
  25739. private _applyToMesh;
  25740. private notifyUpdate;
  25741. /**
  25742. * Load the geometry if it was flagged as delay loaded
  25743. * @param scene defines the hosting scene
  25744. * @param onLoaded defines a callback called when the geometry is loaded
  25745. */
  25746. load(scene: Scene, onLoaded?: () => void): void;
  25747. private _queueLoad;
  25748. /**
  25749. * Invert the geometry to move from a right handed system to a left handed one.
  25750. */
  25751. toLeftHanded(): void;
  25752. /** @hidden */
  25753. _resetPointsArrayCache(): void;
  25754. /** @hidden */
  25755. _generatePointsArray(): boolean;
  25756. /**
  25757. * Gets a value indicating if the geometry is disposed
  25758. * @returns true if the geometry was disposed
  25759. */
  25760. isDisposed(): boolean;
  25761. private _disposeVertexArrayObjects;
  25762. /**
  25763. * Free all associated resources
  25764. */
  25765. dispose(): void;
  25766. /**
  25767. * Clone the current geometry into a new geometry
  25768. * @param id defines the unique ID of the new geometry
  25769. * @returns a new geometry object
  25770. */
  25771. copy(id: string): Geometry;
  25772. /**
  25773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25774. * @return a JSON representation of the current geometry data (without the vertices data)
  25775. */
  25776. serialize(): any;
  25777. private toNumberArray;
  25778. /**
  25779. * Serialize all vertices data into a JSON oject
  25780. * @returns a JSON representation of the current geometry data
  25781. */
  25782. serializeVerticeData(): any;
  25783. /**
  25784. * Extracts a clone of a mesh geometry
  25785. * @param mesh defines the source mesh
  25786. * @param id defines the unique ID of the new geometry object
  25787. * @returns the new geometry object
  25788. */
  25789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25790. /**
  25791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25793. * Be aware Math.random() could cause collisions, but:
  25794. * "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"
  25795. * @returns a string containing a new GUID
  25796. */
  25797. static RandomId(): string;
  25798. /** @hidden */
  25799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25800. private static _CleanMatricesWeights;
  25801. /**
  25802. * Create a new geometry from persisted data (Using .babylon file format)
  25803. * @param parsedVertexData defines the persisted data
  25804. * @param scene defines the hosting scene
  25805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25806. * @returns the new geometry object
  25807. */
  25808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25809. }
  25810. }
  25811. declare module "babylonjs/Meshes/mesh.vertexData" {
  25812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25815. import { Geometry } from "babylonjs/Meshes/geometry";
  25816. import { Mesh } from "babylonjs/Meshes/mesh";
  25817. /**
  25818. * Define an interface for all classes that will get and set the data on vertices
  25819. */
  25820. export interface IGetSetVerticesData {
  25821. /**
  25822. * Gets a boolean indicating if specific vertex data is present
  25823. * @param kind defines the vertex data kind to use
  25824. * @returns true is data kind is present
  25825. */
  25826. isVerticesDataPresent(kind: string): boolean;
  25827. /**
  25828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25829. * @param kind defines the data kind (Position, normal, etc...)
  25830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25832. * @returns a float array containing vertex data
  25833. */
  25834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25835. /**
  25836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25837. * @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.
  25838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25839. * @returns the indices array or an empty array if the mesh has no geometry
  25840. */
  25841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25842. /**
  25843. * Set specific vertex data
  25844. * @param kind defines the data kind (Position, normal, etc...)
  25845. * @param data defines the vertex data to use
  25846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25848. */
  25849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25850. /**
  25851. * Update a specific associated vertex buffer
  25852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25853. * - VertexBuffer.PositionKind
  25854. * - VertexBuffer.UVKind
  25855. * - VertexBuffer.UV2Kind
  25856. * - VertexBuffer.UV3Kind
  25857. * - VertexBuffer.UV4Kind
  25858. * - VertexBuffer.UV5Kind
  25859. * - VertexBuffer.UV6Kind
  25860. * - VertexBuffer.ColorKind
  25861. * - VertexBuffer.MatricesIndicesKind
  25862. * - VertexBuffer.MatricesIndicesExtraKind
  25863. * - VertexBuffer.MatricesWeightsKind
  25864. * - VertexBuffer.MatricesWeightsExtraKind
  25865. * @param data defines the data source
  25866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25867. * @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)
  25868. */
  25869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25870. /**
  25871. * Creates a new index buffer
  25872. * @param indices defines the indices to store in the index buffer
  25873. * @param totalVertices defines the total number of vertices (could be null)
  25874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25875. */
  25876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25877. }
  25878. /**
  25879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25880. */
  25881. export class VertexData {
  25882. /**
  25883. * Mesh side orientation : usually the external or front surface
  25884. */
  25885. static readonly FRONTSIDE: number;
  25886. /**
  25887. * Mesh side orientation : usually the internal or back surface
  25888. */
  25889. static readonly BACKSIDE: number;
  25890. /**
  25891. * Mesh side orientation : both internal and external or front and back surfaces
  25892. */
  25893. static readonly DOUBLESIDE: number;
  25894. /**
  25895. * Mesh side orientation : by default, `FRONTSIDE`
  25896. */
  25897. static readonly DEFAULTSIDE: number;
  25898. /**
  25899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25900. */
  25901. positions: Nullable<FloatArray>;
  25902. /**
  25903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25904. */
  25905. normals: Nullable<FloatArray>;
  25906. /**
  25907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25908. */
  25909. tangents: Nullable<FloatArray>;
  25910. /**
  25911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25912. */
  25913. uvs: Nullable<FloatArray>;
  25914. /**
  25915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25916. */
  25917. uvs2: Nullable<FloatArray>;
  25918. /**
  25919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25920. */
  25921. uvs3: Nullable<FloatArray>;
  25922. /**
  25923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25924. */
  25925. uvs4: Nullable<FloatArray>;
  25926. /**
  25927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25928. */
  25929. uvs5: Nullable<FloatArray>;
  25930. /**
  25931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25932. */
  25933. uvs6: Nullable<FloatArray>;
  25934. /**
  25935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25936. */
  25937. colors: Nullable<FloatArray>;
  25938. /**
  25939. * 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).
  25940. */
  25941. matricesIndices: Nullable<FloatArray>;
  25942. /**
  25943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25944. */
  25945. matricesWeights: Nullable<FloatArray>;
  25946. /**
  25947. * An array extending the number of possible indices
  25948. */
  25949. matricesIndicesExtra: Nullable<FloatArray>;
  25950. /**
  25951. * An array extending the number of possible weights when the number of indices is extended
  25952. */
  25953. matricesWeightsExtra: Nullable<FloatArray>;
  25954. /**
  25955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25956. */
  25957. indices: Nullable<IndicesArray>;
  25958. /**
  25959. * Uses the passed data array to set the set the values for the specified kind of data
  25960. * @param data a linear array of floating numbers
  25961. * @param kind the type of data that is being set, eg positions, colors etc
  25962. */
  25963. set(data: FloatArray, kind: string): void;
  25964. /**
  25965. * Associates the vertexData to the passed Mesh.
  25966. * Sets it as updatable or not (default `false`)
  25967. * @param mesh the mesh the vertexData is applied to
  25968. * @param updatable when used and having the value true allows new data to update the vertexData
  25969. * @returns the VertexData
  25970. */
  25971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25972. /**
  25973. * Associates the vertexData to the passed Geometry.
  25974. * Sets it as updatable or not (default `false`)
  25975. * @param geometry the geometry the vertexData is applied to
  25976. * @param updatable when used and having the value true allows new data to update the vertexData
  25977. * @returns VertexData
  25978. */
  25979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25980. /**
  25981. * Updates the associated mesh
  25982. * @param mesh the mesh to be updated
  25983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25984. * @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
  25985. * @returns VertexData
  25986. */
  25987. updateMesh(mesh: Mesh): VertexData;
  25988. /**
  25989. * Updates the associated geometry
  25990. * @param geometry the geometry to be updated
  25991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25992. * @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
  25993. * @returns VertexData.
  25994. */
  25995. updateGeometry(geometry: Geometry): VertexData;
  25996. private _applyTo;
  25997. private _update;
  25998. /**
  25999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26000. * @param matrix the transforming matrix
  26001. * @returns the VertexData
  26002. */
  26003. transform(matrix: Matrix): VertexData;
  26004. /**
  26005. * Merges the passed VertexData into the current one
  26006. * @param other the VertexData to be merged into the current one
  26007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26008. * @returns the modified VertexData
  26009. */
  26010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26011. private _mergeElement;
  26012. private _validate;
  26013. /**
  26014. * Serializes the VertexData
  26015. * @returns a serialized object
  26016. */
  26017. serialize(): any;
  26018. /**
  26019. * Extracts the vertexData from a mesh
  26020. * @param mesh the mesh from which to extract the VertexData
  26021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26023. * @returns the object VertexData associated to the passed mesh
  26024. */
  26025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26026. /**
  26027. * Extracts the vertexData from the geometry
  26028. * @param geometry the geometry from which to extract the VertexData
  26029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26031. * @returns the object VertexData associated to the passed mesh
  26032. */
  26033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26034. private static _ExtractFrom;
  26035. /**
  26036. * Creates the VertexData for a Ribbon
  26037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26038. * * pathArray array of paths, each of which an array of successive Vector3
  26039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26041. * * 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
  26042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26043. * * 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)
  26044. * * 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)
  26045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26048. * @returns the VertexData of the ribbon
  26049. */
  26050. static CreateRibbon(options: {
  26051. pathArray: Vector3[][];
  26052. closeArray?: boolean;
  26053. closePath?: boolean;
  26054. offset?: number;
  26055. sideOrientation?: number;
  26056. frontUVs?: Vector4;
  26057. backUVs?: Vector4;
  26058. invertUV?: boolean;
  26059. uvs?: Vector2[];
  26060. colors?: Color4[];
  26061. }): VertexData;
  26062. /**
  26063. * Creates the VertexData for a box
  26064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26072. * * 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)
  26073. * * 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)
  26074. * @returns the VertexData of the box
  26075. */
  26076. static CreateBox(options: {
  26077. size?: number;
  26078. width?: number;
  26079. height?: number;
  26080. depth?: number;
  26081. faceUV?: Vector4[];
  26082. faceColors?: Color4[];
  26083. sideOrientation?: number;
  26084. frontUVs?: Vector4;
  26085. backUVs?: Vector4;
  26086. }): VertexData;
  26087. /**
  26088. * Creates the VertexData for a tiled box
  26089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26094. * @returns the VertexData of the box
  26095. */
  26096. static CreateTiledBox(options: {
  26097. pattern?: number;
  26098. width?: number;
  26099. height?: number;
  26100. depth?: number;
  26101. tileSize?: number;
  26102. tileWidth?: number;
  26103. tileHeight?: number;
  26104. alignHorizontal?: number;
  26105. alignVertical?: number;
  26106. faceUV?: Vector4[];
  26107. faceColors?: Color4[];
  26108. sideOrientation?: number;
  26109. }): VertexData;
  26110. /**
  26111. * Creates the VertexData for a tiled plane
  26112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26113. * * pattern a limited pattern arrangement depending on the number
  26114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26118. * * 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)
  26119. * * 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)
  26120. * @returns the VertexData of the tiled plane
  26121. */
  26122. static CreateTiledPlane(options: {
  26123. pattern?: number;
  26124. tileSize?: number;
  26125. tileWidth?: number;
  26126. tileHeight?: number;
  26127. size?: number;
  26128. width?: number;
  26129. height?: number;
  26130. alignHorizontal?: number;
  26131. alignVertical?: number;
  26132. sideOrientation?: number;
  26133. frontUVs?: Vector4;
  26134. backUVs?: Vector4;
  26135. }): VertexData;
  26136. /**
  26137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26139. * * segments sets the number of horizontal strips optional, default 32
  26140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26144. * * 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
  26145. * * 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
  26146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26147. * * 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)
  26148. * * 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)
  26149. * @returns the VertexData of the ellipsoid
  26150. */
  26151. static CreateSphere(options: {
  26152. segments?: number;
  26153. diameter?: number;
  26154. diameterX?: number;
  26155. diameterY?: number;
  26156. diameterZ?: number;
  26157. arc?: number;
  26158. slice?: number;
  26159. sideOrientation?: number;
  26160. frontUVs?: Vector4;
  26161. backUVs?: Vector4;
  26162. }): VertexData;
  26163. /**
  26164. * Creates the VertexData for a cylinder, cone or prism
  26165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26166. * * height sets the height (y direction) of the cylinder, optional, default 2
  26167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26172. * * 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
  26173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26178. * * 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)
  26179. * * 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)
  26180. * @returns the VertexData of the cylinder, cone or prism
  26181. */
  26182. static CreateCylinder(options: {
  26183. height?: number;
  26184. diameterTop?: number;
  26185. diameterBottom?: number;
  26186. diameter?: number;
  26187. tessellation?: number;
  26188. subdivisions?: number;
  26189. arc?: number;
  26190. faceColors?: Color4[];
  26191. faceUV?: Vector4[];
  26192. hasRings?: boolean;
  26193. enclose?: boolean;
  26194. sideOrientation?: number;
  26195. frontUVs?: Vector4;
  26196. backUVs?: Vector4;
  26197. }): VertexData;
  26198. /**
  26199. * Creates the VertexData for a torus
  26200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26201. * * diameter the diameter of the torus, optional default 1
  26202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26205. * * 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)
  26206. * * 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)
  26207. * @returns the VertexData of the torus
  26208. */
  26209. static CreateTorus(options: {
  26210. diameter?: number;
  26211. thickness?: number;
  26212. tessellation?: number;
  26213. sideOrientation?: number;
  26214. frontUVs?: Vector4;
  26215. backUVs?: Vector4;
  26216. }): VertexData;
  26217. /**
  26218. * Creates the VertexData of the LineSystem
  26219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26220. * - lines an array of lines, each line being an array of successive Vector3
  26221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26222. * @returns the VertexData of the LineSystem
  26223. */
  26224. static CreateLineSystem(options: {
  26225. lines: Vector3[][];
  26226. colors?: Nullable<Color4[][]>;
  26227. }): VertexData;
  26228. /**
  26229. * Create the VertexData for a DashedLines
  26230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26231. * - points an array successive Vector3
  26232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26234. * - dashNb the intended total number of dashes, optional, default 200
  26235. * @returns the VertexData for the DashedLines
  26236. */
  26237. static CreateDashedLines(options: {
  26238. points: Vector3[];
  26239. dashSize?: number;
  26240. gapSize?: number;
  26241. dashNb?: number;
  26242. }): VertexData;
  26243. /**
  26244. * Creates the VertexData for a Ground
  26245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26246. * - width the width (x direction) of the ground, optional, default 1
  26247. * - height the height (z direction) of the ground, optional, default 1
  26248. * - subdivisions the number of subdivisions per side, optional, default 1
  26249. * @returns the VertexData of the Ground
  26250. */
  26251. static CreateGround(options: {
  26252. width?: number;
  26253. height?: number;
  26254. subdivisions?: number;
  26255. subdivisionsX?: number;
  26256. subdivisionsY?: number;
  26257. }): VertexData;
  26258. /**
  26259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26261. * * xmin the ground minimum X coordinate, optional, default -1
  26262. * * zmin the ground minimum Z coordinate, optional, default -1
  26263. * * xmax the ground maximum X coordinate, optional, default 1
  26264. * * zmax the ground maximum Z coordinate, optional, default 1
  26265. * * 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}
  26266. * * 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}
  26267. * @returns the VertexData of the TiledGround
  26268. */
  26269. static CreateTiledGround(options: {
  26270. xmin: number;
  26271. zmin: number;
  26272. xmax: number;
  26273. zmax: number;
  26274. subdivisions?: {
  26275. w: number;
  26276. h: number;
  26277. };
  26278. precision?: {
  26279. w: number;
  26280. h: number;
  26281. };
  26282. }): VertexData;
  26283. /**
  26284. * Creates the VertexData of the Ground designed from a heightmap
  26285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26286. * * width the width (x direction) of the ground
  26287. * * height the height (z direction) of the ground
  26288. * * subdivisions the number of subdivisions per side
  26289. * * minHeight the minimum altitude on the ground, optional, default 0
  26290. * * maxHeight the maximum altitude on the ground, optional default 1
  26291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26292. * * buffer the array holding the image color data
  26293. * * bufferWidth the width of image
  26294. * * bufferHeight the height of image
  26295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26296. * @returns the VertexData of the Ground designed from a heightmap
  26297. */
  26298. static CreateGroundFromHeightMap(options: {
  26299. width: number;
  26300. height: number;
  26301. subdivisions: number;
  26302. minHeight: number;
  26303. maxHeight: number;
  26304. colorFilter: Color3;
  26305. buffer: Uint8Array;
  26306. bufferWidth: number;
  26307. bufferHeight: number;
  26308. alphaFilter: number;
  26309. }): VertexData;
  26310. /**
  26311. * Creates the VertexData for a Plane
  26312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26313. * * size sets the width and height of the plane to the value of size, optional default 1
  26314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26317. * * 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)
  26318. * * 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)
  26319. * @returns the VertexData of the box
  26320. */
  26321. static CreatePlane(options: {
  26322. size?: number;
  26323. width?: number;
  26324. height?: number;
  26325. sideOrientation?: number;
  26326. frontUVs?: Vector4;
  26327. backUVs?: Vector4;
  26328. }): VertexData;
  26329. /**
  26330. * Creates the VertexData of the Disc or regular Polygon
  26331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26332. * * radius the radius of the disc, optional default 0.5
  26333. * * tessellation the number of polygon sides, optional, default 64
  26334. * * 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
  26335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26336. * * 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)
  26337. * * 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)
  26338. * @returns the VertexData of the box
  26339. */
  26340. static CreateDisc(options: {
  26341. radius?: number;
  26342. tessellation?: number;
  26343. arc?: number;
  26344. sideOrientation?: number;
  26345. frontUVs?: Vector4;
  26346. backUVs?: Vector4;
  26347. }): VertexData;
  26348. /**
  26349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26351. * @param polygon a mesh built from polygonTriangulation.build()
  26352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26355. * @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)
  26356. * @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)
  26357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26358. * @returns the VertexData of the Polygon
  26359. */
  26360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26361. /**
  26362. * Creates the VertexData of the IcoSphere
  26363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26364. * * radius the radius of the IcoSphere, optional default 1
  26365. * * radiusX allows stretching in the x direction, optional, default radius
  26366. * * radiusY allows stretching in the y direction, optional, default radius
  26367. * * radiusZ allows stretching in the z direction, optional, default radius
  26368. * * flat when true creates a flat shaded mesh, optional, default true
  26369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26371. * * 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)
  26372. * * 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)
  26373. * @returns the VertexData of the IcoSphere
  26374. */
  26375. static CreateIcoSphere(options: {
  26376. radius?: number;
  26377. radiusX?: number;
  26378. radiusY?: number;
  26379. radiusZ?: number;
  26380. flat?: boolean;
  26381. subdivisions?: number;
  26382. sideOrientation?: number;
  26383. frontUVs?: Vector4;
  26384. backUVs?: Vector4;
  26385. }): VertexData;
  26386. /**
  26387. * Creates the VertexData for a Polyhedron
  26388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26389. * * type provided types are:
  26390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26391. * * 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)
  26392. * * size the size of the IcoSphere, optional default 1
  26393. * * sizeX allows stretching in the x direction, optional, default size
  26394. * * sizeY allows stretching in the y direction, optional, default size
  26395. * * sizeZ allows stretching in the z direction, optional, default size
  26396. * * 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
  26397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26399. * * flat when true creates a flat shaded mesh, optional, default true
  26400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26402. * * 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)
  26403. * * 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)
  26404. * @returns the VertexData of the Polyhedron
  26405. */
  26406. static CreatePolyhedron(options: {
  26407. type?: number;
  26408. size?: number;
  26409. sizeX?: number;
  26410. sizeY?: number;
  26411. sizeZ?: number;
  26412. custom?: any;
  26413. faceUV?: Vector4[];
  26414. faceColors?: Color4[];
  26415. flat?: boolean;
  26416. sideOrientation?: number;
  26417. frontUVs?: Vector4;
  26418. backUVs?: Vector4;
  26419. }): VertexData;
  26420. /**
  26421. * Creates the VertexData for a TorusKnot
  26422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26423. * * radius the radius of the torus knot, optional, default 2
  26424. * * tube the thickness of the tube, optional, default 0.5
  26425. * * radialSegments the number of sides on each tube segments, optional, default 32
  26426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26427. * * p the number of windings around the z axis, optional, default 2
  26428. * * q the number of windings around the x axis, optional, default 3
  26429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26430. * * 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)
  26431. * * 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)
  26432. * @returns the VertexData of the Torus Knot
  26433. */
  26434. static CreateTorusKnot(options: {
  26435. radius?: number;
  26436. tube?: number;
  26437. radialSegments?: number;
  26438. tubularSegments?: number;
  26439. p?: number;
  26440. q?: number;
  26441. sideOrientation?: number;
  26442. frontUVs?: Vector4;
  26443. backUVs?: Vector4;
  26444. }): VertexData;
  26445. /**
  26446. * Compute normals for given positions and indices
  26447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26451. * * facetNormals : optional array of facet normals (vector3)
  26452. * * facetPositions : optional array of facet positions (vector3)
  26453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26455. * * bInfo : optional bounding info, required for facetPartitioning computation
  26456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26458. * * useRightHandedSystem: optional boolean to for right handed system computation
  26459. * * depthSort : optional boolean to enable the facet depth sort computation
  26460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26462. */
  26463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26464. facetNormals?: any;
  26465. facetPositions?: any;
  26466. facetPartitioning?: any;
  26467. ratio?: number;
  26468. bInfo?: any;
  26469. bbSize?: Vector3;
  26470. subDiv?: any;
  26471. useRightHandedSystem?: boolean;
  26472. depthSort?: boolean;
  26473. distanceTo?: Vector3;
  26474. depthSortedFacets?: any;
  26475. }): void;
  26476. /** @hidden */
  26477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26478. /**
  26479. * Applies VertexData created from the imported parameters to the geometry
  26480. * @param parsedVertexData the parsed data from an imported file
  26481. * @param geometry the geometry to apply the VertexData to
  26482. */
  26483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26484. }
  26485. }
  26486. declare module "babylonjs/Morph/morphTarget" {
  26487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26488. import { Observable } from "babylonjs/Misc/observable";
  26489. import { Nullable, FloatArray } from "babylonjs/types";
  26490. import { Scene } from "babylonjs/scene";
  26491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26493. /**
  26494. * Defines a target to use with MorphTargetManager
  26495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26496. */
  26497. export class MorphTarget implements IAnimatable {
  26498. /** defines the name of the target */
  26499. name: string;
  26500. /**
  26501. * Gets or sets the list of animations
  26502. */
  26503. animations: import("babylonjs/Animations/animation").Animation[];
  26504. private _scene;
  26505. private _positions;
  26506. private _normals;
  26507. private _tangents;
  26508. private _uvs;
  26509. private _influence;
  26510. private _uniqueId;
  26511. /**
  26512. * Observable raised when the influence changes
  26513. */
  26514. onInfluenceChanged: Observable<boolean>;
  26515. /** @hidden */
  26516. _onDataLayoutChanged: Observable<void>;
  26517. /**
  26518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26519. */
  26520. get influence(): number;
  26521. set influence(influence: number);
  26522. /**
  26523. * Gets or sets the id of the morph Target
  26524. */
  26525. id: string;
  26526. private _animationPropertiesOverride;
  26527. /**
  26528. * Gets or sets the animation properties override
  26529. */
  26530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26532. /**
  26533. * Creates a new MorphTarget
  26534. * @param name defines the name of the target
  26535. * @param influence defines the influence to use
  26536. * @param scene defines the scene the morphtarget belongs to
  26537. */
  26538. constructor(
  26539. /** defines the name of the target */
  26540. name: string, influence?: number, scene?: Nullable<Scene>);
  26541. /**
  26542. * Gets the unique ID of this manager
  26543. */
  26544. get uniqueId(): number;
  26545. /**
  26546. * Gets a boolean defining if the target contains position data
  26547. */
  26548. get hasPositions(): boolean;
  26549. /**
  26550. * Gets a boolean defining if the target contains normal data
  26551. */
  26552. get hasNormals(): boolean;
  26553. /**
  26554. * Gets a boolean defining if the target contains tangent data
  26555. */
  26556. get hasTangents(): boolean;
  26557. /**
  26558. * Gets a boolean defining if the target contains texture coordinates data
  26559. */
  26560. get hasUVs(): boolean;
  26561. /**
  26562. * Affects position data to this target
  26563. * @param data defines the position data to use
  26564. */
  26565. setPositions(data: Nullable<FloatArray>): void;
  26566. /**
  26567. * Gets the position data stored in this target
  26568. * @returns a FloatArray containing the position data (or null if not present)
  26569. */
  26570. getPositions(): Nullable<FloatArray>;
  26571. /**
  26572. * Affects normal data to this target
  26573. * @param data defines the normal data to use
  26574. */
  26575. setNormals(data: Nullable<FloatArray>): void;
  26576. /**
  26577. * Gets the normal data stored in this target
  26578. * @returns a FloatArray containing the normal data (or null if not present)
  26579. */
  26580. getNormals(): Nullable<FloatArray>;
  26581. /**
  26582. * Affects tangent data to this target
  26583. * @param data defines the tangent data to use
  26584. */
  26585. setTangents(data: Nullable<FloatArray>): void;
  26586. /**
  26587. * Gets the tangent data stored in this target
  26588. * @returns a FloatArray containing the tangent data (or null if not present)
  26589. */
  26590. getTangents(): Nullable<FloatArray>;
  26591. /**
  26592. * Affects texture coordinates data to this target
  26593. * @param data defines the texture coordinates data to use
  26594. */
  26595. setUVs(data: Nullable<FloatArray>): void;
  26596. /**
  26597. * Gets the texture coordinates data stored in this target
  26598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26599. */
  26600. getUVs(): Nullable<FloatArray>;
  26601. /**
  26602. * Clone the current target
  26603. * @returns a new MorphTarget
  26604. */
  26605. clone(): MorphTarget;
  26606. /**
  26607. * Serializes the current target into a Serialization object
  26608. * @returns the serialized object
  26609. */
  26610. serialize(): any;
  26611. /**
  26612. * Returns the string "MorphTarget"
  26613. * @returns "MorphTarget"
  26614. */
  26615. getClassName(): string;
  26616. /**
  26617. * Creates a new target from serialized data
  26618. * @param serializationObject defines the serialized data to use
  26619. * @returns a new MorphTarget
  26620. */
  26621. static Parse(serializationObject: any): MorphTarget;
  26622. /**
  26623. * Creates a MorphTarget from mesh data
  26624. * @param mesh defines the source mesh
  26625. * @param name defines the name to use for the new target
  26626. * @param influence defines the influence to attach to the target
  26627. * @returns a new MorphTarget
  26628. */
  26629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26630. }
  26631. }
  26632. declare module "babylonjs/Morph/morphTargetManager" {
  26633. import { Nullable } from "babylonjs/types";
  26634. import { Scene } from "babylonjs/scene";
  26635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26636. /**
  26637. * This class is used to deform meshes using morphing between different targets
  26638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26639. */
  26640. export class MorphTargetManager {
  26641. private _targets;
  26642. private _targetInfluenceChangedObservers;
  26643. private _targetDataLayoutChangedObservers;
  26644. private _activeTargets;
  26645. private _scene;
  26646. private _influences;
  26647. private _supportsNormals;
  26648. private _supportsTangents;
  26649. private _supportsUVs;
  26650. private _vertexCount;
  26651. private _uniqueId;
  26652. private _tempInfluences;
  26653. /**
  26654. * Gets or sets a boolean indicating if normals must be morphed
  26655. */
  26656. enableNormalMorphing: boolean;
  26657. /**
  26658. * Gets or sets a boolean indicating if tangents must be morphed
  26659. */
  26660. enableTangentMorphing: boolean;
  26661. /**
  26662. * Gets or sets a boolean indicating if UV must be morphed
  26663. */
  26664. enableUVMorphing: boolean;
  26665. /**
  26666. * Creates a new MorphTargetManager
  26667. * @param scene defines the current scene
  26668. */
  26669. constructor(scene?: Nullable<Scene>);
  26670. /**
  26671. * Gets the unique ID of this manager
  26672. */
  26673. get uniqueId(): number;
  26674. /**
  26675. * Gets the number of vertices handled by this manager
  26676. */
  26677. get vertexCount(): number;
  26678. /**
  26679. * Gets a boolean indicating if this manager supports morphing of normals
  26680. */
  26681. get supportsNormals(): boolean;
  26682. /**
  26683. * Gets a boolean indicating if this manager supports morphing of tangents
  26684. */
  26685. get supportsTangents(): boolean;
  26686. /**
  26687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26688. */
  26689. get supportsUVs(): boolean;
  26690. /**
  26691. * Gets the number of targets stored in this manager
  26692. */
  26693. get numTargets(): number;
  26694. /**
  26695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26696. */
  26697. get numInfluencers(): number;
  26698. /**
  26699. * Gets the list of influences (one per target)
  26700. */
  26701. get influences(): Float32Array;
  26702. /**
  26703. * Gets the active target at specified index. An active target is a target with an influence > 0
  26704. * @param index defines the index to check
  26705. * @returns the requested target
  26706. */
  26707. getActiveTarget(index: number): MorphTarget;
  26708. /**
  26709. * Gets the target at specified index
  26710. * @param index defines the index to check
  26711. * @returns the requested target
  26712. */
  26713. getTarget(index: number): MorphTarget;
  26714. /**
  26715. * Add a new target to this manager
  26716. * @param target defines the target to add
  26717. */
  26718. addTarget(target: MorphTarget): void;
  26719. /**
  26720. * Removes a target from the manager
  26721. * @param target defines the target to remove
  26722. */
  26723. removeTarget(target: MorphTarget): void;
  26724. /**
  26725. * Clone the current manager
  26726. * @returns a new MorphTargetManager
  26727. */
  26728. clone(): MorphTargetManager;
  26729. /**
  26730. * Serializes the current manager into a Serialization object
  26731. * @returns the serialized object
  26732. */
  26733. serialize(): any;
  26734. private _syncActiveTargets;
  26735. /**
  26736. * Syncrhonize the targets with all the meshes using this morph target manager
  26737. */
  26738. synchronize(): void;
  26739. /**
  26740. * Creates a new MorphTargetManager from serialized data
  26741. * @param serializationObject defines the serialized data
  26742. * @param scene defines the hosting scene
  26743. * @returns the new MorphTargetManager
  26744. */
  26745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26746. }
  26747. }
  26748. declare module "babylonjs/Meshes/meshLODLevel" {
  26749. import { Mesh } from "babylonjs/Meshes/mesh";
  26750. import { Nullable } from "babylonjs/types";
  26751. /**
  26752. * Class used to represent a specific level of detail of a mesh
  26753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26754. */
  26755. export class MeshLODLevel {
  26756. /** Defines the distance where this level should start being displayed */
  26757. distance: number;
  26758. /** Defines the mesh to use to render this level */
  26759. mesh: Nullable<Mesh>;
  26760. /**
  26761. * Creates a new LOD level
  26762. * @param distance defines the distance where this level should star being displayed
  26763. * @param mesh defines the mesh to use to render this level
  26764. */
  26765. constructor(
  26766. /** Defines the distance where this level should start being displayed */
  26767. distance: number,
  26768. /** Defines the mesh to use to render this level */
  26769. mesh: Nullable<Mesh>);
  26770. }
  26771. }
  26772. declare module "babylonjs/Misc/canvasGenerator" {
  26773. /**
  26774. * Helper class used to generate a canvas to manipulate images
  26775. */
  26776. export class CanvasGenerator {
  26777. /**
  26778. * Create a new canvas (or offscreen canvas depending on the context)
  26779. * @param width defines the expected width
  26780. * @param height defines the expected height
  26781. * @return a new canvas or offscreen canvas
  26782. */
  26783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26784. }
  26785. }
  26786. declare module "babylonjs/Meshes/groundMesh" {
  26787. import { Scene } from "babylonjs/scene";
  26788. import { Vector3 } from "babylonjs/Maths/math.vector";
  26789. import { Mesh } from "babylonjs/Meshes/mesh";
  26790. /**
  26791. * Mesh representing the gorund
  26792. */
  26793. export class GroundMesh extends Mesh {
  26794. /** If octree should be generated */
  26795. generateOctree: boolean;
  26796. private _heightQuads;
  26797. /** @hidden */
  26798. _subdivisionsX: number;
  26799. /** @hidden */
  26800. _subdivisionsY: number;
  26801. /** @hidden */
  26802. _width: number;
  26803. /** @hidden */
  26804. _height: number;
  26805. /** @hidden */
  26806. _minX: number;
  26807. /** @hidden */
  26808. _maxX: number;
  26809. /** @hidden */
  26810. _minZ: number;
  26811. /** @hidden */
  26812. _maxZ: number;
  26813. constructor(name: string, scene: Scene);
  26814. /**
  26815. * "GroundMesh"
  26816. * @returns "GroundMesh"
  26817. */
  26818. getClassName(): string;
  26819. /**
  26820. * The minimum of x and y subdivisions
  26821. */
  26822. get subdivisions(): number;
  26823. /**
  26824. * X subdivisions
  26825. */
  26826. get subdivisionsX(): number;
  26827. /**
  26828. * Y subdivisions
  26829. */
  26830. get subdivisionsY(): number;
  26831. /**
  26832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26834. * @param chunksCount the number of subdivisions for x and y
  26835. * @param octreeBlocksSize (Default: 32)
  26836. */
  26837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26838. /**
  26839. * Returns a height (y) value in the Worl system :
  26840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26841. * @param x x coordinate
  26842. * @param z z coordinate
  26843. * @returns the ground y position if (x, z) are outside the ground surface.
  26844. */
  26845. getHeightAtCoordinates(x: number, z: number): number;
  26846. /**
  26847. * Returns a normalized vector (Vector3) orthogonal to the ground
  26848. * at the ground coordinates (x, z) expressed in the World system.
  26849. * @param x x coordinate
  26850. * @param z z coordinate
  26851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26852. */
  26853. getNormalAtCoordinates(x: number, z: number): Vector3;
  26854. /**
  26855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26856. * at the ground coordinates (x, z) expressed in the World system.
  26857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26858. * @param x x coordinate
  26859. * @param z z coordinate
  26860. * @param ref vector to store the result
  26861. * @returns the GroundMesh.
  26862. */
  26863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26864. /**
  26865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26866. * if the ground has been updated.
  26867. * This can be used in the render loop.
  26868. * @returns the GroundMesh.
  26869. */
  26870. updateCoordinateHeights(): GroundMesh;
  26871. private _getFacetAt;
  26872. private _initHeightQuads;
  26873. private _computeHeightQuads;
  26874. /**
  26875. * Serializes this ground mesh
  26876. * @param serializationObject object to write serialization to
  26877. */
  26878. serialize(serializationObject: any): void;
  26879. /**
  26880. * Parses a serialized ground mesh
  26881. * @param parsedMesh the serialized mesh
  26882. * @param scene the scene to create the ground mesh in
  26883. * @returns the created ground mesh
  26884. */
  26885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26886. }
  26887. }
  26888. declare module "babylonjs/Physics/physicsJoint" {
  26889. import { Vector3 } from "babylonjs/Maths/math.vector";
  26890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26891. /**
  26892. * Interface for Physics-Joint data
  26893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26894. */
  26895. export interface PhysicsJointData {
  26896. /**
  26897. * The main pivot of the joint
  26898. */
  26899. mainPivot?: Vector3;
  26900. /**
  26901. * The connected pivot of the joint
  26902. */
  26903. connectedPivot?: Vector3;
  26904. /**
  26905. * The main axis of the joint
  26906. */
  26907. mainAxis?: Vector3;
  26908. /**
  26909. * The connected axis of the joint
  26910. */
  26911. connectedAxis?: Vector3;
  26912. /**
  26913. * The collision of the joint
  26914. */
  26915. collision?: boolean;
  26916. /**
  26917. * Native Oimo/Cannon/Energy data
  26918. */
  26919. nativeParams?: any;
  26920. }
  26921. /**
  26922. * This is a holder class for the physics joint created by the physics plugin
  26923. * It holds a set of functions to control the underlying joint
  26924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26925. */
  26926. export class PhysicsJoint {
  26927. /**
  26928. * The type of the physics joint
  26929. */
  26930. type: number;
  26931. /**
  26932. * The data for the physics joint
  26933. */
  26934. jointData: PhysicsJointData;
  26935. private _physicsJoint;
  26936. protected _physicsPlugin: IPhysicsEnginePlugin;
  26937. /**
  26938. * Initializes the physics joint
  26939. * @param type The type of the physics joint
  26940. * @param jointData The data for the physics joint
  26941. */
  26942. constructor(
  26943. /**
  26944. * The type of the physics joint
  26945. */
  26946. type: number,
  26947. /**
  26948. * The data for the physics joint
  26949. */
  26950. jointData: PhysicsJointData);
  26951. /**
  26952. * Gets the physics joint
  26953. */
  26954. get physicsJoint(): any;
  26955. /**
  26956. * Sets the physics joint
  26957. */
  26958. set physicsJoint(newJoint: any);
  26959. /**
  26960. * Sets the physics plugin
  26961. */
  26962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26963. /**
  26964. * Execute a function that is physics-plugin specific.
  26965. * @param {Function} func the function that will be executed.
  26966. * It accepts two parameters: the physics world and the physics joint
  26967. */
  26968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26969. /**
  26970. * Distance-Joint type
  26971. */
  26972. static DistanceJoint: number;
  26973. /**
  26974. * Hinge-Joint type
  26975. */
  26976. static HingeJoint: number;
  26977. /**
  26978. * Ball-and-Socket joint type
  26979. */
  26980. static BallAndSocketJoint: number;
  26981. /**
  26982. * Wheel-Joint type
  26983. */
  26984. static WheelJoint: number;
  26985. /**
  26986. * Slider-Joint type
  26987. */
  26988. static SliderJoint: number;
  26989. /**
  26990. * Prismatic-Joint type
  26991. */
  26992. static PrismaticJoint: number;
  26993. /**
  26994. * Universal-Joint type
  26995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26996. */
  26997. static UniversalJoint: number;
  26998. /**
  26999. * Hinge-Joint 2 type
  27000. */
  27001. static Hinge2Joint: number;
  27002. /**
  27003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27004. */
  27005. static PointToPointJoint: number;
  27006. /**
  27007. * Spring-Joint type
  27008. */
  27009. static SpringJoint: number;
  27010. /**
  27011. * Lock-Joint type
  27012. */
  27013. static LockJoint: number;
  27014. }
  27015. /**
  27016. * A class representing a physics distance joint
  27017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27018. */
  27019. export class DistanceJoint extends PhysicsJoint {
  27020. /**
  27021. *
  27022. * @param jointData The data for the Distance-Joint
  27023. */
  27024. constructor(jointData: DistanceJointData);
  27025. /**
  27026. * Update the predefined distance.
  27027. * @param maxDistance The maximum preferred distance
  27028. * @param minDistance The minimum preferred distance
  27029. */
  27030. updateDistance(maxDistance: number, minDistance?: number): void;
  27031. }
  27032. /**
  27033. * Represents a Motor-Enabled Joint
  27034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27035. */
  27036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27037. /**
  27038. * Initializes the Motor-Enabled Joint
  27039. * @param type The type of the joint
  27040. * @param jointData The physica joint data for the joint
  27041. */
  27042. constructor(type: number, jointData: PhysicsJointData);
  27043. /**
  27044. * Set the motor values.
  27045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27046. * @param force the force to apply
  27047. * @param maxForce max force for this motor.
  27048. */
  27049. setMotor(force?: number, maxForce?: number): void;
  27050. /**
  27051. * Set the motor's limits.
  27052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27053. * @param upperLimit The upper limit of the motor
  27054. * @param lowerLimit The lower limit of the motor
  27055. */
  27056. setLimit(upperLimit: number, lowerLimit?: number): void;
  27057. }
  27058. /**
  27059. * This class represents a single physics Hinge-Joint
  27060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27061. */
  27062. export class HingeJoint extends MotorEnabledJoint {
  27063. /**
  27064. * Initializes the Hinge-Joint
  27065. * @param jointData The joint data for the Hinge-Joint
  27066. */
  27067. constructor(jointData: PhysicsJointData);
  27068. /**
  27069. * Set the motor values.
  27070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27071. * @param {number} force the force to apply
  27072. * @param {number} maxForce max force for this motor.
  27073. */
  27074. setMotor(force?: number, maxForce?: number): void;
  27075. /**
  27076. * Set the motor's limits.
  27077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27078. * @param upperLimit The upper limit of the motor
  27079. * @param lowerLimit The lower limit of the motor
  27080. */
  27081. setLimit(upperLimit: number, lowerLimit?: number): void;
  27082. }
  27083. /**
  27084. * This class represents a dual hinge physics joint (same as wheel joint)
  27085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27086. */
  27087. export class Hinge2Joint extends MotorEnabledJoint {
  27088. /**
  27089. * Initializes the Hinge2-Joint
  27090. * @param jointData The joint data for the Hinge2-Joint
  27091. */
  27092. constructor(jointData: PhysicsJointData);
  27093. /**
  27094. * Set the motor values.
  27095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27096. * @param {number} targetSpeed the speed the motor is to reach
  27097. * @param {number} maxForce max force for this motor.
  27098. * @param {motorIndex} the motor's index, 0 or 1.
  27099. */
  27100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27101. /**
  27102. * Set the motor limits.
  27103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27104. * @param {number} upperLimit the upper limit
  27105. * @param {number} lowerLimit lower limit
  27106. * @param {motorIndex} the motor's index, 0 or 1.
  27107. */
  27108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27109. }
  27110. /**
  27111. * Interface for a motor enabled joint
  27112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27113. */
  27114. export interface IMotorEnabledJoint {
  27115. /**
  27116. * Physics joint
  27117. */
  27118. physicsJoint: any;
  27119. /**
  27120. * Sets the motor of the motor-enabled joint
  27121. * @param force The force of the motor
  27122. * @param maxForce The maximum force of the motor
  27123. * @param motorIndex The index of the motor
  27124. */
  27125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27126. /**
  27127. * Sets the limit of the motor
  27128. * @param upperLimit The upper limit of the motor
  27129. * @param lowerLimit The lower limit of the motor
  27130. * @param motorIndex The index of the motor
  27131. */
  27132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27133. }
  27134. /**
  27135. * Joint data for a Distance-Joint
  27136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27137. */
  27138. export interface DistanceJointData extends PhysicsJointData {
  27139. /**
  27140. * Max distance the 2 joint objects can be apart
  27141. */
  27142. maxDistance: number;
  27143. }
  27144. /**
  27145. * Joint data from a spring joint
  27146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27147. */
  27148. export interface SpringJointData extends PhysicsJointData {
  27149. /**
  27150. * Length of the spring
  27151. */
  27152. length: number;
  27153. /**
  27154. * Stiffness of the spring
  27155. */
  27156. stiffness: number;
  27157. /**
  27158. * Damping of the spring
  27159. */
  27160. damping: number;
  27161. /** this callback will be called when applying the force to the impostors. */
  27162. forceApplicationCallback: () => void;
  27163. }
  27164. }
  27165. declare module "babylonjs/Physics/physicsRaycastResult" {
  27166. import { Vector3 } from "babylonjs/Maths/math.vector";
  27167. /**
  27168. * Holds the data for the raycast result
  27169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27170. */
  27171. export class PhysicsRaycastResult {
  27172. private _hasHit;
  27173. private _hitDistance;
  27174. private _hitNormalWorld;
  27175. private _hitPointWorld;
  27176. private _rayFromWorld;
  27177. private _rayToWorld;
  27178. /**
  27179. * Gets if there was a hit
  27180. */
  27181. get hasHit(): boolean;
  27182. /**
  27183. * Gets the distance from the hit
  27184. */
  27185. get hitDistance(): number;
  27186. /**
  27187. * Gets the hit normal/direction in the world
  27188. */
  27189. get hitNormalWorld(): Vector3;
  27190. /**
  27191. * Gets the hit point in the world
  27192. */
  27193. get hitPointWorld(): Vector3;
  27194. /**
  27195. * Gets the ray "start point" of the ray in the world
  27196. */
  27197. get rayFromWorld(): Vector3;
  27198. /**
  27199. * Gets the ray "end point" of the ray in the world
  27200. */
  27201. get rayToWorld(): Vector3;
  27202. /**
  27203. * Sets the hit data (normal & point in world space)
  27204. * @param hitNormalWorld defines the normal in world space
  27205. * @param hitPointWorld defines the point in world space
  27206. */
  27207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27208. /**
  27209. * Sets the distance from the start point to the hit point
  27210. * @param distance
  27211. */
  27212. setHitDistance(distance: number): void;
  27213. /**
  27214. * Calculates the distance manually
  27215. */
  27216. calculateHitDistance(): void;
  27217. /**
  27218. * Resets all the values to default
  27219. * @param from The from point on world space
  27220. * @param to The to point on world space
  27221. */
  27222. reset(from?: Vector3, to?: Vector3): void;
  27223. }
  27224. /**
  27225. * Interface for the size containing width and height
  27226. */
  27227. interface IXYZ {
  27228. /**
  27229. * X
  27230. */
  27231. x: number;
  27232. /**
  27233. * Y
  27234. */
  27235. y: number;
  27236. /**
  27237. * Z
  27238. */
  27239. z: number;
  27240. }
  27241. }
  27242. declare module "babylonjs/Physics/IPhysicsEngine" {
  27243. import { Nullable } from "babylonjs/types";
  27244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27249. /**
  27250. * Interface used to describe a physics joint
  27251. */
  27252. export interface PhysicsImpostorJoint {
  27253. /** Defines the main impostor to which the joint is linked */
  27254. mainImpostor: PhysicsImpostor;
  27255. /** Defines the impostor that is connected to the main impostor using this joint */
  27256. connectedImpostor: PhysicsImpostor;
  27257. /** Defines the joint itself */
  27258. joint: PhysicsJoint;
  27259. }
  27260. /** @hidden */
  27261. export interface IPhysicsEnginePlugin {
  27262. world: any;
  27263. name: string;
  27264. setGravity(gravity: Vector3): void;
  27265. setTimeStep(timeStep: number): void;
  27266. getTimeStep(): number;
  27267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27271. removePhysicsBody(impostor: PhysicsImpostor): void;
  27272. generateJoint(joint: PhysicsImpostorJoint): void;
  27273. removeJoint(joint: PhysicsImpostorJoint): void;
  27274. isSupported(): boolean;
  27275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27282. getBodyMass(impostor: PhysicsImpostor): number;
  27283. getBodyFriction(impostor: PhysicsImpostor): number;
  27284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27285. getBodyRestitution(impostor: PhysicsImpostor): number;
  27286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27287. getBodyPressure?(impostor: PhysicsImpostor): number;
  27288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27297. sleepBody(impostor: PhysicsImpostor): void;
  27298. wakeUpBody(impostor: PhysicsImpostor): void;
  27299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27303. getRadius(impostor: PhysicsImpostor): number;
  27304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27306. dispose(): void;
  27307. }
  27308. /**
  27309. * Interface used to define a physics engine
  27310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27311. */
  27312. export interface IPhysicsEngine {
  27313. /**
  27314. * Gets the gravity vector used by the simulation
  27315. */
  27316. gravity: Vector3;
  27317. /**
  27318. * Sets the gravity vector used by the simulation
  27319. * @param gravity defines the gravity vector to use
  27320. */
  27321. setGravity(gravity: Vector3): void;
  27322. /**
  27323. * Set the time step of the physics engine.
  27324. * Default is 1/60.
  27325. * To slow it down, enter 1/600 for example.
  27326. * To speed it up, 1/30
  27327. * @param newTimeStep the new timestep to apply to this world.
  27328. */
  27329. setTimeStep(newTimeStep: number): void;
  27330. /**
  27331. * Get the time step of the physics engine.
  27332. * @returns the current time step
  27333. */
  27334. getTimeStep(): number;
  27335. /**
  27336. * Set the sub time step of the physics engine.
  27337. * Default is 0 meaning there is no sub steps
  27338. * To increase physics resolution precision, set a small value (like 1 ms)
  27339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27340. */
  27341. setSubTimeStep(subTimeStep: number): void;
  27342. /**
  27343. * Get the sub time step of the physics engine.
  27344. * @returns the current sub time step
  27345. */
  27346. getSubTimeStep(): number;
  27347. /**
  27348. * Release all resources
  27349. */
  27350. dispose(): void;
  27351. /**
  27352. * Gets the name of the current physics plugin
  27353. * @returns the name of the plugin
  27354. */
  27355. getPhysicsPluginName(): string;
  27356. /**
  27357. * Adding a new impostor for the impostor tracking.
  27358. * This will be done by the impostor itself.
  27359. * @param impostor the impostor to add
  27360. */
  27361. addImpostor(impostor: PhysicsImpostor): void;
  27362. /**
  27363. * Remove an impostor from the engine.
  27364. * This impostor and its mesh will not longer be updated by the physics engine.
  27365. * @param impostor the impostor to remove
  27366. */
  27367. removeImpostor(impostor: PhysicsImpostor): void;
  27368. /**
  27369. * Add a joint to the physics engine
  27370. * @param mainImpostor defines the main impostor to which the joint is added.
  27371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27372. * @param joint defines the joint that will connect both impostors.
  27373. */
  27374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27375. /**
  27376. * Removes a joint from the simulation
  27377. * @param mainImpostor defines the impostor used with the joint
  27378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27379. * @param joint defines the joint to remove
  27380. */
  27381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27382. /**
  27383. * Gets the current plugin used to run the simulation
  27384. * @returns current plugin
  27385. */
  27386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27387. /**
  27388. * Gets the list of physic impostors
  27389. * @returns an array of PhysicsImpostor
  27390. */
  27391. getImpostors(): Array<PhysicsImpostor>;
  27392. /**
  27393. * Gets the impostor for a physics enabled object
  27394. * @param object defines the object impersonated by the impostor
  27395. * @returns the PhysicsImpostor or null if not found
  27396. */
  27397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27398. /**
  27399. * Gets the impostor for a physics body object
  27400. * @param body defines physics body used by the impostor
  27401. * @returns the PhysicsImpostor or null if not found
  27402. */
  27403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27404. /**
  27405. * Does a raycast in the physics world
  27406. * @param from when should the ray start?
  27407. * @param to when should the ray end?
  27408. * @returns PhysicsRaycastResult
  27409. */
  27410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27411. /**
  27412. * Called by the scene. No need to call it.
  27413. * @param delta defines the timespam between frames
  27414. */
  27415. _step(delta: number): void;
  27416. }
  27417. }
  27418. declare module "babylonjs/Physics/physicsImpostor" {
  27419. import { Nullable, IndicesArray } from "babylonjs/types";
  27420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27423. import { Scene } from "babylonjs/scene";
  27424. import { Bone } from "babylonjs/Bones/bone";
  27425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27427. import { Space } from "babylonjs/Maths/math.axis";
  27428. /**
  27429. * The interface for the physics imposter parameters
  27430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27431. */
  27432. export interface PhysicsImpostorParameters {
  27433. /**
  27434. * The mass of the physics imposter
  27435. */
  27436. mass: number;
  27437. /**
  27438. * The friction of the physics imposter
  27439. */
  27440. friction?: number;
  27441. /**
  27442. * The coefficient of restitution of the physics imposter
  27443. */
  27444. restitution?: number;
  27445. /**
  27446. * The native options of the physics imposter
  27447. */
  27448. nativeOptions?: any;
  27449. /**
  27450. * Specifies if the parent should be ignored
  27451. */
  27452. ignoreParent?: boolean;
  27453. /**
  27454. * Specifies if bi-directional transformations should be disabled
  27455. */
  27456. disableBidirectionalTransformation?: boolean;
  27457. /**
  27458. * The pressure inside the physics imposter, soft object only
  27459. */
  27460. pressure?: number;
  27461. /**
  27462. * The stiffness the physics imposter, soft object only
  27463. */
  27464. stiffness?: number;
  27465. /**
  27466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27467. */
  27468. velocityIterations?: number;
  27469. /**
  27470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27471. */
  27472. positionIterations?: number;
  27473. /**
  27474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27476. * Add to fix multiple points
  27477. */
  27478. fixedPoints?: number;
  27479. /**
  27480. * The collision margin around a soft object
  27481. */
  27482. margin?: number;
  27483. /**
  27484. * The collision margin around a soft object
  27485. */
  27486. damping?: number;
  27487. /**
  27488. * The path for a rope based on an extrusion
  27489. */
  27490. path?: any;
  27491. /**
  27492. * The shape of an extrusion used for a rope based on an extrusion
  27493. */
  27494. shape?: any;
  27495. }
  27496. /**
  27497. * Interface for a physics-enabled object
  27498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27499. */
  27500. export interface IPhysicsEnabledObject {
  27501. /**
  27502. * The position of the physics-enabled object
  27503. */
  27504. position: Vector3;
  27505. /**
  27506. * The rotation of the physics-enabled object
  27507. */
  27508. rotationQuaternion: Nullable<Quaternion>;
  27509. /**
  27510. * The scale of the physics-enabled object
  27511. */
  27512. scaling: Vector3;
  27513. /**
  27514. * The rotation of the physics-enabled object
  27515. */
  27516. rotation?: Vector3;
  27517. /**
  27518. * The parent of the physics-enabled object
  27519. */
  27520. parent?: any;
  27521. /**
  27522. * The bounding info of the physics-enabled object
  27523. * @returns The bounding info of the physics-enabled object
  27524. */
  27525. getBoundingInfo(): BoundingInfo;
  27526. /**
  27527. * Computes the world matrix
  27528. * @param force Specifies if the world matrix should be computed by force
  27529. * @returns A world matrix
  27530. */
  27531. computeWorldMatrix(force: boolean): Matrix;
  27532. /**
  27533. * Gets the world matrix
  27534. * @returns A world matrix
  27535. */
  27536. getWorldMatrix?(): Matrix;
  27537. /**
  27538. * Gets the child meshes
  27539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27540. * @returns An array of abstract meshes
  27541. */
  27542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27543. /**
  27544. * Gets the vertex data
  27545. * @param kind The type of vertex data
  27546. * @returns A nullable array of numbers, or a float32 array
  27547. */
  27548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27549. /**
  27550. * Gets the indices from the mesh
  27551. * @returns A nullable array of index arrays
  27552. */
  27553. getIndices?(): Nullable<IndicesArray>;
  27554. /**
  27555. * Gets the scene from the mesh
  27556. * @returns the indices array or null
  27557. */
  27558. getScene?(): Scene;
  27559. /**
  27560. * Gets the absolute position from the mesh
  27561. * @returns the absolute position
  27562. */
  27563. getAbsolutePosition(): Vector3;
  27564. /**
  27565. * Gets the absolute pivot point from the mesh
  27566. * @returns the absolute pivot point
  27567. */
  27568. getAbsolutePivotPoint(): Vector3;
  27569. /**
  27570. * Rotates the mesh
  27571. * @param axis The axis of rotation
  27572. * @param amount The amount of rotation
  27573. * @param space The space of the rotation
  27574. * @returns The rotation transform node
  27575. */
  27576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27577. /**
  27578. * Translates the mesh
  27579. * @param axis The axis of translation
  27580. * @param distance The distance of translation
  27581. * @param space The space of the translation
  27582. * @returns The transform node
  27583. */
  27584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27585. /**
  27586. * Sets the absolute position of the mesh
  27587. * @param absolutePosition The absolute position of the mesh
  27588. * @returns The transform node
  27589. */
  27590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27591. /**
  27592. * Gets the class name of the mesh
  27593. * @returns The class name
  27594. */
  27595. getClassName(): string;
  27596. }
  27597. /**
  27598. * Represents a physics imposter
  27599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27600. */
  27601. export class PhysicsImpostor {
  27602. /**
  27603. * The physics-enabled object used as the physics imposter
  27604. */
  27605. object: IPhysicsEnabledObject;
  27606. /**
  27607. * The type of the physics imposter
  27608. */
  27609. type: number;
  27610. private _options;
  27611. private _scene?;
  27612. /**
  27613. * The default object size of the imposter
  27614. */
  27615. static DEFAULT_OBJECT_SIZE: Vector3;
  27616. /**
  27617. * The identity quaternion of the imposter
  27618. */
  27619. static IDENTITY_QUATERNION: Quaternion;
  27620. /** @hidden */
  27621. _pluginData: any;
  27622. private _physicsEngine;
  27623. private _physicsBody;
  27624. private _bodyUpdateRequired;
  27625. private _onBeforePhysicsStepCallbacks;
  27626. private _onAfterPhysicsStepCallbacks;
  27627. /** @hidden */
  27628. _onPhysicsCollideCallbacks: Array<{
  27629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27630. otherImpostors: Array<PhysicsImpostor>;
  27631. }>;
  27632. private _deltaPosition;
  27633. private _deltaRotation;
  27634. private _deltaRotationConjugated;
  27635. /** @hidden */
  27636. _isFromLine: boolean;
  27637. private _parent;
  27638. private _isDisposed;
  27639. private static _tmpVecs;
  27640. private static _tmpQuat;
  27641. /**
  27642. * Specifies if the physics imposter is disposed
  27643. */
  27644. get isDisposed(): boolean;
  27645. /**
  27646. * Gets the mass of the physics imposter
  27647. */
  27648. get mass(): number;
  27649. set mass(value: number);
  27650. /**
  27651. * Gets the coefficient of friction
  27652. */
  27653. get friction(): number;
  27654. /**
  27655. * Sets the coefficient of friction
  27656. */
  27657. set friction(value: number);
  27658. /**
  27659. * Gets the coefficient of restitution
  27660. */
  27661. get restitution(): number;
  27662. /**
  27663. * Sets the coefficient of restitution
  27664. */
  27665. set restitution(value: number);
  27666. /**
  27667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27668. */
  27669. get pressure(): number;
  27670. /**
  27671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27672. */
  27673. set pressure(value: number);
  27674. /**
  27675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27676. */
  27677. get stiffness(): number;
  27678. /**
  27679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27680. */
  27681. set stiffness(value: number);
  27682. /**
  27683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27684. */
  27685. get velocityIterations(): number;
  27686. /**
  27687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27688. */
  27689. set velocityIterations(value: number);
  27690. /**
  27691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27692. */
  27693. get positionIterations(): number;
  27694. /**
  27695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27696. */
  27697. set positionIterations(value: number);
  27698. /**
  27699. * The unique id of the physics imposter
  27700. * set by the physics engine when adding this impostor to the array
  27701. */
  27702. uniqueId: number;
  27703. /**
  27704. * @hidden
  27705. */
  27706. soft: boolean;
  27707. /**
  27708. * @hidden
  27709. */
  27710. segments: number;
  27711. private _joints;
  27712. /**
  27713. * Initializes the physics imposter
  27714. * @param object The physics-enabled object used as the physics imposter
  27715. * @param type The type of the physics imposter
  27716. * @param _options The options for the physics imposter
  27717. * @param _scene The Babylon scene
  27718. */
  27719. constructor(
  27720. /**
  27721. * The physics-enabled object used as the physics imposter
  27722. */
  27723. object: IPhysicsEnabledObject,
  27724. /**
  27725. * The type of the physics imposter
  27726. */
  27727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27728. /**
  27729. * This function will completly initialize this impostor.
  27730. * It will create a new body - but only if this mesh has no parent.
  27731. * If it has, this impostor will not be used other than to define the impostor
  27732. * of the child mesh.
  27733. * @hidden
  27734. */
  27735. _init(): void;
  27736. private _getPhysicsParent;
  27737. /**
  27738. * Should a new body be generated.
  27739. * @returns boolean specifying if body initialization is required
  27740. */
  27741. isBodyInitRequired(): boolean;
  27742. /**
  27743. * Sets the updated scaling
  27744. * @param updated Specifies if the scaling is updated
  27745. */
  27746. setScalingUpdated(): void;
  27747. /**
  27748. * Force a regeneration of this or the parent's impostor's body.
  27749. * Use under cautious - This will remove all joints already implemented.
  27750. */
  27751. forceUpdate(): void;
  27752. /**
  27753. * Gets the body that holds this impostor. Either its own, or its parent.
  27754. */
  27755. get physicsBody(): any;
  27756. /**
  27757. * Get the parent of the physics imposter
  27758. * @returns Physics imposter or null
  27759. */
  27760. get parent(): Nullable<PhysicsImpostor>;
  27761. /**
  27762. * Sets the parent of the physics imposter
  27763. */
  27764. set parent(value: Nullable<PhysicsImpostor>);
  27765. /**
  27766. * Set the physics body. Used mainly by the physics engine/plugin
  27767. */
  27768. set physicsBody(physicsBody: any);
  27769. /**
  27770. * Resets the update flags
  27771. */
  27772. resetUpdateFlags(): void;
  27773. /**
  27774. * Gets the object extend size
  27775. * @returns the object extend size
  27776. */
  27777. getObjectExtendSize(): Vector3;
  27778. /**
  27779. * Gets the object center
  27780. * @returns The object center
  27781. */
  27782. getObjectCenter(): Vector3;
  27783. /**
  27784. * Get a specific parameter from the options parameters
  27785. * @param paramName The object parameter name
  27786. * @returns The object parameter
  27787. */
  27788. getParam(paramName: string): any;
  27789. /**
  27790. * Sets a specific parameter in the options given to the physics plugin
  27791. * @param paramName The parameter name
  27792. * @param value The value of the parameter
  27793. */
  27794. setParam(paramName: string, value: number): void;
  27795. /**
  27796. * Specifically change the body's mass option. Won't recreate the physics body object
  27797. * @param mass The mass of the physics imposter
  27798. */
  27799. setMass(mass: number): void;
  27800. /**
  27801. * Gets the linear velocity
  27802. * @returns linear velocity or null
  27803. */
  27804. getLinearVelocity(): Nullable<Vector3>;
  27805. /**
  27806. * Sets the linear velocity
  27807. * @param velocity linear velocity or null
  27808. */
  27809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27810. /**
  27811. * Gets the angular velocity
  27812. * @returns angular velocity or null
  27813. */
  27814. getAngularVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the angular velocity
  27817. * @param velocity The velocity or null
  27818. */
  27819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Execute a function with the physics plugin native code
  27822. * Provide a function the will have two variables - the world object and the physics body object
  27823. * @param func The function to execute with the physics plugin native code
  27824. */
  27825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27826. /**
  27827. * Register a function that will be executed before the physics world is stepping forward
  27828. * @param func The function to execute before the physics world is stepped forward
  27829. */
  27830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27831. /**
  27832. * Unregister a function that will be executed before the physics world is stepping forward
  27833. * @param func The function to execute before the physics world is stepped forward
  27834. */
  27835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27836. /**
  27837. * Register a function that will be executed after the physics step
  27838. * @param func The function to execute after physics step
  27839. */
  27840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregisters a function that will be executed after the physics step
  27843. * @param func The function to execute after physics step
  27844. */
  27845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * register a function that will be executed when this impostor collides against a different body
  27848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27849. * @param func Callback that is executed on collision
  27850. */
  27851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27852. /**
  27853. * Unregisters the physics imposter on contact
  27854. * @param collideAgainst The physics object to collide against
  27855. * @param func Callback to execute on collision
  27856. */
  27857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27858. private _tmpQuat;
  27859. private _tmpQuat2;
  27860. /**
  27861. * Get the parent rotation
  27862. * @returns The parent rotation
  27863. */
  27864. getParentsRotation(): Quaternion;
  27865. /**
  27866. * this function is executed by the physics engine.
  27867. */
  27868. beforeStep: () => void;
  27869. /**
  27870. * this function is executed by the physics engine
  27871. */
  27872. afterStep: () => void;
  27873. /**
  27874. * Legacy collision detection event support
  27875. */
  27876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27877. /**
  27878. * event and body object due to cannon's event-based architecture.
  27879. */
  27880. onCollide: (e: {
  27881. body: any;
  27882. }) => void;
  27883. /**
  27884. * Apply a force
  27885. * @param force The force to apply
  27886. * @param contactPoint The contact point for the force
  27887. * @returns The physics imposter
  27888. */
  27889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27890. /**
  27891. * Apply an impulse
  27892. * @param force The impulse force
  27893. * @param contactPoint The contact point for the impulse force
  27894. * @returns The physics imposter
  27895. */
  27896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27897. /**
  27898. * A help function to create a joint
  27899. * @param otherImpostor A physics imposter used to create a joint
  27900. * @param jointType The type of joint
  27901. * @param jointData The data for the joint
  27902. * @returns The physics imposter
  27903. */
  27904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27905. /**
  27906. * Add a joint to this impostor with a different impostor
  27907. * @param otherImpostor A physics imposter used to add a joint
  27908. * @param joint The joint to add
  27909. * @returns The physics imposter
  27910. */
  27911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27912. /**
  27913. * Add an anchor to a cloth impostor
  27914. * @param otherImpostor rigid impostor to anchor to
  27915. * @param width ratio across width from 0 to 1
  27916. * @param height ratio up height from 0 to 1
  27917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27919. * @returns impostor the soft imposter
  27920. */
  27921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27922. /**
  27923. * Add a hook to a rope impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param length ratio across rope from 0 to 1
  27926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27928. * @returns impostor the rope imposter
  27929. */
  27930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27931. /**
  27932. * Will keep this body still, in a sleep mode.
  27933. * @returns the physics imposter
  27934. */
  27935. sleep(): PhysicsImpostor;
  27936. /**
  27937. * Wake the body up.
  27938. * @returns The physics imposter
  27939. */
  27940. wakeUp(): PhysicsImpostor;
  27941. /**
  27942. * Clones the physics imposter
  27943. * @param newObject The physics imposter clones to this physics-enabled object
  27944. * @returns A nullable physics imposter
  27945. */
  27946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27947. /**
  27948. * Disposes the physics imposter
  27949. */
  27950. dispose(): void;
  27951. /**
  27952. * Sets the delta position
  27953. * @param position The delta position amount
  27954. */
  27955. setDeltaPosition(position: Vector3): void;
  27956. /**
  27957. * Sets the delta rotation
  27958. * @param rotation The delta rotation amount
  27959. */
  27960. setDeltaRotation(rotation: Quaternion): void;
  27961. /**
  27962. * Gets the box size of the physics imposter and stores the result in the input parameter
  27963. * @param result Stores the box size
  27964. * @returns The physics imposter
  27965. */
  27966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27967. /**
  27968. * Gets the radius of the physics imposter
  27969. * @returns Radius of the physics imposter
  27970. */
  27971. getRadius(): number;
  27972. /**
  27973. * Sync a bone with this impostor
  27974. * @param bone The bone to sync to the impostor.
  27975. * @param boneMesh The mesh that the bone is influencing.
  27976. * @param jointPivot The pivot of the joint / bone in local space.
  27977. * @param distToJoint Optional distance from the impostor to the joint.
  27978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27979. */
  27980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27981. /**
  27982. * Sync impostor to a bone
  27983. * @param bone The bone that the impostor will be synced to.
  27984. * @param boneMesh The mesh that the bone is influencing.
  27985. * @param jointPivot The pivot of the joint / bone in local space.
  27986. * @param distToJoint Optional distance from the impostor to the joint.
  27987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27988. * @param boneAxis Optional vector3 axis the bone is aligned with
  27989. */
  27990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27991. /**
  27992. * No-Imposter type
  27993. */
  27994. static NoImpostor: number;
  27995. /**
  27996. * Sphere-Imposter type
  27997. */
  27998. static SphereImpostor: number;
  27999. /**
  28000. * Box-Imposter type
  28001. */
  28002. static BoxImpostor: number;
  28003. /**
  28004. * Plane-Imposter type
  28005. */
  28006. static PlaneImpostor: number;
  28007. /**
  28008. * Mesh-imposter type
  28009. */
  28010. static MeshImpostor: number;
  28011. /**
  28012. * Capsule-Impostor type (Ammo.js plugin only)
  28013. */
  28014. static CapsuleImpostor: number;
  28015. /**
  28016. * Cylinder-Imposter type
  28017. */
  28018. static CylinderImpostor: number;
  28019. /**
  28020. * Particle-Imposter type
  28021. */
  28022. static ParticleImpostor: number;
  28023. /**
  28024. * Heightmap-Imposter type
  28025. */
  28026. static HeightmapImpostor: number;
  28027. /**
  28028. * ConvexHull-Impostor type (Ammo.js plugin only)
  28029. */
  28030. static ConvexHullImpostor: number;
  28031. /**
  28032. * Custom-Imposter type (Ammo.js plugin only)
  28033. */
  28034. static CustomImpostor: number;
  28035. /**
  28036. * Rope-Imposter type
  28037. */
  28038. static RopeImpostor: number;
  28039. /**
  28040. * Cloth-Imposter type
  28041. */
  28042. static ClothImpostor: number;
  28043. /**
  28044. * Softbody-Imposter type
  28045. */
  28046. static SoftbodyImpostor: number;
  28047. }
  28048. }
  28049. declare module "babylonjs/Meshes/mesh" {
  28050. import { Observable } from "babylonjs/Misc/observable";
  28051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28053. import { Camera } from "babylonjs/Cameras/camera";
  28054. import { Scene } from "babylonjs/scene";
  28055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28056. import { Color4 } from "babylonjs/Maths/math.color";
  28057. import { Engine } from "babylonjs/Engines/engine";
  28058. import { Node } from "babylonjs/node";
  28059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28061. import { Buffer } from "babylonjs/Meshes/buffer";
  28062. import { Geometry } from "babylonjs/Meshes/geometry";
  28063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28066. import { Effect } from "babylonjs/Materials/effect";
  28067. import { Material } from "babylonjs/Materials/material";
  28068. import { Skeleton } from "babylonjs/Bones/skeleton";
  28069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28071. import { Path3D } from "babylonjs/Maths/math.path";
  28072. import { Plane } from "babylonjs/Maths/math.plane";
  28073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28079. /**
  28080. * @hidden
  28081. **/
  28082. export class _CreationDataStorage {
  28083. closePath?: boolean;
  28084. closeArray?: boolean;
  28085. idx: number[];
  28086. dashSize: number;
  28087. gapSize: number;
  28088. path3D: Path3D;
  28089. pathArray: Vector3[][];
  28090. arc: number;
  28091. radius: number;
  28092. cap: number;
  28093. tessellation: number;
  28094. }
  28095. /**
  28096. * @hidden
  28097. **/
  28098. class _InstanceDataStorage {
  28099. visibleInstances: any;
  28100. batchCache: _InstancesBatch;
  28101. instancesBufferSize: number;
  28102. instancesBuffer: Nullable<Buffer>;
  28103. instancesData: Float32Array;
  28104. overridenInstanceCount: number;
  28105. isFrozen: boolean;
  28106. previousBatch: Nullable<_InstancesBatch>;
  28107. hardwareInstancedRendering: boolean;
  28108. sideOrientation: number;
  28109. manualUpdate: boolean;
  28110. }
  28111. /**
  28112. * @hidden
  28113. **/
  28114. export class _InstancesBatch {
  28115. mustReturn: boolean;
  28116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28117. renderSelf: boolean[];
  28118. hardwareInstancedRendering: boolean[];
  28119. }
  28120. /**
  28121. * @hidden
  28122. **/
  28123. class _ThinInstanceDataStorage {
  28124. instancesCount: number;
  28125. matrixBuffer: Nullable<Buffer>;
  28126. matrixBufferSize: number;
  28127. matrixData: Nullable<Float32Array>;
  28128. boundingVectors: Array<Vector3>;
  28129. }
  28130. /**
  28131. * Class used to represent renderable models
  28132. */
  28133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28134. /**
  28135. * Mesh side orientation : usually the external or front surface
  28136. */
  28137. static readonly FRONTSIDE: number;
  28138. /**
  28139. * Mesh side orientation : usually the internal or back surface
  28140. */
  28141. static readonly BACKSIDE: number;
  28142. /**
  28143. * Mesh side orientation : both internal and external or front and back surfaces
  28144. */
  28145. static readonly DOUBLESIDE: number;
  28146. /**
  28147. * Mesh side orientation : by default, `FRONTSIDE`
  28148. */
  28149. static readonly DEFAULTSIDE: number;
  28150. /**
  28151. * Mesh cap setting : no cap
  28152. */
  28153. static readonly NO_CAP: number;
  28154. /**
  28155. * Mesh cap setting : one cap at the beginning of the mesh
  28156. */
  28157. static readonly CAP_START: number;
  28158. /**
  28159. * Mesh cap setting : one cap at the end of the mesh
  28160. */
  28161. static readonly CAP_END: number;
  28162. /**
  28163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28164. */
  28165. static readonly CAP_ALL: number;
  28166. /**
  28167. * Mesh pattern setting : no flip or rotate
  28168. */
  28169. static readonly NO_FLIP: number;
  28170. /**
  28171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28172. */
  28173. static readonly FLIP_TILE: number;
  28174. /**
  28175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28176. */
  28177. static readonly ROTATE_TILE: number;
  28178. /**
  28179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28180. */
  28181. static readonly FLIP_ROW: number;
  28182. /**
  28183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28184. */
  28185. static readonly ROTATE_ROW: number;
  28186. /**
  28187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28188. */
  28189. static readonly FLIP_N_ROTATE_TILE: number;
  28190. /**
  28191. * Mesh pattern setting : rotate pattern and rotate
  28192. */
  28193. static readonly FLIP_N_ROTATE_ROW: number;
  28194. /**
  28195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28196. */
  28197. static readonly CENTER: number;
  28198. /**
  28199. * Mesh tile positioning : part tiles on left
  28200. */
  28201. static readonly LEFT: number;
  28202. /**
  28203. * Mesh tile positioning : part tiles on right
  28204. */
  28205. static readonly RIGHT: number;
  28206. /**
  28207. * Mesh tile positioning : part tiles on top
  28208. */
  28209. static readonly TOP: number;
  28210. /**
  28211. * Mesh tile positioning : part tiles on bottom
  28212. */
  28213. static readonly BOTTOM: number;
  28214. /**
  28215. * Gets the default side orientation.
  28216. * @param orientation the orientation to value to attempt to get
  28217. * @returns the default orientation
  28218. * @hidden
  28219. */
  28220. static _GetDefaultSideOrientation(orientation?: number): number;
  28221. private _internalMeshDataInfo;
  28222. /**
  28223. * An event triggered before rendering the mesh
  28224. */
  28225. get onBeforeRenderObservable(): Observable<Mesh>;
  28226. /**
  28227. * An event triggered before binding the mesh
  28228. */
  28229. get onBeforeBindObservable(): Observable<Mesh>;
  28230. /**
  28231. * An event triggered after rendering the mesh
  28232. */
  28233. get onAfterRenderObservable(): Observable<Mesh>;
  28234. /**
  28235. * An event triggered before drawing the mesh
  28236. */
  28237. get onBeforeDrawObservable(): Observable<Mesh>;
  28238. private _onBeforeDrawObserver;
  28239. /**
  28240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28241. */
  28242. set onBeforeDraw(callback: () => void);
  28243. get hasInstances(): boolean;
  28244. get hasThinInstances(): boolean;
  28245. /**
  28246. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28247. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28248. */
  28249. delayLoadState: number;
  28250. /**
  28251. * Gets the list of instances created from this mesh
  28252. * it is not supposed to be modified manually.
  28253. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28254. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28255. */
  28256. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28257. /**
  28258. * Gets the file containing delay loading data for this mesh
  28259. */
  28260. delayLoadingFile: string;
  28261. /** @hidden */
  28262. _binaryInfo: any;
  28263. /**
  28264. * User defined function used to change how LOD level selection is done
  28265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28266. */
  28267. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28268. /**
  28269. * Gets or sets the morph target manager
  28270. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28271. */
  28272. get morphTargetManager(): Nullable<MorphTargetManager>;
  28273. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28274. /** @hidden */
  28275. _creationDataStorage: Nullable<_CreationDataStorage>;
  28276. /** @hidden */
  28277. _geometry: Nullable<Geometry>;
  28278. /** @hidden */
  28279. _delayInfo: Array<string>;
  28280. /** @hidden */
  28281. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28282. /** @hidden */
  28283. _instanceDataStorage: _InstanceDataStorage;
  28284. /** @hidden */
  28285. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28286. private _effectiveMaterial;
  28287. /** @hidden */
  28288. _shouldGenerateFlatShading: boolean;
  28289. /** @hidden */
  28290. _originalBuilderSideOrientation: number;
  28291. /**
  28292. * Use this property to change the original side orientation defined at construction time
  28293. */
  28294. overrideMaterialSideOrientation: Nullable<number>;
  28295. /**
  28296. * Gets the source mesh (the one used to clone this one from)
  28297. */
  28298. get source(): Nullable<Mesh>;
  28299. /**
  28300. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28301. */
  28302. get isUnIndexed(): boolean;
  28303. set isUnIndexed(value: boolean);
  28304. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28305. get worldMatrixInstancedBuffer(): Float32Array;
  28306. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28307. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28308. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28309. /**
  28310. * @constructor
  28311. * @param name The value used by scene.getMeshByName() to do a lookup.
  28312. * @param scene The scene to add this mesh to.
  28313. * @param parent The parent of this mesh, if it has one
  28314. * @param source An optional Mesh from which geometry is shared, cloned.
  28315. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28316. * When false, achieved by calling a clone(), also passing False.
  28317. * This will make creation of children, recursive.
  28318. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28319. */
  28320. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28321. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28322. doNotInstantiate: boolean;
  28323. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28324. /**
  28325. * Gets the class name
  28326. * @returns the string "Mesh".
  28327. */
  28328. getClassName(): string;
  28329. /** @hidden */
  28330. get _isMesh(): boolean;
  28331. /**
  28332. * Returns a description of this mesh
  28333. * @param fullDetails define if full details about this mesh must be used
  28334. * @returns a descriptive string representing this mesh
  28335. */
  28336. toString(fullDetails?: boolean): string;
  28337. /** @hidden */
  28338. _unBindEffect(): void;
  28339. /**
  28340. * Gets a boolean indicating if this mesh has LOD
  28341. */
  28342. get hasLODLevels(): boolean;
  28343. /**
  28344. * Gets the list of MeshLODLevel associated with the current mesh
  28345. * @returns an array of MeshLODLevel
  28346. */
  28347. getLODLevels(): MeshLODLevel[];
  28348. private _sortLODLevels;
  28349. /**
  28350. * Add a mesh as LOD level triggered at the given distance.
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param distance The distance from the center of the object to show this level
  28353. * @param mesh The mesh to be added as LOD level (can be null)
  28354. * @return This mesh (for chaining)
  28355. */
  28356. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28357. /**
  28358. * Returns the LOD level mesh at the passed distance or null if not found.
  28359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28360. * @param distance The distance from the center of the object to show this level
  28361. * @returns a Mesh or `null`
  28362. */
  28363. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28364. /**
  28365. * Remove a mesh from the LOD array
  28366. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28367. * @param mesh defines the mesh to be removed
  28368. * @return This mesh (for chaining)
  28369. */
  28370. removeLODLevel(mesh: Mesh): Mesh;
  28371. /**
  28372. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28374. * @param camera defines the camera to use to compute distance
  28375. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28376. * @return This mesh (for chaining)
  28377. */
  28378. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28379. /**
  28380. * Gets the mesh internal Geometry object
  28381. */
  28382. get geometry(): Nullable<Geometry>;
  28383. /**
  28384. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28385. * @returns the total number of vertices
  28386. */
  28387. getTotalVertices(): number;
  28388. /**
  28389. * Returns the content of an associated vertex buffer
  28390. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28391. * - VertexBuffer.PositionKind
  28392. * - VertexBuffer.UVKind
  28393. * - VertexBuffer.UV2Kind
  28394. * - VertexBuffer.UV3Kind
  28395. * - VertexBuffer.UV4Kind
  28396. * - VertexBuffer.UV5Kind
  28397. * - VertexBuffer.UV6Kind
  28398. * - VertexBuffer.ColorKind
  28399. * - VertexBuffer.MatricesIndicesKind
  28400. * - VertexBuffer.MatricesIndicesExtraKind
  28401. * - VertexBuffer.MatricesWeightsKind
  28402. * - VertexBuffer.MatricesWeightsExtraKind
  28403. * @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
  28404. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28405. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28406. */
  28407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28408. /**
  28409. * Returns the mesh VertexBuffer object from the requested `kind`
  28410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28411. * - VertexBuffer.PositionKind
  28412. * - VertexBuffer.NormalKind
  28413. * - VertexBuffer.UVKind
  28414. * - VertexBuffer.UV2Kind
  28415. * - VertexBuffer.UV3Kind
  28416. * - VertexBuffer.UV4Kind
  28417. * - VertexBuffer.UV5Kind
  28418. * - VertexBuffer.UV6Kind
  28419. * - VertexBuffer.ColorKind
  28420. * - VertexBuffer.MatricesIndicesKind
  28421. * - VertexBuffer.MatricesIndicesExtraKind
  28422. * - VertexBuffer.MatricesWeightsKind
  28423. * - VertexBuffer.MatricesWeightsExtraKind
  28424. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28425. */
  28426. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28427. /**
  28428. * Tests if a specific vertex buffer is associated with this mesh
  28429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28430. * - VertexBuffer.PositionKind
  28431. * - VertexBuffer.NormalKind
  28432. * - VertexBuffer.UVKind
  28433. * - VertexBuffer.UV2Kind
  28434. * - VertexBuffer.UV3Kind
  28435. * - VertexBuffer.UV4Kind
  28436. * - VertexBuffer.UV5Kind
  28437. * - VertexBuffer.UV6Kind
  28438. * - VertexBuffer.ColorKind
  28439. * - VertexBuffer.MatricesIndicesKind
  28440. * - VertexBuffer.MatricesIndicesExtraKind
  28441. * - VertexBuffer.MatricesWeightsKind
  28442. * - VertexBuffer.MatricesWeightsExtraKind
  28443. * @returns a boolean
  28444. */
  28445. isVerticesDataPresent(kind: string): boolean;
  28446. /**
  28447. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28449. * - VertexBuffer.PositionKind
  28450. * - VertexBuffer.UVKind
  28451. * - VertexBuffer.UV2Kind
  28452. * - VertexBuffer.UV3Kind
  28453. * - VertexBuffer.UV4Kind
  28454. * - VertexBuffer.UV5Kind
  28455. * - VertexBuffer.UV6Kind
  28456. * - VertexBuffer.ColorKind
  28457. * - VertexBuffer.MatricesIndicesKind
  28458. * - VertexBuffer.MatricesIndicesExtraKind
  28459. * - VertexBuffer.MatricesWeightsKind
  28460. * - VertexBuffer.MatricesWeightsExtraKind
  28461. * @returns a boolean
  28462. */
  28463. isVertexBufferUpdatable(kind: string): boolean;
  28464. /**
  28465. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28466. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28467. * - VertexBuffer.PositionKind
  28468. * - VertexBuffer.NormalKind
  28469. * - VertexBuffer.UVKind
  28470. * - VertexBuffer.UV2Kind
  28471. * - VertexBuffer.UV3Kind
  28472. * - VertexBuffer.UV4Kind
  28473. * - VertexBuffer.UV5Kind
  28474. * - VertexBuffer.UV6Kind
  28475. * - VertexBuffer.ColorKind
  28476. * - VertexBuffer.MatricesIndicesKind
  28477. * - VertexBuffer.MatricesIndicesExtraKind
  28478. * - VertexBuffer.MatricesWeightsKind
  28479. * - VertexBuffer.MatricesWeightsExtraKind
  28480. * @returns an array of strings
  28481. */
  28482. getVerticesDataKinds(): string[];
  28483. /**
  28484. * Returns a positive integer : the total number of indices in this mesh geometry.
  28485. * @returns the numner of indices or zero if the mesh has no geometry.
  28486. */
  28487. getTotalIndices(): number;
  28488. /**
  28489. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28490. * @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.
  28491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28492. * @returns the indices array or an empty array if the mesh has no geometry
  28493. */
  28494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28495. get isBlocked(): boolean;
  28496. /**
  28497. * Determine if the current mesh is ready to be rendered
  28498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28499. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28500. * @returns true if all associated assets are ready (material, textures, shaders)
  28501. */
  28502. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28503. /**
  28504. * 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.
  28505. */
  28506. get areNormalsFrozen(): boolean;
  28507. /**
  28508. * 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.
  28509. * @returns the current mesh
  28510. */
  28511. freezeNormals(): Mesh;
  28512. /**
  28513. * 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
  28514. * @returns the current mesh
  28515. */
  28516. unfreezeNormals(): Mesh;
  28517. /**
  28518. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28519. */
  28520. set overridenInstanceCount(count: number);
  28521. /** @hidden */
  28522. _preActivate(): Mesh;
  28523. /** @hidden */
  28524. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28525. /** @hidden */
  28526. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28527. protected _afterComputeWorldMatrix(): void;
  28528. /** @hidden */
  28529. _postActivate(): void;
  28530. /**
  28531. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28532. * This means the mesh underlying bounding box and sphere are recomputed.
  28533. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28534. * @returns the current mesh
  28535. */
  28536. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28537. /** @hidden */
  28538. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28539. /**
  28540. * This function will subdivide the mesh into multiple submeshes
  28541. * @param count defines the expected number of submeshes
  28542. */
  28543. subdivide(count: number): void;
  28544. /**
  28545. * Copy a FloatArray into a specific associated vertex buffer
  28546. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28547. * - VertexBuffer.PositionKind
  28548. * - VertexBuffer.UVKind
  28549. * - VertexBuffer.UV2Kind
  28550. * - VertexBuffer.UV3Kind
  28551. * - VertexBuffer.UV4Kind
  28552. * - VertexBuffer.UV5Kind
  28553. * - VertexBuffer.UV6Kind
  28554. * - VertexBuffer.ColorKind
  28555. * - VertexBuffer.MatricesIndicesKind
  28556. * - VertexBuffer.MatricesIndicesExtraKind
  28557. * - VertexBuffer.MatricesWeightsKind
  28558. * - VertexBuffer.MatricesWeightsExtraKind
  28559. * @param data defines the data source
  28560. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28561. * @param stride defines the data stride size (can be null)
  28562. * @returns the current mesh
  28563. */
  28564. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28565. /**
  28566. * Delete a vertex buffer associated with this mesh
  28567. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28568. * - VertexBuffer.PositionKind
  28569. * - VertexBuffer.UVKind
  28570. * - VertexBuffer.UV2Kind
  28571. * - VertexBuffer.UV3Kind
  28572. * - VertexBuffer.UV4Kind
  28573. * - VertexBuffer.UV5Kind
  28574. * - VertexBuffer.UV6Kind
  28575. * - VertexBuffer.ColorKind
  28576. * - VertexBuffer.MatricesIndicesKind
  28577. * - VertexBuffer.MatricesIndicesExtraKind
  28578. * - VertexBuffer.MatricesWeightsKind
  28579. * - VertexBuffer.MatricesWeightsExtraKind
  28580. */
  28581. removeVerticesData(kind: string): void;
  28582. /**
  28583. * Flags an associated vertex buffer as updatable
  28584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28585. * - VertexBuffer.PositionKind
  28586. * - VertexBuffer.UVKind
  28587. * - VertexBuffer.UV2Kind
  28588. * - VertexBuffer.UV3Kind
  28589. * - VertexBuffer.UV4Kind
  28590. * - VertexBuffer.UV5Kind
  28591. * - VertexBuffer.UV6Kind
  28592. * - VertexBuffer.ColorKind
  28593. * - VertexBuffer.MatricesIndicesKind
  28594. * - VertexBuffer.MatricesIndicesExtraKind
  28595. * - VertexBuffer.MatricesWeightsKind
  28596. * - VertexBuffer.MatricesWeightsExtraKind
  28597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28598. */
  28599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28600. /**
  28601. * Sets the mesh global Vertex Buffer
  28602. * @param buffer defines the buffer to use
  28603. * @returns the current mesh
  28604. */
  28605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28606. /**
  28607. * Update a specific associated vertex buffer
  28608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28609. * - VertexBuffer.PositionKind
  28610. * - VertexBuffer.UVKind
  28611. * - VertexBuffer.UV2Kind
  28612. * - VertexBuffer.UV3Kind
  28613. * - VertexBuffer.UV4Kind
  28614. * - VertexBuffer.UV5Kind
  28615. * - VertexBuffer.UV6Kind
  28616. * - VertexBuffer.ColorKind
  28617. * - VertexBuffer.MatricesIndicesKind
  28618. * - VertexBuffer.MatricesIndicesExtraKind
  28619. * - VertexBuffer.MatricesWeightsKind
  28620. * - VertexBuffer.MatricesWeightsExtraKind
  28621. * @param data defines the data source
  28622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28623. * @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)
  28624. * @returns the current mesh
  28625. */
  28626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28627. /**
  28628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28629. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28632. * @returns the current mesh
  28633. */
  28634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28635. /**
  28636. * Creates a un-shared specific occurence of the geometry for the mesh.
  28637. * @returns the current mesh
  28638. */
  28639. makeGeometryUnique(): Mesh;
  28640. /**
  28641. * Set the index buffer of this mesh
  28642. * @param indices defines the source data
  28643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28645. * @returns the current mesh
  28646. */
  28647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28648. /**
  28649. * Update the current index buffer
  28650. * @param indices defines the source data
  28651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28652. * @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)
  28653. * @returns the current mesh
  28654. */
  28655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28656. /**
  28657. * Invert the geometry to move from a right handed system to a left handed one.
  28658. * @returns the current mesh
  28659. */
  28660. toLeftHanded(): Mesh;
  28661. /** @hidden */
  28662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28663. /** @hidden */
  28664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28665. /**
  28666. * Registers for this mesh a javascript function called just before the rendering process
  28667. * @param func defines the function to call before rendering this mesh
  28668. * @returns the current mesh
  28669. */
  28670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28671. /**
  28672. * Disposes a previously registered javascript function called before the rendering
  28673. * @param func defines the function to remove
  28674. * @returns the current mesh
  28675. */
  28676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28677. /**
  28678. * Registers for this mesh a javascript function called just after the rendering is complete
  28679. * @param func defines the function to call after rendering this mesh
  28680. * @returns the current mesh
  28681. */
  28682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28683. /**
  28684. * Disposes a previously registered javascript function called after the rendering.
  28685. * @param func defines the function to remove
  28686. * @returns the current mesh
  28687. */
  28688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28689. /** @hidden */
  28690. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28691. /** @hidden */
  28692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28693. /** @hidden */
  28694. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28695. /** @hidden */
  28696. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28697. /** @hidden */
  28698. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28699. /** @hidden */
  28700. _rebuild(): void;
  28701. /** @hidden */
  28702. _freeze(): void;
  28703. /** @hidden */
  28704. _unFreeze(): void;
  28705. /**
  28706. * 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
  28707. * @param subMesh defines the subMesh to render
  28708. * @param enableAlphaMode defines if alpha mode can be changed
  28709. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28710. * @returns the current mesh
  28711. */
  28712. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28713. private _onBeforeDraw;
  28714. /**
  28715. * Renormalize the mesh and patch it up if there are no weights
  28716. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28717. * However in the case of zero weights then we set just a single influence to 1.
  28718. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28719. */
  28720. cleanMatrixWeights(): void;
  28721. private normalizeSkinFourWeights;
  28722. private normalizeSkinWeightsAndExtra;
  28723. /**
  28724. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28725. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28726. * the user know there was an issue with importing the mesh
  28727. * @returns a validation object with skinned, valid and report string
  28728. */
  28729. validateSkinning(): {
  28730. skinned: boolean;
  28731. valid: boolean;
  28732. report: string;
  28733. };
  28734. /** @hidden */
  28735. _checkDelayState(): Mesh;
  28736. private _queueLoad;
  28737. /**
  28738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28739. * A mesh is in the frustum if its bounding box intersects the frustum
  28740. * @param frustumPlanes defines the frustum to test
  28741. * @returns true if the mesh is in the frustum planes
  28742. */
  28743. isInFrustum(frustumPlanes: Plane[]): boolean;
  28744. /**
  28745. * Sets the mesh material by the material or multiMaterial `id` property
  28746. * @param id is a string identifying the material or the multiMaterial
  28747. * @returns the current mesh
  28748. */
  28749. setMaterialByID(id: string): Mesh;
  28750. /**
  28751. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28752. * @returns an array of IAnimatable
  28753. */
  28754. getAnimatables(): IAnimatable[];
  28755. /**
  28756. * Modifies the mesh geometry according to the passed transformation matrix.
  28757. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28758. * The mesh normals are modified using the same transformation.
  28759. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28760. * @param transform defines the transform matrix to use
  28761. * @see https://doc.babylonjs.com/resources/baking_transformations
  28762. * @returns the current mesh
  28763. */
  28764. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28765. /**
  28766. * Modifies the mesh geometry according to its own current World Matrix.
  28767. * The mesh World Matrix is then reset.
  28768. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28770. * @see https://doc.babylonjs.com/resources/baking_transformations
  28771. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28772. * @returns the current mesh
  28773. */
  28774. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28775. /** @hidden */
  28776. get _positions(): Nullable<Vector3[]>;
  28777. /** @hidden */
  28778. _resetPointsArrayCache(): Mesh;
  28779. /** @hidden */
  28780. _generatePointsArray(): boolean;
  28781. /**
  28782. * Returns a new Mesh object generated from the current mesh properties.
  28783. * This method must not get confused with createInstance()
  28784. * @param name is a string, the name given to the new mesh
  28785. * @param newParent can be any Node object (default `null`)
  28786. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28787. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28788. * @returns a new mesh
  28789. */
  28790. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28791. /**
  28792. * Releases resources associated with this mesh.
  28793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28795. */
  28796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28797. /** @hidden */
  28798. _disposeInstanceSpecificData(): void;
  28799. /** @hidden */
  28800. _disposeThinInstanceSpecificData(): void;
  28801. /**
  28802. * Modifies the mesh geometry according to a displacement map.
  28803. * 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.
  28804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28805. * @param url is a string, the URL from the image file is to be downloaded.
  28806. * @param minHeight is the lower limit of the displacement.
  28807. * @param maxHeight is the upper limit of the displacement.
  28808. * @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.
  28809. * @param uvOffset is an optional vector2 used to offset UV.
  28810. * @param uvScale is an optional vector2 used to scale UV.
  28811. * @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.
  28812. * @returns the Mesh.
  28813. */
  28814. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28815. /**
  28816. * Modifies the mesh geometry according to a displacementMap buffer.
  28817. * 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.
  28818. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28819. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28820. * @param heightMapWidth is the width of the buffer image.
  28821. * @param heightMapHeight is the height of the buffer image.
  28822. * @param minHeight is the lower limit of the displacement.
  28823. * @param maxHeight is the upper limit of the displacement.
  28824. * @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.
  28825. * @param uvOffset is an optional vector2 used to offset UV.
  28826. * @param uvScale is an optional vector2 used to scale UV.
  28827. * @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.
  28828. * @returns the Mesh.
  28829. */
  28830. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28831. /**
  28832. * Modify the mesh to get a flat shading rendering.
  28833. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28834. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28835. * @returns current mesh
  28836. */
  28837. convertToFlatShadedMesh(): Mesh;
  28838. /**
  28839. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28840. * In other words, more vertices, no more indices and a single bigger VBO.
  28841. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28842. * @returns current mesh
  28843. */
  28844. convertToUnIndexedMesh(): Mesh;
  28845. /**
  28846. * Inverses facet orientations.
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. * @param flipNormals will also inverts the normals
  28849. * @returns current mesh
  28850. */
  28851. flipFaces(flipNormals?: boolean): Mesh;
  28852. /**
  28853. * Increase the number of facets and hence vertices in a mesh
  28854. * Vertex normals are interpolated from existing vertex normals
  28855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28856. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28857. */
  28858. increaseVertices(numberPerEdge: number): void;
  28859. /**
  28860. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28861. * This will undo any application of covertToFlatShadedMesh
  28862. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28863. */
  28864. forceSharedVertices(): void;
  28865. /** @hidden */
  28866. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28867. /** @hidden */
  28868. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28869. /**
  28870. * Creates a new InstancedMesh object from the mesh model.
  28871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28872. * @param name defines the name of the new instance
  28873. * @returns a new InstancedMesh
  28874. */
  28875. createInstance(name: string): InstancedMesh;
  28876. /**
  28877. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28878. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28879. * @returns the current mesh
  28880. */
  28881. synchronizeInstances(): Mesh;
  28882. /**
  28883. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28884. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28885. * This should be used together with the simplification to avoid disappearing triangles.
  28886. * @param successCallback an optional success callback to be called after the optimization finished.
  28887. * @returns the current mesh
  28888. */
  28889. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28890. /**
  28891. * Serialize current mesh
  28892. * @param serializationObject defines the object which will receive the serialization data
  28893. */
  28894. serialize(serializationObject: any): void;
  28895. /** @hidden */
  28896. _syncGeometryWithMorphTargetManager(): void;
  28897. /** @hidden */
  28898. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28899. /**
  28900. * Returns a new Mesh object parsed from the source provided.
  28901. * @param parsedMesh is the source
  28902. * @param scene defines the hosting scene
  28903. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28904. * @returns a new Mesh
  28905. */
  28906. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28907. /**
  28908. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28910. * @param name defines the name of the mesh to create
  28911. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28912. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28913. * @param closePath creates a seam between the first and the last points of each path of the path array
  28914. * @param offset is taken in account only if the `pathArray` is containing a single path
  28915. * @param scene defines the hosting scene
  28916. * @param updatable defines if the mesh must be flagged as updatable
  28917. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28918. * @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)
  28919. * @returns a new Mesh
  28920. */
  28921. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28922. /**
  28923. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28924. * @param name defines the name of the mesh to create
  28925. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28926. * @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
  28927. * @param scene defines the hosting scene
  28928. * @param updatable defines if the mesh must be flagged as updatable
  28929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28930. * @returns a new Mesh
  28931. */
  28932. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28933. /**
  28934. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28935. * @param name defines the name of the mesh to create
  28936. * @param size sets the size (float) of each box side (default 1)
  28937. * @param scene defines the hosting scene
  28938. * @param updatable defines if the mesh must be flagged as updatable
  28939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28940. * @returns a new Mesh
  28941. */
  28942. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28943. /**
  28944. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28945. * @param name defines the name of the mesh to create
  28946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28948. * @param scene defines the hosting scene
  28949. * @param updatable defines if the mesh must be flagged as updatable
  28950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28951. * @returns a new Mesh
  28952. */
  28953. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28954. /**
  28955. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28956. * @param name defines the name of the mesh to create
  28957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28959. * @param scene defines the hosting scene
  28960. * @returns a new Mesh
  28961. */
  28962. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28963. /**
  28964. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28965. * @param name defines the name of the mesh to create
  28966. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28967. * @param diameterTop set the top cap diameter (floats, default 1)
  28968. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28969. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28970. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28971. * @param scene defines the hosting scene
  28972. * @param updatable defines if the mesh must be flagged as updatable
  28973. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28974. * @returns a new Mesh
  28975. */
  28976. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28977. /**
  28978. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28979. * @param name defines the name of the mesh to create
  28980. * @param diameter sets the diameter size (float) of the torus (default 1)
  28981. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28982. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28983. * @param scene defines the hosting scene
  28984. * @param updatable defines if the mesh must be flagged as updatable
  28985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28986. * @returns a new Mesh
  28987. */
  28988. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28989. /**
  28990. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28991. * @param name defines the name of the mesh to create
  28992. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28993. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28994. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28995. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28996. * @param p the number of windings on X axis (positive integers, default 2)
  28997. * @param q the number of windings on Y axis (positive integers, default 3)
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @returns a new Mesh
  29002. */
  29003. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29004. /**
  29005. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29006. * @param name defines the name of the mesh to create
  29007. * @param points is an array successive Vector3
  29008. * @param scene defines the hosting scene
  29009. * @param updatable defines if the mesh must be flagged as updatable
  29010. * @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).
  29011. * @returns a new Mesh
  29012. */
  29013. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29014. /**
  29015. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29016. * @param name defines the name of the mesh to create
  29017. * @param points is an array successive Vector3
  29018. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29019. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29020. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29021. * @param scene defines the hosting scene
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @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)
  29024. * @returns a new Mesh
  29025. */
  29026. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29027. /**
  29028. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29030. * 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.
  29031. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29032. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29033. * Remember you can only change the shape positions, not their number when updating a polygon.
  29034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29035. * @param name defines the name of the mesh to create
  29036. * @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
  29037. * @param scene defines the hosting scene
  29038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29039. * @param updatable defines if the mesh must be flagged as updatable
  29040. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29041. * @param earcutInjection can be used to inject your own earcut reference
  29042. * @returns a new Mesh
  29043. */
  29044. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29045. /**
  29046. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29048. * @param name defines the name of the mesh to create
  29049. * @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
  29050. * @param depth defines the height of extrusion
  29051. * @param scene defines the hosting scene
  29052. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29053. * @param updatable defines if the mesh must be flagged as updatable
  29054. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29055. * @param earcutInjection can be used to inject your own earcut reference
  29056. * @returns a new Mesh
  29057. */
  29058. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29059. /**
  29060. * Creates an extruded shape mesh.
  29061. * 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
  29062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29064. * @param name defines the name of the mesh to create
  29065. * @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
  29066. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29067. * @param scale is the value to scale the shape
  29068. * @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
  29069. * @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
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @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)
  29074. * @returns a new Mesh
  29075. */
  29076. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29077. /**
  29078. * Creates an custom extruded shape mesh.
  29079. * The custom extrusion is a parametric shape.
  29080. * It has no predefined shape. Its final shape will depend on the input parameters.
  29081. * Please consider using the same method from the MeshBuilder class instead
  29082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29083. * @param name defines the name of the mesh to create
  29084. * @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
  29085. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29086. * @param scaleFunction is a custom Javascript function called on each path point
  29087. * @param rotationFunction is a custom Javascript function called on each path point
  29088. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29089. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29090. * @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
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @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)
  29095. * @returns a new Mesh
  29096. */
  29097. 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;
  29098. /**
  29099. * Creates lathe mesh.
  29100. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29101. * Please consider using the same method from the MeshBuilder class instead
  29102. * @param name defines the name of the mesh to create
  29103. * @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
  29104. * @param radius is the radius value of the lathe
  29105. * @param tessellation is the side number of the lathe.
  29106. * @param scene defines the hosting scene
  29107. * @param updatable defines if the mesh must be flagged as updatable
  29108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29109. * @returns a new Mesh
  29110. */
  29111. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29112. /**
  29113. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29114. * @param name defines the name of the mesh to create
  29115. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29116. * @param scene defines the hosting scene
  29117. * @param updatable defines if the mesh must be flagged as updatable
  29118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29119. * @returns a new Mesh
  29120. */
  29121. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29122. /**
  29123. * Creates a ground mesh.
  29124. * Please consider using the same method from the MeshBuilder class instead
  29125. * @param name defines the name of the mesh to create
  29126. * @param width set the width of the ground
  29127. * @param height set the height of the ground
  29128. * @param subdivisions sets the number of subdivisions per side
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @returns a new Mesh
  29132. */
  29133. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29134. /**
  29135. * Creates a tiled ground mesh.
  29136. * Please consider using the same method from the MeshBuilder class instead
  29137. * @param name defines the name of the mesh to create
  29138. * @param xmin set the ground minimum X coordinate
  29139. * @param zmin set the ground minimum Y coordinate
  29140. * @param xmax set the ground maximum X coordinate
  29141. * @param zmax set the ground maximum Z coordinate
  29142. * @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
  29143. * @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
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @returns a new Mesh
  29147. */
  29148. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29149. w: number;
  29150. h: number;
  29151. }, precision: {
  29152. w: number;
  29153. h: number;
  29154. }, scene: Scene, updatable?: boolean): Mesh;
  29155. /**
  29156. * Creates a ground mesh from a height map.
  29157. * Please consider using the same method from the MeshBuilder class instead
  29158. * @see https://doc.babylonjs.com/babylon101/height_map
  29159. * @param name defines the name of the mesh to create
  29160. * @param url sets the URL of the height map image resource
  29161. * @param width set the ground width size
  29162. * @param height set the ground height size
  29163. * @param subdivisions sets the number of subdivision per side
  29164. * @param minHeight is the minimum altitude on the ground
  29165. * @param maxHeight is the maximum altitude on the ground
  29166. * @param scene defines the hosting scene
  29167. * @param updatable defines if the mesh must be flagged as updatable
  29168. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29169. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29170. * @returns a new Mesh
  29171. */
  29172. 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;
  29173. /**
  29174. * Creates a tube mesh.
  29175. * The tube is a parametric shape.
  29176. * It has no predefined shape. Its final shape will depend on the input parameters.
  29177. * Please consider using the same method from the MeshBuilder class instead
  29178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29179. * @param name defines the name of the mesh to create
  29180. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29181. * @param radius sets the tube radius size
  29182. * @param tessellation is the number of sides on the tubular surface
  29183. * @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
  29184. * @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
  29185. * @param scene defines the hosting scene
  29186. * @param updatable defines if the mesh must be flagged as updatable
  29187. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29188. * @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)
  29189. * @returns a new Mesh
  29190. */
  29191. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29192. (i: number, distance: number): number;
  29193. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29194. /**
  29195. * Creates a polyhedron mesh.
  29196. * Please consider using the same method from the MeshBuilder class instead.
  29197. * * 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
  29198. * * The parameter `size` (positive float, default 1) sets the polygon size
  29199. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29200. * * 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`
  29201. * * 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
  29202. * * 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)`)
  29203. * * 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
  29204. * * 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
  29205. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29208. * @param name defines the name of the mesh to create
  29209. * @param options defines the options used to create the mesh
  29210. * @param scene defines the hosting scene
  29211. * @returns a new Mesh
  29212. */
  29213. static CreatePolyhedron(name: string, options: {
  29214. type?: number;
  29215. size?: number;
  29216. sizeX?: number;
  29217. sizeY?: number;
  29218. sizeZ?: number;
  29219. custom?: any;
  29220. faceUV?: Vector4[];
  29221. faceColors?: Color4[];
  29222. updatable?: boolean;
  29223. sideOrientation?: number;
  29224. }, scene: Scene): Mesh;
  29225. /**
  29226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29228. * * 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`)
  29229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29230. * * 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
  29231. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29234. * @param name defines the name of the mesh
  29235. * @param options defines the options used to create the mesh
  29236. * @param scene defines the hosting scene
  29237. * @returns a new Mesh
  29238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29239. */
  29240. static CreateIcoSphere(name: string, options: {
  29241. radius?: number;
  29242. flat?: boolean;
  29243. subdivisions?: number;
  29244. sideOrientation?: number;
  29245. updatable?: boolean;
  29246. }, scene: Scene): Mesh;
  29247. /**
  29248. * Creates a decal mesh.
  29249. * Please consider using the same method from the MeshBuilder class instead.
  29250. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29251. * @param name defines the name of the mesh
  29252. * @param sourceMesh defines the mesh receiving the decal
  29253. * @param position sets the position of the decal in world coordinates
  29254. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29255. * @param size sets the decal scaling
  29256. * @param angle sets the angle to rotate the decal
  29257. * @returns a new Mesh
  29258. */
  29259. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29260. /**
  29261. * Prepare internal position array for software CPU skinning
  29262. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29263. */
  29264. setPositionsForCPUSkinning(): Float32Array;
  29265. /**
  29266. * Prepare internal normal array for software CPU skinning
  29267. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29268. */
  29269. setNormalsForCPUSkinning(): Float32Array;
  29270. /**
  29271. * Updates the vertex buffer by applying transformation from the bones
  29272. * @param skeleton defines the skeleton to apply to current mesh
  29273. * @returns the current mesh
  29274. */
  29275. applySkeleton(skeleton: Skeleton): Mesh;
  29276. /**
  29277. * 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
  29278. * @param meshes defines the list of meshes to scan
  29279. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29280. */
  29281. static MinMax(meshes: AbstractMesh[]): {
  29282. min: Vector3;
  29283. max: Vector3;
  29284. };
  29285. /**
  29286. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29287. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29288. * @returns a vector3
  29289. */
  29290. static Center(meshesOrMinMaxVector: {
  29291. min: Vector3;
  29292. max: Vector3;
  29293. } | AbstractMesh[]): Vector3;
  29294. /**
  29295. * Merge the array of meshes into a single mesh for performance reasons.
  29296. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29297. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29298. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29299. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29300. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29301. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29302. * @returns a new mesh
  29303. */
  29304. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29305. /** @hidden */
  29306. addInstance(instance: InstancedMesh): void;
  29307. /** @hidden */
  29308. removeInstance(instance: InstancedMesh): void;
  29309. }
  29310. }
  29311. declare module "babylonjs/Cameras/camera" {
  29312. import { SmartArray } from "babylonjs/Misc/smartArray";
  29313. import { Observable } from "babylonjs/Misc/observable";
  29314. import { Nullable } from "babylonjs/types";
  29315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29316. import { Scene } from "babylonjs/scene";
  29317. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29318. import { Node } from "babylonjs/node";
  29319. import { Mesh } from "babylonjs/Meshes/mesh";
  29320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29321. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29322. import { Viewport } from "babylonjs/Maths/math.viewport";
  29323. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29324. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29326. import { Ray } from "babylonjs/Culling/ray";
  29327. /**
  29328. * This is the base class of all the camera used in the application.
  29329. * @see https://doc.babylonjs.com/features/cameras
  29330. */
  29331. export class Camera extends Node {
  29332. /** @hidden */
  29333. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29334. /**
  29335. * This is the default projection mode used by the cameras.
  29336. * It helps recreating a feeling of perspective and better appreciate depth.
  29337. * This is the best way to simulate real life cameras.
  29338. */
  29339. static readonly PERSPECTIVE_CAMERA: number;
  29340. /**
  29341. * This helps creating camera with an orthographic mode.
  29342. * 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.
  29343. */
  29344. static readonly ORTHOGRAPHIC_CAMERA: number;
  29345. /**
  29346. * This is the default FOV mode for perspective cameras.
  29347. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29348. */
  29349. static readonly FOVMODE_VERTICAL_FIXED: number;
  29350. /**
  29351. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29352. */
  29353. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29354. /**
  29355. * This specifies ther is no need for a camera rig.
  29356. * Basically only one eye is rendered corresponding to the camera.
  29357. */
  29358. static readonly RIG_MODE_NONE: number;
  29359. /**
  29360. * Simulates a camera Rig with one blue eye and one red eye.
  29361. * This can be use with 3d blue and red glasses.
  29362. */
  29363. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29364. /**
  29365. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29366. */
  29367. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29368. /**
  29369. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered over under each other.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29380. /**
  29381. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29382. */
  29383. static readonly RIG_MODE_VR: number;
  29384. /**
  29385. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29386. */
  29387. static readonly RIG_MODE_WEBVR: number;
  29388. /**
  29389. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29390. */
  29391. static readonly RIG_MODE_CUSTOM: number;
  29392. /**
  29393. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29394. */
  29395. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29396. /**
  29397. * Define the input manager associated with the camera.
  29398. */
  29399. inputs: CameraInputsManager<Camera>;
  29400. /** @hidden */
  29401. _position: Vector3;
  29402. /**
  29403. * Define the current local position of the camera in the scene
  29404. */
  29405. get position(): Vector3;
  29406. set position(newPosition: Vector3);
  29407. /**
  29408. * The vector the camera should consider as up.
  29409. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29410. */
  29411. upVector: Vector3;
  29412. /**
  29413. * Define the current limit on the left side for an orthographic camera
  29414. * In scene unit
  29415. */
  29416. orthoLeft: Nullable<number>;
  29417. /**
  29418. * Define the current limit on the right side for an orthographic camera
  29419. * In scene unit
  29420. */
  29421. orthoRight: Nullable<number>;
  29422. /**
  29423. * Define the current limit on the bottom side for an orthographic camera
  29424. * In scene unit
  29425. */
  29426. orthoBottom: Nullable<number>;
  29427. /**
  29428. * Define the current limit on the top side for an orthographic camera
  29429. * In scene unit
  29430. */
  29431. orthoTop: Nullable<number>;
  29432. /**
  29433. * Field Of View is set in Radians. (default is 0.8)
  29434. */
  29435. fov: number;
  29436. /**
  29437. * Define the minimum distance the camera can see from.
  29438. * This is important to note that the depth buffer are not infinite and the closer it starts
  29439. * the more your scene might encounter depth fighting issue.
  29440. */
  29441. minZ: number;
  29442. /**
  29443. * Define the maximum distance the camera can see to.
  29444. * This is important to note that the depth buffer are not infinite and the further it end
  29445. * the more your scene might encounter depth fighting issue.
  29446. */
  29447. maxZ: number;
  29448. /**
  29449. * Define the default inertia of the camera.
  29450. * This helps giving a smooth feeling to the camera movement.
  29451. */
  29452. inertia: number;
  29453. /**
  29454. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29455. */
  29456. mode: number;
  29457. /**
  29458. * Define whether the camera is intermediate.
  29459. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29460. */
  29461. isIntermediate: boolean;
  29462. /**
  29463. * Define the viewport of the camera.
  29464. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29465. */
  29466. viewport: Viewport;
  29467. /**
  29468. * Restricts the camera to viewing objects with the same layerMask.
  29469. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29470. */
  29471. layerMask: number;
  29472. /**
  29473. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29474. */
  29475. fovMode: number;
  29476. /**
  29477. * Rig mode of the camera.
  29478. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29479. * This is normally controlled byt the camera themselves as internal use.
  29480. */
  29481. cameraRigMode: number;
  29482. /**
  29483. * Defines the distance between both "eyes" in case of a RIG
  29484. */
  29485. interaxialDistance: number;
  29486. /**
  29487. * Defines if stereoscopic rendering is done side by side or over under.
  29488. */
  29489. isStereoscopicSideBySide: boolean;
  29490. /**
  29491. * 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
  29492. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29493. * else in the scene. (Eg. security camera)
  29494. *
  29495. * 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)
  29496. */
  29497. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29498. /**
  29499. * When set, the camera will render to this render target instead of the default canvas
  29500. *
  29501. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29502. */
  29503. outputRenderTarget: Nullable<RenderTargetTexture>;
  29504. /**
  29505. * Observable triggered when the camera view matrix has changed.
  29506. */
  29507. onViewMatrixChangedObservable: Observable<Camera>;
  29508. /**
  29509. * Observable triggered when the camera Projection matrix has changed.
  29510. */
  29511. onProjectionMatrixChangedObservable: Observable<Camera>;
  29512. /**
  29513. * Observable triggered when the inputs have been processed.
  29514. */
  29515. onAfterCheckInputsObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when reset has been called and applied to the camera.
  29518. */
  29519. onRestoreStateObservable: Observable<Camera>;
  29520. /**
  29521. * Is this camera a part of a rig system?
  29522. */
  29523. isRigCamera: boolean;
  29524. /**
  29525. * If isRigCamera set to true this will be set with the parent camera.
  29526. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29527. */
  29528. rigParent?: Camera;
  29529. /** @hidden */
  29530. _cameraRigParams: any;
  29531. /** @hidden */
  29532. _rigCameras: Camera[];
  29533. /** @hidden */
  29534. _rigPostProcess: Nullable<PostProcess>;
  29535. protected _webvrViewMatrix: Matrix;
  29536. /** @hidden */
  29537. _skipRendering: boolean;
  29538. /** @hidden */
  29539. _projectionMatrix: Matrix;
  29540. /** @hidden */
  29541. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29542. /** @hidden */
  29543. _activeMeshes: SmartArray<AbstractMesh>;
  29544. protected _globalPosition: Vector3;
  29545. /** @hidden */
  29546. _computedViewMatrix: Matrix;
  29547. private _doNotComputeProjectionMatrix;
  29548. private _transformMatrix;
  29549. private _frustumPlanes;
  29550. private _refreshFrustumPlanes;
  29551. private _storedFov;
  29552. private _stateStored;
  29553. /**
  29554. * Instantiates a new camera object.
  29555. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29556. * @see https://doc.babylonjs.com/features/cameras
  29557. * @param name Defines the name of the camera in the scene
  29558. * @param position Defines the position of the camera
  29559. * @param scene Defines the scene the camera belongs too
  29560. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29561. */
  29562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29563. /**
  29564. * Store current camera state (fov, position, etc..)
  29565. * @returns the camera
  29566. */
  29567. storeState(): Camera;
  29568. /**
  29569. * Restores the camera state values if it has been stored. You must call storeState() first
  29570. */
  29571. protected _restoreStateValues(): boolean;
  29572. /**
  29573. * Restored camera state. You must call storeState() first.
  29574. * @returns true if restored and false otherwise
  29575. */
  29576. restoreState(): boolean;
  29577. /**
  29578. * Gets the class name of the camera.
  29579. * @returns the class name
  29580. */
  29581. getClassName(): string;
  29582. /** @hidden */
  29583. readonly _isCamera: boolean;
  29584. /**
  29585. * Gets a string representation of the camera useful for debug purpose.
  29586. * @param fullDetails Defines that a more verboe level of logging is required
  29587. * @returns the string representation
  29588. */
  29589. toString(fullDetails?: boolean): string;
  29590. /**
  29591. * Gets the current world space position of the camera.
  29592. */
  29593. get globalPosition(): Vector3;
  29594. /**
  29595. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29596. * @returns the active meshe list
  29597. */
  29598. getActiveMeshes(): SmartArray<AbstractMesh>;
  29599. /**
  29600. * Check whether a mesh is part of the current active mesh list of the camera
  29601. * @param mesh Defines the mesh to check
  29602. * @returns true if active, false otherwise
  29603. */
  29604. isActiveMesh(mesh: Mesh): boolean;
  29605. /**
  29606. * Is this camera ready to be used/rendered
  29607. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29608. * @return true if the camera is ready
  29609. */
  29610. isReady(completeCheck?: boolean): boolean;
  29611. /** @hidden */
  29612. _initCache(): void;
  29613. /** @hidden */
  29614. _updateCache(ignoreParentClass?: boolean): void;
  29615. /** @hidden */
  29616. _isSynchronized(): boolean;
  29617. /** @hidden */
  29618. _isSynchronizedViewMatrix(): boolean;
  29619. /** @hidden */
  29620. _isSynchronizedProjectionMatrix(): boolean;
  29621. /**
  29622. * Attach the input controls to a specific dom element to get the input from.
  29623. * @param element Defines the element the controls should be listened from
  29624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29625. */
  29626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29627. /**
  29628. * Detach the current controls from the specified dom element.
  29629. * @param element Defines the element to stop listening the inputs from
  29630. */
  29631. detachControl(element: HTMLElement): void;
  29632. /**
  29633. * Update the camera state according to the different inputs gathered during the frame.
  29634. */
  29635. update(): void;
  29636. /** @hidden */
  29637. _checkInputs(): void;
  29638. /** @hidden */
  29639. get rigCameras(): Camera[];
  29640. /**
  29641. * Gets the post process used by the rig cameras
  29642. */
  29643. get rigPostProcess(): Nullable<PostProcess>;
  29644. /**
  29645. * Internal, gets the first post proces.
  29646. * @returns the first post process to be run on this camera.
  29647. */
  29648. _getFirstPostProcess(): Nullable<PostProcess>;
  29649. private _cascadePostProcessesToRigCams;
  29650. /**
  29651. * Attach a post process to the camera.
  29652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29653. * @param postProcess The post process to attach to the camera
  29654. * @param insertAt The position of the post process in case several of them are in use in the scene
  29655. * @returns the position the post process has been inserted at
  29656. */
  29657. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29658. /**
  29659. * Detach a post process to the camera.
  29660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29661. * @param postProcess The post process to detach from the camera
  29662. */
  29663. detachPostProcess(postProcess: PostProcess): void;
  29664. /**
  29665. * Gets the current world matrix of the camera
  29666. */
  29667. getWorldMatrix(): Matrix;
  29668. /** @hidden */
  29669. _getViewMatrix(): Matrix;
  29670. /**
  29671. * Gets the current view matrix of the camera.
  29672. * @param force forces the camera to recompute the matrix without looking at the cached state
  29673. * @returns the view matrix
  29674. */
  29675. getViewMatrix(force?: boolean): Matrix;
  29676. /**
  29677. * Freeze the projection matrix.
  29678. * It will prevent the cache check of the camera projection compute and can speed up perf
  29679. * if no parameter of the camera are meant to change
  29680. * @param projection Defines manually a projection if necessary
  29681. */
  29682. freezeProjectionMatrix(projection?: Matrix): void;
  29683. /**
  29684. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29685. */
  29686. unfreezeProjectionMatrix(): void;
  29687. /**
  29688. * Gets the current projection matrix of the camera.
  29689. * @param force forces the camera to recompute the matrix without looking at the cached state
  29690. * @returns the projection matrix
  29691. */
  29692. getProjectionMatrix(force?: boolean): Matrix;
  29693. /**
  29694. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29695. * @returns a Matrix
  29696. */
  29697. getTransformationMatrix(): Matrix;
  29698. private _updateFrustumPlanes;
  29699. /**
  29700. * Checks if a cullable object (mesh...) is in the camera frustum
  29701. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29702. * @param target The object to check
  29703. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29704. * @returns true if the object is in frustum otherwise false
  29705. */
  29706. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29707. /**
  29708. * Checks if a cullable object (mesh...) is in the camera frustum
  29709. * Unlike isInFrustum this cheks the full bounding box
  29710. * @param target The object to check
  29711. * @returns true if the object is in frustum otherwise false
  29712. */
  29713. isCompletelyInFrustum(target: ICullable): boolean;
  29714. /**
  29715. * Gets a ray in the forward direction from the camera.
  29716. * @param length Defines the length of the ray to create
  29717. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29718. * @param origin Defines the start point of the ray which defaults to the camera position
  29719. * @returns the forward ray
  29720. */
  29721. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29722. /**
  29723. * Releases resources associated with this node.
  29724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29726. */
  29727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29728. /** @hidden */
  29729. _isLeftCamera: boolean;
  29730. /**
  29731. * Gets the left camera of a rig setup in case of Rigged Camera
  29732. */
  29733. get isLeftCamera(): boolean;
  29734. /** @hidden */
  29735. _isRightCamera: boolean;
  29736. /**
  29737. * Gets the right camera of a rig setup in case of Rigged Camera
  29738. */
  29739. get isRightCamera(): boolean;
  29740. /**
  29741. * Gets the left camera of a rig setup in case of Rigged Camera
  29742. */
  29743. get leftCamera(): Nullable<FreeCamera>;
  29744. /**
  29745. * Gets the right camera of a rig setup in case of Rigged Camera
  29746. */
  29747. get rightCamera(): Nullable<FreeCamera>;
  29748. /**
  29749. * Gets the left camera target of a rig setup in case of Rigged Camera
  29750. * @returns the target position
  29751. */
  29752. getLeftTarget(): Nullable<Vector3>;
  29753. /**
  29754. * Gets the right camera target of a rig setup in case of Rigged Camera
  29755. * @returns the target position
  29756. */
  29757. getRightTarget(): Nullable<Vector3>;
  29758. /**
  29759. * @hidden
  29760. */
  29761. setCameraRigMode(mode: number, rigParams: any): void;
  29762. /** @hidden */
  29763. static _setStereoscopicRigMode(camera: Camera): void;
  29764. /** @hidden */
  29765. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29766. /** @hidden */
  29767. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29768. /** @hidden */
  29769. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29770. /** @hidden */
  29771. _getVRProjectionMatrix(): Matrix;
  29772. protected _updateCameraRotationMatrix(): void;
  29773. protected _updateWebVRCameraRotationMatrix(): void;
  29774. /**
  29775. * This function MUST be overwritten by the different WebVR cameras available.
  29776. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29777. * @hidden
  29778. */
  29779. _getWebVRProjectionMatrix(): Matrix;
  29780. /**
  29781. * This function MUST be overwritten by the different WebVR cameras available.
  29782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29783. * @hidden
  29784. */
  29785. _getWebVRViewMatrix(): Matrix;
  29786. /** @hidden */
  29787. setCameraRigParameter(name: string, value: any): void;
  29788. /**
  29789. * needs to be overridden by children so sub has required properties to be copied
  29790. * @hidden
  29791. */
  29792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29793. /**
  29794. * May need to be overridden by children
  29795. * @hidden
  29796. */
  29797. _updateRigCameras(): void;
  29798. /** @hidden */
  29799. _setupInputs(): void;
  29800. /**
  29801. * Serialiaze the camera setup to a json represention
  29802. * @returns the JSON representation
  29803. */
  29804. serialize(): any;
  29805. /**
  29806. * Clones the current camera.
  29807. * @param name The cloned camera name
  29808. * @returns the cloned camera
  29809. */
  29810. clone(name: string): Camera;
  29811. /**
  29812. * Gets the direction of the camera relative to a given local axis.
  29813. * @param localAxis Defines the reference axis to provide a relative direction.
  29814. * @return the direction
  29815. */
  29816. getDirection(localAxis: Vector3): Vector3;
  29817. /**
  29818. * Returns the current camera absolute rotation
  29819. */
  29820. get absoluteRotation(): Quaternion;
  29821. /**
  29822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29823. * @param localAxis Defines the reference axis to provide a relative direction.
  29824. * @param result Defines the vector to store the result in
  29825. */
  29826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29827. /**
  29828. * Gets a camera constructor for a given camera type
  29829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29830. * @param name The name of the camera the result will be able to instantiate
  29831. * @param scene The scene the result will construct the camera in
  29832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29834. * @returns a factory method to construc the camera
  29835. */
  29836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29837. /**
  29838. * Compute the world matrix of the camera.
  29839. * @returns the camera world matrix
  29840. */
  29841. computeWorldMatrix(): Matrix;
  29842. /**
  29843. * Parse a JSON and creates the camera from the parsed information
  29844. * @param parsedCamera The JSON to parse
  29845. * @param scene The scene to instantiate the camera in
  29846. * @returns the newly constructed camera
  29847. */
  29848. static Parse(parsedCamera: any, scene: Scene): Camera;
  29849. }
  29850. }
  29851. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29852. import { Nullable } from "babylonjs/types";
  29853. import { Scene } from "babylonjs/scene";
  29854. import { Vector4 } from "babylonjs/Maths/math.vector";
  29855. import { Mesh } from "babylonjs/Meshes/mesh";
  29856. /**
  29857. * Class containing static functions to help procedurally build meshes
  29858. */
  29859. export class DiscBuilder {
  29860. /**
  29861. * Creates a plane polygonal mesh. By default, this is a disc
  29862. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29863. * * 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
  29864. * * 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
  29865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29868. * @param name defines the name of the mesh
  29869. * @param options defines the options used to create the mesh
  29870. * @param scene defines the hosting scene
  29871. * @returns the plane polygonal mesh
  29872. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29873. */
  29874. static CreateDisc(name: string, options: {
  29875. radius?: number;
  29876. tessellation?: number;
  29877. arc?: number;
  29878. updatable?: boolean;
  29879. sideOrientation?: number;
  29880. frontUVs?: Vector4;
  29881. backUVs?: Vector4;
  29882. }, scene?: Nullable<Scene>): Mesh;
  29883. }
  29884. }
  29885. declare module "babylonjs/Materials/fresnelParameters" {
  29886. import { DeepImmutable } from "babylonjs/types";
  29887. import { Color3 } from "babylonjs/Maths/math.color";
  29888. /**
  29889. * Options to be used when creating a FresnelParameters.
  29890. */
  29891. export type IFresnelParametersCreationOptions = {
  29892. /**
  29893. * Define the color used on edges (grazing angle)
  29894. */
  29895. leftColor?: Color3;
  29896. /**
  29897. * Define the color used on center
  29898. */
  29899. rightColor?: Color3;
  29900. /**
  29901. * Define bias applied to computed fresnel term
  29902. */
  29903. bias?: number;
  29904. /**
  29905. * Defined the power exponent applied to fresnel term
  29906. */
  29907. power?: number;
  29908. /**
  29909. * Define if the fresnel effect is enable or not.
  29910. */
  29911. isEnabled?: boolean;
  29912. };
  29913. /**
  29914. * Serialized format for FresnelParameters.
  29915. */
  29916. export type IFresnelParametersSerialized = {
  29917. /**
  29918. * Define the color used on edges (grazing angle) [as an array]
  29919. */
  29920. leftColor: number[];
  29921. /**
  29922. * Define the color used on center [as an array]
  29923. */
  29924. rightColor: number[];
  29925. /**
  29926. * Define bias applied to computed fresnel term
  29927. */
  29928. bias: number;
  29929. /**
  29930. * Defined the power exponent applied to fresnel term
  29931. */
  29932. power?: number;
  29933. /**
  29934. * Define if the fresnel effect is enable or not.
  29935. */
  29936. isEnabled: boolean;
  29937. };
  29938. /**
  29939. * This represents all the required information to add a fresnel effect on a material:
  29940. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29941. */
  29942. export class FresnelParameters {
  29943. private _isEnabled;
  29944. /**
  29945. * Define if the fresnel effect is enable or not.
  29946. */
  29947. get isEnabled(): boolean;
  29948. set isEnabled(value: boolean);
  29949. /**
  29950. * Define the color used on edges (grazing angle)
  29951. */
  29952. leftColor: Color3;
  29953. /**
  29954. * Define the color used on center
  29955. */
  29956. rightColor: Color3;
  29957. /**
  29958. * Define bias applied to computed fresnel term
  29959. */
  29960. bias: number;
  29961. /**
  29962. * Defined the power exponent applied to fresnel term
  29963. */
  29964. power: number;
  29965. /**
  29966. * Creates a new FresnelParameters object.
  29967. *
  29968. * @param options provide your own settings to optionally to override defaults
  29969. */
  29970. constructor(options?: IFresnelParametersCreationOptions);
  29971. /**
  29972. * Clones the current fresnel and its valuues
  29973. * @returns a clone fresnel configuration
  29974. */
  29975. clone(): FresnelParameters;
  29976. /**
  29977. * Determines equality between FresnelParameters objects
  29978. * @param otherFresnelParameters defines the second operand
  29979. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29980. */
  29981. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29982. /**
  29983. * Serializes the current fresnel parameters to a JSON representation.
  29984. * @return the JSON serialization
  29985. */
  29986. serialize(): IFresnelParametersSerialized;
  29987. /**
  29988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29989. * @param parsedFresnelParameters Define the JSON representation
  29990. * @returns the parsed parameters
  29991. */
  29992. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29993. }
  29994. }
  29995. declare module "babylonjs/Materials/materialFlags" {
  29996. /**
  29997. * This groups all the flags used to control the materials channel.
  29998. */
  29999. export class MaterialFlags {
  30000. private static _DiffuseTextureEnabled;
  30001. /**
  30002. * Are diffuse textures enabled in the application.
  30003. */
  30004. static get DiffuseTextureEnabled(): boolean;
  30005. static set DiffuseTextureEnabled(value: boolean);
  30006. private static _DetailTextureEnabled;
  30007. /**
  30008. * Are detail textures enabled in the application.
  30009. */
  30010. static get DetailTextureEnabled(): boolean;
  30011. static set DetailTextureEnabled(value: boolean);
  30012. private static _AmbientTextureEnabled;
  30013. /**
  30014. * Are ambient textures enabled in the application.
  30015. */
  30016. static get AmbientTextureEnabled(): boolean;
  30017. static set AmbientTextureEnabled(value: boolean);
  30018. private static _OpacityTextureEnabled;
  30019. /**
  30020. * Are opacity textures enabled in the application.
  30021. */
  30022. static get OpacityTextureEnabled(): boolean;
  30023. static set OpacityTextureEnabled(value: boolean);
  30024. private static _ReflectionTextureEnabled;
  30025. /**
  30026. * Are reflection textures enabled in the application.
  30027. */
  30028. static get ReflectionTextureEnabled(): boolean;
  30029. static set ReflectionTextureEnabled(value: boolean);
  30030. private static _EmissiveTextureEnabled;
  30031. /**
  30032. * Are emissive textures enabled in the application.
  30033. */
  30034. static get EmissiveTextureEnabled(): boolean;
  30035. static set EmissiveTextureEnabled(value: boolean);
  30036. private static _SpecularTextureEnabled;
  30037. /**
  30038. * Are specular textures enabled in the application.
  30039. */
  30040. static get SpecularTextureEnabled(): boolean;
  30041. static set SpecularTextureEnabled(value: boolean);
  30042. private static _BumpTextureEnabled;
  30043. /**
  30044. * Are bump textures enabled in the application.
  30045. */
  30046. static get BumpTextureEnabled(): boolean;
  30047. static set BumpTextureEnabled(value: boolean);
  30048. private static _LightmapTextureEnabled;
  30049. /**
  30050. * Are lightmap textures enabled in the application.
  30051. */
  30052. static get LightmapTextureEnabled(): boolean;
  30053. static set LightmapTextureEnabled(value: boolean);
  30054. private static _RefractionTextureEnabled;
  30055. /**
  30056. * Are refraction textures enabled in the application.
  30057. */
  30058. static get RefractionTextureEnabled(): boolean;
  30059. static set RefractionTextureEnabled(value: boolean);
  30060. private static _ColorGradingTextureEnabled;
  30061. /**
  30062. * Are color grading textures enabled in the application.
  30063. */
  30064. static get ColorGradingTextureEnabled(): boolean;
  30065. static set ColorGradingTextureEnabled(value: boolean);
  30066. private static _FresnelEnabled;
  30067. /**
  30068. * Are fresnels enabled in the application.
  30069. */
  30070. static get FresnelEnabled(): boolean;
  30071. static set FresnelEnabled(value: boolean);
  30072. private static _ClearCoatTextureEnabled;
  30073. /**
  30074. * Are clear coat textures enabled in the application.
  30075. */
  30076. static get ClearCoatTextureEnabled(): boolean;
  30077. static set ClearCoatTextureEnabled(value: boolean);
  30078. private static _ClearCoatBumpTextureEnabled;
  30079. /**
  30080. * Are clear coat bump textures enabled in the application.
  30081. */
  30082. static get ClearCoatBumpTextureEnabled(): boolean;
  30083. static set ClearCoatBumpTextureEnabled(value: boolean);
  30084. private static _ClearCoatTintTextureEnabled;
  30085. /**
  30086. * Are clear coat tint textures enabled in the application.
  30087. */
  30088. static get ClearCoatTintTextureEnabled(): boolean;
  30089. static set ClearCoatTintTextureEnabled(value: boolean);
  30090. private static _SheenTextureEnabled;
  30091. /**
  30092. * Are sheen textures enabled in the application.
  30093. */
  30094. static get SheenTextureEnabled(): boolean;
  30095. static set SheenTextureEnabled(value: boolean);
  30096. private static _AnisotropicTextureEnabled;
  30097. /**
  30098. * Are anisotropic textures enabled in the application.
  30099. */
  30100. static get AnisotropicTextureEnabled(): boolean;
  30101. static set AnisotropicTextureEnabled(value: boolean);
  30102. private static _ThicknessTextureEnabled;
  30103. /**
  30104. * Are thickness textures enabled in the application.
  30105. */
  30106. static get ThicknessTextureEnabled(): boolean;
  30107. static set ThicknessTextureEnabled(value: boolean);
  30108. }
  30109. }
  30110. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30111. /** @hidden */
  30112. export var defaultFragmentDeclaration: {
  30113. name: string;
  30114. shader: string;
  30115. };
  30116. }
  30117. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30118. /** @hidden */
  30119. export var defaultUboDeclaration: {
  30120. name: string;
  30121. shader: string;
  30122. };
  30123. }
  30124. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30125. /** @hidden */
  30126. export var lightFragmentDeclaration: {
  30127. name: string;
  30128. shader: string;
  30129. };
  30130. }
  30131. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30132. /** @hidden */
  30133. export var lightUboDeclaration: {
  30134. name: string;
  30135. shader: string;
  30136. };
  30137. }
  30138. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30139. /** @hidden */
  30140. export var lightsFragmentFunctions: {
  30141. name: string;
  30142. shader: string;
  30143. };
  30144. }
  30145. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30146. /** @hidden */
  30147. export var shadowsFragmentFunctions: {
  30148. name: string;
  30149. shader: string;
  30150. };
  30151. }
  30152. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30153. /** @hidden */
  30154. export var fresnelFunction: {
  30155. name: string;
  30156. shader: string;
  30157. };
  30158. }
  30159. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30160. /** @hidden */
  30161. export var bumpFragmentMainFunctions: {
  30162. name: string;
  30163. shader: string;
  30164. };
  30165. }
  30166. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30167. /** @hidden */
  30168. export var bumpFragmentFunctions: {
  30169. name: string;
  30170. shader: string;
  30171. };
  30172. }
  30173. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30174. /** @hidden */
  30175. export var logDepthDeclaration: {
  30176. name: string;
  30177. shader: string;
  30178. };
  30179. }
  30180. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30181. /** @hidden */
  30182. export var bumpFragment: {
  30183. name: string;
  30184. shader: string;
  30185. };
  30186. }
  30187. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30188. /** @hidden */
  30189. export var depthPrePass: {
  30190. name: string;
  30191. shader: string;
  30192. };
  30193. }
  30194. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30195. /** @hidden */
  30196. export var lightFragment: {
  30197. name: string;
  30198. shader: string;
  30199. };
  30200. }
  30201. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30202. /** @hidden */
  30203. export var logDepthFragment: {
  30204. name: string;
  30205. shader: string;
  30206. };
  30207. }
  30208. declare module "babylonjs/Shaders/default.fragment" {
  30209. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30210. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30211. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30212. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30215. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30216. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30217. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30218. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30219. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30220. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30221. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30222. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30223. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30224. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30225. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30226. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30227. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30228. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30229. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30230. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30231. /** @hidden */
  30232. export var defaultPixelShader: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30238. /** @hidden */
  30239. export var defaultVertexDeclaration: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30245. /** @hidden */
  30246. export var bumpVertexDeclaration: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30252. /** @hidden */
  30253. export var bumpVertex: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30259. /** @hidden */
  30260. export var fogVertex: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30266. /** @hidden */
  30267. export var shadowsVertex: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30273. /** @hidden */
  30274. export var pointCloudVertex: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30280. /** @hidden */
  30281. export var logDepthVertex: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module "babylonjs/Shaders/default.vertex" {
  30287. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30290. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30304. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30305. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30306. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30307. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30308. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30309. /** @hidden */
  30310. export var defaultVertexShader: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30316. import { Nullable } from "babylonjs/types";
  30317. import { Scene } from "babylonjs/scene";
  30318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30320. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30321. /**
  30322. * @hidden
  30323. */
  30324. export interface IMaterialDetailMapDefines {
  30325. DETAIL: boolean;
  30326. DETAILDIRECTUV: number;
  30327. DETAIL_NORMALBLENDMETHOD: number;
  30328. /** @hidden */
  30329. _areTexturesDirty: boolean;
  30330. }
  30331. /**
  30332. * Define the code related to the detail map parameters of a material
  30333. *
  30334. * Inspired from:
  30335. * 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
  30336. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30337. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30338. */
  30339. export class DetailMapConfiguration {
  30340. private _texture;
  30341. /**
  30342. * The detail texture of the material.
  30343. */
  30344. texture: Nullable<BaseTexture>;
  30345. /**
  30346. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30347. * Bigger values mean stronger blending
  30348. */
  30349. diffuseBlendLevel: number;
  30350. /**
  30351. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30352. * Bigger values mean stronger blending. Only used with PBR materials
  30353. */
  30354. roughnessBlendLevel: number;
  30355. /**
  30356. * Defines how strong the bump effect from the detail map is
  30357. * Bigger values mean stronger effect
  30358. */
  30359. bumpLevel: number;
  30360. private _normalBlendMethod;
  30361. /**
  30362. * The method used to blend the bump and detail normals together
  30363. */
  30364. normalBlendMethod: number;
  30365. private _isEnabled;
  30366. /**
  30367. * Enable or disable the detail map on this material
  30368. */
  30369. isEnabled: boolean;
  30370. /** @hidden */
  30371. private _internalMarkAllSubMeshesAsTexturesDirty;
  30372. /** @hidden */
  30373. _markAllSubMeshesAsTexturesDirty(): void;
  30374. /**
  30375. * Instantiate a new detail map
  30376. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30377. */
  30378. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30379. /**
  30380. * Gets whether the submesh is ready to be used or not.
  30381. * @param defines the list of "defines" to update.
  30382. * @param scene defines the scene the material belongs to.
  30383. * @returns - boolean indicating that the submesh is ready or not.
  30384. */
  30385. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30386. /**
  30387. * Update the defines for detail map usage
  30388. * @param defines the list of "defines" to update.
  30389. * @param scene defines the scene the material belongs to.
  30390. */
  30391. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30392. /**
  30393. * Binds the material data.
  30394. * @param uniformBuffer defines the Uniform buffer to fill in.
  30395. * @param scene defines the scene the material belongs to.
  30396. * @param isFrozen defines whether the material is frozen or not.
  30397. */
  30398. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30399. /**
  30400. * Checks to see if a texture is used in the material.
  30401. * @param texture - Base texture to use.
  30402. * @returns - Boolean specifying if a texture is used in the material.
  30403. */
  30404. hasTexture(texture: BaseTexture): boolean;
  30405. /**
  30406. * Returns an array of the actively used textures.
  30407. * @param activeTextures Array of BaseTextures
  30408. */
  30409. getActiveTextures(activeTextures: BaseTexture[]): void;
  30410. /**
  30411. * Returns the animatable textures.
  30412. * @param animatables Array of animatable textures.
  30413. */
  30414. getAnimatables(animatables: IAnimatable[]): void;
  30415. /**
  30416. * Disposes the resources of the material.
  30417. * @param forceDisposeTextures - Forces the disposal of all textures.
  30418. */
  30419. dispose(forceDisposeTextures?: boolean): void;
  30420. /**
  30421. * Get the current class name useful for serialization or dynamic coding.
  30422. * @returns "DetailMap"
  30423. */
  30424. getClassName(): string;
  30425. /**
  30426. * Add the required uniforms to the current list.
  30427. * @param uniforms defines the current uniform list.
  30428. */
  30429. static AddUniforms(uniforms: string[]): void;
  30430. /**
  30431. * Add the required samplers to the current list.
  30432. * @param samplers defines the current sampler list.
  30433. */
  30434. static AddSamplers(samplers: string[]): void;
  30435. /**
  30436. * Add the required uniforms to the current buffer.
  30437. * @param uniformBuffer defines the current uniform buffer.
  30438. */
  30439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30440. /**
  30441. * Makes a duplicate of the current instance into another one.
  30442. * @param detailMap define the instance where to copy the info
  30443. */
  30444. copyTo(detailMap: DetailMapConfiguration): void;
  30445. /**
  30446. * Serializes this detail map instance
  30447. * @returns - An object with the serialized instance.
  30448. */
  30449. serialize(): any;
  30450. /**
  30451. * Parses a detail map setting from a serialized object.
  30452. * @param source - Serialized object.
  30453. * @param scene Defines the scene we are parsing for
  30454. * @param rootUrl Defines the rootUrl to load from
  30455. */
  30456. parse(source: any, scene: Scene, rootUrl: string): void;
  30457. }
  30458. }
  30459. declare module "babylonjs/Materials/standardMaterial" {
  30460. import { SmartArray } from "babylonjs/Misc/smartArray";
  30461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30462. import { Nullable } from "babylonjs/types";
  30463. import { Scene } from "babylonjs/scene";
  30464. import { Matrix } from "babylonjs/Maths/math.vector";
  30465. import { Color3 } from "babylonjs/Maths/math.color";
  30466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30468. import { Mesh } from "babylonjs/Meshes/mesh";
  30469. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30470. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30471. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30476. import "babylonjs/Shaders/default.fragment";
  30477. import "babylonjs/Shaders/default.vertex";
  30478. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30479. /** @hidden */
  30480. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30481. MAINUV1: boolean;
  30482. MAINUV2: boolean;
  30483. DIFFUSE: boolean;
  30484. DIFFUSEDIRECTUV: number;
  30485. DETAIL: boolean;
  30486. DETAILDIRECTUV: number;
  30487. DETAIL_NORMALBLENDMETHOD: number;
  30488. AMBIENT: boolean;
  30489. AMBIENTDIRECTUV: number;
  30490. OPACITY: boolean;
  30491. OPACITYDIRECTUV: number;
  30492. OPACITYRGB: boolean;
  30493. REFLECTION: boolean;
  30494. EMISSIVE: boolean;
  30495. EMISSIVEDIRECTUV: number;
  30496. SPECULAR: boolean;
  30497. SPECULARDIRECTUV: number;
  30498. BUMP: boolean;
  30499. BUMPDIRECTUV: number;
  30500. PARALLAX: boolean;
  30501. PARALLAXOCCLUSION: boolean;
  30502. SPECULAROVERALPHA: boolean;
  30503. CLIPPLANE: boolean;
  30504. CLIPPLANE2: boolean;
  30505. CLIPPLANE3: boolean;
  30506. CLIPPLANE4: boolean;
  30507. CLIPPLANE5: boolean;
  30508. CLIPPLANE6: boolean;
  30509. ALPHATEST: boolean;
  30510. DEPTHPREPASS: boolean;
  30511. ALPHAFROMDIFFUSE: boolean;
  30512. POINTSIZE: boolean;
  30513. FOG: boolean;
  30514. SPECULARTERM: boolean;
  30515. DIFFUSEFRESNEL: boolean;
  30516. OPACITYFRESNEL: boolean;
  30517. REFLECTIONFRESNEL: boolean;
  30518. REFRACTIONFRESNEL: boolean;
  30519. EMISSIVEFRESNEL: boolean;
  30520. FRESNEL: boolean;
  30521. NORMAL: boolean;
  30522. UV1: boolean;
  30523. UV2: boolean;
  30524. VERTEXCOLOR: boolean;
  30525. VERTEXALPHA: boolean;
  30526. NUM_BONE_INFLUENCERS: number;
  30527. BonesPerMesh: number;
  30528. BONETEXTURE: boolean;
  30529. INSTANCES: boolean;
  30530. THIN_INSTANCES: boolean;
  30531. GLOSSINESS: boolean;
  30532. ROUGHNESS: boolean;
  30533. EMISSIVEASILLUMINATION: boolean;
  30534. LINKEMISSIVEWITHDIFFUSE: boolean;
  30535. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30536. LIGHTMAP: boolean;
  30537. LIGHTMAPDIRECTUV: number;
  30538. OBJECTSPACE_NORMALMAP: boolean;
  30539. USELIGHTMAPASSHADOWMAP: boolean;
  30540. REFLECTIONMAP_3D: boolean;
  30541. REFLECTIONMAP_SPHERICAL: boolean;
  30542. REFLECTIONMAP_PLANAR: boolean;
  30543. REFLECTIONMAP_CUBIC: boolean;
  30544. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30545. REFLECTIONMAP_PROJECTION: boolean;
  30546. REFLECTIONMAP_SKYBOX: boolean;
  30547. REFLECTIONMAP_EXPLICIT: boolean;
  30548. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30549. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30550. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30551. INVERTCUBICMAP: boolean;
  30552. LOGARITHMICDEPTH: boolean;
  30553. REFRACTION: boolean;
  30554. REFRACTIONMAP_3D: boolean;
  30555. REFLECTIONOVERALPHA: boolean;
  30556. TWOSIDEDLIGHTING: boolean;
  30557. SHADOWFLOAT: boolean;
  30558. MORPHTARGETS: boolean;
  30559. MORPHTARGETS_NORMAL: boolean;
  30560. MORPHTARGETS_TANGENT: boolean;
  30561. MORPHTARGETS_UV: boolean;
  30562. NUM_MORPH_INFLUENCERS: number;
  30563. NONUNIFORMSCALING: boolean;
  30564. PREMULTIPLYALPHA: boolean;
  30565. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30566. ALPHABLEND: boolean;
  30567. PREPASS: boolean;
  30568. SCENE_MRT_COUNT: number;
  30569. RGBDLIGHTMAP: boolean;
  30570. RGBDREFLECTION: boolean;
  30571. RGBDREFRACTION: boolean;
  30572. IMAGEPROCESSING: boolean;
  30573. VIGNETTE: boolean;
  30574. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30575. VIGNETTEBLENDMODEOPAQUE: boolean;
  30576. TONEMAPPING: boolean;
  30577. TONEMAPPING_ACES: boolean;
  30578. CONTRAST: boolean;
  30579. COLORCURVES: boolean;
  30580. COLORGRADING: boolean;
  30581. COLORGRADING3D: boolean;
  30582. SAMPLER3DGREENDEPTH: boolean;
  30583. SAMPLER3DBGRMAP: boolean;
  30584. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30585. MULTIVIEW: boolean;
  30586. /**
  30587. * If the reflection texture on this material is in linear color space
  30588. * @hidden
  30589. */
  30590. IS_REFLECTION_LINEAR: boolean;
  30591. /**
  30592. * If the refraction texture on this material is in linear color space
  30593. * @hidden
  30594. */
  30595. IS_REFRACTION_LINEAR: boolean;
  30596. EXPOSURE: boolean;
  30597. constructor();
  30598. setReflectionMode(modeToEnable: string): void;
  30599. }
  30600. /**
  30601. * This is the default material used in Babylon. It is the best trade off between quality
  30602. * and performances.
  30603. * @see https://doc.babylonjs.com/babylon101/materials
  30604. */
  30605. export class StandardMaterial extends PushMaterial {
  30606. private _diffuseTexture;
  30607. /**
  30608. * The basic texture of the material as viewed under a light.
  30609. */
  30610. diffuseTexture: Nullable<BaseTexture>;
  30611. private _ambientTexture;
  30612. /**
  30613. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30614. */
  30615. ambientTexture: Nullable<BaseTexture>;
  30616. private _opacityTexture;
  30617. /**
  30618. * Define the transparency of the material from a texture.
  30619. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30620. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30621. */
  30622. opacityTexture: Nullable<BaseTexture>;
  30623. private _reflectionTexture;
  30624. /**
  30625. * Define the texture used to display the reflection.
  30626. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30627. */
  30628. reflectionTexture: Nullable<BaseTexture>;
  30629. private _emissiveTexture;
  30630. /**
  30631. * Define texture of the material as if self lit.
  30632. * This will be mixed in the final result even in the absence of light.
  30633. */
  30634. emissiveTexture: Nullable<BaseTexture>;
  30635. private _specularTexture;
  30636. /**
  30637. * Define how the color and intensity of the highlight given by the light in the material.
  30638. */
  30639. specularTexture: Nullable<BaseTexture>;
  30640. private _bumpTexture;
  30641. /**
  30642. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30643. * 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.
  30644. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30645. */
  30646. bumpTexture: Nullable<BaseTexture>;
  30647. private _lightmapTexture;
  30648. /**
  30649. * Complex lighting can be computationally expensive to compute at runtime.
  30650. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30651. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30652. */
  30653. lightmapTexture: Nullable<BaseTexture>;
  30654. private _refractionTexture;
  30655. /**
  30656. * Define the texture used to display the refraction.
  30657. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30658. */
  30659. refractionTexture: Nullable<BaseTexture>;
  30660. /**
  30661. * The color of the material lit by the environmental background lighting.
  30662. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30663. */
  30664. ambientColor: Color3;
  30665. /**
  30666. * The basic color of the material as viewed under a light.
  30667. */
  30668. diffuseColor: Color3;
  30669. /**
  30670. * Define how the color and intensity of the highlight given by the light in the material.
  30671. */
  30672. specularColor: Color3;
  30673. /**
  30674. * Define the color of the material as if self lit.
  30675. * This will be mixed in the final result even in the absence of light.
  30676. */
  30677. emissiveColor: Color3;
  30678. /**
  30679. * Defines how sharp are the highlights in the material.
  30680. * The bigger the value the sharper giving a more glossy feeling to the result.
  30681. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30682. */
  30683. specularPower: number;
  30684. private _useAlphaFromDiffuseTexture;
  30685. /**
  30686. * Does the transparency come from the diffuse texture alpha channel.
  30687. */
  30688. useAlphaFromDiffuseTexture: boolean;
  30689. private _useEmissiveAsIllumination;
  30690. /**
  30691. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30692. */
  30693. useEmissiveAsIllumination: boolean;
  30694. private _linkEmissiveWithDiffuse;
  30695. /**
  30696. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30697. * the emissive level when the final color is close to one.
  30698. */
  30699. linkEmissiveWithDiffuse: boolean;
  30700. private _useSpecularOverAlpha;
  30701. /**
  30702. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30703. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30704. */
  30705. useSpecularOverAlpha: boolean;
  30706. private _useReflectionOverAlpha;
  30707. /**
  30708. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30709. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30710. */
  30711. useReflectionOverAlpha: boolean;
  30712. private _disableLighting;
  30713. /**
  30714. * Does lights from the scene impacts this material.
  30715. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30716. */
  30717. disableLighting: boolean;
  30718. private _useObjectSpaceNormalMap;
  30719. /**
  30720. * Allows using an object space normal map (instead of tangent space).
  30721. */
  30722. useObjectSpaceNormalMap: boolean;
  30723. private _useParallax;
  30724. /**
  30725. * Is parallax enabled or not.
  30726. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30727. */
  30728. useParallax: boolean;
  30729. private _useParallaxOcclusion;
  30730. /**
  30731. * Is parallax occlusion enabled or not.
  30732. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30733. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30734. */
  30735. useParallaxOcclusion: boolean;
  30736. /**
  30737. * 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.
  30738. */
  30739. parallaxScaleBias: number;
  30740. private _roughness;
  30741. /**
  30742. * Helps to define how blurry the reflections should appears in the material.
  30743. */
  30744. roughness: number;
  30745. /**
  30746. * In case of refraction, define the value of the index of refraction.
  30747. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30748. */
  30749. indexOfRefraction: number;
  30750. /**
  30751. * Invert the refraction texture alongside the y axis.
  30752. * It can be useful with procedural textures or probe for instance.
  30753. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30754. */
  30755. invertRefractionY: boolean;
  30756. /**
  30757. * Defines the alpha limits in alpha test mode.
  30758. */
  30759. alphaCutOff: number;
  30760. private _useLightmapAsShadowmap;
  30761. /**
  30762. * In case of light mapping, define whether the map contains light or shadow informations.
  30763. */
  30764. useLightmapAsShadowmap: boolean;
  30765. private _diffuseFresnelParameters;
  30766. /**
  30767. * Define the diffuse fresnel parameters of the material.
  30768. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30769. */
  30770. diffuseFresnelParameters: FresnelParameters;
  30771. private _opacityFresnelParameters;
  30772. /**
  30773. * Define the opacity fresnel parameters of the material.
  30774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30775. */
  30776. opacityFresnelParameters: FresnelParameters;
  30777. private _reflectionFresnelParameters;
  30778. /**
  30779. * Define the reflection fresnel parameters of the material.
  30780. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30781. */
  30782. reflectionFresnelParameters: FresnelParameters;
  30783. private _refractionFresnelParameters;
  30784. /**
  30785. * Define the refraction fresnel parameters of the material.
  30786. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30787. */
  30788. refractionFresnelParameters: FresnelParameters;
  30789. private _emissiveFresnelParameters;
  30790. /**
  30791. * Define the emissive fresnel parameters of the material.
  30792. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30793. */
  30794. emissiveFresnelParameters: FresnelParameters;
  30795. private _useReflectionFresnelFromSpecular;
  30796. /**
  30797. * If true automatically deducts the fresnels values from the material specularity.
  30798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30799. */
  30800. useReflectionFresnelFromSpecular: boolean;
  30801. private _useGlossinessFromSpecularMapAlpha;
  30802. /**
  30803. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30804. */
  30805. useGlossinessFromSpecularMapAlpha: boolean;
  30806. private _maxSimultaneousLights;
  30807. /**
  30808. * Defines the maximum number of lights that can be used in the material
  30809. */
  30810. maxSimultaneousLights: number;
  30811. private _invertNormalMapX;
  30812. /**
  30813. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30814. */
  30815. invertNormalMapX: boolean;
  30816. private _invertNormalMapY;
  30817. /**
  30818. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30819. */
  30820. invertNormalMapY: boolean;
  30821. private _twoSidedLighting;
  30822. /**
  30823. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30824. */
  30825. twoSidedLighting: boolean;
  30826. /**
  30827. * Default configuration related to image processing available in the standard Material.
  30828. */
  30829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30830. /**
  30831. * Gets the image processing configuration used either in this material.
  30832. */
  30833. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30834. /**
  30835. * Sets the Default image processing configuration used either in the this material.
  30836. *
  30837. * If sets to null, the scene one is in use.
  30838. */
  30839. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30840. /**
  30841. * Keep track of the image processing observer to allow dispose and replace.
  30842. */
  30843. private _imageProcessingObserver;
  30844. /**
  30845. * Attaches a new image processing configuration to the Standard Material.
  30846. * @param configuration
  30847. */
  30848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30849. /**
  30850. * Gets wether the color curves effect is enabled.
  30851. */
  30852. get cameraColorCurvesEnabled(): boolean;
  30853. /**
  30854. * Sets wether the color curves effect is enabled.
  30855. */
  30856. set cameraColorCurvesEnabled(value: boolean);
  30857. /**
  30858. * Gets wether the color grading effect is enabled.
  30859. */
  30860. get cameraColorGradingEnabled(): boolean;
  30861. /**
  30862. * Gets wether the color grading effect is enabled.
  30863. */
  30864. set cameraColorGradingEnabled(value: boolean);
  30865. /**
  30866. * Gets wether tonemapping is enabled or not.
  30867. */
  30868. get cameraToneMappingEnabled(): boolean;
  30869. /**
  30870. * Sets wether tonemapping is enabled or not
  30871. */
  30872. set cameraToneMappingEnabled(value: boolean);
  30873. /**
  30874. * The camera exposure used on this material.
  30875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30876. * This corresponds to a photographic exposure.
  30877. */
  30878. get cameraExposure(): number;
  30879. /**
  30880. * The camera exposure used on this material.
  30881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30882. * This corresponds to a photographic exposure.
  30883. */
  30884. set cameraExposure(value: number);
  30885. /**
  30886. * Gets The camera contrast used on this material.
  30887. */
  30888. get cameraContrast(): number;
  30889. /**
  30890. * Sets The camera contrast used on this material.
  30891. */
  30892. set cameraContrast(value: number);
  30893. /**
  30894. * Gets the Color Grading 2D Lookup Texture.
  30895. */
  30896. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30897. /**
  30898. * Sets the Color Grading 2D Lookup Texture.
  30899. */
  30900. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30901. /**
  30902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30904. * 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;
  30905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30906. */
  30907. get cameraColorCurves(): Nullable<ColorCurves>;
  30908. /**
  30909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30911. * 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;
  30912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30913. */
  30914. set cameraColorCurves(value: Nullable<ColorCurves>);
  30915. /**
  30916. * Defines the detail map parameters for the material.
  30917. */
  30918. readonly detailMap: DetailMapConfiguration;
  30919. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30920. protected _worldViewProjectionMatrix: Matrix;
  30921. protected _globalAmbientColor: Color3;
  30922. protected _useLogarithmicDepth: boolean;
  30923. protected _rebuildInParallel: boolean;
  30924. /**
  30925. * Instantiates a new standard material.
  30926. * This is the default material used in Babylon. It is the best trade off between quality
  30927. * and performances.
  30928. * @see https://doc.babylonjs.com/babylon101/materials
  30929. * @param name Define the name of the material in the scene
  30930. * @param scene Define the scene the material belong to
  30931. */
  30932. constructor(name: string, scene: Scene);
  30933. /**
  30934. * Gets a boolean indicating that current material needs to register RTT
  30935. */
  30936. get hasRenderTargetTextures(): boolean;
  30937. /**
  30938. * Gets the current class name of the material e.g. "StandardMaterial"
  30939. * Mainly use in serialization.
  30940. * @returns the class name
  30941. */
  30942. getClassName(): string;
  30943. /**
  30944. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30945. * You can try switching to logarithmic depth.
  30946. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30947. */
  30948. get useLogarithmicDepth(): boolean;
  30949. set useLogarithmicDepth(value: boolean);
  30950. /**
  30951. * Specifies if the material will require alpha blending
  30952. * @returns a boolean specifying if alpha blending is needed
  30953. */
  30954. needAlphaBlending(): boolean;
  30955. /**
  30956. * Specifies if this material should be rendered in alpha test mode
  30957. * @returns a boolean specifying if an alpha test is needed.
  30958. */
  30959. needAlphaTesting(): boolean;
  30960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30961. /**
  30962. * Get the texture used for alpha test purpose.
  30963. * @returns the diffuse texture in case of the standard material.
  30964. */
  30965. getAlphaTestTexture(): Nullable<BaseTexture>;
  30966. /**
  30967. * Get if the submesh is ready to be used and all its information available.
  30968. * Child classes can use it to update shaders
  30969. * @param mesh defines the mesh to check
  30970. * @param subMesh defines which submesh to check
  30971. * @param useInstances specifies that instances should be used
  30972. * @returns a boolean indicating that the submesh is ready or not
  30973. */
  30974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30975. /**
  30976. * Builds the material UBO layouts.
  30977. * Used internally during the effect preparation.
  30978. */
  30979. buildUniformLayout(): void;
  30980. /**
  30981. * Unbinds the material from the mesh
  30982. */
  30983. unbind(): void;
  30984. /**
  30985. * Binds the submesh to this material by preparing the effect and shader to draw
  30986. * @param world defines the world transformation matrix
  30987. * @param mesh defines the mesh containing the submesh
  30988. * @param subMesh defines the submesh to bind the material to
  30989. */
  30990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30991. /**
  30992. * Get the list of animatables in the material.
  30993. * @returns the list of animatables object used in the material
  30994. */
  30995. getAnimatables(): IAnimatable[];
  30996. /**
  30997. * Gets the active textures from the material
  30998. * @returns an array of textures
  30999. */
  31000. getActiveTextures(): BaseTexture[];
  31001. /**
  31002. * Specifies if the material uses a texture
  31003. * @param texture defines the texture to check against the material
  31004. * @returns a boolean specifying if the material uses the texture
  31005. */
  31006. hasTexture(texture: BaseTexture): boolean;
  31007. /**
  31008. * Disposes the material
  31009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31011. */
  31012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31013. /**
  31014. * Makes a duplicate of the material, and gives it a new name
  31015. * @param name defines the new name for the duplicated material
  31016. * @returns the cloned material
  31017. */
  31018. clone(name: string): StandardMaterial;
  31019. /**
  31020. * Serializes this material in a JSON representation
  31021. * @returns the serialized material object
  31022. */
  31023. serialize(): any;
  31024. /**
  31025. * Creates a standard material from parsed material data
  31026. * @param source defines the JSON representation of the material
  31027. * @param scene defines the hosting scene
  31028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31029. * @returns a new standard material
  31030. */
  31031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31032. /**
  31033. * Are diffuse textures enabled in the application.
  31034. */
  31035. static get DiffuseTextureEnabled(): boolean;
  31036. static set DiffuseTextureEnabled(value: boolean);
  31037. /**
  31038. * Are detail textures enabled in the application.
  31039. */
  31040. static get DetailTextureEnabled(): boolean;
  31041. static set DetailTextureEnabled(value: boolean);
  31042. /**
  31043. * Are ambient textures enabled in the application.
  31044. */
  31045. static get AmbientTextureEnabled(): boolean;
  31046. static set AmbientTextureEnabled(value: boolean);
  31047. /**
  31048. * Are opacity textures enabled in the application.
  31049. */
  31050. static get OpacityTextureEnabled(): boolean;
  31051. static set OpacityTextureEnabled(value: boolean);
  31052. /**
  31053. * Are reflection textures enabled in the application.
  31054. */
  31055. static get ReflectionTextureEnabled(): boolean;
  31056. static set ReflectionTextureEnabled(value: boolean);
  31057. /**
  31058. * Are emissive textures enabled in the application.
  31059. */
  31060. static get EmissiveTextureEnabled(): boolean;
  31061. static set EmissiveTextureEnabled(value: boolean);
  31062. /**
  31063. * Are specular textures enabled in the application.
  31064. */
  31065. static get SpecularTextureEnabled(): boolean;
  31066. static set SpecularTextureEnabled(value: boolean);
  31067. /**
  31068. * Are bump textures enabled in the application.
  31069. */
  31070. static get BumpTextureEnabled(): boolean;
  31071. static set BumpTextureEnabled(value: boolean);
  31072. /**
  31073. * Are lightmap textures enabled in the application.
  31074. */
  31075. static get LightmapTextureEnabled(): boolean;
  31076. static set LightmapTextureEnabled(value: boolean);
  31077. /**
  31078. * Are refraction textures enabled in the application.
  31079. */
  31080. static get RefractionTextureEnabled(): boolean;
  31081. static set RefractionTextureEnabled(value: boolean);
  31082. /**
  31083. * Are color grading textures enabled in the application.
  31084. */
  31085. static get ColorGradingTextureEnabled(): boolean;
  31086. static set ColorGradingTextureEnabled(value: boolean);
  31087. /**
  31088. * Are fresnels enabled in the application.
  31089. */
  31090. static get FresnelEnabled(): boolean;
  31091. static set FresnelEnabled(value: boolean);
  31092. }
  31093. }
  31094. declare module "babylonjs/Particles/solidParticleSystem" {
  31095. import { Nullable } from "babylonjs/types";
  31096. import { Mesh } from "babylonjs/Meshes/mesh";
  31097. import { Scene, IDisposable } from "babylonjs/scene";
  31098. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31099. import { Material } from "babylonjs/Materials/material";
  31100. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31101. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31102. /**
  31103. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31104. *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.
  31105. * The SPS is also a particle system. It provides some methods to manage the particles.
  31106. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31107. *
  31108. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31109. */
  31110. export class SolidParticleSystem implements IDisposable {
  31111. /**
  31112. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31113. * Example : var p = SPS.particles[i];
  31114. */
  31115. particles: SolidParticle[];
  31116. /**
  31117. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31118. */
  31119. nbParticles: number;
  31120. /**
  31121. * If the particles must ever face the camera (default false). Useful for planar particles.
  31122. */
  31123. billboard: boolean;
  31124. /**
  31125. * Recompute normals when adding a shape
  31126. */
  31127. recomputeNormals: boolean;
  31128. /**
  31129. * This a counter ofr your own usage. It's not set by any SPS functions.
  31130. */
  31131. counter: number;
  31132. /**
  31133. * The SPS name. This name is also given to the underlying mesh.
  31134. */
  31135. name: string;
  31136. /**
  31137. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31138. */
  31139. mesh: Mesh;
  31140. /**
  31141. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31142. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31143. */
  31144. vars: any;
  31145. /**
  31146. * This array is populated when the SPS is set as 'pickable'.
  31147. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31148. * Each element of this array is an object `{idx: int, faceId: int}`.
  31149. * `idx` is the picked particle index in the `SPS.particles` array
  31150. * `faceId` is the picked face index counted within this particle.
  31151. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31152. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31153. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31154. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31155. */
  31156. pickedParticles: {
  31157. idx: number;
  31158. faceId: number;
  31159. }[];
  31160. /**
  31161. * This array is populated when the SPS is set as 'pickable'
  31162. * Each key of this array is a submesh index.
  31163. * Each element of this array is a second array defined like this :
  31164. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31165. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31166. * `idx` is the picked particle index in the `SPS.particles` array
  31167. * `faceId` is the picked face index counted within this particle.
  31168. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31169. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31170. */
  31171. pickedBySubMesh: {
  31172. idx: number;
  31173. faceId: number;
  31174. }[][];
  31175. /**
  31176. * This array is populated when `enableDepthSort` is set to true.
  31177. * Each element of this array is an instance of the class DepthSortedParticle.
  31178. */
  31179. depthSortedParticles: DepthSortedParticle[];
  31180. /**
  31181. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31182. * @hidden
  31183. */
  31184. _bSphereOnly: boolean;
  31185. /**
  31186. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31187. * @hidden
  31188. */
  31189. _bSphereRadiusFactor: number;
  31190. private _scene;
  31191. private _positions;
  31192. private _indices;
  31193. private _normals;
  31194. private _colors;
  31195. private _uvs;
  31196. private _indices32;
  31197. private _positions32;
  31198. private _normals32;
  31199. private _fixedNormal32;
  31200. private _colors32;
  31201. private _uvs32;
  31202. private _index;
  31203. private _updatable;
  31204. private _pickable;
  31205. private _isVisibilityBoxLocked;
  31206. private _alwaysVisible;
  31207. private _depthSort;
  31208. private _expandable;
  31209. private _shapeCounter;
  31210. private _copy;
  31211. private _color;
  31212. private _computeParticleColor;
  31213. private _computeParticleTexture;
  31214. private _computeParticleRotation;
  31215. private _computeParticleVertex;
  31216. private _computeBoundingBox;
  31217. private _depthSortParticles;
  31218. private _camera;
  31219. private _mustUnrotateFixedNormals;
  31220. private _particlesIntersect;
  31221. private _needs32Bits;
  31222. private _isNotBuilt;
  31223. private _lastParticleId;
  31224. private _idxOfId;
  31225. private _multimaterialEnabled;
  31226. private _useModelMaterial;
  31227. private _indicesByMaterial;
  31228. private _materialIndexes;
  31229. private _depthSortFunction;
  31230. private _materialSortFunction;
  31231. private _materials;
  31232. private _multimaterial;
  31233. private _materialIndexesById;
  31234. private _defaultMaterial;
  31235. private _autoUpdateSubMeshes;
  31236. private _tmpVertex;
  31237. /**
  31238. * Creates a SPS (Solid Particle System) object.
  31239. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31240. * @param scene (Scene) is the scene in which the SPS is added.
  31241. * @param options defines the options of the sps e.g.
  31242. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31243. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31244. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31245. * * 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.
  31246. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31247. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31248. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31249. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31250. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31251. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31252. */
  31253. constructor(name: string, scene: Scene, options?: {
  31254. updatable?: boolean;
  31255. isPickable?: boolean;
  31256. enableDepthSort?: boolean;
  31257. particleIntersection?: boolean;
  31258. boundingSphereOnly?: boolean;
  31259. bSphereRadiusFactor?: number;
  31260. expandable?: boolean;
  31261. useModelMaterial?: boolean;
  31262. enableMultiMaterial?: boolean;
  31263. });
  31264. /**
  31265. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31266. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31267. * @returns the created mesh
  31268. */
  31269. buildMesh(): Mesh;
  31270. /**
  31271. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31272. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31273. * Thus the particles generated from `digest()` have their property `position` set yet.
  31274. * @param mesh ( Mesh ) is the mesh to be digested
  31275. * @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
  31276. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31277. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31278. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31279. * @returns the current SPS
  31280. */
  31281. digest(mesh: Mesh, options?: {
  31282. facetNb?: number;
  31283. number?: number;
  31284. delta?: number;
  31285. storage?: [];
  31286. }): SolidParticleSystem;
  31287. /**
  31288. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31289. * @hidden
  31290. */
  31291. private _unrotateFixedNormals;
  31292. /**
  31293. * Resets the temporary working copy particle
  31294. * @hidden
  31295. */
  31296. private _resetCopy;
  31297. /**
  31298. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31299. * @param p the current index in the positions array to be updated
  31300. * @param ind the current index in the indices array
  31301. * @param shape a Vector3 array, the shape geometry
  31302. * @param positions the positions array to be updated
  31303. * @param meshInd the shape indices array
  31304. * @param indices the indices array to be updated
  31305. * @param meshUV the shape uv array
  31306. * @param uvs the uv array to be updated
  31307. * @param meshCol the shape color array
  31308. * @param colors the color array to be updated
  31309. * @param meshNor the shape normals array
  31310. * @param normals the normals array to be updated
  31311. * @param idx the particle index
  31312. * @param idxInShape the particle index in its shape
  31313. * @param options the addShape() method passed options
  31314. * @model the particle model
  31315. * @hidden
  31316. */
  31317. private _meshBuilder;
  31318. /**
  31319. * Returns a shape Vector3 array from positions float array
  31320. * @param positions float array
  31321. * @returns a vector3 array
  31322. * @hidden
  31323. */
  31324. private _posToShape;
  31325. /**
  31326. * Returns a shapeUV array from a float uvs (array deep copy)
  31327. * @param uvs as a float array
  31328. * @returns a shapeUV array
  31329. * @hidden
  31330. */
  31331. private _uvsToShapeUV;
  31332. /**
  31333. * Adds a new particle object in the particles array
  31334. * @param idx particle index in particles array
  31335. * @param id particle id
  31336. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31337. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31338. * @param model particle ModelShape object
  31339. * @param shapeId model shape identifier
  31340. * @param idxInShape index of the particle in the current model
  31341. * @param bInfo model bounding info object
  31342. * @param storage target storage array, if any
  31343. * @hidden
  31344. */
  31345. private _addParticle;
  31346. /**
  31347. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31348. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31349. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31350. * @param nb (positive integer) the number of particles to be created from this model
  31351. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31352. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31354. * @returns the number of shapes in the system
  31355. */
  31356. addShape(mesh: Mesh, nb: number, options?: {
  31357. positionFunction?: any;
  31358. vertexFunction?: any;
  31359. storage?: [];
  31360. }): number;
  31361. /**
  31362. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31363. * @hidden
  31364. */
  31365. private _rebuildParticle;
  31366. /**
  31367. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31368. * @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.
  31369. * @returns the SPS.
  31370. */
  31371. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31372. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31373. * Returns an array with the removed particles.
  31374. * 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.
  31375. * The SPS can't be empty so at least one particle needs to remain in place.
  31376. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31377. * @param start index of the first particle to remove
  31378. * @param end index of the last particle to remove (included)
  31379. * @returns an array populated with the removed particles
  31380. */
  31381. removeParticles(start: number, end: number): SolidParticle[];
  31382. /**
  31383. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31384. * @param solidParticleArray an array populated with Solid Particles objects
  31385. * @returns the SPS
  31386. */
  31387. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31388. /**
  31389. * Creates a new particle and modifies the SPS mesh geometry :
  31390. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31391. * - calls _addParticle() to populate the particle array
  31392. * factorized code from addShape() and insertParticlesFromArray()
  31393. * @param idx particle index in the particles array
  31394. * @param i particle index in its shape
  31395. * @param modelShape particle ModelShape object
  31396. * @param shape shape vertex array
  31397. * @param meshInd shape indices array
  31398. * @param meshUV shape uv array
  31399. * @param meshCol shape color array
  31400. * @param meshNor shape normals array
  31401. * @param bbInfo shape bounding info
  31402. * @param storage target particle storage
  31403. * @options addShape() passed options
  31404. * @hidden
  31405. */
  31406. private _insertNewParticle;
  31407. /**
  31408. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31409. * This method calls `updateParticle()` for each particle of the SPS.
  31410. * For an animated SPS, it is usually called within the render loop.
  31411. * 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.
  31412. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31413. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31414. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31415. * @returns the SPS.
  31416. */
  31417. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31418. /**
  31419. * Disposes the SPS.
  31420. */
  31421. dispose(): void;
  31422. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31423. * idx is the particle index in the SPS
  31424. * faceId is the picked face index counted within this particle.
  31425. * Returns null if the pickInfo can't identify a picked particle.
  31426. * @param pickingInfo (PickingInfo object)
  31427. * @returns {idx: number, faceId: number} or null
  31428. */
  31429. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31430. idx: number;
  31431. faceId: number;
  31432. }>;
  31433. /**
  31434. * Returns a SolidParticle object from its identifier : particle.id
  31435. * @param id (integer) the particle Id
  31436. * @returns the searched particle or null if not found in the SPS.
  31437. */
  31438. getParticleById(id: number): Nullable<SolidParticle>;
  31439. /**
  31440. * Returns a new array populated with the particles having the passed shapeId.
  31441. * @param shapeId (integer) the shape identifier
  31442. * @returns a new solid particle array
  31443. */
  31444. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31445. /**
  31446. * Populates the passed array "ref" with the particles having the passed shapeId.
  31447. * @param shapeId the shape identifier
  31448. * @returns the SPS
  31449. * @param ref
  31450. */
  31451. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31452. /**
  31453. * Computes the required SubMeshes according the materials assigned to the particles.
  31454. * @returns the solid particle system.
  31455. * Does nothing if called before the SPS mesh is built.
  31456. */
  31457. computeSubMeshes(): SolidParticleSystem;
  31458. /**
  31459. * Sorts the solid particles by material when MultiMaterial is enabled.
  31460. * Updates the indices32 array.
  31461. * Updates the indicesByMaterial array.
  31462. * Updates the mesh indices array.
  31463. * @returns the SPS
  31464. * @hidden
  31465. */
  31466. private _sortParticlesByMaterial;
  31467. /**
  31468. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31469. * @hidden
  31470. */
  31471. private _setMaterialIndexesById;
  31472. /**
  31473. * Returns an array with unique values of Materials from the passed array
  31474. * @param array the material array to be checked and filtered
  31475. * @hidden
  31476. */
  31477. private _filterUniqueMaterialId;
  31478. /**
  31479. * Sets a new Standard Material as _defaultMaterial if not already set.
  31480. * @hidden
  31481. */
  31482. private _setDefaultMaterial;
  31483. /**
  31484. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31485. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31486. * @returns the SPS.
  31487. */
  31488. refreshVisibleSize(): SolidParticleSystem;
  31489. /**
  31490. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31491. * @param size the size (float) of the visibility box
  31492. * note : this doesn't lock the SPS mesh bounding box.
  31493. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31494. */
  31495. setVisibilityBox(size: number): void;
  31496. /**
  31497. * Gets whether the SPS as always visible or not
  31498. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31499. */
  31500. get isAlwaysVisible(): boolean;
  31501. /**
  31502. * Sets the SPS as always visible or not
  31503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31504. */
  31505. set isAlwaysVisible(val: boolean);
  31506. /**
  31507. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31509. */
  31510. set isVisibilityBoxLocked(val: boolean);
  31511. /**
  31512. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31513. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31514. */
  31515. get isVisibilityBoxLocked(): boolean;
  31516. /**
  31517. * Tells to `setParticles()` to compute the particle rotations or not.
  31518. * Default value : true. The SPS is faster when it's set to false.
  31519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31520. */
  31521. set computeParticleRotation(val: boolean);
  31522. /**
  31523. * Tells to `setParticles()` to compute the particle colors or not.
  31524. * Default value : true. The SPS is faster when it's set to false.
  31525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31526. */
  31527. set computeParticleColor(val: boolean);
  31528. set computeParticleTexture(val: boolean);
  31529. /**
  31530. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31531. * Default value : false. The SPS is faster when it's set to false.
  31532. * Note : the particle custom vertex positions aren't stored values.
  31533. */
  31534. set computeParticleVertex(val: boolean);
  31535. /**
  31536. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31537. */
  31538. set computeBoundingBox(val: boolean);
  31539. /**
  31540. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31541. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31542. * Default : `true`
  31543. */
  31544. set depthSortParticles(val: boolean);
  31545. /**
  31546. * Gets if `setParticles()` computes the particle rotations or not.
  31547. * Default value : true. The SPS is faster when it's set to false.
  31548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31549. */
  31550. get computeParticleRotation(): boolean;
  31551. /**
  31552. * Gets if `setParticles()` computes the particle colors or not.
  31553. * Default value : true. The SPS is faster when it's set to false.
  31554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31555. */
  31556. get computeParticleColor(): boolean;
  31557. /**
  31558. * Gets if `setParticles()` computes the particle textures or not.
  31559. * Default value : true. The SPS is faster when it's set to false.
  31560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31561. */
  31562. get computeParticleTexture(): boolean;
  31563. /**
  31564. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31565. * Default value : false. The SPS is faster when it's set to false.
  31566. * Note : the particle custom vertex positions aren't stored values.
  31567. */
  31568. get computeParticleVertex(): boolean;
  31569. /**
  31570. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31571. */
  31572. get computeBoundingBox(): boolean;
  31573. /**
  31574. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31576. * Default : `true`
  31577. */
  31578. get depthSortParticles(): boolean;
  31579. /**
  31580. * Gets if the SPS is created as expandable at construction time.
  31581. * Default : `false`
  31582. */
  31583. get expandable(): boolean;
  31584. /**
  31585. * Gets if the SPS supports the Multi Materials
  31586. */
  31587. get multimaterialEnabled(): boolean;
  31588. /**
  31589. * Gets if the SPS uses the model materials for its own multimaterial.
  31590. */
  31591. get useModelMaterial(): boolean;
  31592. /**
  31593. * The SPS used material array.
  31594. */
  31595. get materials(): Material[];
  31596. /**
  31597. * Sets the SPS MultiMaterial from the passed materials.
  31598. * Note : the passed array is internally copied and not used then by reference.
  31599. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31600. */
  31601. setMultiMaterial(materials: Material[]): void;
  31602. /**
  31603. * The SPS computed multimaterial object
  31604. */
  31605. get multimaterial(): MultiMaterial;
  31606. set multimaterial(mm: MultiMaterial);
  31607. /**
  31608. * If the subMeshes must be updated on the next call to setParticles()
  31609. */
  31610. get autoUpdateSubMeshes(): boolean;
  31611. set autoUpdateSubMeshes(val: boolean);
  31612. /**
  31613. * This function does nothing. It may be overwritten to set all the particle first values.
  31614. * The SPS doesn't call this function, you may have to call it by your own.
  31615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31616. */
  31617. initParticles(): void;
  31618. /**
  31619. * This function does nothing. It may be overwritten to recycle a particle.
  31620. * The SPS doesn't call this function, you may have to call it by your own.
  31621. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31622. * @param particle The particle to recycle
  31623. * @returns the recycled particle
  31624. */
  31625. recycleParticle(particle: SolidParticle): SolidParticle;
  31626. /**
  31627. * Updates a particle : this function should be overwritten by the user.
  31628. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31630. * @example : just set a particle position or velocity and recycle conditions
  31631. * @param particle The particle to update
  31632. * @returns the updated particle
  31633. */
  31634. updateParticle(particle: SolidParticle): SolidParticle;
  31635. /**
  31636. * Updates a vertex of a particle : it can be overwritten by the user.
  31637. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31638. * @param particle the current particle
  31639. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31640. * @param pt the index of the current vertex in the particle shape
  31641. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31642. * @example : just set a vertex particle position or color
  31643. * @returns the sps
  31644. */
  31645. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31646. /**
  31647. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31648. * This does nothing and may be overwritten by the user.
  31649. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31650. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31651. * @param update the boolean update value actually passed to setParticles()
  31652. */
  31653. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31654. /**
  31655. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31656. * This will be passed three parameters.
  31657. * This does nothing and may be overwritten by the user.
  31658. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31659. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31660. * @param update the boolean update value actually passed to setParticles()
  31661. */
  31662. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31663. }
  31664. }
  31665. declare module "babylonjs/Particles/solidParticle" {
  31666. import { Nullable } from "babylonjs/types";
  31667. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31668. import { Color4 } from "babylonjs/Maths/math.color";
  31669. import { Mesh } from "babylonjs/Meshes/mesh";
  31670. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31671. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31672. import { Plane } from "babylonjs/Maths/math.plane";
  31673. import { Material } from "babylonjs/Materials/material";
  31674. /**
  31675. * Represents one particle of a solid particle system.
  31676. */
  31677. export class SolidParticle {
  31678. /**
  31679. * particle global index
  31680. */
  31681. idx: number;
  31682. /**
  31683. * particle identifier
  31684. */
  31685. id: number;
  31686. /**
  31687. * The color of the particle
  31688. */
  31689. color: Nullable<Color4>;
  31690. /**
  31691. * The world space position of the particle.
  31692. */
  31693. position: Vector3;
  31694. /**
  31695. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31696. */
  31697. rotation: Vector3;
  31698. /**
  31699. * The world space rotation quaternion of the particle.
  31700. */
  31701. rotationQuaternion: Nullable<Quaternion>;
  31702. /**
  31703. * The scaling of the particle.
  31704. */
  31705. scaling: Vector3;
  31706. /**
  31707. * The uvs of the particle.
  31708. */
  31709. uvs: Vector4;
  31710. /**
  31711. * The current speed of the particle.
  31712. */
  31713. velocity: Vector3;
  31714. /**
  31715. * The pivot point in the particle local space.
  31716. */
  31717. pivot: Vector3;
  31718. /**
  31719. * Must the particle be translated from its pivot point in its local space ?
  31720. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31721. * Default : false
  31722. */
  31723. translateFromPivot: boolean;
  31724. /**
  31725. * Is the particle active or not ?
  31726. */
  31727. alive: boolean;
  31728. /**
  31729. * Is the particle visible or not ?
  31730. */
  31731. isVisible: boolean;
  31732. /**
  31733. * Index of this particle in the global "positions" array (Internal use)
  31734. * @hidden
  31735. */
  31736. _pos: number;
  31737. /**
  31738. * @hidden Index of this particle in the global "indices" array (Internal use)
  31739. */
  31740. _ind: number;
  31741. /**
  31742. * @hidden ModelShape of this particle (Internal use)
  31743. */
  31744. _model: ModelShape;
  31745. /**
  31746. * ModelShape id of this particle
  31747. */
  31748. shapeId: number;
  31749. /**
  31750. * Index of the particle in its shape id
  31751. */
  31752. idxInShape: number;
  31753. /**
  31754. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31755. */
  31756. _modelBoundingInfo: BoundingInfo;
  31757. /**
  31758. * @hidden Particle BoundingInfo object (Internal use)
  31759. */
  31760. _boundingInfo: BoundingInfo;
  31761. /**
  31762. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31763. */
  31764. _sps: SolidParticleSystem;
  31765. /**
  31766. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31767. */
  31768. _stillInvisible: boolean;
  31769. /**
  31770. * @hidden Last computed particle rotation matrix
  31771. */
  31772. _rotationMatrix: number[];
  31773. /**
  31774. * Parent particle Id, if any.
  31775. * Default null.
  31776. */
  31777. parentId: Nullable<number>;
  31778. /**
  31779. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31780. */
  31781. materialIndex: Nullable<number>;
  31782. /**
  31783. * Custom object or properties.
  31784. */
  31785. props: Nullable<any>;
  31786. /**
  31787. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31788. * The possible values are :
  31789. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31790. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31791. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31792. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31793. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31794. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31795. * */
  31796. cullingStrategy: number;
  31797. /**
  31798. * @hidden Internal global position in the SPS.
  31799. */
  31800. _globalPosition: Vector3;
  31801. /**
  31802. * Creates a Solid Particle object.
  31803. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31804. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31805. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31806. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31807. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31808. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31809. * @param shapeId (integer) is the model shape identifier in the SPS.
  31810. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31811. * @param sps defines the sps it is associated to
  31812. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31813. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31814. */
  31815. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31816. /**
  31817. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31818. * @param target the particle target
  31819. * @returns the current particle
  31820. */
  31821. copyToRef(target: SolidParticle): SolidParticle;
  31822. /**
  31823. * Legacy support, changed scale to scaling
  31824. */
  31825. get scale(): Vector3;
  31826. /**
  31827. * Legacy support, changed scale to scaling
  31828. */
  31829. set scale(scale: Vector3);
  31830. /**
  31831. * Legacy support, changed quaternion to rotationQuaternion
  31832. */
  31833. get quaternion(): Nullable<Quaternion>;
  31834. /**
  31835. * Legacy support, changed quaternion to rotationQuaternion
  31836. */
  31837. set quaternion(q: Nullable<Quaternion>);
  31838. /**
  31839. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31840. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31841. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31842. * @returns true if it intersects
  31843. */
  31844. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31845. /**
  31846. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31847. * A particle is in the frustum if its bounding box intersects the frustum
  31848. * @param frustumPlanes defines the frustum to test
  31849. * @returns true if the particle is in the frustum planes
  31850. */
  31851. isInFrustum(frustumPlanes: Plane[]): boolean;
  31852. /**
  31853. * get the rotation matrix of the particle
  31854. * @hidden
  31855. */
  31856. getRotationMatrix(m: Matrix): void;
  31857. }
  31858. /**
  31859. * Represents the shape of the model used by one particle of a solid particle system.
  31860. * SPS internal tool, don't use it manually.
  31861. */
  31862. export class ModelShape {
  31863. /**
  31864. * The shape id
  31865. * @hidden
  31866. */
  31867. shapeID: number;
  31868. /**
  31869. * flat array of model positions (internal use)
  31870. * @hidden
  31871. */
  31872. _shape: Vector3[];
  31873. /**
  31874. * flat array of model UVs (internal use)
  31875. * @hidden
  31876. */
  31877. _shapeUV: number[];
  31878. /**
  31879. * color array of the model
  31880. * @hidden
  31881. */
  31882. _shapeColors: number[];
  31883. /**
  31884. * indices array of the model
  31885. * @hidden
  31886. */
  31887. _indices: number[];
  31888. /**
  31889. * normals array of the model
  31890. * @hidden
  31891. */
  31892. _normals: number[];
  31893. /**
  31894. * length of the shape in the model indices array (internal use)
  31895. * @hidden
  31896. */
  31897. _indicesLength: number;
  31898. /**
  31899. * Custom position function (internal use)
  31900. * @hidden
  31901. */
  31902. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31903. /**
  31904. * Custom vertex function (internal use)
  31905. * @hidden
  31906. */
  31907. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31908. /**
  31909. * Model material (internal use)
  31910. * @hidden
  31911. */
  31912. _material: Nullable<Material>;
  31913. /**
  31914. * 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.
  31915. * SPS internal tool, don't use it manually.
  31916. * @hidden
  31917. */
  31918. 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>);
  31919. }
  31920. /**
  31921. * Represents a Depth Sorted Particle in the solid particle system.
  31922. * @hidden
  31923. */
  31924. export class DepthSortedParticle {
  31925. /**
  31926. * Particle index
  31927. */
  31928. idx: number;
  31929. /**
  31930. * Index of the particle in the "indices" array
  31931. */
  31932. ind: number;
  31933. /**
  31934. * Length of the particle shape in the "indices" array
  31935. */
  31936. indicesLength: number;
  31937. /**
  31938. * Squared distance from the particle to the camera
  31939. */
  31940. sqDistance: number;
  31941. /**
  31942. * Material index when used with MultiMaterials
  31943. */
  31944. materialIndex: number;
  31945. /**
  31946. * Creates a new sorted particle
  31947. * @param materialIndex
  31948. */
  31949. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31950. }
  31951. /**
  31952. * Represents a solid particle vertex
  31953. */
  31954. export class SolidParticleVertex {
  31955. /**
  31956. * Vertex position
  31957. */
  31958. position: Vector3;
  31959. /**
  31960. * Vertex color
  31961. */
  31962. color: Color4;
  31963. /**
  31964. * Vertex UV
  31965. */
  31966. uv: Vector2;
  31967. /**
  31968. * Creates a new solid particle vertex
  31969. */
  31970. constructor();
  31971. /** Vertex x coordinate */
  31972. get x(): number;
  31973. set x(val: number);
  31974. /** Vertex y coordinate */
  31975. get y(): number;
  31976. set y(val: number);
  31977. /** Vertex z coordinate */
  31978. get z(): number;
  31979. set z(val: number);
  31980. }
  31981. }
  31982. declare module "babylonjs/Collisions/meshCollisionData" {
  31983. import { Collider } from "babylonjs/Collisions/collider";
  31984. import { Vector3 } from "babylonjs/Maths/math.vector";
  31985. import { Nullable } from "babylonjs/types";
  31986. import { Observer } from "babylonjs/Misc/observable";
  31987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31988. /**
  31989. * @hidden
  31990. */
  31991. export class _MeshCollisionData {
  31992. _checkCollisions: boolean;
  31993. _collisionMask: number;
  31994. _collisionGroup: number;
  31995. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31996. _collider: Nullable<Collider>;
  31997. _oldPositionForCollisions: Vector3;
  31998. _diffPositionForCollisions: Vector3;
  31999. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32000. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32001. }
  32002. }
  32003. declare module "babylonjs/Meshes/abstractMesh" {
  32004. import { Observable } from "babylonjs/Misc/observable";
  32005. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32006. import { Camera } from "babylonjs/Cameras/camera";
  32007. import { Scene, IDisposable } from "babylonjs/scene";
  32008. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32009. import { Node } from "babylonjs/node";
  32010. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32012. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32014. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32015. import { Material } from "babylonjs/Materials/material";
  32016. import { Light } from "babylonjs/Lights/light";
  32017. import { Skeleton } from "babylonjs/Bones/skeleton";
  32018. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32019. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32020. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32021. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32022. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32023. import { Plane } from "babylonjs/Maths/math.plane";
  32024. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32025. import { Ray } from "babylonjs/Culling/ray";
  32026. import { Collider } from "babylonjs/Collisions/collider";
  32027. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32028. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32029. /** @hidden */
  32030. class _FacetDataStorage {
  32031. facetPositions: Vector3[];
  32032. facetNormals: Vector3[];
  32033. facetPartitioning: number[][];
  32034. facetNb: number;
  32035. partitioningSubdivisions: number;
  32036. partitioningBBoxRatio: number;
  32037. facetDataEnabled: boolean;
  32038. facetParameters: any;
  32039. bbSize: Vector3;
  32040. subDiv: {
  32041. max: number;
  32042. X: number;
  32043. Y: number;
  32044. Z: number;
  32045. };
  32046. facetDepthSort: boolean;
  32047. facetDepthSortEnabled: boolean;
  32048. depthSortedIndices: IndicesArray;
  32049. depthSortedFacets: {
  32050. ind: number;
  32051. sqDistance: number;
  32052. }[];
  32053. facetDepthSortFunction: (f1: {
  32054. ind: number;
  32055. sqDistance: number;
  32056. }, f2: {
  32057. ind: number;
  32058. sqDistance: number;
  32059. }) => number;
  32060. facetDepthSortFrom: Vector3;
  32061. facetDepthSortOrigin: Vector3;
  32062. invertedMatrix: Matrix;
  32063. }
  32064. /**
  32065. * @hidden
  32066. **/
  32067. class _InternalAbstractMeshDataInfo {
  32068. _hasVertexAlpha: boolean;
  32069. _useVertexColors: boolean;
  32070. _numBoneInfluencers: number;
  32071. _applyFog: boolean;
  32072. _receiveShadows: boolean;
  32073. _facetData: _FacetDataStorage;
  32074. _visibility: number;
  32075. _skeleton: Nullable<Skeleton>;
  32076. _layerMask: number;
  32077. _computeBonesUsingShaders: boolean;
  32078. _isActive: boolean;
  32079. _onlyForInstances: boolean;
  32080. _isActiveIntermediate: boolean;
  32081. _onlyForInstancesIntermediate: boolean;
  32082. _actAsRegularMesh: boolean;
  32083. }
  32084. /**
  32085. * Class used to store all common mesh properties
  32086. */
  32087. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32088. /** No occlusion */
  32089. static OCCLUSION_TYPE_NONE: number;
  32090. /** Occlusion set to optimisitic */
  32091. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32092. /** Occlusion set to strict */
  32093. static OCCLUSION_TYPE_STRICT: number;
  32094. /** Use an accurante occlusion algorithm */
  32095. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32096. /** Use a conservative occlusion algorithm */
  32097. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32098. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32099. * Test order :
  32100. * Is the bounding sphere outside the frustum ?
  32101. * If not, are the bounding box vertices outside the frustum ?
  32102. * It not, then the cullable object is in the frustum.
  32103. */
  32104. static readonly CULLINGSTRATEGY_STANDARD: number;
  32105. /** Culling strategy : Bounding Sphere Only.
  32106. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32107. * It's also less accurate than the standard because some not visible objects can still be selected.
  32108. * Test : is the bounding sphere outside the frustum ?
  32109. * If not, then the cullable object is in the frustum.
  32110. */
  32111. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32112. /** Culling strategy : Optimistic Inclusion.
  32113. * This in an inclusion test first, then the standard exclusion test.
  32114. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32115. * 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.
  32116. * Anyway, it's as accurate as the standard strategy.
  32117. * Test :
  32118. * Is the cullable object bounding sphere center in the frustum ?
  32119. * If not, apply the default culling strategy.
  32120. */
  32121. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32122. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32123. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32124. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32125. * 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.
  32126. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32127. * Test :
  32128. * Is the cullable object bounding sphere center in the frustum ?
  32129. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32130. */
  32131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32132. /**
  32133. * No billboard
  32134. */
  32135. static get BILLBOARDMODE_NONE(): number;
  32136. /** Billboard on X axis */
  32137. static get BILLBOARDMODE_X(): number;
  32138. /** Billboard on Y axis */
  32139. static get BILLBOARDMODE_Y(): number;
  32140. /** Billboard on Z axis */
  32141. static get BILLBOARDMODE_Z(): number;
  32142. /** Billboard on all axes */
  32143. static get BILLBOARDMODE_ALL(): number;
  32144. /** Billboard on using position instead of orientation */
  32145. static get BILLBOARDMODE_USE_POSITION(): number;
  32146. /** @hidden */
  32147. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32148. /**
  32149. * The culling strategy to use to check whether the mesh must be rendered or not.
  32150. * This value can be changed at any time and will be used on the next render mesh selection.
  32151. * The possible values are :
  32152. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32153. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32154. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32156. * Please read each static variable documentation to get details about the culling process.
  32157. * */
  32158. cullingStrategy: number;
  32159. /**
  32160. * Gets the number of facets in the mesh
  32161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32162. */
  32163. get facetNb(): number;
  32164. /**
  32165. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32167. */
  32168. get partitioningSubdivisions(): number;
  32169. set partitioningSubdivisions(nb: number);
  32170. /**
  32171. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32172. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32174. */
  32175. get partitioningBBoxRatio(): number;
  32176. set partitioningBBoxRatio(ratio: number);
  32177. /**
  32178. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32179. * Works only for updatable meshes.
  32180. * Doesn't work with multi-materials
  32181. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32182. */
  32183. get mustDepthSortFacets(): boolean;
  32184. set mustDepthSortFacets(sort: boolean);
  32185. /**
  32186. * The location (Vector3) where the facet depth sort must be computed from.
  32187. * By default, the active camera position.
  32188. * Used only when facet depth sort is enabled
  32189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32190. */
  32191. get facetDepthSortFrom(): Vector3;
  32192. set facetDepthSortFrom(location: Vector3);
  32193. /**
  32194. * gets a boolean indicating if facetData is enabled
  32195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32196. */
  32197. get isFacetDataEnabled(): boolean;
  32198. /** @hidden */
  32199. _updateNonUniformScalingState(value: boolean): boolean;
  32200. /**
  32201. * An event triggered when this mesh collides with another one
  32202. */
  32203. onCollideObservable: Observable<AbstractMesh>;
  32204. /** Set a function to call when this mesh collides with another one */
  32205. set onCollide(callback: () => void);
  32206. /**
  32207. * An event triggered when the collision's position changes
  32208. */
  32209. onCollisionPositionChangeObservable: Observable<Vector3>;
  32210. /** Set a function to call when the collision's position changes */
  32211. set onCollisionPositionChange(callback: () => void);
  32212. /**
  32213. * An event triggered when material is changed
  32214. */
  32215. onMaterialChangedObservable: Observable<AbstractMesh>;
  32216. /**
  32217. * Gets or sets the orientation for POV movement & rotation
  32218. */
  32219. definedFacingForward: boolean;
  32220. /** @hidden */
  32221. _occlusionQuery: Nullable<WebGLQuery>;
  32222. /** @hidden */
  32223. _renderingGroup: Nullable<RenderingGroup>;
  32224. /**
  32225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32226. */
  32227. get visibility(): number;
  32228. /**
  32229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32230. */
  32231. set visibility(value: number);
  32232. /** Gets or sets the alpha index used to sort transparent meshes
  32233. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32234. */
  32235. alphaIndex: number;
  32236. /**
  32237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32238. */
  32239. isVisible: boolean;
  32240. /**
  32241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32242. */
  32243. isPickable: boolean;
  32244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32245. showSubMeshesBoundingBox: boolean;
  32246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32247. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32248. */
  32249. isBlocker: boolean;
  32250. /**
  32251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32252. */
  32253. enablePointerMoveEvents: boolean;
  32254. /**
  32255. * Specifies the rendering group id for this mesh (0 by default)
  32256. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32257. */
  32258. renderingGroupId: number;
  32259. private _material;
  32260. /** Gets or sets current material */
  32261. get material(): Nullable<Material>;
  32262. set material(value: Nullable<Material>);
  32263. /**
  32264. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32265. * @see https://doc.babylonjs.com/babylon101/shadows
  32266. */
  32267. get receiveShadows(): boolean;
  32268. set receiveShadows(value: boolean);
  32269. /** Defines color to use when rendering outline */
  32270. outlineColor: Color3;
  32271. /** Define width to use when rendering outline */
  32272. outlineWidth: number;
  32273. /** Defines color to use when rendering overlay */
  32274. overlayColor: Color3;
  32275. /** Defines alpha to use when rendering overlay */
  32276. overlayAlpha: number;
  32277. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32278. get hasVertexAlpha(): boolean;
  32279. set hasVertexAlpha(value: boolean);
  32280. /** 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) */
  32281. get useVertexColors(): boolean;
  32282. set useVertexColors(value: boolean);
  32283. /**
  32284. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32285. */
  32286. get computeBonesUsingShaders(): boolean;
  32287. set computeBonesUsingShaders(value: boolean);
  32288. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32289. get numBoneInfluencers(): number;
  32290. set numBoneInfluencers(value: number);
  32291. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32292. get applyFog(): boolean;
  32293. set applyFog(value: boolean);
  32294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32295. useOctreeForRenderingSelection: boolean;
  32296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32297. useOctreeForPicking: boolean;
  32298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32299. useOctreeForCollisions: boolean;
  32300. /**
  32301. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32302. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32303. */
  32304. get layerMask(): number;
  32305. set layerMask(value: number);
  32306. /**
  32307. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32308. */
  32309. alwaysSelectAsActiveMesh: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32312. */
  32313. doNotSyncBoundingInfo: boolean;
  32314. /**
  32315. * Gets or sets the current action manager
  32316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32317. */
  32318. actionManager: Nullable<AbstractActionManager>;
  32319. private _meshCollisionData;
  32320. /**
  32321. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32323. */
  32324. ellipsoid: Vector3;
  32325. /**
  32326. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32327. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32328. */
  32329. ellipsoidOffset: Vector3;
  32330. /**
  32331. * Gets or sets a collision mask used to mask collisions (default is -1).
  32332. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32333. */
  32334. get collisionMask(): number;
  32335. set collisionMask(mask: number);
  32336. /**
  32337. * Gets or sets the current collision group mask (-1 by default).
  32338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32339. */
  32340. get collisionGroup(): number;
  32341. set collisionGroup(mask: number);
  32342. /**
  32343. * Gets or sets current surrounding meshes (null by default).
  32344. *
  32345. * By default collision detection is tested against every mesh in the scene.
  32346. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32347. * meshes will be tested for the collision.
  32348. *
  32349. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32350. */
  32351. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32352. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32353. /**
  32354. * Defines edge width used when edgesRenderer is enabled
  32355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32356. */
  32357. edgesWidth: number;
  32358. /**
  32359. * Defines edge color used when edgesRenderer is enabled
  32360. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32361. */
  32362. edgesColor: Color4;
  32363. /** @hidden */
  32364. _edgesRenderer: Nullable<IEdgesRenderer>;
  32365. /** @hidden */
  32366. _masterMesh: Nullable<AbstractMesh>;
  32367. /** @hidden */
  32368. _boundingInfo: Nullable<BoundingInfo>;
  32369. /** @hidden */
  32370. _renderId: number;
  32371. /**
  32372. * Gets or sets the list of subMeshes
  32373. * @see https://doc.babylonjs.com/how_to/multi_materials
  32374. */
  32375. subMeshes: SubMesh[];
  32376. /** @hidden */
  32377. _intersectionsInProgress: AbstractMesh[];
  32378. /** @hidden */
  32379. _unIndexed: boolean;
  32380. /** @hidden */
  32381. _lightSources: Light[];
  32382. /** Gets the list of lights affecting that mesh */
  32383. get lightSources(): Light[];
  32384. /** @hidden */
  32385. get _positions(): Nullable<Vector3[]>;
  32386. /** @hidden */
  32387. _waitingData: {
  32388. lods: Nullable<any>;
  32389. actions: Nullable<any>;
  32390. freezeWorldMatrix: Nullable<boolean>;
  32391. };
  32392. /** @hidden */
  32393. _bonesTransformMatrices: Nullable<Float32Array>;
  32394. /** @hidden */
  32395. _transformMatrixTexture: Nullable<RawTexture>;
  32396. /**
  32397. * Gets or sets a skeleton to apply skining transformations
  32398. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32399. */
  32400. set skeleton(value: Nullable<Skeleton>);
  32401. get skeleton(): Nullable<Skeleton>;
  32402. /**
  32403. * An event triggered when the mesh is rebuilt.
  32404. */
  32405. onRebuildObservable: Observable<AbstractMesh>;
  32406. /**
  32407. * Creates a new AbstractMesh
  32408. * @param name defines the name of the mesh
  32409. * @param scene defines the hosting scene
  32410. */
  32411. constructor(name: string, scene?: Nullable<Scene>);
  32412. /**
  32413. * Returns the string "AbstractMesh"
  32414. * @returns "AbstractMesh"
  32415. */
  32416. getClassName(): string;
  32417. /**
  32418. * Gets a string representation of the current mesh
  32419. * @param fullDetails defines a boolean indicating if full details must be included
  32420. * @returns a string representation of the current mesh
  32421. */
  32422. toString(fullDetails?: boolean): string;
  32423. /**
  32424. * @hidden
  32425. */
  32426. protected _getEffectiveParent(): Nullable<Node>;
  32427. /** @hidden */
  32428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32429. /** @hidden */
  32430. _rebuild(): void;
  32431. /** @hidden */
  32432. _resyncLightSources(): void;
  32433. /** @hidden */
  32434. _resyncLightSource(light: Light): void;
  32435. /** @hidden */
  32436. _unBindEffect(): void;
  32437. /** @hidden */
  32438. _removeLightSource(light: Light, dispose: boolean): void;
  32439. private _markSubMeshesAsDirty;
  32440. /** @hidden */
  32441. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32442. /** @hidden */
  32443. _markSubMeshesAsAttributesDirty(): void;
  32444. /** @hidden */
  32445. _markSubMeshesAsMiscDirty(): void;
  32446. /**
  32447. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32448. */
  32449. get scaling(): Vector3;
  32450. set scaling(newScaling: Vector3);
  32451. /**
  32452. * Returns true if the mesh is blocked. Implemented by child classes
  32453. */
  32454. get isBlocked(): boolean;
  32455. /**
  32456. * Returns the mesh itself by default. Implemented by child classes
  32457. * @param camera defines the camera to use to pick the right LOD level
  32458. * @returns the currentAbstractMesh
  32459. */
  32460. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32461. /**
  32462. * Returns 0 by default. Implemented by child classes
  32463. * @returns an integer
  32464. */
  32465. getTotalVertices(): number;
  32466. /**
  32467. * Returns a positive integer : the total number of indices in this mesh geometry.
  32468. * @returns the numner of indices or zero if the mesh has no geometry.
  32469. */
  32470. getTotalIndices(): number;
  32471. /**
  32472. * Returns null by default. Implemented by child classes
  32473. * @returns null
  32474. */
  32475. getIndices(): Nullable<IndicesArray>;
  32476. /**
  32477. * Returns the array of the requested vertex data kind. Implemented by child classes
  32478. * @param kind defines the vertex data kind to use
  32479. * @returns null
  32480. */
  32481. getVerticesData(kind: string): Nullable<FloatArray>;
  32482. /**
  32483. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32484. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32485. * Note that a new underlying VertexBuffer object is created each call.
  32486. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32487. * @param kind defines vertex data kind:
  32488. * * VertexBuffer.PositionKind
  32489. * * VertexBuffer.UVKind
  32490. * * VertexBuffer.UV2Kind
  32491. * * VertexBuffer.UV3Kind
  32492. * * VertexBuffer.UV4Kind
  32493. * * VertexBuffer.UV5Kind
  32494. * * VertexBuffer.UV6Kind
  32495. * * VertexBuffer.ColorKind
  32496. * * VertexBuffer.MatricesIndicesKind
  32497. * * VertexBuffer.MatricesIndicesExtraKind
  32498. * * VertexBuffer.MatricesWeightsKind
  32499. * * VertexBuffer.MatricesWeightsExtraKind
  32500. * @param data defines the data source
  32501. * @param updatable defines if the data must be flagged as updatable (or static)
  32502. * @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
  32503. * @returns the current mesh
  32504. */
  32505. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32506. /**
  32507. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32508. * If the mesh has no geometry, it is simply returned as it is.
  32509. * @param kind defines vertex data kind:
  32510. * * VertexBuffer.PositionKind
  32511. * * VertexBuffer.UVKind
  32512. * * VertexBuffer.UV2Kind
  32513. * * VertexBuffer.UV3Kind
  32514. * * VertexBuffer.UV4Kind
  32515. * * VertexBuffer.UV5Kind
  32516. * * VertexBuffer.UV6Kind
  32517. * * VertexBuffer.ColorKind
  32518. * * VertexBuffer.MatricesIndicesKind
  32519. * * VertexBuffer.MatricesIndicesExtraKind
  32520. * * VertexBuffer.MatricesWeightsKind
  32521. * * VertexBuffer.MatricesWeightsExtraKind
  32522. * @param data defines the data source
  32523. * @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
  32524. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32525. * @returns the current mesh
  32526. */
  32527. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32528. /**
  32529. * Sets the mesh indices,
  32530. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32531. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32532. * @param totalVertices Defines the total number of vertices
  32533. * @returns the current mesh
  32534. */
  32535. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32536. /**
  32537. * Gets a boolean indicating if specific vertex data is present
  32538. * @param kind defines the vertex data kind to use
  32539. * @returns true is data kind is present
  32540. */
  32541. isVerticesDataPresent(kind: string): boolean;
  32542. /**
  32543. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32544. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32545. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32546. * @returns a BoundingInfo
  32547. */
  32548. getBoundingInfo(): BoundingInfo;
  32549. /**
  32550. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32551. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32552. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32553. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32554. * @returns the current mesh
  32555. */
  32556. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32557. /**
  32558. * Overwrite the current bounding info
  32559. * @param boundingInfo defines the new bounding info
  32560. * @returns the current mesh
  32561. */
  32562. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32563. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32564. get useBones(): boolean;
  32565. /** @hidden */
  32566. _preActivate(): void;
  32567. /** @hidden */
  32568. _preActivateForIntermediateRendering(renderId: number): void;
  32569. /** @hidden */
  32570. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32571. /** @hidden */
  32572. _postActivate(): void;
  32573. /** @hidden */
  32574. _freeze(): void;
  32575. /** @hidden */
  32576. _unFreeze(): void;
  32577. /**
  32578. * Gets the current world matrix
  32579. * @returns a Matrix
  32580. */
  32581. getWorldMatrix(): Matrix;
  32582. /** @hidden */
  32583. _getWorldMatrixDeterminant(): number;
  32584. /**
  32585. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32586. */
  32587. get isAnInstance(): boolean;
  32588. /**
  32589. * Gets a boolean indicating if this mesh has instances
  32590. */
  32591. get hasInstances(): boolean;
  32592. /**
  32593. * Gets a boolean indicating if this mesh has thin instances
  32594. */
  32595. get hasThinInstances(): boolean;
  32596. /**
  32597. * Perform relative position change from the point of view of behind the front of the mesh.
  32598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32599. * Supports definition of mesh facing forward or backward
  32600. * @param amountRight defines the distance on the right axis
  32601. * @param amountUp defines the distance on the up axis
  32602. * @param amountForward defines the distance on the forward axis
  32603. * @returns the current mesh
  32604. */
  32605. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32606. /**
  32607. * Calculate relative position change from the point of view of behind the front of the mesh.
  32608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32609. * Supports definition of mesh facing forward or backward
  32610. * @param amountRight defines the distance on the right axis
  32611. * @param amountUp defines the distance on the up axis
  32612. * @param amountForward defines the distance on the forward axis
  32613. * @returns the new displacement vector
  32614. */
  32615. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32616. /**
  32617. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32618. * Supports definition of mesh facing forward or backward
  32619. * @param flipBack defines the flip
  32620. * @param twirlClockwise defines the twirl
  32621. * @param tiltRight defines the tilt
  32622. * @returns the current mesh
  32623. */
  32624. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32625. /**
  32626. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32627. * Supports definition of mesh facing forward or backward.
  32628. * @param flipBack defines the flip
  32629. * @param twirlClockwise defines the twirl
  32630. * @param tiltRight defines the tilt
  32631. * @returns the new rotation vector
  32632. */
  32633. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32634. /**
  32635. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32636. * This means the mesh underlying bounding box and sphere are recomputed.
  32637. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32638. * @returns the current mesh
  32639. */
  32640. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32641. /** @hidden */
  32642. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32643. /** @hidden */
  32644. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32645. /** @hidden */
  32646. _updateBoundingInfo(): AbstractMesh;
  32647. /** @hidden */
  32648. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32649. /** @hidden */
  32650. protected _afterComputeWorldMatrix(): void;
  32651. /** @hidden */
  32652. get _effectiveMesh(): AbstractMesh;
  32653. /**
  32654. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32655. * A mesh is in the frustum if its bounding box intersects the frustum
  32656. * @param frustumPlanes defines the frustum to test
  32657. * @returns true if the mesh is in the frustum planes
  32658. */
  32659. isInFrustum(frustumPlanes: Plane[]): boolean;
  32660. /**
  32661. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32662. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32663. * @param frustumPlanes defines the frustum to test
  32664. * @returns true if the mesh is completely in the frustum planes
  32665. */
  32666. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32667. /**
  32668. * True if the mesh intersects another mesh or a SolidParticle object
  32669. * @param mesh defines a target mesh or SolidParticle to test
  32670. * @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)
  32671. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32672. * @returns true if there is an intersection
  32673. */
  32674. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32675. /**
  32676. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32677. * @param point defines the point to test
  32678. * @returns true if there is an intersection
  32679. */
  32680. intersectsPoint(point: Vector3): boolean;
  32681. /**
  32682. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32684. */
  32685. get checkCollisions(): boolean;
  32686. set checkCollisions(collisionEnabled: boolean);
  32687. /**
  32688. * Gets Collider object used to compute collisions (not physics)
  32689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32690. */
  32691. get collider(): Nullable<Collider>;
  32692. /**
  32693. * Move the mesh using collision engine
  32694. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32695. * @param displacement defines the requested displacement vector
  32696. * @returns the current mesh
  32697. */
  32698. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32699. private _onCollisionPositionChange;
  32700. /** @hidden */
  32701. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32702. /** @hidden */
  32703. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32704. /** @hidden */
  32705. _checkCollision(collider: Collider): AbstractMesh;
  32706. /** @hidden */
  32707. _generatePointsArray(): boolean;
  32708. /**
  32709. * Checks if the passed Ray intersects with the mesh
  32710. * @param ray defines the ray to use
  32711. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32713. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32714. * @returns the picking info
  32715. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32716. */
  32717. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32718. /**
  32719. * Clones the current mesh
  32720. * @param name defines the mesh name
  32721. * @param newParent defines the new mesh parent
  32722. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32723. * @returns the new mesh
  32724. */
  32725. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32726. /**
  32727. * Disposes all the submeshes of the current meshnp
  32728. * @returns the current mesh
  32729. */
  32730. releaseSubMeshes(): AbstractMesh;
  32731. /**
  32732. * Releases resources associated with this abstract mesh.
  32733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32735. */
  32736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32737. /**
  32738. * Adds the passed mesh as a child to the current mesh
  32739. * @param mesh defines the child mesh
  32740. * @returns the current mesh
  32741. */
  32742. addChild(mesh: AbstractMesh): AbstractMesh;
  32743. /**
  32744. * Removes the passed mesh from the current mesh children list
  32745. * @param mesh defines the child mesh
  32746. * @returns the current mesh
  32747. */
  32748. removeChild(mesh: AbstractMesh): AbstractMesh;
  32749. /** @hidden */
  32750. private _initFacetData;
  32751. /**
  32752. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32753. * This method can be called within the render loop.
  32754. * 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
  32755. * @returns the current mesh
  32756. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32757. */
  32758. updateFacetData(): AbstractMesh;
  32759. /**
  32760. * Returns the facetLocalNormals array.
  32761. * The normals are expressed in the mesh local spac
  32762. * @returns an array of Vector3
  32763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32764. */
  32765. getFacetLocalNormals(): Vector3[];
  32766. /**
  32767. * Returns the facetLocalPositions array.
  32768. * The facet positions are expressed in the mesh local space
  32769. * @returns an array of Vector3
  32770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32771. */
  32772. getFacetLocalPositions(): Vector3[];
  32773. /**
  32774. * Returns the facetLocalPartioning array
  32775. * @returns an array of array of numbers
  32776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32777. */
  32778. getFacetLocalPartitioning(): number[][];
  32779. /**
  32780. * Returns the i-th facet position in the world system.
  32781. * This method allocates a new Vector3 per call
  32782. * @param i defines the facet index
  32783. * @returns a new Vector3
  32784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32785. */
  32786. getFacetPosition(i: number): Vector3;
  32787. /**
  32788. * Sets the reference Vector3 with the i-th facet position in the world system
  32789. * @param i defines the facet index
  32790. * @param ref defines the target vector
  32791. * @returns the current mesh
  32792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32793. */
  32794. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32795. /**
  32796. * Returns the i-th facet normal in the world system.
  32797. * This method allocates a new Vector3 per call
  32798. * @param i defines the facet index
  32799. * @returns a new Vector3
  32800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32801. */
  32802. getFacetNormal(i: number): Vector3;
  32803. /**
  32804. * Sets the reference Vector3 with the i-th facet normal in the world system
  32805. * @param i defines the facet index
  32806. * @param ref defines the target vector
  32807. * @returns the current mesh
  32808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32809. */
  32810. getFacetNormalToRef(i: number, ref: Vector3): this;
  32811. /**
  32812. * 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)
  32813. * @param x defines x coordinate
  32814. * @param y defines y coordinate
  32815. * @param z defines z coordinate
  32816. * @returns the array of facet indexes
  32817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32818. */
  32819. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32820. /**
  32821. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32822. * @param projected sets as the (x,y,z) world projection on the facet
  32823. * @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
  32824. * @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
  32825. * @param x defines x coordinate
  32826. * @param y defines y coordinate
  32827. * @param z defines z coordinate
  32828. * @returns the face index if found (or null instead)
  32829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32830. */
  32831. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32832. /**
  32833. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32834. * @param projected sets as the (x,y,z) local projection on the facet
  32835. * @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
  32836. * @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
  32837. * @param x defines x coordinate
  32838. * @param y defines y coordinate
  32839. * @param z defines z coordinate
  32840. * @returns the face index if found (or null instead)
  32841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32842. */
  32843. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32844. /**
  32845. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32846. * @returns the parameters
  32847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32848. */
  32849. getFacetDataParameters(): any;
  32850. /**
  32851. * Disables the feature FacetData and frees the related memory
  32852. * @returns the current mesh
  32853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32854. */
  32855. disableFacetData(): AbstractMesh;
  32856. /**
  32857. * Updates the AbstractMesh indices array
  32858. * @param indices defines the data source
  32859. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32860. * @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)
  32861. * @returns the current mesh
  32862. */
  32863. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32864. /**
  32865. * Creates new normals data for the mesh
  32866. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32867. * @returns the current mesh
  32868. */
  32869. createNormals(updatable: boolean): AbstractMesh;
  32870. /**
  32871. * Align the mesh with a normal
  32872. * @param normal defines the normal to use
  32873. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32874. * @returns the current mesh
  32875. */
  32876. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32877. /** @hidden */
  32878. _checkOcclusionQuery(): boolean;
  32879. /**
  32880. * Disables the mesh edge rendering mode
  32881. * @returns the currentAbstractMesh
  32882. */
  32883. disableEdgesRendering(): AbstractMesh;
  32884. /**
  32885. * Enables the edge rendering mode on the mesh.
  32886. * This mode makes the mesh edges visible
  32887. * @param epsilon defines the maximal distance between two angles to detect a face
  32888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32889. * @returns the currentAbstractMesh
  32890. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32891. */
  32892. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32893. /**
  32894. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32895. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32896. */
  32897. getConnectedParticleSystems(): IParticleSystem[];
  32898. }
  32899. }
  32900. declare module "babylonjs/Actions/actionEvent" {
  32901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32902. import { Nullable } from "babylonjs/types";
  32903. import { Sprite } from "babylonjs/Sprites/sprite";
  32904. import { Scene } from "babylonjs/scene";
  32905. import { Vector2 } from "babylonjs/Maths/math.vector";
  32906. /**
  32907. * Interface used to define ActionEvent
  32908. */
  32909. export interface IActionEvent {
  32910. /** The mesh or sprite that triggered the action */
  32911. source: any;
  32912. /** The X mouse cursor position at the time of the event */
  32913. pointerX: number;
  32914. /** The Y mouse cursor position at the time of the event */
  32915. pointerY: number;
  32916. /** The mesh that is currently pointed at (can be null) */
  32917. meshUnderPointer: Nullable<AbstractMesh>;
  32918. /** the original (browser) event that triggered the ActionEvent */
  32919. sourceEvent?: any;
  32920. /** additional data for the event */
  32921. additionalData?: any;
  32922. }
  32923. /**
  32924. * ActionEvent is the event being sent when an action is triggered.
  32925. */
  32926. export class ActionEvent implements IActionEvent {
  32927. /** The mesh or sprite that triggered the action */
  32928. source: any;
  32929. /** The X mouse cursor position at the time of the event */
  32930. pointerX: number;
  32931. /** The Y mouse cursor position at the time of the event */
  32932. pointerY: number;
  32933. /** The mesh that is currently pointed at (can be null) */
  32934. meshUnderPointer: Nullable<AbstractMesh>;
  32935. /** the original (browser) event that triggered the ActionEvent */
  32936. sourceEvent?: any;
  32937. /** additional data for the event */
  32938. additionalData?: any;
  32939. /**
  32940. * Creates a new ActionEvent
  32941. * @param source The mesh or sprite that triggered the action
  32942. * @param pointerX The X mouse cursor position at the time of the event
  32943. * @param pointerY The Y mouse cursor position at the time of the event
  32944. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32945. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32946. * @param additionalData additional data for the event
  32947. */
  32948. constructor(
  32949. /** The mesh or sprite that triggered the action */
  32950. source: any,
  32951. /** The X mouse cursor position at the time of the event */
  32952. pointerX: number,
  32953. /** The Y mouse cursor position at the time of the event */
  32954. pointerY: number,
  32955. /** The mesh that is currently pointed at (can be null) */
  32956. meshUnderPointer: Nullable<AbstractMesh>,
  32957. /** the original (browser) event that triggered the ActionEvent */
  32958. sourceEvent?: any,
  32959. /** additional data for the event */
  32960. additionalData?: any);
  32961. /**
  32962. * Helper function to auto-create an ActionEvent from a source mesh.
  32963. * @param source The source mesh that triggered the event
  32964. * @param evt The original (browser) event
  32965. * @param additionalData additional data for the event
  32966. * @returns the new ActionEvent
  32967. */
  32968. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32969. /**
  32970. * Helper function to auto-create an ActionEvent from a source sprite
  32971. * @param source The source sprite that triggered the event
  32972. * @param scene Scene associated with the sprite
  32973. * @param evt The original (browser) event
  32974. * @param additionalData additional data for the event
  32975. * @returns the new ActionEvent
  32976. */
  32977. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32978. /**
  32979. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32980. * @param scene the scene where the event occurred
  32981. * @param evt The original (browser) event
  32982. * @returns the new ActionEvent
  32983. */
  32984. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32985. /**
  32986. * Helper function to auto-create an ActionEvent from a primitive
  32987. * @param prim defines the target primitive
  32988. * @param pointerPos defines the pointer position
  32989. * @param evt The original (browser) event
  32990. * @param additionalData additional data for the event
  32991. * @returns the new ActionEvent
  32992. */
  32993. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32994. }
  32995. }
  32996. declare module "babylonjs/Actions/abstractActionManager" {
  32997. import { IDisposable } from "babylonjs/scene";
  32998. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32999. import { IAction } from "babylonjs/Actions/action";
  33000. import { Nullable } from "babylonjs/types";
  33001. /**
  33002. * Abstract class used to decouple action Manager from scene and meshes.
  33003. * Do not instantiate.
  33004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33005. */
  33006. export abstract class AbstractActionManager implements IDisposable {
  33007. /** Gets the list of active triggers */
  33008. static Triggers: {
  33009. [key: string]: number;
  33010. };
  33011. /** Gets the cursor to use when hovering items */
  33012. hoverCursor: string;
  33013. /** Gets the list of actions */
  33014. actions: IAction[];
  33015. /**
  33016. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33017. */
  33018. isRecursive: boolean;
  33019. /**
  33020. * Releases all associated resources
  33021. */
  33022. abstract dispose(): void;
  33023. /**
  33024. * Does this action manager has pointer triggers
  33025. */
  33026. abstract get hasPointerTriggers(): boolean;
  33027. /**
  33028. * Does this action manager has pick triggers
  33029. */
  33030. abstract get hasPickTriggers(): boolean;
  33031. /**
  33032. * Process a specific trigger
  33033. * @param trigger defines the trigger to process
  33034. * @param evt defines the event details to be processed
  33035. */
  33036. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33037. /**
  33038. * Does this action manager handles actions of any of the given triggers
  33039. * @param triggers defines the triggers to be tested
  33040. * @return a boolean indicating whether one (or more) of the triggers is handled
  33041. */
  33042. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33043. /**
  33044. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33045. * speed.
  33046. * @param triggerA defines the trigger to be tested
  33047. * @param triggerB defines the trigger to be tested
  33048. * @return a boolean indicating whether one (or more) of the triggers is handled
  33049. */
  33050. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33051. /**
  33052. * Does this action manager handles actions of a given trigger
  33053. * @param trigger defines the trigger to be tested
  33054. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33055. * @return whether the trigger is handled
  33056. */
  33057. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33058. /**
  33059. * Serialize this manager to a JSON object
  33060. * @param name defines the property name to store this manager
  33061. * @returns a JSON representation of this manager
  33062. */
  33063. abstract serialize(name: string): any;
  33064. /**
  33065. * Registers an action to this action manager
  33066. * @param action defines the action to be registered
  33067. * @return the action amended (prepared) after registration
  33068. */
  33069. abstract registerAction(action: IAction): Nullable<IAction>;
  33070. /**
  33071. * Unregisters an action to this action manager
  33072. * @param action defines the action to be unregistered
  33073. * @return a boolean indicating whether the action has been unregistered
  33074. */
  33075. abstract unregisterAction(action: IAction): Boolean;
  33076. /**
  33077. * Does exist one action manager with at least one trigger
  33078. **/
  33079. static get HasTriggers(): boolean;
  33080. /**
  33081. * Does exist one action manager with at least one pick trigger
  33082. **/
  33083. static get HasPickTriggers(): boolean;
  33084. /**
  33085. * Does exist one action manager that handles actions of a given trigger
  33086. * @param trigger defines the trigger to be tested
  33087. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33088. **/
  33089. static HasSpecificTrigger(trigger: number): boolean;
  33090. }
  33091. }
  33092. declare module "babylonjs/node" {
  33093. import { Scene } from "babylonjs/scene";
  33094. import { Nullable } from "babylonjs/types";
  33095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33096. import { Engine } from "babylonjs/Engines/engine";
  33097. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33098. import { Observable } from "babylonjs/Misc/observable";
  33099. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33101. import { Animatable } from "babylonjs/Animations/animatable";
  33102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33103. import { Animation } from "babylonjs/Animations/animation";
  33104. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33106. /**
  33107. * Defines how a node can be built from a string name.
  33108. */
  33109. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33110. /**
  33111. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33112. */
  33113. export class Node implements IBehaviorAware<Node> {
  33114. /** @hidden */
  33115. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33116. private static _NodeConstructors;
  33117. /**
  33118. * Add a new node constructor
  33119. * @param type defines the type name of the node to construct
  33120. * @param constructorFunc defines the constructor function
  33121. */
  33122. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33123. /**
  33124. * Returns a node constructor based on type name
  33125. * @param type defines the type name
  33126. * @param name defines the new node name
  33127. * @param scene defines the hosting scene
  33128. * @param options defines optional options to transmit to constructors
  33129. * @returns the new constructor or null
  33130. */
  33131. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33132. /**
  33133. * Gets or sets the name of the node
  33134. */
  33135. name: string;
  33136. /**
  33137. * Gets or sets the id of the node
  33138. */
  33139. id: string;
  33140. /**
  33141. * Gets or sets the unique id of the node
  33142. */
  33143. uniqueId: number;
  33144. /**
  33145. * Gets or sets a string used to store user defined state for the node
  33146. */
  33147. state: string;
  33148. /**
  33149. * Gets or sets an object used to store user defined information for the node
  33150. */
  33151. metadata: any;
  33152. /**
  33153. * For internal use only. Please do not use.
  33154. */
  33155. reservedDataStore: any;
  33156. /**
  33157. * List of inspectable custom properties (used by the Inspector)
  33158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33159. */
  33160. inspectableCustomProperties: IInspectable[];
  33161. private _doNotSerialize;
  33162. /**
  33163. * Gets or sets a boolean used to define if the node must be serialized
  33164. */
  33165. get doNotSerialize(): boolean;
  33166. set doNotSerialize(value: boolean);
  33167. /** @hidden */
  33168. _isDisposed: boolean;
  33169. /**
  33170. * Gets a list of Animations associated with the node
  33171. */
  33172. animations: import("babylonjs/Animations/animation").Animation[];
  33173. protected _ranges: {
  33174. [name: string]: Nullable<AnimationRange>;
  33175. };
  33176. /**
  33177. * Callback raised when the node is ready to be used
  33178. */
  33179. onReady: Nullable<(node: Node) => void>;
  33180. private _isEnabled;
  33181. private _isParentEnabled;
  33182. private _isReady;
  33183. /** @hidden */
  33184. _currentRenderId: number;
  33185. private _parentUpdateId;
  33186. /** @hidden */
  33187. _childUpdateId: number;
  33188. /** @hidden */
  33189. _waitingParentId: Nullable<string>;
  33190. /** @hidden */
  33191. _scene: Scene;
  33192. /** @hidden */
  33193. _cache: any;
  33194. private _parentNode;
  33195. private _children;
  33196. /** @hidden */
  33197. _worldMatrix: Matrix;
  33198. /** @hidden */
  33199. _worldMatrixDeterminant: number;
  33200. /** @hidden */
  33201. _worldMatrixDeterminantIsDirty: boolean;
  33202. /** @hidden */
  33203. private _sceneRootNodesIndex;
  33204. /**
  33205. * Gets a boolean indicating if the node has been disposed
  33206. * @returns true if the node was disposed
  33207. */
  33208. isDisposed(): boolean;
  33209. /**
  33210. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33211. * @see https://doc.babylonjs.com/how_to/parenting
  33212. */
  33213. set parent(parent: Nullable<Node>);
  33214. get parent(): Nullable<Node>;
  33215. /** @hidden */
  33216. _addToSceneRootNodes(): void;
  33217. /** @hidden */
  33218. _removeFromSceneRootNodes(): void;
  33219. private _animationPropertiesOverride;
  33220. /**
  33221. * Gets or sets the animation properties override
  33222. */
  33223. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33224. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33225. /**
  33226. * Gets a string idenfifying the name of the class
  33227. * @returns "Node" string
  33228. */
  33229. getClassName(): string;
  33230. /** @hidden */
  33231. readonly _isNode: boolean;
  33232. /**
  33233. * An event triggered when the mesh is disposed
  33234. */
  33235. onDisposeObservable: Observable<Node>;
  33236. private _onDisposeObserver;
  33237. /**
  33238. * Sets a callback that will be raised when the node will be disposed
  33239. */
  33240. set onDispose(callback: () => void);
  33241. /**
  33242. * Creates a new Node
  33243. * @param name the name and id to be given to this node
  33244. * @param scene the scene this node will be added to
  33245. */
  33246. constructor(name: string, scene?: Nullable<Scene>);
  33247. /**
  33248. * Gets the scene of the node
  33249. * @returns a scene
  33250. */
  33251. getScene(): Scene;
  33252. /**
  33253. * Gets the engine of the node
  33254. * @returns a Engine
  33255. */
  33256. getEngine(): Engine;
  33257. private _behaviors;
  33258. /**
  33259. * Attach a behavior to the node
  33260. * @see https://doc.babylonjs.com/features/behaviour
  33261. * @param behavior defines the behavior to attach
  33262. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33263. * @returns the current Node
  33264. */
  33265. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33266. /**
  33267. * Remove an attached behavior
  33268. * @see https://doc.babylonjs.com/features/behaviour
  33269. * @param behavior defines the behavior to attach
  33270. * @returns the current Node
  33271. */
  33272. removeBehavior(behavior: Behavior<Node>): Node;
  33273. /**
  33274. * Gets the list of attached behaviors
  33275. * @see https://doc.babylonjs.com/features/behaviour
  33276. */
  33277. get behaviors(): Behavior<Node>[];
  33278. /**
  33279. * Gets an attached behavior by name
  33280. * @param name defines the name of the behavior to look for
  33281. * @see https://doc.babylonjs.com/features/behaviour
  33282. * @returns null if behavior was not found else the requested behavior
  33283. */
  33284. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33285. /**
  33286. * Returns the latest update of the World matrix
  33287. * @returns a Matrix
  33288. */
  33289. getWorldMatrix(): Matrix;
  33290. /** @hidden */
  33291. _getWorldMatrixDeterminant(): number;
  33292. /**
  33293. * Returns directly the latest state of the mesh World matrix.
  33294. * A Matrix is returned.
  33295. */
  33296. get worldMatrixFromCache(): Matrix;
  33297. /** @hidden */
  33298. _initCache(): void;
  33299. /** @hidden */
  33300. updateCache(force?: boolean): void;
  33301. /** @hidden */
  33302. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33303. /** @hidden */
  33304. _updateCache(ignoreParentClass?: boolean): void;
  33305. /** @hidden */
  33306. _isSynchronized(): boolean;
  33307. /** @hidden */
  33308. _markSyncedWithParent(): void;
  33309. /** @hidden */
  33310. isSynchronizedWithParent(): boolean;
  33311. /** @hidden */
  33312. isSynchronized(): boolean;
  33313. /**
  33314. * Is this node ready to be used/rendered
  33315. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33316. * @return true if the node is ready
  33317. */
  33318. isReady(completeCheck?: boolean): boolean;
  33319. /**
  33320. * Is this node enabled?
  33321. * 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
  33322. * @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
  33323. * @return whether this node (and its parent) is enabled
  33324. */
  33325. isEnabled(checkAncestors?: boolean): boolean;
  33326. /** @hidden */
  33327. protected _syncParentEnabledState(): void;
  33328. /**
  33329. * Set the enabled state of this node
  33330. * @param value defines the new enabled state
  33331. */
  33332. setEnabled(value: boolean): void;
  33333. /**
  33334. * Is this node a descendant of the given node?
  33335. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33336. * @param ancestor defines the parent node to inspect
  33337. * @returns a boolean indicating if this node is a descendant of the given node
  33338. */
  33339. isDescendantOf(ancestor: Node): boolean;
  33340. /** @hidden */
  33341. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33342. /**
  33343. * Will return all nodes that have this node as ascendant
  33344. * @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
  33345. * @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
  33346. * @return all children nodes of all types
  33347. */
  33348. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33349. /**
  33350. * Get all child-meshes of this node
  33351. * @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)
  33352. * @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
  33353. * @returns an array of AbstractMesh
  33354. */
  33355. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33356. /**
  33357. * Get all direct children of this node
  33358. * @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
  33359. * @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)
  33360. * @returns an array of Node
  33361. */
  33362. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33363. /** @hidden */
  33364. _setReady(state: boolean): void;
  33365. /**
  33366. * Get an animation by name
  33367. * @param name defines the name of the animation to look for
  33368. * @returns null if not found else the requested animation
  33369. */
  33370. getAnimationByName(name: string): Nullable<Animation>;
  33371. /**
  33372. * Creates an animation range for this node
  33373. * @param name defines the name of the range
  33374. * @param from defines the starting key
  33375. * @param to defines the end key
  33376. */
  33377. createAnimationRange(name: string, from: number, to: number): void;
  33378. /**
  33379. * Delete a specific animation range
  33380. * @param name defines the name of the range to delete
  33381. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33382. */
  33383. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33384. /**
  33385. * Get an animation range by name
  33386. * @param name defines the name of the animation range to look for
  33387. * @returns null if not found else the requested animation range
  33388. */
  33389. getAnimationRange(name: string): Nullable<AnimationRange>;
  33390. /**
  33391. * Gets the list of all animation ranges defined on this node
  33392. * @returns an array
  33393. */
  33394. getAnimationRanges(): Nullable<AnimationRange>[];
  33395. /**
  33396. * Will start the animation sequence
  33397. * @param name defines the range frames for animation sequence
  33398. * @param loop defines if the animation should loop (false by default)
  33399. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33400. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33401. * @returns the object created for this animation. If range does not exist, it will return null
  33402. */
  33403. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33404. /**
  33405. * Serialize animation ranges into a JSON compatible object
  33406. * @returns serialization object
  33407. */
  33408. serializeAnimationRanges(): any;
  33409. /**
  33410. * Computes the world matrix of the node
  33411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33412. * @returns the world matrix
  33413. */
  33414. computeWorldMatrix(force?: boolean): Matrix;
  33415. /**
  33416. * Releases resources associated with this node.
  33417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33419. */
  33420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33421. /**
  33422. * Parse animation range data from a serialization object and store them into a given node
  33423. * @param node defines where to store the animation ranges
  33424. * @param parsedNode defines the serialization object to read data from
  33425. * @param scene defines the hosting scene
  33426. */
  33427. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33428. /**
  33429. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33430. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33431. * @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
  33432. * @returns the new bounding vectors
  33433. */
  33434. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33435. min: Vector3;
  33436. max: Vector3;
  33437. };
  33438. }
  33439. }
  33440. declare module "babylonjs/Animations/animation" {
  33441. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33442. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33443. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33444. import { Nullable } from "babylonjs/types";
  33445. import { Scene } from "babylonjs/scene";
  33446. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33447. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33448. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33449. import { Node } from "babylonjs/node";
  33450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33451. import { Size } from "babylonjs/Maths/math.size";
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33454. /**
  33455. * @hidden
  33456. */
  33457. export class _IAnimationState {
  33458. key: number;
  33459. repeatCount: number;
  33460. workValue?: any;
  33461. loopMode?: number;
  33462. offsetValue?: any;
  33463. highLimitValue?: any;
  33464. }
  33465. /**
  33466. * Class used to store any kind of animation
  33467. */
  33468. export class Animation {
  33469. /**Name of the animation */
  33470. name: string;
  33471. /**Property to animate */
  33472. targetProperty: string;
  33473. /**The frames per second of the animation */
  33474. framePerSecond: number;
  33475. /**The data type of the animation */
  33476. dataType: number;
  33477. /**The loop mode of the animation */
  33478. loopMode?: number | undefined;
  33479. /**Specifies if blending should be enabled */
  33480. enableBlending?: boolean | undefined;
  33481. /**
  33482. * Use matrix interpolation instead of using direct key value when animating matrices
  33483. */
  33484. static AllowMatricesInterpolation: boolean;
  33485. /**
  33486. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33487. */
  33488. static AllowMatrixDecomposeForInterpolation: boolean;
  33489. /** Define the Url to load snippets */
  33490. static SnippetUrl: string;
  33491. /** Snippet ID if the animation was created from the snippet server */
  33492. snippetId: string;
  33493. /**
  33494. * Stores the key frames of the animation
  33495. */
  33496. private _keys;
  33497. /**
  33498. * Stores the easing function of the animation
  33499. */
  33500. private _easingFunction;
  33501. /**
  33502. * @hidden Internal use only
  33503. */
  33504. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33505. /**
  33506. * The set of event that will be linked to this animation
  33507. */
  33508. private _events;
  33509. /**
  33510. * Stores an array of target property paths
  33511. */
  33512. targetPropertyPath: string[];
  33513. /**
  33514. * Stores the blending speed of the animation
  33515. */
  33516. blendingSpeed: number;
  33517. /**
  33518. * Stores the animation ranges for the animation
  33519. */
  33520. private _ranges;
  33521. /**
  33522. * @hidden Internal use
  33523. */
  33524. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33525. /**
  33526. * Sets up an animation
  33527. * @param property The property to animate
  33528. * @param animationType The animation type to apply
  33529. * @param framePerSecond The frames per second of the animation
  33530. * @param easingFunction The easing function used in the animation
  33531. * @returns The created animation
  33532. */
  33533. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33534. /**
  33535. * Create and start an animation on a node
  33536. * @param name defines the name of the global animation that will be run on all nodes
  33537. * @param node defines the root node where the animation will take place
  33538. * @param targetProperty defines property to animate
  33539. * @param framePerSecond defines the number of frame per second yo use
  33540. * @param totalFrame defines the number of frames in total
  33541. * @param from defines the initial value
  33542. * @param to defines the final value
  33543. * @param loopMode defines which loop mode you want to use (off by default)
  33544. * @param easingFunction defines the easing function to use (linear by default)
  33545. * @param onAnimationEnd defines the callback to call when animation end
  33546. * @returns the animatable created for this animation
  33547. */
  33548. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33549. /**
  33550. * Create and start an animation on a node and its descendants
  33551. * @param name defines the name of the global animation that will be run on all nodes
  33552. * @param node defines the root node where the animation will take place
  33553. * @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
  33554. * @param targetProperty defines property to animate
  33555. * @param framePerSecond defines the number of frame per second to use
  33556. * @param totalFrame defines the number of frames in total
  33557. * @param from defines the initial value
  33558. * @param to defines the final value
  33559. * @param loopMode defines which loop mode you want to use (off by default)
  33560. * @param easingFunction defines the easing function to use (linear by default)
  33561. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33562. * @returns the list of animatables created for all nodes
  33563. * @example https://www.babylonjs-playground.com/#MH0VLI
  33564. */
  33565. 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[]>;
  33566. /**
  33567. * Creates a new animation, merges it with the existing animations and starts it
  33568. * @param name Name of the animation
  33569. * @param node Node which contains the scene that begins the animations
  33570. * @param targetProperty Specifies which property to animate
  33571. * @param framePerSecond The frames per second of the animation
  33572. * @param totalFrame The total number of frames
  33573. * @param from The frame at the beginning of the animation
  33574. * @param to The frame at the end of the animation
  33575. * @param loopMode Specifies the loop mode of the animation
  33576. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33577. * @param onAnimationEnd Callback to run once the animation is complete
  33578. * @returns Nullable animation
  33579. */
  33580. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33581. /**
  33582. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33583. * @param sourceAnimation defines the Animation containing keyframes to convert
  33584. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33585. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33586. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33587. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33588. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33589. */
  33590. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33591. /**
  33592. * Transition property of an host to the target Value
  33593. * @param property The property to transition
  33594. * @param targetValue The target Value of the property
  33595. * @param host The object where the property to animate belongs
  33596. * @param scene Scene used to run the animation
  33597. * @param frameRate Framerate (in frame/s) to use
  33598. * @param transition The transition type we want to use
  33599. * @param duration The duration of the animation, in milliseconds
  33600. * @param onAnimationEnd Callback trigger at the end of the animation
  33601. * @returns Nullable animation
  33602. */
  33603. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33604. /**
  33605. * Return the array of runtime animations currently using this animation
  33606. */
  33607. get runtimeAnimations(): RuntimeAnimation[];
  33608. /**
  33609. * Specifies if any of the runtime animations are currently running
  33610. */
  33611. get hasRunningRuntimeAnimations(): boolean;
  33612. /**
  33613. * Initializes the animation
  33614. * @param name Name of the animation
  33615. * @param targetProperty Property to animate
  33616. * @param framePerSecond The frames per second of the animation
  33617. * @param dataType The data type of the animation
  33618. * @param loopMode The loop mode of the animation
  33619. * @param enableBlending Specifies if blending should be enabled
  33620. */
  33621. constructor(
  33622. /**Name of the animation */
  33623. name: string,
  33624. /**Property to animate */
  33625. targetProperty: string,
  33626. /**The frames per second of the animation */
  33627. framePerSecond: number,
  33628. /**The data type of the animation */
  33629. dataType: number,
  33630. /**The loop mode of the animation */
  33631. loopMode?: number | undefined,
  33632. /**Specifies if blending should be enabled */
  33633. enableBlending?: boolean | undefined);
  33634. /**
  33635. * Converts the animation to a string
  33636. * @param fullDetails support for multiple levels of logging within scene loading
  33637. * @returns String form of the animation
  33638. */
  33639. toString(fullDetails?: boolean): string;
  33640. /**
  33641. * Add an event to this animation
  33642. * @param event Event to add
  33643. */
  33644. addEvent(event: AnimationEvent): void;
  33645. /**
  33646. * Remove all events found at the given frame
  33647. * @param frame The frame to remove events from
  33648. */
  33649. removeEvents(frame: number): void;
  33650. /**
  33651. * Retrieves all the events from the animation
  33652. * @returns Events from the animation
  33653. */
  33654. getEvents(): AnimationEvent[];
  33655. /**
  33656. * Creates an animation range
  33657. * @param name Name of the animation range
  33658. * @param from Starting frame of the animation range
  33659. * @param to Ending frame of the animation
  33660. */
  33661. createRange(name: string, from: number, to: number): void;
  33662. /**
  33663. * Deletes an animation range by name
  33664. * @param name Name of the animation range to delete
  33665. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33666. */
  33667. deleteRange(name: string, deleteFrames?: boolean): void;
  33668. /**
  33669. * Gets the animation range by name, or null if not defined
  33670. * @param name Name of the animation range
  33671. * @returns Nullable animation range
  33672. */
  33673. getRange(name: string): Nullable<AnimationRange>;
  33674. /**
  33675. * Gets the key frames from the animation
  33676. * @returns The key frames of the animation
  33677. */
  33678. getKeys(): Array<IAnimationKey>;
  33679. /**
  33680. * Gets the highest frame rate of the animation
  33681. * @returns Highest frame rate of the animation
  33682. */
  33683. getHighestFrame(): number;
  33684. /**
  33685. * Gets the easing function of the animation
  33686. * @returns Easing function of the animation
  33687. */
  33688. getEasingFunction(): IEasingFunction;
  33689. /**
  33690. * Sets the easing function of the animation
  33691. * @param easingFunction A custom mathematical formula for animation
  33692. */
  33693. setEasingFunction(easingFunction: EasingFunction): void;
  33694. /**
  33695. * Interpolates a scalar linearly
  33696. * @param startValue Start value of the animation curve
  33697. * @param endValue End value of the animation curve
  33698. * @param gradient Scalar amount to interpolate
  33699. * @returns Interpolated scalar value
  33700. */
  33701. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33702. /**
  33703. * Interpolates a scalar cubically
  33704. * @param startValue Start value of the animation curve
  33705. * @param outTangent End tangent of the animation
  33706. * @param endValue End value of the animation curve
  33707. * @param inTangent Start tangent of the animation curve
  33708. * @param gradient Scalar amount to interpolate
  33709. * @returns Interpolated scalar value
  33710. */
  33711. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33712. /**
  33713. * Interpolates a quaternion using a spherical linear interpolation
  33714. * @param startValue Start value of the animation curve
  33715. * @param endValue End value of the animation curve
  33716. * @param gradient Scalar amount to interpolate
  33717. * @returns Interpolated quaternion value
  33718. */
  33719. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33720. /**
  33721. * Interpolates a quaternion cubically
  33722. * @param startValue Start value of the animation curve
  33723. * @param outTangent End tangent of the animation curve
  33724. * @param endValue End value of the animation curve
  33725. * @param inTangent Start tangent of the animation curve
  33726. * @param gradient Scalar amount to interpolate
  33727. * @returns Interpolated quaternion value
  33728. */
  33729. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33730. /**
  33731. * Interpolates a Vector3 linearl
  33732. * @param startValue Start value of the animation curve
  33733. * @param endValue End value of the animation curve
  33734. * @param gradient Scalar amount to interpolate
  33735. * @returns Interpolated scalar value
  33736. */
  33737. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33738. /**
  33739. * Interpolates a Vector3 cubically
  33740. * @param startValue Start value of the animation curve
  33741. * @param outTangent End tangent of the animation
  33742. * @param endValue End value of the animation curve
  33743. * @param inTangent Start tangent of the animation curve
  33744. * @param gradient Scalar amount to interpolate
  33745. * @returns InterpolatedVector3 value
  33746. */
  33747. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33748. /**
  33749. * Interpolates a Vector2 linearly
  33750. * @param startValue Start value of the animation curve
  33751. * @param endValue End value of the animation curve
  33752. * @param gradient Scalar amount to interpolate
  33753. * @returns Interpolated Vector2 value
  33754. */
  33755. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33756. /**
  33757. * Interpolates a Vector2 cubically
  33758. * @param startValue Start value of the animation curve
  33759. * @param outTangent End tangent of the animation
  33760. * @param endValue End value of the animation curve
  33761. * @param inTangent Start tangent of the animation curve
  33762. * @param gradient Scalar amount to interpolate
  33763. * @returns Interpolated Vector2 value
  33764. */
  33765. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33766. /**
  33767. * Interpolates a size linearly
  33768. * @param startValue Start value of the animation curve
  33769. * @param endValue End value of the animation curve
  33770. * @param gradient Scalar amount to interpolate
  33771. * @returns Interpolated Size value
  33772. */
  33773. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33774. /**
  33775. * Interpolates a Color3 linearly
  33776. * @param startValue Start value of the animation curve
  33777. * @param endValue End value of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated Color3 value
  33780. */
  33781. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33782. /**
  33783. * Interpolates a Color4 linearly
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated Color3 value
  33788. */
  33789. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33790. /**
  33791. * @hidden Internal use only
  33792. */
  33793. _getKeyValue(value: any): any;
  33794. /**
  33795. * @hidden Internal use only
  33796. */
  33797. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33798. /**
  33799. * Defines the function to use to interpolate matrices
  33800. * @param startValue defines the start matrix
  33801. * @param endValue defines the end matrix
  33802. * @param gradient defines the gradient between both matrices
  33803. * @param result defines an optional target matrix where to store the interpolation
  33804. * @returns the interpolated matrix
  33805. */
  33806. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33807. /**
  33808. * Makes a copy of the animation
  33809. * @returns Cloned animation
  33810. */
  33811. clone(): Animation;
  33812. /**
  33813. * Sets the key frames of the animation
  33814. * @param values The animation key frames to set
  33815. */
  33816. setKeys(values: Array<IAnimationKey>): void;
  33817. /**
  33818. * Serializes the animation to an object
  33819. * @returns Serialized object
  33820. */
  33821. serialize(): any;
  33822. /**
  33823. * Float animation type
  33824. */
  33825. static readonly ANIMATIONTYPE_FLOAT: number;
  33826. /**
  33827. * Vector3 animation type
  33828. */
  33829. static readonly ANIMATIONTYPE_VECTOR3: number;
  33830. /**
  33831. * Quaternion animation type
  33832. */
  33833. static readonly ANIMATIONTYPE_QUATERNION: number;
  33834. /**
  33835. * Matrix animation type
  33836. */
  33837. static readonly ANIMATIONTYPE_MATRIX: number;
  33838. /**
  33839. * Color3 animation type
  33840. */
  33841. static readonly ANIMATIONTYPE_COLOR3: number;
  33842. /**
  33843. * Color3 animation type
  33844. */
  33845. static readonly ANIMATIONTYPE_COLOR4: number;
  33846. /**
  33847. * Vector2 animation type
  33848. */
  33849. static readonly ANIMATIONTYPE_VECTOR2: number;
  33850. /**
  33851. * Size animation type
  33852. */
  33853. static readonly ANIMATIONTYPE_SIZE: number;
  33854. /**
  33855. * Relative Loop Mode
  33856. */
  33857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33858. /**
  33859. * Cycle Loop Mode
  33860. */
  33861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33862. /**
  33863. * Constant Loop Mode
  33864. */
  33865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33866. /** @hidden */
  33867. static _UniversalLerp(left: any, right: any, amount: number): any;
  33868. /**
  33869. * Parses an animation object and creates an animation
  33870. * @param parsedAnimation Parsed animation object
  33871. * @returns Animation object
  33872. */
  33873. static Parse(parsedAnimation: any): Animation;
  33874. /**
  33875. * Appends the serialized animations from the source animations
  33876. * @param source Source containing the animations
  33877. * @param destination Target to store the animations
  33878. */
  33879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33880. /**
  33881. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33882. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33883. * @param url defines the url to load from
  33884. * @returns a promise that will resolve to the new animation or an array of animations
  33885. */
  33886. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33887. /**
  33888. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33889. * @param snippetId defines the snippet to load
  33890. * @returns a promise that will resolve to the new animation or a new array of animations
  33891. */
  33892. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33893. }
  33894. }
  33895. declare module "babylonjs/Animations/animatable.interface" {
  33896. import { Nullable } from "babylonjs/types";
  33897. import { Animation } from "babylonjs/Animations/animation";
  33898. /**
  33899. * Interface containing an array of animations
  33900. */
  33901. export interface IAnimatable {
  33902. /**
  33903. * Array of animations
  33904. */
  33905. animations: Nullable<Array<Animation>>;
  33906. }
  33907. }
  33908. declare module "babylonjs/Misc/decorators" {
  33909. import { Nullable } from "babylonjs/types";
  33910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33911. import { Scene } from "babylonjs/scene";
  33912. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33913. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33914. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33916. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33917. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33918. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33919. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33920. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33921. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33922. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33923. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33924. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33925. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33926. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33927. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33928. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33929. /**
  33930. * Decorator used to define property that can be serialized as reference to a camera
  33931. * @param sourceName defines the name of the property to decorate
  33932. */
  33933. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33934. /**
  33935. * Class used to help serialization objects
  33936. */
  33937. export class SerializationHelper {
  33938. /** @hidden */
  33939. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33940. /** @hidden */
  33941. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33942. /** @hidden */
  33943. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33944. /** @hidden */
  33945. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33946. /**
  33947. * Appends the serialized animations from the source animations
  33948. * @param source Source containing the animations
  33949. * @param destination Target to store the animations
  33950. */
  33951. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33952. /**
  33953. * Static function used to serialized a specific entity
  33954. * @param entity defines the entity to serialize
  33955. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33956. * @returns a JSON compatible object representing the serialization of the entity
  33957. */
  33958. static Serialize<T>(entity: T, serializationObject?: any): any;
  33959. /**
  33960. * Creates a new entity from a serialization data object
  33961. * @param creationFunction defines a function used to instanciated the new entity
  33962. * @param source defines the source serialization data
  33963. * @param scene defines the hosting scene
  33964. * @param rootUrl defines the root url for resources
  33965. * @returns a new entity
  33966. */
  33967. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33968. /**
  33969. * Clones an object
  33970. * @param creationFunction defines the function used to instanciate the new object
  33971. * @param source defines the source object
  33972. * @returns the cloned object
  33973. */
  33974. static Clone<T>(creationFunction: () => T, source: T): T;
  33975. /**
  33976. * Instanciates a new object based on a source one (some data will be shared between both object)
  33977. * @param creationFunction defines the function used to instanciate the new object
  33978. * @param source defines the source object
  33979. * @returns the new object
  33980. */
  33981. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33982. }
  33983. }
  33984. declare module "babylonjs/Materials/Textures/baseTexture" {
  33985. import { Observable } from "babylonjs/Misc/observable";
  33986. import { Nullable } from "babylonjs/types";
  33987. import { Scene } from "babylonjs/scene";
  33988. import { Matrix } from "babylonjs/Maths/math.vector";
  33989. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33991. import { ISize } from "babylonjs/Maths/math.size";
  33992. import "babylonjs/Misc/fileTools";
  33993. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33994. /**
  33995. * Base class of all the textures in babylon.
  33996. * It groups all the common properties the materials, post process, lights... might need
  33997. * in order to make a correct use of the texture.
  33998. */
  33999. export class BaseTexture implements IAnimatable {
  34000. /**
  34001. * Default anisotropic filtering level for the application.
  34002. * It is set to 4 as a good tradeoff between perf and quality.
  34003. */
  34004. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34005. /**
  34006. * Gets or sets the unique id of the texture
  34007. */
  34008. uniqueId: number;
  34009. /**
  34010. * Define the name of the texture.
  34011. */
  34012. name: string;
  34013. /**
  34014. * Gets or sets an object used to store user defined information.
  34015. */
  34016. metadata: any;
  34017. /**
  34018. * For internal use only. Please do not use.
  34019. */
  34020. reservedDataStore: any;
  34021. private _hasAlpha;
  34022. /**
  34023. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34024. */
  34025. set hasAlpha(value: boolean);
  34026. get hasAlpha(): boolean;
  34027. /**
  34028. * Defines if the alpha value should be determined via the rgb values.
  34029. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34030. */
  34031. getAlphaFromRGB: boolean;
  34032. /**
  34033. * Intensity or strength of the texture.
  34034. * It is commonly used by materials to fine tune the intensity of the texture
  34035. */
  34036. level: number;
  34037. /**
  34038. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34039. * This is part of the texture as textures usually maps to one uv set.
  34040. */
  34041. coordinatesIndex: number;
  34042. private _coordinatesMode;
  34043. /**
  34044. * How a texture is mapped.
  34045. *
  34046. * | Value | Type | Description |
  34047. * | ----- | ----------------------------------- | ----------- |
  34048. * | 0 | EXPLICIT_MODE | |
  34049. * | 1 | SPHERICAL_MODE | |
  34050. * | 2 | PLANAR_MODE | |
  34051. * | 3 | CUBIC_MODE | |
  34052. * | 4 | PROJECTION_MODE | |
  34053. * | 5 | SKYBOX_MODE | |
  34054. * | 6 | INVCUBIC_MODE | |
  34055. * | 7 | EQUIRECTANGULAR_MODE | |
  34056. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34057. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34058. */
  34059. set coordinatesMode(value: number);
  34060. get coordinatesMode(): number;
  34061. /**
  34062. * | Value | Type | Description |
  34063. * | ----- | ------------------ | ----------- |
  34064. * | 0 | CLAMP_ADDRESSMODE | |
  34065. * | 1 | WRAP_ADDRESSMODE | |
  34066. * | 2 | MIRROR_ADDRESSMODE | |
  34067. */
  34068. wrapU: number;
  34069. /**
  34070. * | Value | Type | Description |
  34071. * | ----- | ------------------ | ----------- |
  34072. * | 0 | CLAMP_ADDRESSMODE | |
  34073. * | 1 | WRAP_ADDRESSMODE | |
  34074. * | 2 | MIRROR_ADDRESSMODE | |
  34075. */
  34076. wrapV: number;
  34077. /**
  34078. * | Value | Type | Description |
  34079. * | ----- | ------------------ | ----------- |
  34080. * | 0 | CLAMP_ADDRESSMODE | |
  34081. * | 1 | WRAP_ADDRESSMODE | |
  34082. * | 2 | MIRROR_ADDRESSMODE | |
  34083. */
  34084. wrapR: number;
  34085. /**
  34086. * With compliant hardware and browser (supporting anisotropic filtering)
  34087. * this defines the level of anisotropic filtering in the texture.
  34088. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34089. */
  34090. anisotropicFilteringLevel: number;
  34091. /**
  34092. * Define if the texture is a cube texture or if false a 2d texture.
  34093. */
  34094. get isCube(): boolean;
  34095. set isCube(value: boolean);
  34096. /**
  34097. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34098. */
  34099. get is3D(): boolean;
  34100. set is3D(value: boolean);
  34101. /**
  34102. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34103. */
  34104. get is2DArray(): boolean;
  34105. set is2DArray(value: boolean);
  34106. /**
  34107. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34108. * HDR texture are usually stored in linear space.
  34109. * This only impacts the PBR and Background materials
  34110. */
  34111. gammaSpace: boolean;
  34112. /**
  34113. * Gets or sets whether or not the texture contains RGBD data.
  34114. */
  34115. get isRGBD(): boolean;
  34116. set isRGBD(value: boolean);
  34117. /**
  34118. * Is Z inverted in the texture (useful in a cube texture).
  34119. */
  34120. invertZ: boolean;
  34121. /**
  34122. * Are mip maps generated for this texture or not.
  34123. */
  34124. get noMipmap(): boolean;
  34125. /**
  34126. * @hidden
  34127. */
  34128. lodLevelInAlpha: boolean;
  34129. /**
  34130. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34131. */
  34132. get lodGenerationOffset(): number;
  34133. set lodGenerationOffset(value: number);
  34134. /**
  34135. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34136. */
  34137. get lodGenerationScale(): number;
  34138. set lodGenerationScale(value: number);
  34139. /**
  34140. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34141. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34142. * average roughness values.
  34143. */
  34144. get linearSpecularLOD(): boolean;
  34145. set linearSpecularLOD(value: boolean);
  34146. /**
  34147. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34148. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34149. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34150. */
  34151. get irradianceTexture(): Nullable<BaseTexture>;
  34152. set irradianceTexture(value: Nullable<BaseTexture>);
  34153. /**
  34154. * Define if the texture is a render target.
  34155. */
  34156. isRenderTarget: boolean;
  34157. /**
  34158. * Define the unique id of the texture in the scene.
  34159. */
  34160. get uid(): string;
  34161. /** @hidden */
  34162. _prefiltered: boolean;
  34163. /**
  34164. * Return a string representation of the texture.
  34165. * @returns the texture as a string
  34166. */
  34167. toString(): string;
  34168. /**
  34169. * Get the class name of the texture.
  34170. * @returns "BaseTexture"
  34171. */
  34172. getClassName(): string;
  34173. /**
  34174. * Define the list of animation attached to the texture.
  34175. */
  34176. animations: import("babylonjs/Animations/animation").Animation[];
  34177. /**
  34178. * An event triggered when the texture is disposed.
  34179. */
  34180. onDisposeObservable: Observable<BaseTexture>;
  34181. private _onDisposeObserver;
  34182. /**
  34183. * Callback triggered when the texture has been disposed.
  34184. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34185. */
  34186. set onDispose(callback: () => void);
  34187. /**
  34188. * Define the current state of the loading sequence when in delayed load mode.
  34189. */
  34190. delayLoadState: number;
  34191. private _scene;
  34192. private _engine;
  34193. /** @hidden */
  34194. _texture: Nullable<InternalTexture>;
  34195. private _uid;
  34196. /**
  34197. * Define if the texture is preventinga material to render or not.
  34198. * If not and the texture is not ready, the engine will use a default black texture instead.
  34199. */
  34200. get isBlocking(): boolean;
  34201. /**
  34202. * Instantiates a new BaseTexture.
  34203. * Base class of all the textures in babylon.
  34204. * It groups all the common properties the materials, post process, lights... might need
  34205. * in order to make a correct use of the texture.
  34206. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34207. */
  34208. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34209. /**
  34210. * Get the scene the texture belongs to.
  34211. * @returns the scene or null if undefined
  34212. */
  34213. getScene(): Nullable<Scene>;
  34214. /** @hidden */
  34215. protected _getEngine(): Nullable<ThinEngine>;
  34216. /**
  34217. * Get the texture transform matrix used to offset tile the texture for istance.
  34218. * @returns the transformation matrix
  34219. */
  34220. getTextureMatrix(): Matrix;
  34221. /**
  34222. * Get the texture reflection matrix used to rotate/transform the reflection.
  34223. * @returns the reflection matrix
  34224. */
  34225. getReflectionTextureMatrix(): Matrix;
  34226. /**
  34227. * Get the underlying lower level texture from Babylon.
  34228. * @returns the insternal texture
  34229. */
  34230. getInternalTexture(): Nullable<InternalTexture>;
  34231. /**
  34232. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34233. * @returns true if ready or not blocking
  34234. */
  34235. isReadyOrNotBlocking(): boolean;
  34236. /**
  34237. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34238. * @returns true if fully ready
  34239. */
  34240. isReady(): boolean;
  34241. private _cachedSize;
  34242. /**
  34243. * Get the size of the texture.
  34244. * @returns the texture size.
  34245. */
  34246. getSize(): ISize;
  34247. /**
  34248. * Get the base size of the texture.
  34249. * It can be different from the size if the texture has been resized for POT for instance
  34250. * @returns the base size
  34251. */
  34252. getBaseSize(): ISize;
  34253. /**
  34254. * Update the sampling mode of the texture.
  34255. * Default is Trilinear mode.
  34256. *
  34257. * | Value | Type | Description |
  34258. * | ----- | ------------------ | ----------- |
  34259. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34260. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34261. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34262. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34263. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34264. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34265. * | 7 | NEAREST_LINEAR | |
  34266. * | 8 | NEAREST_NEAREST | |
  34267. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34268. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34269. * | 11 | LINEAR_LINEAR | |
  34270. * | 12 | LINEAR_NEAREST | |
  34271. *
  34272. * > _mag_: magnification filter (close to the viewer)
  34273. * > _min_: minification filter (far from the viewer)
  34274. * > _mip_: filter used between mip map levels
  34275. *@param samplingMode Define the new sampling mode of the texture
  34276. */
  34277. updateSamplingMode(samplingMode: number): void;
  34278. /**
  34279. * Scales the texture if is `canRescale()`
  34280. * @param ratio the resize factor we want to use to rescale
  34281. */
  34282. scale(ratio: number): void;
  34283. /**
  34284. * Get if the texture can rescale.
  34285. */
  34286. get canRescale(): boolean;
  34287. /** @hidden */
  34288. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34289. /** @hidden */
  34290. _rebuild(): void;
  34291. /**
  34292. * Triggers the load sequence in delayed load mode.
  34293. */
  34294. delayLoad(): void;
  34295. /**
  34296. * Clones the texture.
  34297. * @returns the cloned texture
  34298. */
  34299. clone(): Nullable<BaseTexture>;
  34300. /**
  34301. * Get the texture underlying type (INT, FLOAT...)
  34302. */
  34303. get textureType(): number;
  34304. /**
  34305. * Get the texture underlying format (RGB, RGBA...)
  34306. */
  34307. get textureFormat(): number;
  34308. /**
  34309. * Indicates that textures need to be re-calculated for all materials
  34310. */
  34311. protected _markAllSubMeshesAsTexturesDirty(): void;
  34312. /**
  34313. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34314. * This will returns an RGBA array buffer containing either in values (0-255) or
  34315. * float values (0-1) depending of the underlying buffer type.
  34316. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34317. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34318. * @param buffer defines a user defined buffer to fill with data (can be null)
  34319. * @returns The Array buffer containing the pixels data.
  34320. */
  34321. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34322. /**
  34323. * Release and destroy the underlying lower level texture aka internalTexture.
  34324. */
  34325. releaseInternalTexture(): void;
  34326. /** @hidden */
  34327. get _lodTextureHigh(): Nullable<BaseTexture>;
  34328. /** @hidden */
  34329. get _lodTextureMid(): Nullable<BaseTexture>;
  34330. /** @hidden */
  34331. get _lodTextureLow(): Nullable<BaseTexture>;
  34332. /**
  34333. * Dispose the texture and release its associated resources.
  34334. */
  34335. dispose(): void;
  34336. /**
  34337. * Serialize the texture into a JSON representation that can be parsed later on.
  34338. * @returns the JSON representation of the texture
  34339. */
  34340. serialize(): any;
  34341. /**
  34342. * Helper function to be called back once a list of texture contains only ready textures.
  34343. * @param textures Define the list of textures to wait for
  34344. * @param callback Define the callback triggered once the entire list will be ready
  34345. */
  34346. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34347. private static _isScene;
  34348. }
  34349. }
  34350. declare module "babylonjs/Materials/effect" {
  34351. import { Observable } from "babylonjs/Misc/observable";
  34352. import { Nullable } from "babylonjs/types";
  34353. import { IDisposable } from "babylonjs/scene";
  34354. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34355. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34356. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34357. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34358. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34359. import { Engine } from "babylonjs/Engines/engine";
  34360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34364. /**
  34365. * Options to be used when creating an effect.
  34366. */
  34367. export interface IEffectCreationOptions {
  34368. /**
  34369. * Atrributes that will be used in the shader.
  34370. */
  34371. attributes: string[];
  34372. /**
  34373. * Uniform varible names that will be set in the shader.
  34374. */
  34375. uniformsNames: string[];
  34376. /**
  34377. * Uniform buffer variable names that will be set in the shader.
  34378. */
  34379. uniformBuffersNames: string[];
  34380. /**
  34381. * Sampler texture variable names that will be set in the shader.
  34382. */
  34383. samplers: string[];
  34384. /**
  34385. * Define statements that will be set in the shader.
  34386. */
  34387. defines: any;
  34388. /**
  34389. * Possible fallbacks for this effect to improve performance when needed.
  34390. */
  34391. fallbacks: Nullable<IEffectFallbacks>;
  34392. /**
  34393. * Callback that will be called when the shader is compiled.
  34394. */
  34395. onCompiled: Nullable<(effect: Effect) => void>;
  34396. /**
  34397. * Callback that will be called if an error occurs during shader compilation.
  34398. */
  34399. onError: Nullable<(effect: Effect, errors: string) => void>;
  34400. /**
  34401. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34402. */
  34403. indexParameters?: any;
  34404. /**
  34405. * Max number of lights that can be used in the shader.
  34406. */
  34407. maxSimultaneousLights?: number;
  34408. /**
  34409. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34410. */
  34411. transformFeedbackVaryings?: Nullable<string[]>;
  34412. /**
  34413. * 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
  34414. */
  34415. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34416. /**
  34417. * Is this effect rendering to several color attachments ?
  34418. */
  34419. multiTarget?: boolean;
  34420. }
  34421. /**
  34422. * Effect containing vertex and fragment shader that can be executed on an object.
  34423. */
  34424. export class Effect implements IDisposable {
  34425. /**
  34426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34427. */
  34428. static ShadersRepository: string;
  34429. /**
  34430. * Enable logging of the shader code when a compilation error occurs
  34431. */
  34432. static LogShaderCodeOnCompilationError: boolean;
  34433. /**
  34434. * Name of the effect.
  34435. */
  34436. name: any;
  34437. /**
  34438. * String container all the define statements that should be set on the shader.
  34439. */
  34440. defines: string;
  34441. /**
  34442. * Callback that will be called when the shader is compiled.
  34443. */
  34444. onCompiled: Nullable<(effect: Effect) => void>;
  34445. /**
  34446. * Callback that will be called if an error occurs during shader compilation.
  34447. */
  34448. onError: Nullable<(effect: Effect, errors: string) => void>;
  34449. /**
  34450. * Callback that will be called when effect is bound.
  34451. */
  34452. onBind: Nullable<(effect: Effect) => void>;
  34453. /**
  34454. * Unique ID of the effect.
  34455. */
  34456. uniqueId: number;
  34457. /**
  34458. * Observable that will be called when the shader is compiled.
  34459. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34460. */
  34461. onCompileObservable: Observable<Effect>;
  34462. /**
  34463. * Observable that will be called if an error occurs during shader compilation.
  34464. */
  34465. onErrorObservable: Observable<Effect>;
  34466. /** @hidden */
  34467. _onBindObservable: Nullable<Observable<Effect>>;
  34468. /**
  34469. * @hidden
  34470. * Specifies if the effect was previously ready
  34471. */
  34472. _wasPreviouslyReady: boolean;
  34473. /**
  34474. * Observable that will be called when effect is bound.
  34475. */
  34476. get onBindObservable(): Observable<Effect>;
  34477. /** @hidden */
  34478. _bonesComputationForcedToCPU: boolean;
  34479. /** @hidden */
  34480. _multiTarget: boolean;
  34481. private static _uniqueIdSeed;
  34482. private _engine;
  34483. private _uniformBuffersNames;
  34484. private _uniformBuffersNamesList;
  34485. private _uniformsNames;
  34486. private _samplerList;
  34487. private _samplers;
  34488. private _isReady;
  34489. private _compilationError;
  34490. private _allFallbacksProcessed;
  34491. private _attributesNames;
  34492. private _attributes;
  34493. private _attributeLocationByName;
  34494. private _uniforms;
  34495. /**
  34496. * Key for the effect.
  34497. * @hidden
  34498. */
  34499. _key: string;
  34500. private _indexParameters;
  34501. private _fallbacks;
  34502. private _vertexSourceCode;
  34503. private _fragmentSourceCode;
  34504. private _vertexSourceCodeOverride;
  34505. private _fragmentSourceCodeOverride;
  34506. private _transformFeedbackVaryings;
  34507. /**
  34508. * Compiled shader to webGL program.
  34509. * @hidden
  34510. */
  34511. _pipelineContext: Nullable<IPipelineContext>;
  34512. private _valueCache;
  34513. private static _baseCache;
  34514. /**
  34515. * Instantiates an effect.
  34516. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34517. * @param baseName Name of the effect.
  34518. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34519. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34520. * @param samplers List of sampler variables that will be passed to the shader.
  34521. * @param engine Engine to be used to render the effect
  34522. * @param defines Define statements to be added to the shader.
  34523. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34524. * @param onCompiled Callback that will be called when the shader is compiled.
  34525. * @param onError Callback that will be called if an error occurs during shader compilation.
  34526. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34527. */
  34528. 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);
  34529. private _useFinalCode;
  34530. /**
  34531. * Unique key for this effect
  34532. */
  34533. get key(): string;
  34534. /**
  34535. * If the effect has been compiled and prepared.
  34536. * @returns if the effect is compiled and prepared.
  34537. */
  34538. isReady(): boolean;
  34539. private _isReadyInternal;
  34540. /**
  34541. * The engine the effect was initialized with.
  34542. * @returns the engine.
  34543. */
  34544. getEngine(): Engine;
  34545. /**
  34546. * The pipeline context for this effect
  34547. * @returns the associated pipeline context
  34548. */
  34549. getPipelineContext(): Nullable<IPipelineContext>;
  34550. /**
  34551. * The set of names of attribute variables for the shader.
  34552. * @returns An array of attribute names.
  34553. */
  34554. getAttributesNames(): string[];
  34555. /**
  34556. * Returns the attribute at the given index.
  34557. * @param index The index of the attribute.
  34558. * @returns The location of the attribute.
  34559. */
  34560. getAttributeLocation(index: number): number;
  34561. /**
  34562. * Returns the attribute based on the name of the variable.
  34563. * @param name of the attribute to look up.
  34564. * @returns the attribute location.
  34565. */
  34566. getAttributeLocationByName(name: string): number;
  34567. /**
  34568. * The number of attributes.
  34569. * @returns the numnber of attributes.
  34570. */
  34571. getAttributesCount(): number;
  34572. /**
  34573. * Gets the index of a uniform variable.
  34574. * @param uniformName of the uniform to look up.
  34575. * @returns the index.
  34576. */
  34577. getUniformIndex(uniformName: string): number;
  34578. /**
  34579. * Returns the attribute based on the name of the variable.
  34580. * @param uniformName of the uniform to look up.
  34581. * @returns the location of the uniform.
  34582. */
  34583. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34584. /**
  34585. * Returns an array of sampler variable names
  34586. * @returns The array of sampler variable names.
  34587. */
  34588. getSamplers(): string[];
  34589. /**
  34590. * Returns an array of uniform variable names
  34591. * @returns The array of uniform variable names.
  34592. */
  34593. getUniformNames(): string[];
  34594. /**
  34595. * Returns an array of uniform buffer variable names
  34596. * @returns The array of uniform buffer variable names.
  34597. */
  34598. getUniformBuffersNames(): string[];
  34599. /**
  34600. * Returns the index parameters used to create the effect
  34601. * @returns The index parameters object
  34602. */
  34603. getIndexParameters(): any;
  34604. /**
  34605. * The error from the last compilation.
  34606. * @returns the error string.
  34607. */
  34608. getCompilationError(): string;
  34609. /**
  34610. * Gets a boolean indicating that all fallbacks were used during compilation
  34611. * @returns true if all fallbacks were used
  34612. */
  34613. allFallbacksProcessed(): boolean;
  34614. /**
  34615. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34616. * @param func The callback to be used.
  34617. */
  34618. executeWhenCompiled(func: (effect: Effect) => void): void;
  34619. private _checkIsReady;
  34620. private _loadShader;
  34621. /**
  34622. * Gets the vertex shader source code of this effect
  34623. */
  34624. get vertexSourceCode(): string;
  34625. /**
  34626. * Gets the fragment shader source code of this effect
  34627. */
  34628. get fragmentSourceCode(): string;
  34629. /**
  34630. * Recompiles the webGL program
  34631. * @param vertexSourceCode The source code for the vertex shader.
  34632. * @param fragmentSourceCode The source code for the fragment shader.
  34633. * @param onCompiled Callback called when completed.
  34634. * @param onError Callback called on error.
  34635. * @hidden
  34636. */
  34637. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34638. /**
  34639. * Prepares the effect
  34640. * @hidden
  34641. */
  34642. _prepareEffect(): void;
  34643. private _getShaderCodeAndErrorLine;
  34644. private _processCompilationErrors;
  34645. /**
  34646. * Checks if the effect is supported. (Must be called after compilation)
  34647. */
  34648. get isSupported(): boolean;
  34649. /**
  34650. * Binds a texture to the engine to be used as output of the shader.
  34651. * @param channel Name of the output variable.
  34652. * @param texture Texture to bind.
  34653. * @hidden
  34654. */
  34655. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34656. /**
  34657. * Sets a texture on the engine to be used in the shader.
  34658. * @param channel Name of the sampler variable.
  34659. * @param texture Texture to set.
  34660. */
  34661. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34662. /**
  34663. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34664. * @param channel Name of the sampler variable.
  34665. * @param texture Texture to set.
  34666. */
  34667. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34668. /**
  34669. * Sets an array of textures on the engine to be used in the shader.
  34670. * @param channel Name of the variable.
  34671. * @param textures Textures to set.
  34672. */
  34673. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34674. /**
  34675. * 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)
  34676. * @param channel Name of the sampler variable.
  34677. * @param postProcess Post process to get the input texture from.
  34678. */
  34679. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34680. /**
  34681. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34682. * 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)
  34683. * @param channel Name of the sampler variable.
  34684. * @param postProcess Post process to get the output texture from.
  34685. */
  34686. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34687. /** @hidden */
  34688. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34689. /** @hidden */
  34690. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34691. /** @hidden */
  34692. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34693. /** @hidden */
  34694. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34695. /**
  34696. * Binds a buffer to a uniform.
  34697. * @param buffer Buffer to bind.
  34698. * @param name Name of the uniform variable to bind to.
  34699. */
  34700. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34701. /**
  34702. * Binds block to a uniform.
  34703. * @param blockName Name of the block to bind.
  34704. * @param index Index to bind.
  34705. */
  34706. bindUniformBlock(blockName: string, index: number): void;
  34707. /**
  34708. * Sets an interger value on a uniform variable.
  34709. * @param uniformName Name of the variable.
  34710. * @param value Value to be set.
  34711. * @returns this effect.
  34712. */
  34713. setInt(uniformName: string, value: number): Effect;
  34714. /**
  34715. * Sets an int array on a uniform variable.
  34716. * @param uniformName Name of the variable.
  34717. * @param array array to be set.
  34718. * @returns this effect.
  34719. */
  34720. setIntArray(uniformName: string, array: Int32Array): Effect;
  34721. /**
  34722. * 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)
  34723. * @param uniformName Name of the variable.
  34724. * @param array array to be set.
  34725. * @returns this effect.
  34726. */
  34727. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34728. /**
  34729. * 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)
  34730. * @param uniformName Name of the variable.
  34731. * @param array array to be set.
  34732. * @returns this effect.
  34733. */
  34734. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34735. /**
  34736. * 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)
  34737. * @param uniformName Name of the variable.
  34738. * @param array array to be set.
  34739. * @returns this effect.
  34740. */
  34741. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34742. /**
  34743. * Sets an float array on a uniform variable.
  34744. * @param uniformName Name of the variable.
  34745. * @param array array to be set.
  34746. * @returns this effect.
  34747. */
  34748. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34749. /**
  34750. * 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)
  34751. * @param uniformName Name of the variable.
  34752. * @param array array to be set.
  34753. * @returns this effect.
  34754. */
  34755. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34756. /**
  34757. * 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)
  34758. * @param uniformName Name of the variable.
  34759. * @param array array to be set.
  34760. * @returns this effect.
  34761. */
  34762. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34763. /**
  34764. * 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)
  34765. * @param uniformName Name of the variable.
  34766. * @param array array to be set.
  34767. * @returns this effect.
  34768. */
  34769. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34770. /**
  34771. * Sets an array on a uniform variable.
  34772. * @param uniformName Name of the variable.
  34773. * @param array array to be set.
  34774. * @returns this effect.
  34775. */
  34776. setArray(uniformName: string, array: number[]): Effect;
  34777. /**
  34778. * 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)
  34779. * @param uniformName Name of the variable.
  34780. * @param array array to be set.
  34781. * @returns this effect.
  34782. */
  34783. setArray2(uniformName: string, array: number[]): Effect;
  34784. /**
  34785. * 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)
  34786. * @param uniformName Name of the variable.
  34787. * @param array array to be set.
  34788. * @returns this effect.
  34789. */
  34790. setArray3(uniformName: string, array: number[]): Effect;
  34791. /**
  34792. * 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)
  34793. * @param uniformName Name of the variable.
  34794. * @param array array to be set.
  34795. * @returns this effect.
  34796. */
  34797. setArray4(uniformName: string, array: number[]): Effect;
  34798. /**
  34799. * Sets matrices on a uniform variable.
  34800. * @param uniformName Name of the variable.
  34801. * @param matrices matrices to be set.
  34802. * @returns this effect.
  34803. */
  34804. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34805. /**
  34806. * Sets matrix on a uniform variable.
  34807. * @param uniformName Name of the variable.
  34808. * @param matrix matrix to be set.
  34809. * @returns this effect.
  34810. */
  34811. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34812. /**
  34813. * 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)
  34814. * @param uniformName Name of the variable.
  34815. * @param matrix matrix to be set.
  34816. * @returns this effect.
  34817. */
  34818. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34819. /**
  34820. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34821. * @param uniformName Name of the variable.
  34822. * @param matrix matrix to be set.
  34823. * @returns this effect.
  34824. */
  34825. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34826. /**
  34827. * Sets a float on a uniform variable.
  34828. * @param uniformName Name of the variable.
  34829. * @param value value to be set.
  34830. * @returns this effect.
  34831. */
  34832. setFloat(uniformName: string, value: number): Effect;
  34833. /**
  34834. * Sets a boolean on a uniform variable.
  34835. * @param uniformName Name of the variable.
  34836. * @param bool value to be set.
  34837. * @returns this effect.
  34838. */
  34839. setBool(uniformName: string, bool: boolean): Effect;
  34840. /**
  34841. * Sets a Vector2 on a uniform variable.
  34842. * @param uniformName Name of the variable.
  34843. * @param vector2 vector2 to be set.
  34844. * @returns this effect.
  34845. */
  34846. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34847. /**
  34848. * Sets a float2 on a uniform variable.
  34849. * @param uniformName Name of the variable.
  34850. * @param x First float in float2.
  34851. * @param y Second float in float2.
  34852. * @returns this effect.
  34853. */
  34854. setFloat2(uniformName: string, x: number, y: number): Effect;
  34855. /**
  34856. * Sets a Vector3 on a uniform variable.
  34857. * @param uniformName Name of the variable.
  34858. * @param vector3 Value to be set.
  34859. * @returns this effect.
  34860. */
  34861. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34862. /**
  34863. * Sets a float3 on a uniform variable.
  34864. * @param uniformName Name of the variable.
  34865. * @param x First float in float3.
  34866. * @param y Second float in float3.
  34867. * @param z Third float in float3.
  34868. * @returns this effect.
  34869. */
  34870. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34871. /**
  34872. * Sets a Vector4 on a uniform variable.
  34873. * @param uniformName Name of the variable.
  34874. * @param vector4 Value to be set.
  34875. * @returns this effect.
  34876. */
  34877. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34878. /**
  34879. * Sets a float4 on a uniform variable.
  34880. * @param uniformName Name of the variable.
  34881. * @param x First float in float4.
  34882. * @param y Second float in float4.
  34883. * @param z Third float in float4.
  34884. * @param w Fourth float in float4.
  34885. * @returns this effect.
  34886. */
  34887. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34888. /**
  34889. * Sets a Color3 on a uniform variable.
  34890. * @param uniformName Name of the variable.
  34891. * @param color3 Value to be set.
  34892. * @returns this effect.
  34893. */
  34894. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34895. /**
  34896. * Sets a Color4 on a uniform variable.
  34897. * @param uniformName Name of the variable.
  34898. * @param color3 Value to be set.
  34899. * @param alpha Alpha value to be set.
  34900. * @returns this effect.
  34901. */
  34902. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34903. /**
  34904. * Sets a Color4 on a uniform variable
  34905. * @param uniformName defines the name of the variable
  34906. * @param color4 defines the value to be set
  34907. * @returns this effect.
  34908. */
  34909. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34910. /** Release all associated resources */
  34911. dispose(): void;
  34912. /**
  34913. * This function will add a new shader to the shader store
  34914. * @param name the name of the shader
  34915. * @param pixelShader optional pixel shader content
  34916. * @param vertexShader optional vertex shader content
  34917. */
  34918. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34919. /**
  34920. * Store of each shader (The can be looked up using effect.key)
  34921. */
  34922. static ShadersStore: {
  34923. [key: string]: string;
  34924. };
  34925. /**
  34926. * Store of each included file for a shader (The can be looked up using effect.key)
  34927. */
  34928. static IncludesShadersStore: {
  34929. [key: string]: string;
  34930. };
  34931. /**
  34932. * Resets the cache of effects.
  34933. */
  34934. static ResetCache(): void;
  34935. }
  34936. }
  34937. declare module "babylonjs/Engines/engineCapabilities" {
  34938. /**
  34939. * Interface used to describe the capabilities of the engine relatively to the current browser
  34940. */
  34941. export interface EngineCapabilities {
  34942. /** Maximum textures units per fragment shader */
  34943. maxTexturesImageUnits: number;
  34944. /** Maximum texture units per vertex shader */
  34945. maxVertexTextureImageUnits: number;
  34946. /** Maximum textures units in the entire pipeline */
  34947. maxCombinedTexturesImageUnits: number;
  34948. /** Maximum texture size */
  34949. maxTextureSize: number;
  34950. /** Maximum texture samples */
  34951. maxSamples?: number;
  34952. /** Maximum cube texture size */
  34953. maxCubemapTextureSize: number;
  34954. /** Maximum render texture size */
  34955. maxRenderTextureSize: number;
  34956. /** Maximum number of vertex attributes */
  34957. maxVertexAttribs: number;
  34958. /** Maximum number of varyings */
  34959. maxVaryingVectors: number;
  34960. /** Maximum number of uniforms per vertex shader */
  34961. maxVertexUniformVectors: number;
  34962. /** Maximum number of uniforms per fragment shader */
  34963. maxFragmentUniformVectors: number;
  34964. /** Defines if standard derivates (dx/dy) are supported */
  34965. standardDerivatives: boolean;
  34966. /** Defines if s3tc texture compression is supported */
  34967. s3tc?: WEBGL_compressed_texture_s3tc;
  34968. /** Defines if pvrtc texture compression is supported */
  34969. pvrtc: any;
  34970. /** Defines if etc1 texture compression is supported */
  34971. etc1: any;
  34972. /** Defines if etc2 texture compression is supported */
  34973. etc2: any;
  34974. /** Defines if astc texture compression is supported */
  34975. astc: any;
  34976. /** Defines if float textures are supported */
  34977. textureFloat: boolean;
  34978. /** Defines if vertex array objects are supported */
  34979. vertexArrayObject: boolean;
  34980. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34981. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34982. /** Gets the maximum level of anisotropy supported */
  34983. maxAnisotropy: number;
  34984. /** Defines if instancing is supported */
  34985. instancedArrays: boolean;
  34986. /** Defines if 32 bits indices are supported */
  34987. uintIndices: boolean;
  34988. /** Defines if high precision shaders are supported */
  34989. highPrecisionShaderSupported: boolean;
  34990. /** Defines if depth reading in the fragment shader is supported */
  34991. fragmentDepthSupported: boolean;
  34992. /** Defines if float texture linear filtering is supported*/
  34993. textureFloatLinearFiltering: boolean;
  34994. /** Defines if rendering to float textures is supported */
  34995. textureFloatRender: boolean;
  34996. /** Defines if half float textures are supported*/
  34997. textureHalfFloat: boolean;
  34998. /** Defines if half float texture linear filtering is supported*/
  34999. textureHalfFloatLinearFiltering: boolean;
  35000. /** Defines if rendering to half float textures is supported */
  35001. textureHalfFloatRender: boolean;
  35002. /** Defines if textureLOD shader command is supported */
  35003. textureLOD: boolean;
  35004. /** Defines if draw buffers extension is supported */
  35005. drawBuffersExtension: boolean;
  35006. /** Defines if depth textures are supported */
  35007. depthTextureExtension: boolean;
  35008. /** Defines if float color buffer are supported */
  35009. colorBufferFloat: boolean;
  35010. /** Gets disjoint timer query extension (null if not supported) */
  35011. timerQuery?: EXT_disjoint_timer_query;
  35012. /** Defines if timestamp can be used with timer query */
  35013. canUseTimestampForTimerQuery: boolean;
  35014. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35015. multiview?: any;
  35016. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35017. oculusMultiview?: any;
  35018. /** Function used to let the system compiles shaders in background */
  35019. parallelShaderCompile?: {
  35020. COMPLETION_STATUS_KHR: number;
  35021. };
  35022. /** Max number of texture samples for MSAA */
  35023. maxMSAASamples: number;
  35024. /** Defines if the blend min max extension is supported */
  35025. blendMinMax: boolean;
  35026. }
  35027. }
  35028. declare module "babylonjs/States/depthCullingState" {
  35029. import { Nullable } from "babylonjs/types";
  35030. /**
  35031. * @hidden
  35032. **/
  35033. export class DepthCullingState {
  35034. private _isDepthTestDirty;
  35035. private _isDepthMaskDirty;
  35036. private _isDepthFuncDirty;
  35037. private _isCullFaceDirty;
  35038. private _isCullDirty;
  35039. private _isZOffsetDirty;
  35040. private _isFrontFaceDirty;
  35041. private _depthTest;
  35042. private _depthMask;
  35043. private _depthFunc;
  35044. private _cull;
  35045. private _cullFace;
  35046. private _zOffset;
  35047. private _frontFace;
  35048. /**
  35049. * Initializes the state.
  35050. */
  35051. constructor();
  35052. get isDirty(): boolean;
  35053. get zOffset(): number;
  35054. set zOffset(value: number);
  35055. get cullFace(): Nullable<number>;
  35056. set cullFace(value: Nullable<number>);
  35057. get cull(): Nullable<boolean>;
  35058. set cull(value: Nullable<boolean>);
  35059. get depthFunc(): Nullable<number>;
  35060. set depthFunc(value: Nullable<number>);
  35061. get depthMask(): boolean;
  35062. set depthMask(value: boolean);
  35063. get depthTest(): boolean;
  35064. set depthTest(value: boolean);
  35065. get frontFace(): Nullable<number>;
  35066. set frontFace(value: Nullable<number>);
  35067. reset(): void;
  35068. apply(gl: WebGLRenderingContext): void;
  35069. }
  35070. }
  35071. declare module "babylonjs/States/stencilState" {
  35072. /**
  35073. * @hidden
  35074. **/
  35075. export class StencilState {
  35076. /** 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 */
  35077. static readonly ALWAYS: number;
  35078. /** Passed to stencilOperation to specify that stencil value must be kept */
  35079. static readonly KEEP: number;
  35080. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35081. static readonly REPLACE: number;
  35082. private _isStencilTestDirty;
  35083. private _isStencilMaskDirty;
  35084. private _isStencilFuncDirty;
  35085. private _isStencilOpDirty;
  35086. private _stencilTest;
  35087. private _stencilMask;
  35088. private _stencilFunc;
  35089. private _stencilFuncRef;
  35090. private _stencilFuncMask;
  35091. private _stencilOpStencilFail;
  35092. private _stencilOpDepthFail;
  35093. private _stencilOpStencilDepthPass;
  35094. get isDirty(): boolean;
  35095. get stencilFunc(): number;
  35096. set stencilFunc(value: number);
  35097. get stencilFuncRef(): number;
  35098. set stencilFuncRef(value: number);
  35099. get stencilFuncMask(): number;
  35100. set stencilFuncMask(value: number);
  35101. get stencilOpStencilFail(): number;
  35102. set stencilOpStencilFail(value: number);
  35103. get stencilOpDepthFail(): number;
  35104. set stencilOpDepthFail(value: number);
  35105. get stencilOpStencilDepthPass(): number;
  35106. set stencilOpStencilDepthPass(value: number);
  35107. get stencilMask(): number;
  35108. set stencilMask(value: number);
  35109. get stencilTest(): boolean;
  35110. set stencilTest(value: boolean);
  35111. constructor();
  35112. reset(): void;
  35113. apply(gl: WebGLRenderingContext): void;
  35114. }
  35115. }
  35116. declare module "babylonjs/States/alphaCullingState" {
  35117. /**
  35118. * @hidden
  35119. **/
  35120. export class AlphaState {
  35121. private _isAlphaBlendDirty;
  35122. private _isBlendFunctionParametersDirty;
  35123. private _isBlendEquationParametersDirty;
  35124. private _isBlendConstantsDirty;
  35125. private _alphaBlend;
  35126. private _blendFunctionParameters;
  35127. private _blendEquationParameters;
  35128. private _blendConstants;
  35129. /**
  35130. * Initializes the state.
  35131. */
  35132. constructor();
  35133. get isDirty(): boolean;
  35134. get alphaBlend(): boolean;
  35135. set alphaBlend(value: boolean);
  35136. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35137. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35138. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35139. reset(): void;
  35140. apply(gl: WebGLRenderingContext): void;
  35141. }
  35142. }
  35143. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35144. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35145. /** @hidden */
  35146. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35147. attributeProcessor(attribute: string): string;
  35148. varyingProcessor(varying: string, isFragment: boolean): string;
  35149. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35150. }
  35151. }
  35152. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35153. /**
  35154. * Interface for attribute information associated with buffer instanciation
  35155. */
  35156. export interface InstancingAttributeInfo {
  35157. /**
  35158. * Name of the GLSL attribute
  35159. * if attribute index is not specified, this is used to retrieve the index from the effect
  35160. */
  35161. attributeName: string;
  35162. /**
  35163. * Index/offset of the attribute in the vertex shader
  35164. * if not specified, this will be computes from the name.
  35165. */
  35166. index?: number;
  35167. /**
  35168. * size of the attribute, 1, 2, 3 or 4
  35169. */
  35170. attributeSize: number;
  35171. /**
  35172. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35173. */
  35174. offset: number;
  35175. /**
  35176. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35177. * default to 1
  35178. */
  35179. divisor?: number;
  35180. /**
  35181. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35182. * default is FLOAT
  35183. */
  35184. attributeType?: number;
  35185. /**
  35186. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35187. */
  35188. normalized?: boolean;
  35189. }
  35190. }
  35191. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35193. import { Nullable } from "babylonjs/types";
  35194. module "babylonjs/Engines/thinEngine" {
  35195. interface ThinEngine {
  35196. /**
  35197. * Update a video texture
  35198. * @param texture defines the texture to update
  35199. * @param video defines the video element to use
  35200. * @param invertY defines if data must be stored with Y axis inverted
  35201. */
  35202. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35203. }
  35204. }
  35205. }
  35206. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35208. import { Nullable } from "babylonjs/types";
  35209. module "babylonjs/Engines/thinEngine" {
  35210. interface ThinEngine {
  35211. /**
  35212. * Creates a dynamic texture
  35213. * @param width defines the width of the texture
  35214. * @param height defines the height of the texture
  35215. * @param generateMipMaps defines if the engine should generate the mip levels
  35216. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35217. * @returns the dynamic texture inside an InternalTexture
  35218. */
  35219. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35220. /**
  35221. * Update the content of a dynamic texture
  35222. * @param texture defines the texture to update
  35223. * @param canvas defines the canvas containing the source
  35224. * @param invertY defines if data must be stored with Y axis inverted
  35225. * @param premulAlpha defines if alpha is stored as premultiplied
  35226. * @param format defines the format of the data
  35227. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35228. */
  35229. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35230. }
  35231. }
  35232. }
  35233. declare module "babylonjs/Materials/Textures/videoTexture" {
  35234. import { Observable } from "babylonjs/Misc/observable";
  35235. import { Nullable } from "babylonjs/types";
  35236. import { Scene } from "babylonjs/scene";
  35237. import { Texture } from "babylonjs/Materials/Textures/texture";
  35238. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35239. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35240. /**
  35241. * Settings for finer control over video usage
  35242. */
  35243. export interface VideoTextureSettings {
  35244. /**
  35245. * Applies `autoplay` to video, if specified
  35246. */
  35247. autoPlay?: boolean;
  35248. /**
  35249. * Applies `loop` to video, if specified
  35250. */
  35251. loop?: boolean;
  35252. /**
  35253. * Automatically updates internal texture from video at every frame in the render loop
  35254. */
  35255. autoUpdateTexture: boolean;
  35256. /**
  35257. * Image src displayed during the video loading or until the user interacts with the video.
  35258. */
  35259. poster?: string;
  35260. }
  35261. /**
  35262. * If you want to display a video in your scene, this is the special texture for that.
  35263. * This special texture works similar to other textures, with the exception of a few parameters.
  35264. * @see https://doc.babylonjs.com/how_to/video_texture
  35265. */
  35266. export class VideoTexture extends Texture {
  35267. /**
  35268. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35269. */
  35270. readonly autoUpdateTexture: boolean;
  35271. /**
  35272. * The video instance used by the texture internally
  35273. */
  35274. readonly video: HTMLVideoElement;
  35275. private _onUserActionRequestedObservable;
  35276. /**
  35277. * Event triggerd when a dom action is required by the user to play the video.
  35278. * This happens due to recent changes in browser policies preventing video to auto start.
  35279. */
  35280. get onUserActionRequestedObservable(): Observable<Texture>;
  35281. private _generateMipMaps;
  35282. private _stillImageCaptured;
  35283. private _displayingPosterTexture;
  35284. private _settings;
  35285. private _createInternalTextureOnEvent;
  35286. private _frameId;
  35287. private _currentSrc;
  35288. /**
  35289. * Creates a video texture.
  35290. * If you want to display a video in your scene, this is the special texture for that.
  35291. * This special texture works similar to other textures, with the exception of a few parameters.
  35292. * @see https://doc.babylonjs.com/how_to/video_texture
  35293. * @param name optional name, will detect from video source, if not defined
  35294. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35295. * @param scene is obviously the current scene.
  35296. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35297. * @param invertY is false by default but can be used to invert video on Y axis
  35298. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35299. * @param settings allows finer control over video usage
  35300. */
  35301. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35302. private _getName;
  35303. private _getVideo;
  35304. private _createInternalTexture;
  35305. private reset;
  35306. /**
  35307. * @hidden Internal method to initiate `update`.
  35308. */
  35309. _rebuild(): void;
  35310. /**
  35311. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35312. */
  35313. update(): void;
  35314. /**
  35315. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35316. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35317. */
  35318. updateTexture(isVisible: boolean): void;
  35319. protected _updateInternalTexture: () => void;
  35320. /**
  35321. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35322. * @param url New url.
  35323. */
  35324. updateURL(url: string): void;
  35325. /**
  35326. * Clones the texture.
  35327. * @returns the cloned texture
  35328. */
  35329. clone(): VideoTexture;
  35330. /**
  35331. * Dispose the texture and release its associated resources.
  35332. */
  35333. dispose(): void;
  35334. /**
  35335. * Creates a video texture straight from a stream.
  35336. * @param scene Define the scene the texture should be created in
  35337. * @param stream Define the stream the texture should be created from
  35338. * @returns The created video texture as a promise
  35339. */
  35340. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35341. /**
  35342. * Creates a video texture straight from your WebCam video feed.
  35343. * @param scene Define the scene the texture should be created in
  35344. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35345. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35346. * @returns The created video texture as a promise
  35347. */
  35348. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35349. minWidth: number;
  35350. maxWidth: number;
  35351. minHeight: number;
  35352. maxHeight: number;
  35353. deviceId: string;
  35354. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35355. /**
  35356. * Creates a video texture straight from your WebCam video feed.
  35357. * @param scene Define the scene the texture should be created in
  35358. * @param onReady Define a callback to triggered once the texture will be ready
  35359. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35360. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35361. */
  35362. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35363. minWidth: number;
  35364. maxWidth: number;
  35365. minHeight: number;
  35366. maxHeight: number;
  35367. deviceId: string;
  35368. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35369. }
  35370. }
  35371. declare module "babylonjs/Engines/thinEngine" {
  35372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35373. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35374. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35376. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35377. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35378. import { Observable } from "babylonjs/Misc/observable";
  35379. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35380. import { StencilState } from "babylonjs/States/stencilState";
  35381. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35383. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35385. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35386. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35387. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35389. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35392. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35393. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35394. import { WebRequest } from "babylonjs/Misc/webRequest";
  35395. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35396. /**
  35397. * Defines the interface used by objects working like Scene
  35398. * @hidden
  35399. */
  35400. export interface ISceneLike {
  35401. _addPendingData(data: any): void;
  35402. _removePendingData(data: any): void;
  35403. offlineProvider: IOfflineProvider;
  35404. }
  35405. /** Interface defining initialization parameters for Engine class */
  35406. export interface EngineOptions extends WebGLContextAttributes {
  35407. /**
  35408. * Defines if the engine should no exceed a specified device ratio
  35409. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35410. */
  35411. limitDeviceRatio?: number;
  35412. /**
  35413. * Defines if webvr should be enabled automatically
  35414. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35415. */
  35416. autoEnableWebVR?: boolean;
  35417. /**
  35418. * Defines if webgl2 should be turned off even if supported
  35419. * @see https://doc.babylonjs.com/features/webgl2
  35420. */
  35421. disableWebGL2Support?: boolean;
  35422. /**
  35423. * Defines if webaudio should be initialized as well
  35424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35425. */
  35426. audioEngine?: boolean;
  35427. /**
  35428. * Defines if animations should run using a deterministic lock step
  35429. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35430. */
  35431. deterministicLockstep?: boolean;
  35432. /** Defines the maximum steps to use with deterministic lock step mode */
  35433. lockstepMaxSteps?: number;
  35434. /** Defines the seconds between each deterministic lock step */
  35435. timeStep?: number;
  35436. /**
  35437. * Defines that engine should ignore context lost events
  35438. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35439. */
  35440. doNotHandleContextLost?: boolean;
  35441. /**
  35442. * Defines that engine should ignore modifying touch action attribute and style
  35443. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35444. */
  35445. doNotHandleTouchAction?: boolean;
  35446. /**
  35447. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35448. */
  35449. useHighPrecisionFloats?: boolean;
  35450. /**
  35451. * Make the canvas XR Compatible for XR sessions
  35452. */
  35453. xrCompatible?: boolean;
  35454. }
  35455. /**
  35456. * The base engine class (root of all engines)
  35457. */
  35458. export class ThinEngine {
  35459. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35460. static ExceptionList: ({
  35461. key: string;
  35462. capture: string;
  35463. captureConstraint: number;
  35464. targets: string[];
  35465. } | {
  35466. key: string;
  35467. capture: null;
  35468. captureConstraint: null;
  35469. targets: string[];
  35470. })[];
  35471. /** @hidden */
  35472. static _TextureLoaders: IInternalTextureLoader[];
  35473. /**
  35474. * Returns the current npm package of the sdk
  35475. */
  35476. static get NpmPackage(): string;
  35477. /**
  35478. * Returns the current version of the framework
  35479. */
  35480. static get Version(): string;
  35481. /**
  35482. * Returns a string describing the current engine
  35483. */
  35484. get description(): string;
  35485. /**
  35486. * Gets or sets the epsilon value used by collision engine
  35487. */
  35488. static CollisionsEpsilon: number;
  35489. /**
  35490. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35491. */
  35492. static get ShadersRepository(): string;
  35493. static set ShadersRepository(value: string);
  35494. /** @hidden */
  35495. _shaderProcessor: IShaderProcessor;
  35496. /**
  35497. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35498. */
  35499. forcePOTTextures: boolean;
  35500. /**
  35501. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35502. */
  35503. isFullscreen: boolean;
  35504. /**
  35505. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35506. */
  35507. cullBackFaces: boolean;
  35508. /**
  35509. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35510. */
  35511. renderEvenInBackground: boolean;
  35512. /**
  35513. * Gets or sets a boolean indicating that cache can be kept between frames
  35514. */
  35515. preventCacheWipeBetweenFrames: boolean;
  35516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35517. validateShaderPrograms: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35520. * This can provide greater z depth for distant objects.
  35521. */
  35522. useReverseDepthBuffer: boolean;
  35523. /**
  35524. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35525. */
  35526. disableUniformBuffers: boolean;
  35527. /** @hidden */
  35528. _uniformBuffers: UniformBuffer[];
  35529. /**
  35530. * Gets a boolean indicating that the engine supports uniform buffers
  35531. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35532. */
  35533. get supportsUniformBuffers(): boolean;
  35534. /** @hidden */
  35535. _gl: WebGLRenderingContext;
  35536. /** @hidden */
  35537. _webGLVersion: number;
  35538. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35539. protected _windowIsBackground: boolean;
  35540. protected _creationOptions: EngineOptions;
  35541. protected _highPrecisionShadersAllowed: boolean;
  35542. /** @hidden */
  35543. get _shouldUseHighPrecisionShader(): boolean;
  35544. /**
  35545. * Gets a boolean indicating that only power of 2 textures are supported
  35546. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35547. */
  35548. get needPOTTextures(): boolean;
  35549. /** @hidden */
  35550. _badOS: boolean;
  35551. /** @hidden */
  35552. _badDesktopOS: boolean;
  35553. private _hardwareScalingLevel;
  35554. /** @hidden */
  35555. _caps: EngineCapabilities;
  35556. private _isStencilEnable;
  35557. private _glVersion;
  35558. private _glRenderer;
  35559. private _glVendor;
  35560. /** @hidden */
  35561. _videoTextureSupported: boolean;
  35562. protected _renderingQueueLaunched: boolean;
  35563. protected _activeRenderLoops: (() => void)[];
  35564. /**
  35565. * Observable signaled when a context lost event is raised
  35566. */
  35567. onContextLostObservable: Observable<ThinEngine>;
  35568. /**
  35569. * Observable signaled when a context restored event is raised
  35570. */
  35571. onContextRestoredObservable: Observable<ThinEngine>;
  35572. private _onContextLost;
  35573. private _onContextRestored;
  35574. protected _contextWasLost: boolean;
  35575. /** @hidden */
  35576. _doNotHandleContextLost: boolean;
  35577. /**
  35578. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35580. */
  35581. get doNotHandleContextLost(): boolean;
  35582. set doNotHandleContextLost(value: boolean);
  35583. /**
  35584. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35585. */
  35586. disableVertexArrayObjects: boolean;
  35587. /** @hidden */
  35588. protected _colorWrite: boolean;
  35589. /** @hidden */
  35590. protected _colorWriteChanged: boolean;
  35591. /** @hidden */
  35592. protected _depthCullingState: DepthCullingState;
  35593. /** @hidden */
  35594. protected _stencilState: StencilState;
  35595. /** @hidden */
  35596. _alphaState: AlphaState;
  35597. /** @hidden */
  35598. _alphaMode: number;
  35599. /** @hidden */
  35600. _alphaEquation: number;
  35601. /** @hidden */
  35602. _internalTexturesCache: InternalTexture[];
  35603. /** @hidden */
  35604. protected _activeChannel: number;
  35605. private _currentTextureChannel;
  35606. /** @hidden */
  35607. protected _boundTexturesCache: {
  35608. [key: string]: Nullable<InternalTexture>;
  35609. };
  35610. /** @hidden */
  35611. protected _currentEffect: Nullable<Effect>;
  35612. /** @hidden */
  35613. protected _currentProgram: Nullable<WebGLProgram>;
  35614. private _compiledEffects;
  35615. private _vertexAttribArraysEnabled;
  35616. /** @hidden */
  35617. protected _cachedViewport: Nullable<IViewportLike>;
  35618. private _cachedVertexArrayObject;
  35619. /** @hidden */
  35620. protected _cachedVertexBuffers: any;
  35621. /** @hidden */
  35622. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35623. /** @hidden */
  35624. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35625. /** @hidden */
  35626. _currentRenderTarget: Nullable<InternalTexture>;
  35627. private _uintIndicesCurrentlySet;
  35628. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35629. /** @hidden */
  35630. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35631. /** @hidden */
  35632. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35633. private _currentBufferPointers;
  35634. private _currentInstanceLocations;
  35635. private _currentInstanceBuffers;
  35636. private _textureUnits;
  35637. /** @hidden */
  35638. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35639. /** @hidden */
  35640. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35641. /** @hidden */
  35642. _boundRenderFunction: any;
  35643. private _vaoRecordInProgress;
  35644. private _mustWipeVertexAttributes;
  35645. private _emptyTexture;
  35646. private _emptyCubeTexture;
  35647. private _emptyTexture3D;
  35648. private _emptyTexture2DArray;
  35649. /** @hidden */
  35650. _frameHandler: number;
  35651. private _nextFreeTextureSlots;
  35652. private _maxSimultaneousTextures;
  35653. private _activeRequests;
  35654. /** @hidden */
  35655. _transformTextureUrl: Nullable<(url: string) => string>;
  35656. protected get _supportsHardwareTextureRescaling(): boolean;
  35657. private _framebufferDimensionsObject;
  35658. /**
  35659. * sets the object from which width and height will be taken from when getting render width and height
  35660. * Will fallback to the gl object
  35661. * @param dimensions the framebuffer width and height that will be used.
  35662. */
  35663. set framebufferDimensionsObject(dimensions: Nullable<{
  35664. framebufferWidth: number;
  35665. framebufferHeight: number;
  35666. }>);
  35667. /**
  35668. * Gets the current viewport
  35669. */
  35670. get currentViewport(): Nullable<IViewportLike>;
  35671. /**
  35672. * Gets the default empty texture
  35673. */
  35674. get emptyTexture(): InternalTexture;
  35675. /**
  35676. * Gets the default empty 3D texture
  35677. */
  35678. get emptyTexture3D(): InternalTexture;
  35679. /**
  35680. * Gets the default empty 2D array texture
  35681. */
  35682. get emptyTexture2DArray(): InternalTexture;
  35683. /**
  35684. * Gets the default empty cube texture
  35685. */
  35686. get emptyCubeTexture(): InternalTexture;
  35687. /**
  35688. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35689. */
  35690. readonly premultipliedAlpha: boolean;
  35691. /**
  35692. * Observable event triggered before each texture is initialized
  35693. */
  35694. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35695. /**
  35696. * Creates a new engine
  35697. * @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
  35698. * @param antialias defines enable antialiasing (default: false)
  35699. * @param options defines further options to be sent to the getContext() function
  35700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35701. */
  35702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35703. private _rebuildInternalTextures;
  35704. private _rebuildEffects;
  35705. /**
  35706. * Gets a boolean indicating if all created effects are ready
  35707. * @returns true if all effects are ready
  35708. */
  35709. areAllEffectsReady(): boolean;
  35710. protected _rebuildBuffers(): void;
  35711. protected _initGLContext(): void;
  35712. /**
  35713. * Gets version of the current webGL context
  35714. */
  35715. get webGLVersion(): number;
  35716. /**
  35717. * Gets a string idenfifying the name of the class
  35718. * @returns "Engine" string
  35719. */
  35720. getClassName(): string;
  35721. /**
  35722. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35723. */
  35724. get isStencilEnable(): boolean;
  35725. /** @hidden */
  35726. _prepareWorkingCanvas(): void;
  35727. /**
  35728. * Reset the texture cache to empty state
  35729. */
  35730. resetTextureCache(): void;
  35731. /**
  35732. * Gets an object containing information about the current webGL context
  35733. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35734. */
  35735. getGlInfo(): {
  35736. vendor: string;
  35737. renderer: string;
  35738. version: string;
  35739. };
  35740. /**
  35741. * Defines the hardware scaling level.
  35742. * By default the hardware scaling level is computed from the window device ratio.
  35743. * 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.
  35744. * @param level defines the level to use
  35745. */
  35746. setHardwareScalingLevel(level: number): void;
  35747. /**
  35748. * Gets the current hardware scaling level.
  35749. * By default the hardware scaling level is computed from the window device ratio.
  35750. * 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.
  35751. * @returns a number indicating the current hardware scaling level
  35752. */
  35753. getHardwareScalingLevel(): number;
  35754. /**
  35755. * Gets the list of loaded textures
  35756. * @returns an array containing all loaded textures
  35757. */
  35758. getLoadedTexturesCache(): InternalTexture[];
  35759. /**
  35760. * Gets the object containing all engine capabilities
  35761. * @returns the EngineCapabilities object
  35762. */
  35763. getCaps(): EngineCapabilities;
  35764. /**
  35765. * stop executing a render loop function and remove it from the execution array
  35766. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35767. */
  35768. stopRenderLoop(renderFunction?: () => void): void;
  35769. /** @hidden */
  35770. _renderLoop(): void;
  35771. /**
  35772. * Gets the HTML canvas attached with the current webGL context
  35773. * @returns a HTML canvas
  35774. */
  35775. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35776. /**
  35777. * Gets host window
  35778. * @returns the host window object
  35779. */
  35780. getHostWindow(): Nullable<Window>;
  35781. /**
  35782. * Gets the current render width
  35783. * @param useScreen defines if screen size must be used (or the current render target if any)
  35784. * @returns a number defining the current render width
  35785. */
  35786. getRenderWidth(useScreen?: boolean): number;
  35787. /**
  35788. * Gets the current render height
  35789. * @param useScreen defines if screen size must be used (or the current render target if any)
  35790. * @returns a number defining the current render height
  35791. */
  35792. getRenderHeight(useScreen?: boolean): number;
  35793. /**
  35794. * Can be used to override the current requestAnimationFrame requester.
  35795. * @hidden
  35796. */
  35797. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35798. /**
  35799. * Register and execute a render loop. The engine can have more than one render function
  35800. * @param renderFunction defines the function to continuously execute
  35801. */
  35802. runRenderLoop(renderFunction: () => void): void;
  35803. /**
  35804. * Clear the current render buffer or the current render target (if any is set up)
  35805. * @param color defines the color to use
  35806. * @param backBuffer defines if the back buffer must be cleared
  35807. * @param depth defines if the depth buffer must be cleared
  35808. * @param stencil defines if the stencil buffer must be cleared
  35809. */
  35810. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35811. private _viewportCached;
  35812. /** @hidden */
  35813. _viewport(x: number, y: number, width: number, height: number): void;
  35814. /**
  35815. * Set the WebGL's viewport
  35816. * @param viewport defines the viewport element to be used
  35817. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35818. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35819. */
  35820. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35821. /**
  35822. * Begin a new frame
  35823. */
  35824. beginFrame(): void;
  35825. /**
  35826. * Enf the current frame
  35827. */
  35828. endFrame(): void;
  35829. /**
  35830. * Resize the view according to the canvas' size
  35831. */
  35832. resize(): void;
  35833. /**
  35834. * Force a specific size of the canvas
  35835. * @param width defines the new canvas' width
  35836. * @param height defines the new canvas' height
  35837. * @returns true if the size was changed
  35838. */
  35839. setSize(width: number, height: number): boolean;
  35840. /**
  35841. * Binds the frame buffer to the specified texture.
  35842. * @param texture The texture to render to or null for the default canvas
  35843. * @param faceIndex The face of the texture to render to in case of cube texture
  35844. * @param requiredWidth The width of the target to render to
  35845. * @param requiredHeight The height of the target to render to
  35846. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35847. * @param lodLevel defines the lod level to bind to the frame buffer
  35848. * @param layer defines the 2d array index to bind to frame buffer to
  35849. */
  35850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35851. /** @hidden */
  35852. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35853. /**
  35854. * Unbind the current render target texture from the webGL context
  35855. * @param texture defines the render target texture to unbind
  35856. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35857. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35858. */
  35859. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35860. /**
  35861. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35862. */
  35863. flushFramebuffer(): void;
  35864. /**
  35865. * Unbind the current render target and bind the default framebuffer
  35866. */
  35867. restoreDefaultFramebuffer(): void;
  35868. /** @hidden */
  35869. protected _resetVertexBufferBinding(): void;
  35870. /**
  35871. * Creates a vertex buffer
  35872. * @param data the data for the vertex buffer
  35873. * @returns the new WebGL static buffer
  35874. */
  35875. createVertexBuffer(data: DataArray): DataBuffer;
  35876. private _createVertexBuffer;
  35877. /**
  35878. * Creates a dynamic vertex buffer
  35879. * @param data the data for the dynamic vertex buffer
  35880. * @returns the new WebGL dynamic buffer
  35881. */
  35882. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35883. protected _resetIndexBufferBinding(): void;
  35884. /**
  35885. * Creates a new index buffer
  35886. * @param indices defines the content of the index buffer
  35887. * @param updatable defines if the index buffer must be updatable
  35888. * @returns a new webGL buffer
  35889. */
  35890. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35891. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35892. /**
  35893. * Bind a webGL buffer to the webGL context
  35894. * @param buffer defines the buffer to bind
  35895. */
  35896. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35897. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35898. private bindBuffer;
  35899. /**
  35900. * update the bound buffer with the given data
  35901. * @param data defines the data to update
  35902. */
  35903. updateArrayBuffer(data: Float32Array): void;
  35904. private _vertexAttribPointer;
  35905. /** @hidden */
  35906. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35907. private _bindVertexBuffersAttributes;
  35908. /**
  35909. * Records a vertex array object
  35910. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35911. * @param vertexBuffers defines the list of vertex buffers to store
  35912. * @param indexBuffer defines the index buffer to store
  35913. * @param effect defines the effect to store
  35914. * @returns the new vertex array object
  35915. */
  35916. recordVertexArrayObject(vertexBuffers: {
  35917. [key: string]: VertexBuffer;
  35918. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35919. /**
  35920. * Bind a specific vertex array object
  35921. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35922. * @param vertexArrayObject defines the vertex array object to bind
  35923. * @param indexBuffer defines the index buffer to bind
  35924. */
  35925. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35926. /**
  35927. * Bind webGl buffers directly to the webGL context
  35928. * @param vertexBuffer defines the vertex buffer to bind
  35929. * @param indexBuffer defines the index buffer to bind
  35930. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35931. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35932. * @param effect defines the effect associated with the vertex buffer
  35933. */
  35934. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35935. private _unbindVertexArrayObject;
  35936. /**
  35937. * Bind a list of vertex buffers to the webGL context
  35938. * @param vertexBuffers defines the list of vertex buffers to bind
  35939. * @param indexBuffer defines the index buffer to bind
  35940. * @param effect defines the effect associated with the vertex buffers
  35941. */
  35942. bindBuffers(vertexBuffers: {
  35943. [key: string]: Nullable<VertexBuffer>;
  35944. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35945. /**
  35946. * Unbind all instance attributes
  35947. */
  35948. unbindInstanceAttributes(): void;
  35949. /**
  35950. * Release and free the memory of a vertex array object
  35951. * @param vao defines the vertex array object to delete
  35952. */
  35953. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35954. /** @hidden */
  35955. _releaseBuffer(buffer: DataBuffer): boolean;
  35956. protected _deleteBuffer(buffer: DataBuffer): void;
  35957. /**
  35958. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35959. * @param instancesBuffer defines the webGL buffer to update and bind
  35960. * @param data defines the data to store in the buffer
  35961. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35962. */
  35963. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35964. /**
  35965. * Bind the content of a webGL buffer used with instantiation
  35966. * @param instancesBuffer defines the webGL buffer to bind
  35967. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35968. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35969. */
  35970. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35971. /**
  35972. * Disable the instance attribute corresponding to the name in parameter
  35973. * @param name defines the name of the attribute to disable
  35974. */
  35975. disableInstanceAttributeByName(name: string): void;
  35976. /**
  35977. * Disable the instance attribute corresponding to the location in parameter
  35978. * @param attributeLocation defines the attribute location of the attribute to disable
  35979. */
  35980. disableInstanceAttribute(attributeLocation: number): void;
  35981. /**
  35982. * Disable the attribute corresponding to the location in parameter
  35983. * @param attributeLocation defines the attribute location of the attribute to disable
  35984. */
  35985. disableAttributeByIndex(attributeLocation: number): void;
  35986. /**
  35987. * Send a draw order
  35988. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35989. * @param indexStart defines the starting index
  35990. * @param indexCount defines the number of index to draw
  35991. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35992. */
  35993. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35994. /**
  35995. * Draw a list of points
  35996. * @param verticesStart defines the index of first vertex to draw
  35997. * @param verticesCount defines the count of vertices to draw
  35998. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35999. */
  36000. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36001. /**
  36002. * Draw a list of unindexed primitives
  36003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36004. * @param verticesStart defines the index of first vertex to draw
  36005. * @param verticesCount defines the count of vertices to draw
  36006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36007. */
  36008. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36009. /**
  36010. * Draw a list of indexed primitives
  36011. * @param fillMode defines the primitive to use
  36012. * @param indexStart defines the starting index
  36013. * @param indexCount defines the number of index to draw
  36014. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36015. */
  36016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36017. /**
  36018. * Draw a list of unindexed primitives
  36019. * @param fillMode defines the primitive to use
  36020. * @param verticesStart defines the index of first vertex to draw
  36021. * @param verticesCount defines the count of vertices to draw
  36022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36023. */
  36024. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36025. private _drawMode;
  36026. /** @hidden */
  36027. protected _reportDrawCall(): void;
  36028. /** @hidden */
  36029. _releaseEffect(effect: Effect): void;
  36030. /** @hidden */
  36031. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36032. /**
  36033. * Create a new effect (used to store vertex/fragment shaders)
  36034. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36035. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36036. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36037. * @param samplers defines an array of string used to represent textures
  36038. * @param defines defines the string containing the defines to use to compile the shaders
  36039. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36040. * @param onCompiled defines a function to call when the effect creation is successful
  36041. * @param onError defines a function to call when the effect creation has failed
  36042. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36043. * @returns the new Effect
  36044. */
  36045. 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;
  36046. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36047. private _compileShader;
  36048. private _compileRawShader;
  36049. /** @hidden */
  36050. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36051. /**
  36052. * Directly creates a webGL program
  36053. * @param pipelineContext defines the pipeline context to attach to
  36054. * @param vertexCode defines the vertex shader code to use
  36055. * @param fragmentCode defines the fragment shader code to use
  36056. * @param context defines the webGL context to use (if not set, the current one will be used)
  36057. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36058. * @returns the new webGL program
  36059. */
  36060. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36061. /**
  36062. * Creates a webGL program
  36063. * @param pipelineContext defines the pipeline context to attach to
  36064. * @param vertexCode defines the vertex shader code to use
  36065. * @param fragmentCode defines the fragment shader code to use
  36066. * @param defines defines the string containing the defines to use to compile the shaders
  36067. * @param context defines the webGL context to use (if not set, the current one will be used)
  36068. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36069. * @returns the new webGL program
  36070. */
  36071. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36072. /**
  36073. * Creates a new pipeline context
  36074. * @returns the new pipeline
  36075. */
  36076. createPipelineContext(): IPipelineContext;
  36077. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36078. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36079. /** @hidden */
  36080. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36081. /** @hidden */
  36082. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36083. /** @hidden */
  36084. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36085. /**
  36086. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36087. * @param pipelineContext defines the pipeline context to use
  36088. * @param uniformsNames defines the list of uniform names
  36089. * @returns an array of webGL uniform locations
  36090. */
  36091. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36092. /**
  36093. * Gets the lsit of active attributes for a given webGL program
  36094. * @param pipelineContext defines the pipeline context to use
  36095. * @param attributesNames defines the list of attribute names to get
  36096. * @returns an array of indices indicating the offset of each attribute
  36097. */
  36098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36099. /**
  36100. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36101. * @param effect defines the effect to activate
  36102. */
  36103. enableEffect(effect: Nullable<Effect>): void;
  36104. /**
  36105. * Set the value of an uniform to a number (int)
  36106. * @param uniform defines the webGL uniform location where to store the value
  36107. * @param value defines the int number to store
  36108. */
  36109. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36110. /**
  36111. * Set the value of an uniform to an array of int32
  36112. * @param uniform defines the webGL uniform location where to store the value
  36113. * @param array defines the array of int32 to store
  36114. */
  36115. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36116. /**
  36117. * Set the value of an uniform to an array of int32 (stored as vec2)
  36118. * @param uniform defines the webGL uniform location where to store the value
  36119. * @param array defines the array of int32 to store
  36120. */
  36121. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36122. /**
  36123. * Set the value of an uniform to an array of int32 (stored as vec3)
  36124. * @param uniform defines the webGL uniform location where to store the value
  36125. * @param array defines the array of int32 to store
  36126. */
  36127. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36128. /**
  36129. * Set the value of an uniform to an array of int32 (stored as vec4)
  36130. * @param uniform defines the webGL uniform location where to store the value
  36131. * @param array defines the array of int32 to store
  36132. */
  36133. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36134. /**
  36135. * Set the value of an uniform to an array of number
  36136. * @param uniform defines the webGL uniform location where to store the value
  36137. * @param array defines the array of number to store
  36138. */
  36139. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36140. /**
  36141. * Set the value of an uniform to an array of number (stored as vec2)
  36142. * @param uniform defines the webGL uniform location where to store the value
  36143. * @param array defines the array of number to store
  36144. */
  36145. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36146. /**
  36147. * Set the value of an uniform to an array of number (stored as vec3)
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param array defines the array of number to store
  36150. */
  36151. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36152. /**
  36153. * Set the value of an uniform to an array of number (stored as vec4)
  36154. * @param uniform defines the webGL uniform location where to store the value
  36155. * @param array defines the array of number to store
  36156. */
  36157. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36158. /**
  36159. * Set the value of an uniform to an array of float32 (stored as matrices)
  36160. * @param uniform defines the webGL uniform location where to store the value
  36161. * @param matrices defines the array of float32 to store
  36162. */
  36163. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36164. /**
  36165. * Set the value of an uniform to a matrix (3x3)
  36166. * @param uniform defines the webGL uniform location where to store the value
  36167. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36168. */
  36169. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36170. /**
  36171. * Set the value of an uniform to a matrix (2x2)
  36172. * @param uniform defines the webGL uniform location where to store the value
  36173. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36174. */
  36175. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36176. /**
  36177. * Set the value of an uniform to a number (float)
  36178. * @param uniform defines the webGL uniform location where to store the value
  36179. * @param value defines the float number to store
  36180. */
  36181. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36182. /**
  36183. * Set the value of an uniform to a vec2
  36184. * @param uniform defines the webGL uniform location where to store the value
  36185. * @param x defines the 1st component of the value
  36186. * @param y defines the 2nd component of the value
  36187. */
  36188. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36189. /**
  36190. * Set the value of an uniform to a vec3
  36191. * @param uniform defines the webGL uniform location where to store the value
  36192. * @param x defines the 1st component of the value
  36193. * @param y defines the 2nd component of the value
  36194. * @param z defines the 3rd component of the value
  36195. */
  36196. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36197. /**
  36198. * Set the value of an uniform to a vec4
  36199. * @param uniform defines the webGL uniform location where to store the value
  36200. * @param x defines the 1st component of the value
  36201. * @param y defines the 2nd component of the value
  36202. * @param z defines the 3rd component of the value
  36203. * @param w defines the 4th component of the value
  36204. */
  36205. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36206. /**
  36207. * Apply all cached states (depth, culling, stencil and alpha)
  36208. */
  36209. applyStates(): void;
  36210. /**
  36211. * Enable or disable color writing
  36212. * @param enable defines the state to set
  36213. */
  36214. setColorWrite(enable: boolean): void;
  36215. /**
  36216. * Gets a boolean indicating if color writing is enabled
  36217. * @returns the current color writing state
  36218. */
  36219. getColorWrite(): boolean;
  36220. /**
  36221. * Gets the depth culling state manager
  36222. */
  36223. get depthCullingState(): DepthCullingState;
  36224. /**
  36225. * Gets the alpha state manager
  36226. */
  36227. get alphaState(): AlphaState;
  36228. /**
  36229. * Gets the stencil state manager
  36230. */
  36231. get stencilState(): StencilState;
  36232. /**
  36233. * Clears the list of texture accessible through engine.
  36234. * This can help preventing texture load conflict due to name collision.
  36235. */
  36236. clearInternalTexturesCache(): void;
  36237. /**
  36238. * Force the entire cache to be cleared
  36239. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36240. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36241. */
  36242. wipeCaches(bruteForce?: boolean): void;
  36243. /** @hidden */
  36244. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36245. min: number;
  36246. mag: number;
  36247. };
  36248. /** @hidden */
  36249. _createTexture(): WebGLTexture;
  36250. /**
  36251. * Usually called from Texture.ts.
  36252. * Passed information to create a WebGLTexture
  36253. * @param url defines a value which contains one of the following:
  36254. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36255. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36256. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36257. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36258. * @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)
  36259. * @param scene needed for loading to the correct scene
  36260. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36261. * @param onLoad optional callback to be called upon successful completion
  36262. * @param onError optional callback to be called upon failure
  36263. * @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
  36264. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36265. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36266. * @param forcedExtension defines the extension to use to pick the right loader
  36267. * @param mimeType defines an optional mime type
  36268. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36269. */
  36270. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  36271. /**
  36272. * Loads an image as an HTMLImageElement.
  36273. * @param input url string, ArrayBuffer, or Blob to load
  36274. * @param onLoad callback called when the image successfully loads
  36275. * @param onError callback called when the image fails to load
  36276. * @param offlineProvider offline provider for caching
  36277. * @param mimeType optional mime type
  36278. * @returns the HTMLImageElement of the loaded image
  36279. * @hidden
  36280. */
  36281. 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>;
  36282. /**
  36283. * @hidden
  36284. */
  36285. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36286. private _unpackFlipYCached;
  36287. /**
  36288. * In case you are sharing the context with other applications, it might
  36289. * be interested to not cache the unpack flip y state to ensure a consistent
  36290. * value would be set.
  36291. */
  36292. enableUnpackFlipYCached: boolean;
  36293. /** @hidden */
  36294. _unpackFlipY(value: boolean): void;
  36295. /** @hidden */
  36296. _getUnpackAlignement(): number;
  36297. private _getTextureTarget;
  36298. /**
  36299. * Update the sampling mode of a given texture
  36300. * @param samplingMode defines the required sampling mode
  36301. * @param texture defines the texture to update
  36302. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36303. */
  36304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36305. /**
  36306. * Update the sampling mode of a given texture
  36307. * @param texture defines the texture to update
  36308. * @param wrapU defines the texture wrap mode of the u coordinates
  36309. * @param wrapV defines the texture wrap mode of the v coordinates
  36310. * @param wrapR defines the texture wrap mode of the r coordinates
  36311. */
  36312. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36313. /** @hidden */
  36314. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36315. width: number;
  36316. height: number;
  36317. layers?: number;
  36318. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36319. /** @hidden */
  36320. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36321. /** @hidden */
  36322. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36323. /**
  36324. * Update a portion of an internal texture
  36325. * @param texture defines the texture to update
  36326. * @param imageData defines the data to store into the texture
  36327. * @param xOffset defines the x coordinates of the update rectangle
  36328. * @param yOffset defines the y coordinates of the update rectangle
  36329. * @param width defines the width of the update rectangle
  36330. * @param height defines the height of the update rectangle
  36331. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36332. * @param lod defines the lod level to update (0 by default)
  36333. */
  36334. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36335. /** @hidden */
  36336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36337. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36338. private _prepareWebGLTexture;
  36339. /** @hidden */
  36340. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36341. private _getDepthStencilBuffer;
  36342. /** @hidden */
  36343. _releaseFramebufferObjects(texture: InternalTexture): void;
  36344. /** @hidden */
  36345. _releaseTexture(texture: InternalTexture): void;
  36346. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36347. protected _setProgram(program: WebGLProgram): void;
  36348. protected _boundUniforms: {
  36349. [key: number]: WebGLUniformLocation;
  36350. };
  36351. /**
  36352. * Binds an effect to the webGL context
  36353. * @param effect defines the effect to bind
  36354. */
  36355. bindSamplers(effect: Effect): void;
  36356. private _activateCurrentTexture;
  36357. /** @hidden */
  36358. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36359. /** @hidden */
  36360. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36361. /**
  36362. * Unbind all textures from the webGL context
  36363. */
  36364. unbindAllTextures(): void;
  36365. /**
  36366. * Sets a texture to the according uniform.
  36367. * @param channel The texture channel
  36368. * @param uniform The uniform to set
  36369. * @param texture The texture to apply
  36370. */
  36371. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36372. private _bindSamplerUniformToChannel;
  36373. private _getTextureWrapMode;
  36374. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36375. /**
  36376. * Sets an array of texture to the webGL context
  36377. * @param channel defines the channel where the texture array must be set
  36378. * @param uniform defines the associated uniform location
  36379. * @param textures defines the array of textures to bind
  36380. */
  36381. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36382. /** @hidden */
  36383. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36384. private _setTextureParameterFloat;
  36385. private _setTextureParameterInteger;
  36386. /**
  36387. * Unbind all vertex attributes from the webGL context
  36388. */
  36389. unbindAllAttributes(): void;
  36390. /**
  36391. * 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
  36392. */
  36393. releaseEffects(): void;
  36394. /**
  36395. * Dispose and release all associated resources
  36396. */
  36397. dispose(): void;
  36398. /**
  36399. * Attach a new callback raised when context lost event is fired
  36400. * @param callback defines the callback to call
  36401. */
  36402. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36403. /**
  36404. * Attach a new callback raised when context restored event is fired
  36405. * @param callback defines the callback to call
  36406. */
  36407. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36408. /**
  36409. * Get the current error code of the webGL context
  36410. * @returns the error code
  36411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36412. */
  36413. getError(): number;
  36414. private _canRenderToFloatFramebuffer;
  36415. private _canRenderToHalfFloatFramebuffer;
  36416. private _canRenderToFramebuffer;
  36417. /** @hidden */
  36418. _getWebGLTextureType(type: number): number;
  36419. /** @hidden */
  36420. _getInternalFormat(format: number): number;
  36421. /** @hidden */
  36422. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36423. /** @hidden */
  36424. _getRGBAMultiSampleBufferFormat(type: number): number;
  36425. /** @hidden */
  36426. _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;
  36427. /**
  36428. * Loads a file from a url
  36429. * @param url url to load
  36430. * @param onSuccess callback called when the file successfully loads
  36431. * @param onProgress callback called while file is loading (if the server supports this mode)
  36432. * @param offlineProvider defines the offline provider for caching
  36433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36434. * @param onError callback called when the file fails to load
  36435. * @returns a file request object
  36436. * @hidden
  36437. */
  36438. 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;
  36439. /**
  36440. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36441. * @param x defines the x coordinate of the rectangle where pixels must be read
  36442. * @param y defines the y coordinate of the rectangle where pixels must be read
  36443. * @param width defines the width of the rectangle where pixels must be read
  36444. * @param height defines the height of the rectangle where pixels must be read
  36445. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36446. * @returns a Uint8Array containing RGBA colors
  36447. */
  36448. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36449. private static _isSupported;
  36450. /**
  36451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36452. * @returns true if the engine can be created
  36453. * @ignorenaming
  36454. */
  36455. static isSupported(): boolean;
  36456. /**
  36457. * Find the next highest power of two.
  36458. * @param x Number to start search from.
  36459. * @return Next highest power of two.
  36460. */
  36461. static CeilingPOT(x: number): number;
  36462. /**
  36463. * Find the next lowest power of two.
  36464. * @param x Number to start search from.
  36465. * @return Next lowest power of two.
  36466. */
  36467. static FloorPOT(x: number): number;
  36468. /**
  36469. * Find the nearest power of two.
  36470. * @param x Number to start search from.
  36471. * @return Next nearest power of two.
  36472. */
  36473. static NearestPOT(x: number): number;
  36474. /**
  36475. * Get the closest exponent of two
  36476. * @param value defines the value to approximate
  36477. * @param max defines the maximum value to return
  36478. * @param mode defines how to define the closest value
  36479. * @returns closest exponent of two of the given value
  36480. */
  36481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36482. /**
  36483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36484. * @param func - the function to be called
  36485. * @param requester - the object that will request the next frame. Falls back to window.
  36486. * @returns frame number
  36487. */
  36488. static QueueNewFrame(func: () => void, requester?: any): number;
  36489. /**
  36490. * Gets host document
  36491. * @returns the host document object
  36492. */
  36493. getHostDocument(): Nullable<Document>;
  36494. }
  36495. }
  36496. declare module "babylonjs/Maths/sphericalPolynomial" {
  36497. import { Vector3 } from "babylonjs/Maths/math.vector";
  36498. import { Color3 } from "babylonjs/Maths/math.color";
  36499. /**
  36500. * Class representing spherical harmonics coefficients to the 3rd degree
  36501. */
  36502. export class SphericalHarmonics {
  36503. /**
  36504. * Defines whether or not the harmonics have been prescaled for rendering.
  36505. */
  36506. preScaled: boolean;
  36507. /**
  36508. * The l0,0 coefficients of the spherical harmonics
  36509. */
  36510. l00: Vector3;
  36511. /**
  36512. * The l1,-1 coefficients of the spherical harmonics
  36513. */
  36514. l1_1: Vector3;
  36515. /**
  36516. * The l1,0 coefficients of the spherical harmonics
  36517. */
  36518. l10: Vector3;
  36519. /**
  36520. * The l1,1 coefficients of the spherical harmonics
  36521. */
  36522. l11: Vector3;
  36523. /**
  36524. * The l2,-2 coefficients of the spherical harmonics
  36525. */
  36526. l2_2: Vector3;
  36527. /**
  36528. * The l2,-1 coefficients of the spherical harmonics
  36529. */
  36530. l2_1: Vector3;
  36531. /**
  36532. * The l2,0 coefficients of the spherical harmonics
  36533. */
  36534. l20: Vector3;
  36535. /**
  36536. * The l2,1 coefficients of the spherical harmonics
  36537. */
  36538. l21: Vector3;
  36539. /**
  36540. * The l2,2 coefficients of the spherical harmonics
  36541. */
  36542. l22: Vector3;
  36543. /**
  36544. * Adds a light to the spherical harmonics
  36545. * @param direction the direction of the light
  36546. * @param color the color of the light
  36547. * @param deltaSolidAngle the delta solid angle of the light
  36548. */
  36549. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36550. /**
  36551. * Scales the spherical harmonics by the given amount
  36552. * @param scale the amount to scale
  36553. */
  36554. scaleInPlace(scale: number): void;
  36555. /**
  36556. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36557. *
  36558. * ```
  36559. * E_lm = A_l * L_lm
  36560. * ```
  36561. *
  36562. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36563. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36564. * the scaling factors are given in equation 9.
  36565. */
  36566. convertIncidentRadianceToIrradiance(): void;
  36567. /**
  36568. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36569. *
  36570. * ```
  36571. * L = (1/pi) * E * rho
  36572. * ```
  36573. *
  36574. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36575. */
  36576. convertIrradianceToLambertianRadiance(): void;
  36577. /**
  36578. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36579. * required operations at run time.
  36580. *
  36581. * This is simply done by scaling back the SH with Ylm constants parameter.
  36582. * The trigonometric part being applied by the shader at run time.
  36583. */
  36584. preScaleForRendering(): void;
  36585. /**
  36586. * Constructs a spherical harmonics from an array.
  36587. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36588. * @returns the spherical harmonics
  36589. */
  36590. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36591. /**
  36592. * Gets the spherical harmonics from polynomial
  36593. * @param polynomial the spherical polynomial
  36594. * @returns the spherical harmonics
  36595. */
  36596. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36597. }
  36598. /**
  36599. * Class representing spherical polynomial coefficients to the 3rd degree
  36600. */
  36601. export class SphericalPolynomial {
  36602. private _harmonics;
  36603. /**
  36604. * The spherical harmonics used to create the polynomials.
  36605. */
  36606. get preScaledHarmonics(): SphericalHarmonics;
  36607. /**
  36608. * The x coefficients of the spherical polynomial
  36609. */
  36610. x: Vector3;
  36611. /**
  36612. * The y coefficients of the spherical polynomial
  36613. */
  36614. y: Vector3;
  36615. /**
  36616. * The z coefficients of the spherical polynomial
  36617. */
  36618. z: Vector3;
  36619. /**
  36620. * The xx coefficients of the spherical polynomial
  36621. */
  36622. xx: Vector3;
  36623. /**
  36624. * The yy coefficients of the spherical polynomial
  36625. */
  36626. yy: Vector3;
  36627. /**
  36628. * The zz coefficients of the spherical polynomial
  36629. */
  36630. zz: Vector3;
  36631. /**
  36632. * The xy coefficients of the spherical polynomial
  36633. */
  36634. xy: Vector3;
  36635. /**
  36636. * The yz coefficients of the spherical polynomial
  36637. */
  36638. yz: Vector3;
  36639. /**
  36640. * The zx coefficients of the spherical polynomial
  36641. */
  36642. zx: Vector3;
  36643. /**
  36644. * Adds an ambient color to the spherical polynomial
  36645. * @param color the color to add
  36646. */
  36647. addAmbient(color: Color3): void;
  36648. /**
  36649. * Scales the spherical polynomial by the given amount
  36650. * @param scale the amount to scale
  36651. */
  36652. scaleInPlace(scale: number): void;
  36653. /**
  36654. * Gets the spherical polynomial from harmonics
  36655. * @param harmonics the spherical harmonics
  36656. * @returns the spherical polynomial
  36657. */
  36658. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36659. /**
  36660. * Constructs a spherical polynomial from an array.
  36661. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36662. * @returns the spherical polynomial
  36663. */
  36664. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36665. }
  36666. }
  36667. declare module "babylonjs/Materials/Textures/internalTexture" {
  36668. import { Observable } from "babylonjs/Misc/observable";
  36669. import { Nullable, int } from "babylonjs/types";
  36670. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36671. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36672. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36673. /**
  36674. * Defines the source of the internal texture
  36675. */
  36676. export enum InternalTextureSource {
  36677. /**
  36678. * The source of the texture data is unknown
  36679. */
  36680. Unknown = 0,
  36681. /**
  36682. * Texture data comes from an URL
  36683. */
  36684. Url = 1,
  36685. /**
  36686. * Texture data is only used for temporary storage
  36687. */
  36688. Temp = 2,
  36689. /**
  36690. * Texture data comes from raw data (ArrayBuffer)
  36691. */
  36692. Raw = 3,
  36693. /**
  36694. * Texture content is dynamic (video or dynamic texture)
  36695. */
  36696. Dynamic = 4,
  36697. /**
  36698. * Texture content is generated by rendering to it
  36699. */
  36700. RenderTarget = 5,
  36701. /**
  36702. * Texture content is part of a multi render target process
  36703. */
  36704. MultiRenderTarget = 6,
  36705. /**
  36706. * Texture data comes from a cube data file
  36707. */
  36708. Cube = 7,
  36709. /**
  36710. * Texture data comes from a raw cube data
  36711. */
  36712. CubeRaw = 8,
  36713. /**
  36714. * Texture data come from a prefiltered cube data file
  36715. */
  36716. CubePrefiltered = 9,
  36717. /**
  36718. * Texture content is raw 3D data
  36719. */
  36720. Raw3D = 10,
  36721. /**
  36722. * Texture content is raw 2D array data
  36723. */
  36724. Raw2DArray = 11,
  36725. /**
  36726. * Texture content is a depth texture
  36727. */
  36728. Depth = 12,
  36729. /**
  36730. * Texture data comes from a raw cube data encoded with RGBD
  36731. */
  36732. CubeRawRGBD = 13
  36733. }
  36734. /**
  36735. * Class used to store data associated with WebGL texture data for the engine
  36736. * This class should not be used directly
  36737. */
  36738. export class InternalTexture {
  36739. /** @hidden */
  36740. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36741. /**
  36742. * Defines if the texture is ready
  36743. */
  36744. isReady: boolean;
  36745. /**
  36746. * Defines if the texture is a cube texture
  36747. */
  36748. isCube: boolean;
  36749. /**
  36750. * Defines if the texture contains 3D data
  36751. */
  36752. is3D: boolean;
  36753. /**
  36754. * Defines if the texture contains 2D array data
  36755. */
  36756. is2DArray: boolean;
  36757. /**
  36758. * Defines if the texture contains multiview data
  36759. */
  36760. isMultiview: boolean;
  36761. /**
  36762. * Gets the URL used to load this texture
  36763. */
  36764. url: string;
  36765. /**
  36766. * Gets the sampling mode of the texture
  36767. */
  36768. samplingMode: number;
  36769. /**
  36770. * Gets a boolean indicating if the texture needs mipmaps generation
  36771. */
  36772. generateMipMaps: boolean;
  36773. /**
  36774. * Gets the number of samples used by the texture (WebGL2+ only)
  36775. */
  36776. samples: number;
  36777. /**
  36778. * Gets the type of the texture (int, float...)
  36779. */
  36780. type: number;
  36781. /**
  36782. * Gets the format of the texture (RGB, RGBA...)
  36783. */
  36784. format: number;
  36785. /**
  36786. * Observable called when the texture is loaded
  36787. */
  36788. onLoadedObservable: Observable<InternalTexture>;
  36789. /**
  36790. * Gets the width of the texture
  36791. */
  36792. width: number;
  36793. /**
  36794. * Gets the height of the texture
  36795. */
  36796. height: number;
  36797. /**
  36798. * Gets the depth of the texture
  36799. */
  36800. depth: number;
  36801. /**
  36802. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36803. */
  36804. baseWidth: number;
  36805. /**
  36806. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36807. */
  36808. baseHeight: number;
  36809. /**
  36810. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36811. */
  36812. baseDepth: number;
  36813. /**
  36814. * Gets a boolean indicating if the texture is inverted on Y axis
  36815. */
  36816. invertY: boolean;
  36817. /** @hidden */
  36818. _invertVScale: boolean;
  36819. /** @hidden */
  36820. _associatedChannel: number;
  36821. /** @hidden */
  36822. _source: InternalTextureSource;
  36823. /** @hidden */
  36824. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36825. /** @hidden */
  36826. _bufferView: Nullable<ArrayBufferView>;
  36827. /** @hidden */
  36828. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36829. /** @hidden */
  36830. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36831. /** @hidden */
  36832. _size: number;
  36833. /** @hidden */
  36834. _extension: string;
  36835. /** @hidden */
  36836. _files: Nullable<string[]>;
  36837. /** @hidden */
  36838. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36839. /** @hidden */
  36840. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36841. /** @hidden */
  36842. _framebuffer: Nullable<WebGLFramebuffer>;
  36843. /** @hidden */
  36844. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36845. /** @hidden */
  36846. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36847. /** @hidden */
  36848. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36849. /** @hidden */
  36850. _attachments: Nullable<number[]>;
  36851. /** @hidden */
  36852. _textureArray: Nullable<InternalTexture[]>;
  36853. /** @hidden */
  36854. _cachedCoordinatesMode: Nullable<number>;
  36855. /** @hidden */
  36856. _cachedWrapU: Nullable<number>;
  36857. /** @hidden */
  36858. _cachedWrapV: Nullable<number>;
  36859. /** @hidden */
  36860. _cachedWrapR: Nullable<number>;
  36861. /** @hidden */
  36862. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36863. /** @hidden */
  36864. _isDisabled: boolean;
  36865. /** @hidden */
  36866. _compression: Nullable<string>;
  36867. /** @hidden */
  36868. _generateStencilBuffer: boolean;
  36869. /** @hidden */
  36870. _generateDepthBuffer: boolean;
  36871. /** @hidden */
  36872. _comparisonFunction: number;
  36873. /** @hidden */
  36874. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36875. /** @hidden */
  36876. _lodGenerationScale: number;
  36877. /** @hidden */
  36878. _lodGenerationOffset: number;
  36879. /** @hidden */
  36880. _depthStencilTexture: Nullable<InternalTexture>;
  36881. /** @hidden */
  36882. _colorTextureArray: Nullable<WebGLTexture>;
  36883. /** @hidden */
  36884. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36885. /** @hidden */
  36886. _lodTextureHigh: Nullable<BaseTexture>;
  36887. /** @hidden */
  36888. _lodTextureMid: Nullable<BaseTexture>;
  36889. /** @hidden */
  36890. _lodTextureLow: Nullable<BaseTexture>;
  36891. /** @hidden */
  36892. _isRGBD: boolean;
  36893. /** @hidden */
  36894. _linearSpecularLOD: boolean;
  36895. /** @hidden */
  36896. _irradianceTexture: Nullable<BaseTexture>;
  36897. /** @hidden */
  36898. _webGLTexture: Nullable<WebGLTexture>;
  36899. /** @hidden */
  36900. _references: number;
  36901. private _engine;
  36902. /**
  36903. * Gets the Engine the texture belongs to.
  36904. * @returns The babylon engine
  36905. */
  36906. getEngine(): ThinEngine;
  36907. /**
  36908. * Gets the data source type of the texture
  36909. */
  36910. get source(): InternalTextureSource;
  36911. /**
  36912. * Creates a new InternalTexture
  36913. * @param engine defines the engine to use
  36914. * @param source defines the type of data that will be used
  36915. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36916. */
  36917. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36918. /**
  36919. * Increments the number of references (ie. the number of Texture that point to it)
  36920. */
  36921. incrementReferences(): void;
  36922. /**
  36923. * Change the size of the texture (not the size of the content)
  36924. * @param width defines the new width
  36925. * @param height defines the new height
  36926. * @param depth defines the new depth (1 by default)
  36927. */
  36928. updateSize(width: int, height: int, depth?: int): void;
  36929. /** @hidden */
  36930. _rebuild(): void;
  36931. /** @hidden */
  36932. _swapAndDie(target: InternalTexture): void;
  36933. /**
  36934. * Dispose the current allocated resources
  36935. */
  36936. dispose(): void;
  36937. }
  36938. }
  36939. declare module "babylonjs/Audio/analyser" {
  36940. import { Scene } from "babylonjs/scene";
  36941. /**
  36942. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36944. */
  36945. export class Analyser {
  36946. /**
  36947. * Gets or sets the smoothing
  36948. * @ignorenaming
  36949. */
  36950. SMOOTHING: number;
  36951. /**
  36952. * Gets or sets the FFT table size
  36953. * @ignorenaming
  36954. */
  36955. FFT_SIZE: number;
  36956. /**
  36957. * Gets or sets the bar graph amplitude
  36958. * @ignorenaming
  36959. */
  36960. BARGRAPHAMPLITUDE: number;
  36961. /**
  36962. * Gets or sets the position of the debug canvas
  36963. * @ignorenaming
  36964. */
  36965. DEBUGCANVASPOS: {
  36966. x: number;
  36967. y: number;
  36968. };
  36969. /**
  36970. * Gets or sets the debug canvas size
  36971. * @ignorenaming
  36972. */
  36973. DEBUGCANVASSIZE: {
  36974. width: number;
  36975. height: number;
  36976. };
  36977. private _byteFreqs;
  36978. private _byteTime;
  36979. private _floatFreqs;
  36980. private _webAudioAnalyser;
  36981. private _debugCanvas;
  36982. private _debugCanvasContext;
  36983. private _scene;
  36984. private _registerFunc;
  36985. private _audioEngine;
  36986. /**
  36987. * Creates a new analyser
  36988. * @param scene defines hosting scene
  36989. */
  36990. constructor(scene: Scene);
  36991. /**
  36992. * Get the number of data values you will have to play with for the visualization
  36993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36994. * @returns a number
  36995. */
  36996. getFrequencyBinCount(): number;
  36997. /**
  36998. * Gets the current frequency data as a byte array
  36999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37000. * @returns a Uint8Array
  37001. */
  37002. getByteFrequencyData(): Uint8Array;
  37003. /**
  37004. * Gets the current waveform as a byte array
  37005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37006. * @returns a Uint8Array
  37007. */
  37008. getByteTimeDomainData(): Uint8Array;
  37009. /**
  37010. * Gets the current frequency data as a float array
  37011. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37012. * @returns a Float32Array
  37013. */
  37014. getFloatFrequencyData(): Float32Array;
  37015. /**
  37016. * Renders the debug canvas
  37017. */
  37018. drawDebugCanvas(): void;
  37019. /**
  37020. * Stops rendering the debug canvas and removes it
  37021. */
  37022. stopDebugCanvas(): void;
  37023. /**
  37024. * Connects two audio nodes
  37025. * @param inputAudioNode defines first node to connect
  37026. * @param outputAudioNode defines second node to connect
  37027. */
  37028. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37029. /**
  37030. * Releases all associated resources
  37031. */
  37032. dispose(): void;
  37033. }
  37034. }
  37035. declare module "babylonjs/Audio/audioEngine" {
  37036. import { IDisposable } from "babylonjs/scene";
  37037. import { Analyser } from "babylonjs/Audio/analyser";
  37038. import { Nullable } from "babylonjs/types";
  37039. import { Observable } from "babylonjs/Misc/observable";
  37040. /**
  37041. * This represents an audio engine and it is responsible
  37042. * to play, synchronize and analyse sounds throughout the application.
  37043. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37044. */
  37045. export interface IAudioEngine extends IDisposable {
  37046. /**
  37047. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37048. */
  37049. readonly canUseWebAudio: boolean;
  37050. /**
  37051. * Gets the current AudioContext if available.
  37052. */
  37053. readonly audioContext: Nullable<AudioContext>;
  37054. /**
  37055. * The master gain node defines the global audio volume of your audio engine.
  37056. */
  37057. readonly masterGain: GainNode;
  37058. /**
  37059. * Gets whether or not mp3 are supported by your browser.
  37060. */
  37061. readonly isMP3supported: boolean;
  37062. /**
  37063. * Gets whether or not ogg are supported by your browser.
  37064. */
  37065. readonly isOGGsupported: boolean;
  37066. /**
  37067. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37068. * @ignoreNaming
  37069. */
  37070. WarnedWebAudioUnsupported: boolean;
  37071. /**
  37072. * Defines if the audio engine relies on a custom unlocked button.
  37073. * In this case, the embedded button will not be displayed.
  37074. */
  37075. useCustomUnlockedButton: boolean;
  37076. /**
  37077. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37078. */
  37079. readonly unlocked: boolean;
  37080. /**
  37081. * Event raised when audio has been unlocked on the browser.
  37082. */
  37083. onAudioUnlockedObservable: Observable<AudioEngine>;
  37084. /**
  37085. * Event raised when audio has been locked on the browser.
  37086. */
  37087. onAudioLockedObservable: Observable<AudioEngine>;
  37088. /**
  37089. * Flags the audio engine in Locked state.
  37090. * This happens due to new browser policies preventing audio to autoplay.
  37091. */
  37092. lock(): void;
  37093. /**
  37094. * Unlocks the audio engine once a user action has been done on the dom.
  37095. * This is helpful to resume play once browser policies have been satisfied.
  37096. */
  37097. unlock(): void;
  37098. /**
  37099. * Gets the global volume sets on the master gain.
  37100. * @returns the global volume if set or -1 otherwise
  37101. */
  37102. getGlobalVolume(): number;
  37103. /**
  37104. * Sets the global volume of your experience (sets on the master gain).
  37105. * @param newVolume Defines the new global volume of the application
  37106. */
  37107. setGlobalVolume(newVolume: number): void;
  37108. /**
  37109. * Connect the audio engine to an audio analyser allowing some amazing
  37110. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37112. * @param analyser The analyser to connect to the engine
  37113. */
  37114. connectToAnalyser(analyser: Analyser): void;
  37115. }
  37116. /**
  37117. * This represents the default audio engine used in babylon.
  37118. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37120. */
  37121. export class AudioEngine implements IAudioEngine {
  37122. private _audioContext;
  37123. private _audioContextInitialized;
  37124. private _muteButton;
  37125. private _hostElement;
  37126. /**
  37127. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37128. */
  37129. canUseWebAudio: boolean;
  37130. /**
  37131. * The master gain node defines the global audio volume of your audio engine.
  37132. */
  37133. masterGain: GainNode;
  37134. /**
  37135. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37136. * @ignoreNaming
  37137. */
  37138. WarnedWebAudioUnsupported: boolean;
  37139. /**
  37140. * Gets whether or not mp3 are supported by your browser.
  37141. */
  37142. isMP3supported: boolean;
  37143. /**
  37144. * Gets whether or not ogg are supported by your browser.
  37145. */
  37146. isOGGsupported: boolean;
  37147. /**
  37148. * Gets whether audio has been unlocked on the device.
  37149. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37150. * a user interaction has happened.
  37151. */
  37152. unlocked: boolean;
  37153. /**
  37154. * Defines if the audio engine relies on a custom unlocked button.
  37155. * In this case, the embedded button will not be displayed.
  37156. */
  37157. useCustomUnlockedButton: boolean;
  37158. /**
  37159. * Event raised when audio has been unlocked on the browser.
  37160. */
  37161. onAudioUnlockedObservable: Observable<AudioEngine>;
  37162. /**
  37163. * Event raised when audio has been locked on the browser.
  37164. */
  37165. onAudioLockedObservable: Observable<AudioEngine>;
  37166. /**
  37167. * Gets the current AudioContext if available.
  37168. */
  37169. get audioContext(): Nullable<AudioContext>;
  37170. private _connectedAnalyser;
  37171. /**
  37172. * Instantiates a new audio engine.
  37173. *
  37174. * There should be only one per page as some browsers restrict the number
  37175. * of audio contexts you can create.
  37176. * @param hostElement defines the host element where to display the mute icon if necessary
  37177. */
  37178. constructor(hostElement?: Nullable<HTMLElement>);
  37179. /**
  37180. * Flags the audio engine in Locked state.
  37181. * This happens due to new browser policies preventing audio to autoplay.
  37182. */
  37183. lock(): void;
  37184. /**
  37185. * Unlocks the audio engine once a user action has been done on the dom.
  37186. * This is helpful to resume play once browser policies have been satisfied.
  37187. */
  37188. unlock(): void;
  37189. private _resumeAudioContext;
  37190. private _initializeAudioContext;
  37191. private _tryToRun;
  37192. private _triggerRunningState;
  37193. private _triggerSuspendedState;
  37194. private _displayMuteButton;
  37195. private _moveButtonToTopLeft;
  37196. private _onResize;
  37197. private _hideMuteButton;
  37198. /**
  37199. * Destroy and release the resources associated with the audio ccontext.
  37200. */
  37201. dispose(): void;
  37202. /**
  37203. * Gets the global volume sets on the master gain.
  37204. * @returns the global volume if set or -1 otherwise
  37205. */
  37206. getGlobalVolume(): number;
  37207. /**
  37208. * Sets the global volume of your experience (sets on the master gain).
  37209. * @param newVolume Defines the new global volume of the application
  37210. */
  37211. setGlobalVolume(newVolume: number): void;
  37212. /**
  37213. * Connect the audio engine to an audio analyser allowing some amazing
  37214. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37216. * @param analyser The analyser to connect to the engine
  37217. */
  37218. connectToAnalyser(analyser: Analyser): void;
  37219. }
  37220. }
  37221. declare module "babylonjs/Loading/loadingScreen" {
  37222. /**
  37223. * Interface used to present a loading screen while loading a scene
  37224. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37225. */
  37226. export interface ILoadingScreen {
  37227. /**
  37228. * Function called to display the loading screen
  37229. */
  37230. displayLoadingUI: () => void;
  37231. /**
  37232. * Function called to hide the loading screen
  37233. */
  37234. hideLoadingUI: () => void;
  37235. /**
  37236. * Gets or sets the color to use for the background
  37237. */
  37238. loadingUIBackgroundColor: string;
  37239. /**
  37240. * Gets or sets the text to display while loading
  37241. */
  37242. loadingUIText: string;
  37243. }
  37244. /**
  37245. * Class used for the default loading screen
  37246. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37247. */
  37248. export class DefaultLoadingScreen implements ILoadingScreen {
  37249. private _renderingCanvas;
  37250. private _loadingText;
  37251. private _loadingDivBackgroundColor;
  37252. private _loadingDiv;
  37253. private _loadingTextDiv;
  37254. /** Gets or sets the logo url to use for the default loading screen */
  37255. static DefaultLogoUrl: string;
  37256. /** Gets or sets the spinner url to use for the default loading screen */
  37257. static DefaultSpinnerUrl: string;
  37258. /**
  37259. * Creates a new default loading screen
  37260. * @param _renderingCanvas defines the canvas used to render the scene
  37261. * @param _loadingText defines the default text to display
  37262. * @param _loadingDivBackgroundColor defines the default background color
  37263. */
  37264. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37265. /**
  37266. * Function called to display the loading screen
  37267. */
  37268. displayLoadingUI(): void;
  37269. /**
  37270. * Function called to hide the loading screen
  37271. */
  37272. hideLoadingUI(): void;
  37273. /**
  37274. * Gets or sets the text to display while loading
  37275. */
  37276. set loadingUIText(text: string);
  37277. get loadingUIText(): string;
  37278. /**
  37279. * Gets or sets the color to use for the background
  37280. */
  37281. get loadingUIBackgroundColor(): string;
  37282. set loadingUIBackgroundColor(color: string);
  37283. private _resizeLoadingUI;
  37284. }
  37285. }
  37286. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37287. /**
  37288. * Interface for any object that can request an animation frame
  37289. */
  37290. export interface ICustomAnimationFrameRequester {
  37291. /**
  37292. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37293. */
  37294. renderFunction?: Function;
  37295. /**
  37296. * Called to request the next frame to render to
  37297. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37298. */
  37299. requestAnimationFrame: Function;
  37300. /**
  37301. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37302. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37303. */
  37304. requestID?: number;
  37305. }
  37306. }
  37307. declare module "babylonjs/Misc/performanceMonitor" {
  37308. /**
  37309. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37310. */
  37311. export class PerformanceMonitor {
  37312. private _enabled;
  37313. private _rollingFrameTime;
  37314. private _lastFrameTimeMs;
  37315. /**
  37316. * constructor
  37317. * @param frameSampleSize The number of samples required to saturate the sliding window
  37318. */
  37319. constructor(frameSampleSize?: number);
  37320. /**
  37321. * Samples current frame
  37322. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37323. */
  37324. sampleFrame(timeMs?: number): void;
  37325. /**
  37326. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37327. */
  37328. get averageFrameTime(): number;
  37329. /**
  37330. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37331. */
  37332. get averageFrameTimeVariance(): number;
  37333. /**
  37334. * Returns the frame time of the most recent frame
  37335. */
  37336. get instantaneousFrameTime(): number;
  37337. /**
  37338. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37339. */
  37340. get averageFPS(): number;
  37341. /**
  37342. * Returns the average framerate in frames per second using the most recent frame time
  37343. */
  37344. get instantaneousFPS(): number;
  37345. /**
  37346. * Returns true if enough samples have been taken to completely fill the sliding window
  37347. */
  37348. get isSaturated(): boolean;
  37349. /**
  37350. * Enables contributions to the sliding window sample set
  37351. */
  37352. enable(): void;
  37353. /**
  37354. * Disables contributions to the sliding window sample set
  37355. * Samples will not be interpolated over the disabled period
  37356. */
  37357. disable(): void;
  37358. /**
  37359. * Returns true if sampling is enabled
  37360. */
  37361. get isEnabled(): boolean;
  37362. /**
  37363. * Resets performance monitor
  37364. */
  37365. reset(): void;
  37366. }
  37367. /**
  37368. * RollingAverage
  37369. *
  37370. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37371. */
  37372. export class RollingAverage {
  37373. /**
  37374. * Current average
  37375. */
  37376. average: number;
  37377. /**
  37378. * Current variance
  37379. */
  37380. variance: number;
  37381. protected _samples: Array<number>;
  37382. protected _sampleCount: number;
  37383. protected _pos: number;
  37384. protected _m2: number;
  37385. /**
  37386. * constructor
  37387. * @param length The number of samples required to saturate the sliding window
  37388. */
  37389. constructor(length: number);
  37390. /**
  37391. * Adds a sample to the sample set
  37392. * @param v The sample value
  37393. */
  37394. add(v: number): void;
  37395. /**
  37396. * Returns previously added values or null if outside of history or outside the sliding window domain
  37397. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37398. * @return Value previously recorded with add() or null if outside of range
  37399. */
  37400. history(i: number): number;
  37401. /**
  37402. * Returns true if enough samples have been taken to completely fill the sliding window
  37403. * @return true if sample-set saturated
  37404. */
  37405. isSaturated(): boolean;
  37406. /**
  37407. * Resets the rolling average (equivalent to 0 samples taken so far)
  37408. */
  37409. reset(): void;
  37410. /**
  37411. * Wraps a value around the sample range boundaries
  37412. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37413. * @return Wrapped position in sample range
  37414. */
  37415. protected _wrapPosition(i: number): number;
  37416. }
  37417. }
  37418. declare module "babylonjs/Misc/perfCounter" {
  37419. /**
  37420. * This class is used to track a performance counter which is number based.
  37421. * The user has access to many properties which give statistics of different nature.
  37422. *
  37423. * The implementer can track two kinds of Performance Counter: time and count.
  37424. * 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.
  37425. * 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.
  37426. */
  37427. export class PerfCounter {
  37428. /**
  37429. * Gets or sets a global boolean to turn on and off all the counters
  37430. */
  37431. static Enabled: boolean;
  37432. /**
  37433. * Returns the smallest value ever
  37434. */
  37435. get min(): number;
  37436. /**
  37437. * Returns the biggest value ever
  37438. */
  37439. get max(): number;
  37440. /**
  37441. * Returns the average value since the performance counter is running
  37442. */
  37443. get average(): number;
  37444. /**
  37445. * Returns the average value of the last second the counter was monitored
  37446. */
  37447. get lastSecAverage(): number;
  37448. /**
  37449. * Returns the current value
  37450. */
  37451. get current(): number;
  37452. /**
  37453. * Gets the accumulated total
  37454. */
  37455. get total(): number;
  37456. /**
  37457. * Gets the total value count
  37458. */
  37459. get count(): number;
  37460. /**
  37461. * Creates a new counter
  37462. */
  37463. constructor();
  37464. /**
  37465. * Call this method to start monitoring a new frame.
  37466. * 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.
  37467. */
  37468. fetchNewFrame(): void;
  37469. /**
  37470. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37471. * @param newCount the count value to add to the monitored count
  37472. * @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.
  37473. */
  37474. addCount(newCount: number, fetchResult: boolean): void;
  37475. /**
  37476. * Start monitoring this performance counter
  37477. */
  37478. beginMonitoring(): void;
  37479. /**
  37480. * Compute the time lapsed since the previous beginMonitoring() call.
  37481. * @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
  37482. */
  37483. endMonitoring(newFrame?: boolean): void;
  37484. private _fetchResult;
  37485. private _startMonitoringTime;
  37486. private _min;
  37487. private _max;
  37488. private _average;
  37489. private _current;
  37490. private _totalValueCount;
  37491. private _totalAccumulated;
  37492. private _lastSecAverage;
  37493. private _lastSecAccumulated;
  37494. private _lastSecTime;
  37495. private _lastSecValueCount;
  37496. }
  37497. }
  37498. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37499. module "babylonjs/Engines/thinEngine" {
  37500. interface ThinEngine {
  37501. /**
  37502. * Sets alpha constants used by some alpha blending modes
  37503. * @param r defines the red component
  37504. * @param g defines the green component
  37505. * @param b defines the blue component
  37506. * @param a defines the alpha component
  37507. */
  37508. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37509. /**
  37510. * Sets the current alpha mode
  37511. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37514. */
  37515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37516. /**
  37517. * Gets the current alpha mode
  37518. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37519. * @returns the current alpha mode
  37520. */
  37521. getAlphaMode(): number;
  37522. /**
  37523. * Sets the current alpha equation
  37524. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37525. */
  37526. setAlphaEquation(equation: number): void;
  37527. /**
  37528. * Gets the current alpha equation.
  37529. * @returns the current alpha equation
  37530. */
  37531. getAlphaEquation(): number;
  37532. }
  37533. }
  37534. }
  37535. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37537. import { Nullable } from "babylonjs/types";
  37538. module "babylonjs/Engines/thinEngine" {
  37539. interface ThinEngine {
  37540. /** @hidden */
  37541. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37542. }
  37543. }
  37544. }
  37545. declare module "babylonjs/Engines/engine" {
  37546. import { Observable } from "babylonjs/Misc/observable";
  37547. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37548. import { Scene } from "babylonjs/scene";
  37549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37550. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37552. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37553. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37554. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37555. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37556. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37557. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37559. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37560. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37561. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37562. import "babylonjs/Engines/Extensions/engine.alpha";
  37563. import "babylonjs/Engines/Extensions/engine.readTexture";
  37564. import { Material } from "babylonjs/Materials/material";
  37565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37566. /**
  37567. * Defines the interface used by display changed events
  37568. */
  37569. export interface IDisplayChangedEventArgs {
  37570. /** Gets the vrDisplay object (if any) */
  37571. vrDisplay: Nullable<any>;
  37572. /** Gets a boolean indicating if webVR is supported */
  37573. vrSupported: boolean;
  37574. }
  37575. /**
  37576. * Defines the interface used by objects containing a viewport (like a camera)
  37577. */
  37578. interface IViewportOwnerLike {
  37579. /**
  37580. * Gets or sets the viewport
  37581. */
  37582. viewport: IViewportLike;
  37583. }
  37584. /**
  37585. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37586. */
  37587. export class Engine extends ThinEngine {
  37588. /** Defines that alpha blending is disabled */
  37589. static readonly ALPHA_DISABLE: number;
  37590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37591. static readonly ALPHA_ADD: number;
  37592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37593. static readonly ALPHA_COMBINE: number;
  37594. /** Defines that alpha blending to DEST - SRC * DEST */
  37595. static readonly ALPHA_SUBTRACT: number;
  37596. /** Defines that alpha blending to SRC * DEST */
  37597. static readonly ALPHA_MULTIPLY: number;
  37598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37599. static readonly ALPHA_MAXIMIZED: number;
  37600. /** Defines that alpha blending to SRC + DEST */
  37601. static readonly ALPHA_ONEONE: number;
  37602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37603. static readonly ALPHA_PREMULTIPLIED: number;
  37604. /**
  37605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37607. */
  37608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37610. static readonly ALPHA_INTERPOLATE: number;
  37611. /**
  37612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37614. */
  37615. static readonly ALPHA_SCREENMODE: number;
  37616. /** Defines that the ressource is not delayed*/
  37617. static readonly DELAYLOADSTATE_NONE: number;
  37618. /** Defines that the ressource was successfully delay loaded */
  37619. static readonly DELAYLOADSTATE_LOADED: number;
  37620. /** Defines that the ressource is currently delay loading */
  37621. static readonly DELAYLOADSTATE_LOADING: number;
  37622. /** Defines that the ressource is delayed and has not started loading */
  37623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37625. static readonly NEVER: number;
  37626. /** 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 */
  37627. static readonly ALWAYS: number;
  37628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37629. static readonly LESS: number;
  37630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37631. static readonly EQUAL: number;
  37632. /** 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 */
  37633. static readonly LEQUAL: number;
  37634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37635. static readonly GREATER: number;
  37636. /** 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 */
  37637. static readonly GEQUAL: number;
  37638. /** 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 */
  37639. static readonly NOTEQUAL: number;
  37640. /** Passed to stencilOperation to specify that stencil value must be kept */
  37641. static readonly KEEP: number;
  37642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37643. static readonly REPLACE: number;
  37644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37645. static readonly INCR: number;
  37646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37647. static readonly DECR: number;
  37648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37649. static readonly INVERT: number;
  37650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37651. static readonly INCR_WRAP: number;
  37652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37653. static readonly DECR_WRAP: number;
  37654. /** Texture is not repeating outside of 0..1 UVs */
  37655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37656. /** Texture is repeating outside of 0..1 UVs */
  37657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37658. /** Texture is repeating and mirrored */
  37659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37660. /** ALPHA */
  37661. static readonly TEXTUREFORMAT_ALPHA: number;
  37662. /** LUMINANCE */
  37663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37664. /** LUMINANCE_ALPHA */
  37665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37666. /** RGB */
  37667. static readonly TEXTUREFORMAT_RGB: number;
  37668. /** RGBA */
  37669. static readonly TEXTUREFORMAT_RGBA: number;
  37670. /** RED */
  37671. static readonly TEXTUREFORMAT_RED: number;
  37672. /** RED (2nd reference) */
  37673. static readonly TEXTUREFORMAT_R: number;
  37674. /** RG */
  37675. static readonly TEXTUREFORMAT_RG: number;
  37676. /** RED_INTEGER */
  37677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37678. /** RED_INTEGER (2nd reference) */
  37679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37680. /** RG_INTEGER */
  37681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37682. /** RGB_INTEGER */
  37683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37684. /** RGBA_INTEGER */
  37685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37686. /** UNSIGNED_BYTE */
  37687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37688. /** UNSIGNED_BYTE (2nd reference) */
  37689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37690. /** FLOAT */
  37691. static readonly TEXTURETYPE_FLOAT: number;
  37692. /** HALF_FLOAT */
  37693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37694. /** BYTE */
  37695. static readonly TEXTURETYPE_BYTE: number;
  37696. /** SHORT */
  37697. static readonly TEXTURETYPE_SHORT: number;
  37698. /** UNSIGNED_SHORT */
  37699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37700. /** INT */
  37701. static readonly TEXTURETYPE_INT: number;
  37702. /** UNSIGNED_INT */
  37703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37704. /** UNSIGNED_SHORT_4_4_4_4 */
  37705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37706. /** UNSIGNED_SHORT_5_5_5_1 */
  37707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37708. /** UNSIGNED_SHORT_5_6_5 */
  37709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37710. /** UNSIGNED_INT_2_10_10_10_REV */
  37711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37712. /** UNSIGNED_INT_24_8 */
  37713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37714. /** UNSIGNED_INT_10F_11F_11F_REV */
  37715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37716. /** UNSIGNED_INT_5_9_9_9_REV */
  37717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37720. /** nearest is mag = nearest and min = nearest and mip = linear */
  37721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37724. /** Trilinear is mag = linear and min = linear and mip = linear */
  37725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37726. /** nearest is mag = nearest and min = nearest and mip = linear */
  37727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37730. /** Trilinear is mag = linear and min = linear and mip = linear */
  37731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37732. /** mag = nearest and min = nearest and mip = nearest */
  37733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37734. /** mag = nearest and min = linear and mip = nearest */
  37735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37736. /** mag = nearest and min = linear and mip = linear */
  37737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37738. /** mag = nearest and min = linear and mip = none */
  37739. static readonly TEXTURE_NEAREST_LINEAR: number;
  37740. /** mag = nearest and min = nearest and mip = none */
  37741. static readonly TEXTURE_NEAREST_NEAREST: number;
  37742. /** mag = linear and min = nearest and mip = nearest */
  37743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37744. /** mag = linear and min = nearest and mip = linear */
  37745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37746. /** mag = linear and min = linear and mip = none */
  37747. static readonly TEXTURE_LINEAR_LINEAR: number;
  37748. /** mag = linear and min = nearest and mip = none */
  37749. static readonly TEXTURE_LINEAR_NEAREST: number;
  37750. /** Explicit coordinates mode */
  37751. static readonly TEXTURE_EXPLICIT_MODE: number;
  37752. /** Spherical coordinates mode */
  37753. static readonly TEXTURE_SPHERICAL_MODE: number;
  37754. /** Planar coordinates mode */
  37755. static readonly TEXTURE_PLANAR_MODE: number;
  37756. /** Cubic coordinates mode */
  37757. static readonly TEXTURE_CUBIC_MODE: number;
  37758. /** Projection coordinates mode */
  37759. static readonly TEXTURE_PROJECTION_MODE: number;
  37760. /** Skybox coordinates mode */
  37761. static readonly TEXTURE_SKYBOX_MODE: number;
  37762. /** Inverse Cubic coordinates mode */
  37763. static readonly TEXTURE_INVCUBIC_MODE: number;
  37764. /** Equirectangular coordinates mode */
  37765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37766. /** Equirectangular Fixed coordinates mode */
  37767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37768. /** Equirectangular Fixed Mirrored coordinates mode */
  37769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37771. static readonly SCALEMODE_FLOOR: number;
  37772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37773. static readonly SCALEMODE_NEAREST: number;
  37774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37775. static readonly SCALEMODE_CEILING: number;
  37776. /**
  37777. * Returns the current npm package of the sdk
  37778. */
  37779. static get NpmPackage(): string;
  37780. /**
  37781. * Returns the current version of the framework
  37782. */
  37783. static get Version(): string;
  37784. /** Gets the list of created engines */
  37785. static get Instances(): Engine[];
  37786. /**
  37787. * Gets the latest created engine
  37788. */
  37789. static get LastCreatedEngine(): Nullable<Engine>;
  37790. /**
  37791. * Gets the latest created scene
  37792. */
  37793. static get LastCreatedScene(): Nullable<Scene>;
  37794. /**
  37795. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37796. * @param flag defines which part of the materials must be marked as dirty
  37797. * @param predicate defines a predicate used to filter which materials should be affected
  37798. */
  37799. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37800. /**
  37801. * Method called to create the default loading screen.
  37802. * This can be overriden in your own app.
  37803. * @param canvas The rendering canvas element
  37804. * @returns The loading screen
  37805. */
  37806. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37807. /**
  37808. * Method called to create the default rescale post process on each engine.
  37809. */
  37810. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37811. /**
  37812. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37813. **/
  37814. enableOfflineSupport: boolean;
  37815. /**
  37816. * 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)
  37817. **/
  37818. disableManifestCheck: boolean;
  37819. /**
  37820. * Gets the list of created scenes
  37821. */
  37822. scenes: Scene[];
  37823. /**
  37824. * Event raised when a new scene is created
  37825. */
  37826. onNewSceneAddedObservable: Observable<Scene>;
  37827. /**
  37828. * Gets the list of created postprocesses
  37829. */
  37830. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37831. /**
  37832. * Gets a boolean indicating if the pointer is currently locked
  37833. */
  37834. isPointerLock: boolean;
  37835. /**
  37836. * Observable event triggered each time the rendering canvas is resized
  37837. */
  37838. onResizeObservable: Observable<Engine>;
  37839. /**
  37840. * Observable event triggered each time the canvas loses focus
  37841. */
  37842. onCanvasBlurObservable: Observable<Engine>;
  37843. /**
  37844. * Observable event triggered each time the canvas gains focus
  37845. */
  37846. onCanvasFocusObservable: Observable<Engine>;
  37847. /**
  37848. * Observable event triggered each time the canvas receives pointerout event
  37849. */
  37850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37851. /**
  37852. * Observable raised when the engine begins a new frame
  37853. */
  37854. onBeginFrameObservable: Observable<Engine>;
  37855. /**
  37856. * If set, will be used to request the next animation frame for the render loop
  37857. */
  37858. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37859. /**
  37860. * Observable raised when the engine ends the current frame
  37861. */
  37862. onEndFrameObservable: Observable<Engine>;
  37863. /**
  37864. * Observable raised when the engine is about to compile a shader
  37865. */
  37866. onBeforeShaderCompilationObservable: Observable<Engine>;
  37867. /**
  37868. * Observable raised when the engine has jsut compiled a shader
  37869. */
  37870. onAfterShaderCompilationObservable: Observable<Engine>;
  37871. /**
  37872. * Gets the audio engine
  37873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37874. * @ignorenaming
  37875. */
  37876. static audioEngine: IAudioEngine;
  37877. /**
  37878. * Default AudioEngine factory responsible of creating the Audio Engine.
  37879. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37880. */
  37881. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37882. /**
  37883. * Default offline support factory responsible of creating a tool used to store data locally.
  37884. * By default, this will create a Database object if the workload has been embedded.
  37885. */
  37886. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37887. private _loadingScreen;
  37888. private _pointerLockRequested;
  37889. private _rescalePostProcess;
  37890. private _deterministicLockstep;
  37891. private _lockstepMaxSteps;
  37892. private _timeStep;
  37893. protected get _supportsHardwareTextureRescaling(): boolean;
  37894. private _fps;
  37895. private _deltaTime;
  37896. /** @hidden */
  37897. _drawCalls: PerfCounter;
  37898. /** 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 */
  37899. canvasTabIndex: number;
  37900. /**
  37901. * Turn this value on if you want to pause FPS computation when in background
  37902. */
  37903. disablePerformanceMonitorInBackground: boolean;
  37904. private _performanceMonitor;
  37905. /**
  37906. * Gets the performance monitor attached to this engine
  37907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37908. */
  37909. get performanceMonitor(): PerformanceMonitor;
  37910. private _onFocus;
  37911. private _onBlur;
  37912. private _onCanvasPointerOut;
  37913. private _onCanvasBlur;
  37914. private _onCanvasFocus;
  37915. private _onFullscreenChange;
  37916. private _onPointerLockChange;
  37917. /**
  37918. * Gets the HTML element used to attach event listeners
  37919. * @returns a HTML element
  37920. */
  37921. getInputElement(): Nullable<HTMLElement>;
  37922. /**
  37923. * Creates a new engine
  37924. * @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
  37925. * @param antialias defines enable antialiasing (default: false)
  37926. * @param options defines further options to be sent to the getContext() function
  37927. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37928. */
  37929. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37930. /**
  37931. * Gets current aspect ratio
  37932. * @param viewportOwner defines the camera to use to get the aspect ratio
  37933. * @param useScreen defines if screen size must be used (or the current render target if any)
  37934. * @returns a number defining the aspect ratio
  37935. */
  37936. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37937. /**
  37938. * Gets current screen aspect ratio
  37939. * @returns a number defining the aspect ratio
  37940. */
  37941. getScreenAspectRatio(): number;
  37942. /**
  37943. * Gets the client rect of the HTML canvas attached with the current webGL context
  37944. * @returns a client rectanglee
  37945. */
  37946. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37947. /**
  37948. * Gets the client rect of the HTML element used for events
  37949. * @returns a client rectanglee
  37950. */
  37951. getInputElementClientRect(): Nullable<ClientRect>;
  37952. /**
  37953. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37955. * @returns true if engine is in deterministic lock step mode
  37956. */
  37957. isDeterministicLockStep(): boolean;
  37958. /**
  37959. * Gets the max steps when engine is running in deterministic lock step
  37960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37961. * @returns the max steps
  37962. */
  37963. getLockstepMaxSteps(): number;
  37964. /**
  37965. * Returns the time in ms between steps when using deterministic lock step.
  37966. * @returns time step in (ms)
  37967. */
  37968. getTimeStep(): number;
  37969. /**
  37970. * Force the mipmap generation for the given render target texture
  37971. * @param texture defines the render target texture to use
  37972. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37973. */
  37974. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37975. /** States */
  37976. /**
  37977. * Set various states to the webGL context
  37978. * @param culling defines backface culling state
  37979. * @param zOffset defines the value to apply to zOffset (0 by default)
  37980. * @param force defines if states must be applied even if cache is up to date
  37981. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37982. */
  37983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37984. /**
  37985. * Set the z offset to apply to current rendering
  37986. * @param value defines the offset to apply
  37987. */
  37988. setZOffset(value: number): void;
  37989. /**
  37990. * Gets the current value of the zOffset
  37991. * @returns the current zOffset state
  37992. */
  37993. getZOffset(): number;
  37994. /**
  37995. * Enable or disable depth buffering
  37996. * @param enable defines the state to set
  37997. */
  37998. setDepthBuffer(enable: boolean): void;
  37999. /**
  38000. * Gets a boolean indicating if depth writing is enabled
  38001. * @returns the current depth writing state
  38002. */
  38003. getDepthWrite(): boolean;
  38004. /**
  38005. * Enable or disable depth writing
  38006. * @param enable defines the state to set
  38007. */
  38008. setDepthWrite(enable: boolean): void;
  38009. /**
  38010. * Gets a boolean indicating if stencil buffer is enabled
  38011. * @returns the current stencil buffer state
  38012. */
  38013. getStencilBuffer(): boolean;
  38014. /**
  38015. * Enable or disable the stencil buffer
  38016. * @param enable defines if the stencil buffer must be enabled or disabled
  38017. */
  38018. setStencilBuffer(enable: boolean): void;
  38019. /**
  38020. * Gets the current stencil mask
  38021. * @returns a number defining the new stencil mask to use
  38022. */
  38023. getStencilMask(): number;
  38024. /**
  38025. * Sets the current stencil mask
  38026. * @param mask defines the new stencil mask to use
  38027. */
  38028. setStencilMask(mask: number): void;
  38029. /**
  38030. * Gets the current stencil function
  38031. * @returns a number defining the stencil function to use
  38032. */
  38033. getStencilFunction(): number;
  38034. /**
  38035. * Gets the current stencil reference value
  38036. * @returns a number defining the stencil reference value to use
  38037. */
  38038. getStencilFunctionReference(): number;
  38039. /**
  38040. * Gets the current stencil mask
  38041. * @returns a number defining the stencil mask to use
  38042. */
  38043. getStencilFunctionMask(): number;
  38044. /**
  38045. * Sets the current stencil function
  38046. * @param stencilFunc defines the new stencil function to use
  38047. */
  38048. setStencilFunction(stencilFunc: number): void;
  38049. /**
  38050. * Sets the current stencil reference
  38051. * @param reference defines the new stencil reference to use
  38052. */
  38053. setStencilFunctionReference(reference: number): void;
  38054. /**
  38055. * Sets the current stencil mask
  38056. * @param mask defines the new stencil mask to use
  38057. */
  38058. setStencilFunctionMask(mask: number): void;
  38059. /**
  38060. * Gets the current stencil operation when stencil fails
  38061. * @returns a number defining stencil operation to use when stencil fails
  38062. */
  38063. getStencilOperationFail(): number;
  38064. /**
  38065. * Gets the current stencil operation when depth fails
  38066. * @returns a number defining stencil operation to use when depth fails
  38067. */
  38068. getStencilOperationDepthFail(): number;
  38069. /**
  38070. * Gets the current stencil operation when stencil passes
  38071. * @returns a number defining stencil operation to use when stencil passes
  38072. */
  38073. getStencilOperationPass(): number;
  38074. /**
  38075. * Sets the stencil operation to use when stencil fails
  38076. * @param operation defines the stencil operation to use when stencil fails
  38077. */
  38078. setStencilOperationFail(operation: number): void;
  38079. /**
  38080. * Sets the stencil operation to use when depth fails
  38081. * @param operation defines the stencil operation to use when depth fails
  38082. */
  38083. setStencilOperationDepthFail(operation: number): void;
  38084. /**
  38085. * Sets the stencil operation to use when stencil passes
  38086. * @param operation defines the stencil operation to use when stencil passes
  38087. */
  38088. setStencilOperationPass(operation: number): void;
  38089. /**
  38090. * Sets a boolean indicating if the dithering state is enabled or disabled
  38091. * @param value defines the dithering state
  38092. */
  38093. setDitheringState(value: boolean): void;
  38094. /**
  38095. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38096. * @param value defines the rasterizer state
  38097. */
  38098. setRasterizerState(value: boolean): void;
  38099. /**
  38100. * Gets the current depth function
  38101. * @returns a number defining the depth function
  38102. */
  38103. getDepthFunction(): Nullable<number>;
  38104. /**
  38105. * Sets the current depth function
  38106. * @param depthFunc defines the function to use
  38107. */
  38108. setDepthFunction(depthFunc: number): void;
  38109. /**
  38110. * Sets the current depth function to GREATER
  38111. */
  38112. setDepthFunctionToGreater(): void;
  38113. /**
  38114. * Sets the current depth function to GEQUAL
  38115. */
  38116. setDepthFunctionToGreaterOrEqual(): void;
  38117. /**
  38118. * Sets the current depth function to LESS
  38119. */
  38120. setDepthFunctionToLess(): void;
  38121. /**
  38122. * Sets the current depth function to LEQUAL
  38123. */
  38124. setDepthFunctionToLessOrEqual(): void;
  38125. private _cachedStencilBuffer;
  38126. private _cachedStencilFunction;
  38127. private _cachedStencilMask;
  38128. private _cachedStencilOperationPass;
  38129. private _cachedStencilOperationFail;
  38130. private _cachedStencilOperationDepthFail;
  38131. private _cachedStencilReference;
  38132. /**
  38133. * Caches the the state of the stencil buffer
  38134. */
  38135. cacheStencilState(): void;
  38136. /**
  38137. * Restores the state of the stencil buffer
  38138. */
  38139. restoreStencilState(): void;
  38140. /**
  38141. * Directly set the WebGL Viewport
  38142. * @param x defines the x coordinate of the viewport (in screen space)
  38143. * @param y defines the y coordinate of the viewport (in screen space)
  38144. * @param width defines the width of the viewport (in screen space)
  38145. * @param height defines the height of the viewport (in screen space)
  38146. * @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
  38147. */
  38148. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38149. /**
  38150. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38151. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38152. * @param y defines the y-coordinate of the corner of the clear rectangle
  38153. * @param width defines the width of the clear rectangle
  38154. * @param height defines the height of the clear rectangle
  38155. * @param clearColor defines the clear color
  38156. */
  38157. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38158. /**
  38159. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38160. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38161. * @param y defines the y-coordinate of the corner of the clear rectangle
  38162. * @param width defines the width of the clear rectangle
  38163. * @param height defines the height of the clear rectangle
  38164. */
  38165. enableScissor(x: number, y: number, width: number, height: number): void;
  38166. /**
  38167. * Disable previously set scissor test rectangle
  38168. */
  38169. disableScissor(): void;
  38170. protected _reportDrawCall(): void;
  38171. /**
  38172. * Initializes a webVR display and starts listening to display change events
  38173. * The onVRDisplayChangedObservable will be notified upon these changes
  38174. * @returns The onVRDisplayChangedObservable
  38175. */
  38176. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38177. /** @hidden */
  38178. _prepareVRComponent(): void;
  38179. /** @hidden */
  38180. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38181. /** @hidden */
  38182. _submitVRFrame(): void;
  38183. /**
  38184. * Call this function to leave webVR mode
  38185. * Will do nothing if webVR is not supported or if there is no webVR device
  38186. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38187. */
  38188. disableVR(): void;
  38189. /**
  38190. * Gets a boolean indicating that the system is in VR mode and is presenting
  38191. * @returns true if VR mode is engaged
  38192. */
  38193. isVRPresenting(): boolean;
  38194. /** @hidden */
  38195. _requestVRFrame(): void;
  38196. /** @hidden */
  38197. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38198. /**
  38199. * Gets the source code of the vertex shader associated with a specific webGL program
  38200. * @param program defines the program to use
  38201. * @returns a string containing the source code of the vertex shader associated with the program
  38202. */
  38203. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38204. /**
  38205. * Gets the source code of the fragment shader associated with a specific webGL program
  38206. * @param program defines the program to use
  38207. * @returns a string containing the source code of the fragment shader associated with the program
  38208. */
  38209. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38210. /**
  38211. * Sets a depth stencil texture from a render target to the according uniform.
  38212. * @param channel The texture channel
  38213. * @param uniform The uniform to set
  38214. * @param texture The render target texture containing the depth stencil texture to apply
  38215. */
  38216. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38217. /**
  38218. * Sets a texture to the webGL context from a postprocess
  38219. * @param channel defines the channel to use
  38220. * @param postProcess defines the source postprocess
  38221. */
  38222. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38223. /**
  38224. * Binds the output of the passed in post process to the texture channel specified
  38225. * @param channel The channel the texture should be bound to
  38226. * @param postProcess The post process which's output should be bound
  38227. */
  38228. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38229. protected _rebuildBuffers(): void;
  38230. /** @hidden */
  38231. _renderFrame(): void;
  38232. _renderLoop(): void;
  38233. /** @hidden */
  38234. _renderViews(): boolean;
  38235. /**
  38236. * Toggle full screen mode
  38237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38238. */
  38239. switchFullscreen(requestPointerLock: boolean): void;
  38240. /**
  38241. * Enters full screen mode
  38242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38243. */
  38244. enterFullscreen(requestPointerLock: boolean): void;
  38245. /**
  38246. * Exits full screen mode
  38247. */
  38248. exitFullscreen(): void;
  38249. /**
  38250. * Enters Pointerlock mode
  38251. */
  38252. enterPointerlock(): void;
  38253. /**
  38254. * Exits Pointerlock mode
  38255. */
  38256. exitPointerlock(): void;
  38257. /**
  38258. * Begin a new frame
  38259. */
  38260. beginFrame(): void;
  38261. /**
  38262. * Enf the current frame
  38263. */
  38264. endFrame(): void;
  38265. resize(): void;
  38266. /**
  38267. * Force a specific size of the canvas
  38268. * @param width defines the new canvas' width
  38269. * @param height defines the new canvas' height
  38270. * @returns true if the size was changed
  38271. */
  38272. setSize(width: number, height: number): boolean;
  38273. /**
  38274. * Updates a dynamic vertex buffer.
  38275. * @param vertexBuffer the vertex buffer to update
  38276. * @param data the data used to update the vertex buffer
  38277. * @param byteOffset the byte offset of the data
  38278. * @param byteLength the byte length of the data
  38279. */
  38280. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38281. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38283. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38284. _releaseTexture(texture: InternalTexture): void;
  38285. /**
  38286. * @hidden
  38287. * Rescales a texture
  38288. * @param source input texutre
  38289. * @param destination destination texture
  38290. * @param scene scene to use to render the resize
  38291. * @param internalFormat format to use when resizing
  38292. * @param onComplete callback to be called when resize has completed
  38293. */
  38294. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38295. /**
  38296. * Gets the current framerate
  38297. * @returns a number representing the framerate
  38298. */
  38299. getFps(): number;
  38300. /**
  38301. * Gets the time spent between current and previous frame
  38302. * @returns a number representing the delta time in ms
  38303. */
  38304. getDeltaTime(): number;
  38305. private _measureFps;
  38306. /** @hidden */
  38307. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38308. /**
  38309. * Update a dynamic index buffer
  38310. * @param indexBuffer defines the target index buffer
  38311. * @param indices defines the data to update
  38312. * @param offset defines the offset in the target index buffer where update should start
  38313. */
  38314. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38315. /**
  38316. * Updates the sample count of a render target texture
  38317. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38318. * @param texture defines the texture to update
  38319. * @param samples defines the sample count to set
  38320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38321. */
  38322. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38323. /**
  38324. * Updates a depth texture Comparison Mode and Function.
  38325. * If the comparison Function is equal to 0, the mode will be set to none.
  38326. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38327. * @param texture The texture to set the comparison function for
  38328. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38329. */
  38330. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38331. /**
  38332. * Creates a webGL buffer to use with instanciation
  38333. * @param capacity defines the size of the buffer
  38334. * @returns the webGL buffer
  38335. */
  38336. createInstancesBuffer(capacity: number): DataBuffer;
  38337. /**
  38338. * Delete a webGL buffer used with instanciation
  38339. * @param buffer defines the webGL buffer to delete
  38340. */
  38341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38342. private _clientWaitAsync;
  38343. /** @hidden */
  38344. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38345. dispose(): void;
  38346. private _disableTouchAction;
  38347. /**
  38348. * Display the loading screen
  38349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38350. */
  38351. displayLoadingUI(): void;
  38352. /**
  38353. * Hide the loading screen
  38354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38355. */
  38356. hideLoadingUI(): void;
  38357. /**
  38358. * Gets the current loading screen object
  38359. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38360. */
  38361. get loadingScreen(): ILoadingScreen;
  38362. /**
  38363. * Sets the current loading screen object
  38364. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38365. */
  38366. set loadingScreen(loadingScreen: ILoadingScreen);
  38367. /**
  38368. * Sets the current loading screen text
  38369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38370. */
  38371. set loadingUIText(text: string);
  38372. /**
  38373. * Sets the current loading screen background color
  38374. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38375. */
  38376. set loadingUIBackgroundColor(color: string);
  38377. /** Pointerlock and fullscreen */
  38378. /**
  38379. * Ask the browser to promote the current element to pointerlock mode
  38380. * @param element defines the DOM element to promote
  38381. */
  38382. static _RequestPointerlock(element: HTMLElement): void;
  38383. /**
  38384. * Asks the browser to exit pointerlock mode
  38385. */
  38386. static _ExitPointerlock(): void;
  38387. /**
  38388. * Ask the browser to promote the current element to fullscreen rendering mode
  38389. * @param element defines the DOM element to promote
  38390. */
  38391. static _RequestFullscreen(element: HTMLElement): void;
  38392. /**
  38393. * Asks the browser to exit fullscreen mode
  38394. */
  38395. static _ExitFullscreen(): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Engines/engineStore" {
  38399. import { Nullable } from "babylonjs/types";
  38400. import { Engine } from "babylonjs/Engines/engine";
  38401. import { Scene } from "babylonjs/scene";
  38402. /**
  38403. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38404. * during the life time of the application.
  38405. */
  38406. export class EngineStore {
  38407. /** Gets the list of created engines */
  38408. static Instances: import("babylonjs/Engines/engine").Engine[];
  38409. /** @hidden */
  38410. static _LastCreatedScene: Nullable<Scene>;
  38411. /**
  38412. * Gets the latest created engine
  38413. */
  38414. static get LastCreatedEngine(): Nullable<Engine>;
  38415. /**
  38416. * Gets the latest created scene
  38417. */
  38418. static get LastCreatedScene(): Nullable<Scene>;
  38419. /**
  38420. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38421. * @ignorenaming
  38422. */
  38423. static UseFallbackTexture: boolean;
  38424. /**
  38425. * Texture content used if a texture cannot loaded
  38426. * @ignorenaming
  38427. */
  38428. static FallbackTexture: string;
  38429. }
  38430. }
  38431. declare module "babylonjs/Misc/promise" {
  38432. /**
  38433. * Helper class that provides a small promise polyfill
  38434. */
  38435. export class PromisePolyfill {
  38436. /**
  38437. * Static function used to check if the polyfill is required
  38438. * If this is the case then the function will inject the polyfill to window.Promise
  38439. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38440. */
  38441. static Apply(force?: boolean): void;
  38442. }
  38443. }
  38444. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38445. /**
  38446. * Interface for screenshot methods with describe argument called `size` as object with options
  38447. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38448. */
  38449. export interface IScreenshotSize {
  38450. /**
  38451. * number in pixels for canvas height
  38452. */
  38453. height?: number;
  38454. /**
  38455. * multiplier allowing render at a higher or lower resolution
  38456. * If value is defined then height and width will be ignored and taken from camera
  38457. */
  38458. precision?: number;
  38459. /**
  38460. * number in pixels for canvas width
  38461. */
  38462. width?: number;
  38463. }
  38464. }
  38465. declare module "babylonjs/Misc/tools" {
  38466. import { Nullable, float } from "babylonjs/types";
  38467. import { DomManagement } from "babylonjs/Misc/domManagement";
  38468. import { WebRequest } from "babylonjs/Misc/webRequest";
  38469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38470. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38471. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38472. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38473. import { Camera } from "babylonjs/Cameras/camera";
  38474. import { Engine } from "babylonjs/Engines/engine";
  38475. interface IColor4Like {
  38476. r: float;
  38477. g: float;
  38478. b: float;
  38479. a: float;
  38480. }
  38481. /**
  38482. * Class containing a set of static utilities functions
  38483. */
  38484. export class Tools {
  38485. /**
  38486. * Gets or sets the base URL to use to load assets
  38487. */
  38488. static get BaseUrl(): string;
  38489. static set BaseUrl(value: string);
  38490. /**
  38491. * Enable/Disable Custom HTTP Request Headers globally.
  38492. * default = false
  38493. * @see CustomRequestHeaders
  38494. */
  38495. static UseCustomRequestHeaders: boolean;
  38496. /**
  38497. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38498. * i.e. when loading files, where the server/service expects an Authorization header
  38499. */
  38500. static CustomRequestHeaders: {
  38501. [key: string]: string;
  38502. };
  38503. /**
  38504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38505. */
  38506. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38507. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38508. /**
  38509. * Default behaviour for cors in the application.
  38510. * It can be a string if the expected behavior is identical in the entire app.
  38511. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38512. */
  38513. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38514. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38515. /**
  38516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38517. * @ignorenaming
  38518. */
  38519. static get UseFallbackTexture(): boolean;
  38520. static set UseFallbackTexture(value: boolean);
  38521. /**
  38522. * Use this object to register external classes like custom textures or material
  38523. * to allow the laoders to instantiate them
  38524. */
  38525. static get RegisteredExternalClasses(): {
  38526. [key: string]: Object;
  38527. };
  38528. static set RegisteredExternalClasses(classes: {
  38529. [key: string]: Object;
  38530. });
  38531. /**
  38532. * Texture content used if a texture cannot loaded
  38533. * @ignorenaming
  38534. */
  38535. static get fallbackTexture(): string;
  38536. static set fallbackTexture(value: string);
  38537. /**
  38538. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38539. * @param u defines the coordinate on X axis
  38540. * @param v defines the coordinate on Y axis
  38541. * @param width defines the width of the source data
  38542. * @param height defines the height of the source data
  38543. * @param pixels defines the source byte array
  38544. * @param color defines the output color
  38545. */
  38546. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38547. /**
  38548. * Interpolates between a and b via alpha
  38549. * @param a The lower value (returned when alpha = 0)
  38550. * @param b The upper value (returned when alpha = 1)
  38551. * @param alpha The interpolation-factor
  38552. * @return The mixed value
  38553. */
  38554. static Mix(a: number, b: number, alpha: number): number;
  38555. /**
  38556. * Tries to instantiate a new object from a given class name
  38557. * @param className defines the class name to instantiate
  38558. * @returns the new object or null if the system was not able to do the instantiation
  38559. */
  38560. static Instantiate(className: string): any;
  38561. /**
  38562. * Provides a slice function that will work even on IE
  38563. * @param data defines the array to slice
  38564. * @param start defines the start of the data (optional)
  38565. * @param end defines the end of the data (optional)
  38566. * @returns the new sliced array
  38567. */
  38568. static Slice<T>(data: T, start?: number, end?: number): T;
  38569. /**
  38570. * Polyfill for setImmediate
  38571. * @param action defines the action to execute after the current execution block
  38572. */
  38573. static SetImmediate(action: () => void): void;
  38574. /**
  38575. * Function indicating if a number is an exponent of 2
  38576. * @param value defines the value to test
  38577. * @returns true if the value is an exponent of 2
  38578. */
  38579. static IsExponentOfTwo(value: number): boolean;
  38580. private static _tmpFloatArray;
  38581. /**
  38582. * Returns the nearest 32-bit single precision float representation of a Number
  38583. * @param value A Number. If the parameter is of a different type, it will get converted
  38584. * to a number or to NaN if it cannot be converted
  38585. * @returns number
  38586. */
  38587. static FloatRound(value: number): number;
  38588. /**
  38589. * Extracts the filename from a path
  38590. * @param path defines the path to use
  38591. * @returns the filename
  38592. */
  38593. static GetFilename(path: string): string;
  38594. /**
  38595. * Extracts the "folder" part of a path (everything before the filename).
  38596. * @param uri The URI to extract the info from
  38597. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38598. * @returns The "folder" part of the path
  38599. */
  38600. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38601. /**
  38602. * Extracts text content from a DOM element hierarchy
  38603. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38604. */
  38605. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38606. /**
  38607. * Convert an angle in radians to degrees
  38608. * @param angle defines the angle to convert
  38609. * @returns the angle in degrees
  38610. */
  38611. static ToDegrees(angle: number): number;
  38612. /**
  38613. * Convert an angle in degrees to radians
  38614. * @param angle defines the angle to convert
  38615. * @returns the angle in radians
  38616. */
  38617. static ToRadians(angle: number): number;
  38618. /**
  38619. * Returns an array if obj is not an array
  38620. * @param obj defines the object to evaluate as an array
  38621. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38622. * @returns either obj directly if obj is an array or a new array containing obj
  38623. */
  38624. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38625. /**
  38626. * Gets the pointer prefix to use
  38627. * @param engine defines the engine we are finding the prefix for
  38628. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38629. */
  38630. static GetPointerPrefix(engine: Engine): string;
  38631. /**
  38632. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38633. * @param url define the url we are trying
  38634. * @param element define the dom element where to configure the cors policy
  38635. */
  38636. static SetCorsBehavior(url: string | string[], element: {
  38637. crossOrigin: string | null;
  38638. }): void;
  38639. /**
  38640. * Removes unwanted characters from an url
  38641. * @param url defines the url to clean
  38642. * @returns the cleaned url
  38643. */
  38644. static CleanUrl(url: string): string;
  38645. /**
  38646. * Gets or sets a function used to pre-process url before using them to load assets
  38647. */
  38648. static get PreprocessUrl(): (url: string) => string;
  38649. static set PreprocessUrl(processor: (url: string) => string);
  38650. /**
  38651. * Loads an image as an HTMLImageElement.
  38652. * @param input url string, ArrayBuffer, or Blob to load
  38653. * @param onLoad callback called when the image successfully loads
  38654. * @param onError callback called when the image fails to load
  38655. * @param offlineProvider offline provider for caching
  38656. * @param mimeType optional mime type
  38657. * @returns the HTMLImageElement of the loaded image
  38658. */
  38659. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38660. /**
  38661. * Loads a file from a url
  38662. * @param url url string, ArrayBuffer, or Blob to load
  38663. * @param onSuccess callback called when the file successfully loads
  38664. * @param onProgress callback called while file is loading (if the server supports this mode)
  38665. * @param offlineProvider defines the offline provider for caching
  38666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38667. * @param onError callback called when the file fails to load
  38668. * @returns a file request object
  38669. */
  38670. 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;
  38671. /**
  38672. * Loads a file from a url
  38673. * @param url the file url to load
  38674. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38675. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38676. */
  38677. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38678. /**
  38679. * Load a script (identified by an url). When the url returns, the
  38680. * content of this file is added into a new script element, attached to the DOM (body element)
  38681. * @param scriptUrl defines the url of the script to laod
  38682. * @param onSuccess defines the callback called when the script is loaded
  38683. * @param onError defines the callback to call if an error occurs
  38684. * @param scriptId defines the id of the script element
  38685. */
  38686. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38687. /**
  38688. * Load an asynchronous script (identified by an url). When the url returns, the
  38689. * content of this file is added into a new script element, attached to the DOM (body element)
  38690. * @param scriptUrl defines the url of the script to laod
  38691. * @param scriptId defines the id of the script element
  38692. * @returns a promise request object
  38693. */
  38694. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38695. /**
  38696. * Loads a file from a blob
  38697. * @param fileToLoad defines the blob to use
  38698. * @param callback defines the callback to call when data is loaded
  38699. * @param progressCallback defines the callback to call during loading process
  38700. * @returns a file request object
  38701. */
  38702. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38703. /**
  38704. * Reads a file from a File object
  38705. * @param file defines the file to load
  38706. * @param onSuccess defines the callback to call when data is loaded
  38707. * @param onProgress defines the callback to call during loading process
  38708. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38709. * @param onError defines the callback to call when an error occurs
  38710. * @returns a file request object
  38711. */
  38712. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38713. /**
  38714. * Creates a data url from a given string content
  38715. * @param content defines the content to convert
  38716. * @returns the new data url link
  38717. */
  38718. static FileAsURL(content: string): string;
  38719. /**
  38720. * Format the given number to a specific decimal format
  38721. * @param value defines the number to format
  38722. * @param decimals defines the number of decimals to use
  38723. * @returns the formatted string
  38724. */
  38725. static Format(value: number, decimals?: number): string;
  38726. /**
  38727. * Tries to copy an object by duplicating every property
  38728. * @param source defines the source object
  38729. * @param destination defines the target object
  38730. * @param doNotCopyList defines a list of properties to avoid
  38731. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38732. */
  38733. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38734. /**
  38735. * Gets a boolean indicating if the given object has no own property
  38736. * @param obj defines the object to test
  38737. * @returns true if object has no own property
  38738. */
  38739. static IsEmpty(obj: any): boolean;
  38740. /**
  38741. * Function used to register events at window level
  38742. * @param windowElement defines the Window object to use
  38743. * @param events defines the events to register
  38744. */
  38745. static RegisterTopRootEvents(windowElement: Window, events: {
  38746. name: string;
  38747. handler: Nullable<(e: FocusEvent) => any>;
  38748. }[]): void;
  38749. /**
  38750. * Function used to unregister events from window level
  38751. * @param windowElement defines the Window object to use
  38752. * @param events defines the events to unregister
  38753. */
  38754. static UnregisterTopRootEvents(windowElement: Window, events: {
  38755. name: string;
  38756. handler: Nullable<(e: FocusEvent) => any>;
  38757. }[]): void;
  38758. /**
  38759. * @ignore
  38760. */
  38761. static _ScreenshotCanvas: HTMLCanvasElement;
  38762. /**
  38763. * Dumps the current bound framebuffer
  38764. * @param width defines the rendering width
  38765. * @param height defines the rendering height
  38766. * @param engine defines the hosting engine
  38767. * @param successCallback defines the callback triggered once the data are available
  38768. * @param mimeType defines the mime type of the result
  38769. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38770. */
  38771. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38772. /**
  38773. * Converts the canvas data to blob.
  38774. * This acts as a polyfill for browsers not supporting the to blob function.
  38775. * @param canvas Defines the canvas to extract the data from
  38776. * @param successCallback Defines the callback triggered once the data are available
  38777. * @param mimeType Defines the mime type of the result
  38778. */
  38779. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38780. /**
  38781. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38782. * @param successCallback defines the callback triggered once the data are available
  38783. * @param mimeType defines the mime type of the result
  38784. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38785. */
  38786. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38787. /**
  38788. * Downloads a blob in the browser
  38789. * @param blob defines the blob to download
  38790. * @param fileName defines the name of the downloaded file
  38791. */
  38792. static Download(blob: Blob, fileName: string): void;
  38793. /**
  38794. * Captures a screenshot of the current rendering
  38795. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38796. * @param engine defines the rendering engine
  38797. * @param camera defines the source camera
  38798. * @param size This parameter can be set to a single number or to an object with the
  38799. * following (optional) properties: precision, width, height. If a single number is passed,
  38800. * it will be used for both width and height. If an object is passed, the screenshot size
  38801. * will be derived from the parameters. The precision property is a multiplier allowing
  38802. * rendering at a higher or lower resolution
  38803. * @param successCallback defines the callback receives a single parameter which contains the
  38804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38805. * src parameter of an <img> to display it
  38806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38807. * Check your browser for supported MIME types
  38808. */
  38809. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38810. /**
  38811. * Captures a screenshot of the current rendering
  38812. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38813. * @param engine defines the rendering engine
  38814. * @param camera defines the source camera
  38815. * @param size This parameter can be set to a single number or to an object with the
  38816. * following (optional) properties: precision, width, height. If a single number is passed,
  38817. * it will be used for both width and height. If an object is passed, the screenshot size
  38818. * will be derived from the parameters. The precision property is a multiplier allowing
  38819. * rendering at a higher or lower resolution
  38820. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38821. * Check your browser for supported MIME types
  38822. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38823. * to the src parameter of an <img> to display it
  38824. */
  38825. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38826. /**
  38827. * Generates an image screenshot from the specified camera.
  38828. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38829. * @param engine The engine to use for rendering
  38830. * @param camera The camera to use for rendering
  38831. * @param size This parameter can be set to a single number or to an object with the
  38832. * following (optional) properties: precision, width, height. If a single number is passed,
  38833. * it will be used for both width and height. If an object is passed, the screenshot size
  38834. * will be derived from the parameters. The precision property is a multiplier allowing
  38835. * rendering at a higher or lower resolution
  38836. * @param successCallback The callback receives a single parameter which contains the
  38837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38838. * src parameter of an <img> to display it
  38839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38840. * Check your browser for supported MIME types
  38841. * @param samples Texture samples (default: 1)
  38842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38843. * @param fileName A name for for the downloaded file.
  38844. */
  38845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38846. /**
  38847. * Generates an image screenshot from the specified camera.
  38848. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38849. * @param engine The engine to use for rendering
  38850. * @param camera The camera to use for rendering
  38851. * @param size This parameter can be set to a single number or to an object with the
  38852. * following (optional) properties: precision, width, height. If a single number is passed,
  38853. * it will be used for both width and height. If an object is passed, the screenshot size
  38854. * will be derived from the parameters. The precision property is a multiplier allowing
  38855. * rendering at a higher or lower resolution
  38856. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38857. * Check your browser for supported MIME types
  38858. * @param samples Texture samples (default: 1)
  38859. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38860. * @param fileName A name for for the downloaded file.
  38861. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38862. * to the src parameter of an <img> to display it
  38863. */
  38864. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38865. /**
  38866. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38867. * Be aware Math.random() could cause collisions, but:
  38868. * "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"
  38869. * @returns a pseudo random id
  38870. */
  38871. static RandomId(): string;
  38872. /**
  38873. * Test if the given uri is a base64 string
  38874. * @param uri The uri to test
  38875. * @return True if the uri is a base64 string or false otherwise
  38876. */
  38877. static IsBase64(uri: string): boolean;
  38878. /**
  38879. * Decode the given base64 uri.
  38880. * @param uri The uri to decode
  38881. * @return The decoded base64 data.
  38882. */
  38883. static DecodeBase64(uri: string): ArrayBuffer;
  38884. /**
  38885. * Gets the absolute url.
  38886. * @param url the input url
  38887. * @return the absolute url
  38888. */
  38889. static GetAbsoluteUrl(url: string): string;
  38890. /**
  38891. * No log
  38892. */
  38893. static readonly NoneLogLevel: number;
  38894. /**
  38895. * Only message logs
  38896. */
  38897. static readonly MessageLogLevel: number;
  38898. /**
  38899. * Only warning logs
  38900. */
  38901. static readonly WarningLogLevel: number;
  38902. /**
  38903. * Only error logs
  38904. */
  38905. static readonly ErrorLogLevel: number;
  38906. /**
  38907. * All logs
  38908. */
  38909. static readonly AllLogLevel: number;
  38910. /**
  38911. * Gets a value indicating the number of loading errors
  38912. * @ignorenaming
  38913. */
  38914. static get errorsCount(): number;
  38915. /**
  38916. * Callback called when a new log is added
  38917. */
  38918. static OnNewCacheEntry: (entry: string) => void;
  38919. /**
  38920. * Log a message to the console
  38921. * @param message defines the message to log
  38922. */
  38923. static Log(message: string): void;
  38924. /**
  38925. * Write a warning message to the console
  38926. * @param message defines the message to log
  38927. */
  38928. static Warn(message: string): void;
  38929. /**
  38930. * Write an error message to the console
  38931. * @param message defines the message to log
  38932. */
  38933. static Error(message: string): void;
  38934. /**
  38935. * Gets current log cache (list of logs)
  38936. */
  38937. static get LogCache(): string;
  38938. /**
  38939. * Clears the log cache
  38940. */
  38941. static ClearLogCache(): void;
  38942. /**
  38943. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38944. */
  38945. static set LogLevels(level: number);
  38946. /**
  38947. * Checks if the window object exists
  38948. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38949. */
  38950. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38951. /**
  38952. * No performance log
  38953. */
  38954. static readonly PerformanceNoneLogLevel: number;
  38955. /**
  38956. * Use user marks to log performance
  38957. */
  38958. static readonly PerformanceUserMarkLogLevel: number;
  38959. /**
  38960. * Log performance to the console
  38961. */
  38962. static readonly PerformanceConsoleLogLevel: number;
  38963. private static _performance;
  38964. /**
  38965. * Sets the current performance log level
  38966. */
  38967. static set PerformanceLogLevel(level: number);
  38968. private static _StartPerformanceCounterDisabled;
  38969. private static _EndPerformanceCounterDisabled;
  38970. private static _StartUserMark;
  38971. private static _EndUserMark;
  38972. private static _StartPerformanceConsole;
  38973. private static _EndPerformanceConsole;
  38974. /**
  38975. * Starts a performance counter
  38976. */
  38977. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38978. /**
  38979. * Ends a specific performance coutner
  38980. */
  38981. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38982. /**
  38983. * Gets either window.performance.now() if supported or Date.now() else
  38984. */
  38985. static get Now(): number;
  38986. /**
  38987. * This method will return the name of the class used to create the instance of the given object.
  38988. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38989. * @param object the object to get the class name from
  38990. * @param isType defines if the object is actually a type
  38991. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38992. */
  38993. static GetClassName(object: any, isType?: boolean): string;
  38994. /**
  38995. * Gets the first element of an array satisfying a given predicate
  38996. * @param array defines the array to browse
  38997. * @param predicate defines the predicate to use
  38998. * @returns null if not found or the element
  38999. */
  39000. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39001. /**
  39002. * This method will return the name of the full name of the class, including its owning module (if any).
  39003. * 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).
  39004. * @param object the object to get the class name from
  39005. * @param isType defines if the object is actually a type
  39006. * @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.
  39007. * @ignorenaming
  39008. */
  39009. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39010. /**
  39011. * Returns a promise that resolves after the given amount of time.
  39012. * @param delay Number of milliseconds to delay
  39013. * @returns Promise that resolves after the given amount of time
  39014. */
  39015. static DelayAsync(delay: number): Promise<void>;
  39016. /**
  39017. * Utility function to detect if the current user agent is Safari
  39018. * @returns whether or not the current user agent is safari
  39019. */
  39020. static IsSafari(): boolean;
  39021. }
  39022. /**
  39023. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39024. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39025. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39026. * @param name The name of the class, case should be preserved
  39027. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39028. */
  39029. export function className(name: string, module?: string): (target: Object) => void;
  39030. /**
  39031. * An implementation of a loop for asynchronous functions.
  39032. */
  39033. export class AsyncLoop {
  39034. /**
  39035. * Defines the number of iterations for the loop
  39036. */
  39037. iterations: number;
  39038. /**
  39039. * Defines the current index of the loop.
  39040. */
  39041. index: number;
  39042. private _done;
  39043. private _fn;
  39044. private _successCallback;
  39045. /**
  39046. * Constructor.
  39047. * @param iterations the number of iterations.
  39048. * @param func the function to run each iteration
  39049. * @param successCallback the callback that will be called upon succesful execution
  39050. * @param offset starting offset.
  39051. */
  39052. constructor(
  39053. /**
  39054. * Defines the number of iterations for the loop
  39055. */
  39056. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39057. /**
  39058. * Execute the next iteration. Must be called after the last iteration was finished.
  39059. */
  39060. executeNext(): void;
  39061. /**
  39062. * Break the loop and run the success callback.
  39063. */
  39064. breakLoop(): void;
  39065. /**
  39066. * Create and run an async loop.
  39067. * @param iterations the number of iterations.
  39068. * @param fn the function to run each iteration
  39069. * @param successCallback the callback that will be called upon succesful execution
  39070. * @param offset starting offset.
  39071. * @returns the created async loop object
  39072. */
  39073. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39074. /**
  39075. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39076. * @param iterations total number of iterations
  39077. * @param syncedIterations number of synchronous iterations in each async iteration.
  39078. * @param fn the function to call each iteration.
  39079. * @param callback a success call back that will be called when iterating stops.
  39080. * @param breakFunction a break condition (optional)
  39081. * @param timeout timeout settings for the setTimeout function. default - 0.
  39082. * @returns the created async loop object
  39083. */
  39084. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39085. }
  39086. }
  39087. declare module "babylonjs/Misc/stringDictionary" {
  39088. import { Nullable } from "babylonjs/types";
  39089. /**
  39090. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39091. * The underlying implementation relies on an associative array to ensure the best performances.
  39092. * The value can be anything including 'null' but except 'undefined'
  39093. */
  39094. export class StringDictionary<T> {
  39095. /**
  39096. * This will clear this dictionary and copy the content from the 'source' one.
  39097. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39098. * @param source the dictionary to take the content from and copy to this dictionary
  39099. */
  39100. copyFrom(source: StringDictionary<T>): void;
  39101. /**
  39102. * Get a value based from its key
  39103. * @param key the given key to get the matching value from
  39104. * @return the value if found, otherwise undefined is returned
  39105. */
  39106. get(key: string): T | undefined;
  39107. /**
  39108. * Get a value from its key or add it if it doesn't exist.
  39109. * This method will ensure you that a given key/data will be present in the dictionary.
  39110. * @param key the given key to get the matching value from
  39111. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39112. * The factory will only be invoked if there's no data for the given key.
  39113. * @return the value corresponding to the key.
  39114. */
  39115. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39116. /**
  39117. * Get a value from its key if present in the dictionary otherwise add it
  39118. * @param key the key to get the value from
  39119. * @param val if there's no such key/value pair in the dictionary add it with this value
  39120. * @return the value corresponding to the key
  39121. */
  39122. getOrAdd(key: string, val: T): T;
  39123. /**
  39124. * Check if there's a given key in the dictionary
  39125. * @param key the key to check for
  39126. * @return true if the key is present, false otherwise
  39127. */
  39128. contains(key: string): boolean;
  39129. /**
  39130. * Add a new key and its corresponding value
  39131. * @param key the key to add
  39132. * @param value the value corresponding to the key
  39133. * @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
  39134. */
  39135. add(key: string, value: T): boolean;
  39136. /**
  39137. * Update a specific value associated to a key
  39138. * @param key defines the key to use
  39139. * @param value defines the value to store
  39140. * @returns true if the value was updated (or false if the key was not found)
  39141. */
  39142. set(key: string, value: T): boolean;
  39143. /**
  39144. * Get the element of the given key and remove it from the dictionary
  39145. * @param key defines the key to search
  39146. * @returns the value associated with the key or null if not found
  39147. */
  39148. getAndRemove(key: string): Nullable<T>;
  39149. /**
  39150. * Remove a key/value from the dictionary.
  39151. * @param key the key to remove
  39152. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39153. */
  39154. remove(key: string): boolean;
  39155. /**
  39156. * Clear the whole content of the dictionary
  39157. */
  39158. clear(): void;
  39159. /**
  39160. * Gets the current count
  39161. */
  39162. get count(): number;
  39163. /**
  39164. * Execute a callback on each key/val of the dictionary.
  39165. * Note that you can remove any element in this dictionary in the callback implementation
  39166. * @param callback the callback to execute on a given key/value pair
  39167. */
  39168. forEach(callback: (key: string, val: T) => void): void;
  39169. /**
  39170. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39171. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39172. * Note that you can remove any element in this dictionary in the callback implementation
  39173. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39174. * @returns the first item
  39175. */
  39176. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39177. private _count;
  39178. private _data;
  39179. }
  39180. }
  39181. declare module "babylonjs/Collisions/collisionCoordinator" {
  39182. import { Nullable } from "babylonjs/types";
  39183. import { Scene } from "babylonjs/scene";
  39184. import { Vector3 } from "babylonjs/Maths/math.vector";
  39185. import { Collider } from "babylonjs/Collisions/collider";
  39186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39187. /** @hidden */
  39188. export interface ICollisionCoordinator {
  39189. createCollider(): Collider;
  39190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39191. init(scene: Scene): void;
  39192. }
  39193. /** @hidden */
  39194. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39195. private _scene;
  39196. private _scaledPosition;
  39197. private _scaledVelocity;
  39198. private _finalPosition;
  39199. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39200. createCollider(): Collider;
  39201. init(scene: Scene): void;
  39202. private _collideWithWorld;
  39203. }
  39204. }
  39205. declare module "babylonjs/Inputs/scene.inputManager" {
  39206. import { Nullable } from "babylonjs/types";
  39207. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39208. import { Vector2 } from "babylonjs/Maths/math.vector";
  39209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39210. import { Scene } from "babylonjs/scene";
  39211. /**
  39212. * Class used to manage all inputs for the scene.
  39213. */
  39214. export class InputManager {
  39215. /** The distance in pixel that you have to move to prevent some events */
  39216. static DragMovementThreshold: number;
  39217. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39218. static LongPressDelay: number;
  39219. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39220. static DoubleClickDelay: number;
  39221. /** If you need to check double click without raising a single click at first click, enable this flag */
  39222. static ExclusiveDoubleClickMode: boolean;
  39223. private _wheelEventName;
  39224. private _onPointerMove;
  39225. private _onPointerDown;
  39226. private _onPointerUp;
  39227. private _initClickEvent;
  39228. private _initActionManager;
  39229. private _delayedSimpleClick;
  39230. private _delayedSimpleClickTimeout;
  39231. private _previousDelayedSimpleClickTimeout;
  39232. private _meshPickProceed;
  39233. private _previousButtonPressed;
  39234. private _currentPickResult;
  39235. private _previousPickResult;
  39236. private _totalPointersPressed;
  39237. private _doubleClickOccured;
  39238. private _pointerOverMesh;
  39239. private _pickedDownMesh;
  39240. private _pickedUpMesh;
  39241. private _pointerX;
  39242. private _pointerY;
  39243. private _unTranslatedPointerX;
  39244. private _unTranslatedPointerY;
  39245. private _startingPointerPosition;
  39246. private _previousStartingPointerPosition;
  39247. private _startingPointerTime;
  39248. private _previousStartingPointerTime;
  39249. private _pointerCaptures;
  39250. private _onKeyDown;
  39251. private _onKeyUp;
  39252. private _onCanvasFocusObserver;
  39253. private _onCanvasBlurObserver;
  39254. private _scene;
  39255. /**
  39256. * Creates a new InputManager
  39257. * @param scene defines the hosting scene
  39258. */
  39259. constructor(scene: Scene);
  39260. /**
  39261. * Gets the mesh that is currently under the pointer
  39262. */
  39263. get meshUnderPointer(): Nullable<AbstractMesh>;
  39264. /**
  39265. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39266. */
  39267. get unTranslatedPointer(): Vector2;
  39268. /**
  39269. * Gets or sets the current on-screen X position of the pointer
  39270. */
  39271. get pointerX(): number;
  39272. set pointerX(value: number);
  39273. /**
  39274. * Gets or sets the current on-screen Y position of the pointer
  39275. */
  39276. get pointerY(): number;
  39277. set pointerY(value: number);
  39278. private _updatePointerPosition;
  39279. private _processPointerMove;
  39280. private _setRayOnPointerInfo;
  39281. private _checkPrePointerObservable;
  39282. /**
  39283. * Use this method to simulate a pointer move on a mesh
  39284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39287. */
  39288. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39289. /**
  39290. * Use this method to simulate a pointer down on a mesh
  39291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39294. */
  39295. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39296. private _processPointerDown;
  39297. /** @hidden */
  39298. _isPointerSwiping(): boolean;
  39299. /**
  39300. * Use this method to simulate a pointer up on a mesh
  39301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39304. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39305. */
  39306. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39307. private _processPointerUp;
  39308. /**
  39309. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39310. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39311. * @returns true if the pointer was captured
  39312. */
  39313. isPointerCaptured(pointerId?: number): boolean;
  39314. /**
  39315. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39316. * @param attachUp defines if you want to attach events to pointerup
  39317. * @param attachDown defines if you want to attach events to pointerdown
  39318. * @param attachMove defines if you want to attach events to pointermove
  39319. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39320. */
  39321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39322. /**
  39323. * Detaches all event handlers
  39324. */
  39325. detachControl(): void;
  39326. /**
  39327. * Force the value of meshUnderPointer
  39328. * @param mesh defines the mesh to use
  39329. */
  39330. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39331. /**
  39332. * Gets the mesh under the pointer
  39333. * @returns a Mesh or null if no mesh is under the pointer
  39334. */
  39335. getPointerOverMesh(): Nullable<AbstractMesh>;
  39336. }
  39337. }
  39338. declare module "babylonjs/Animations/animationGroup" {
  39339. import { Animatable } from "babylonjs/Animations/animatable";
  39340. import { Animation } from "babylonjs/Animations/animation";
  39341. import { Scene, IDisposable } from "babylonjs/scene";
  39342. import { Observable } from "babylonjs/Misc/observable";
  39343. import { Nullable } from "babylonjs/types";
  39344. import "babylonjs/Animations/animatable";
  39345. /**
  39346. * This class defines the direct association between an animation and a target
  39347. */
  39348. export class TargetedAnimation {
  39349. /**
  39350. * Animation to perform
  39351. */
  39352. animation: Animation;
  39353. /**
  39354. * Target to animate
  39355. */
  39356. target: any;
  39357. /**
  39358. * Returns the string "TargetedAnimation"
  39359. * @returns "TargetedAnimation"
  39360. */
  39361. getClassName(): string;
  39362. /**
  39363. * Serialize the object
  39364. * @returns the JSON object representing the current entity
  39365. */
  39366. serialize(): any;
  39367. }
  39368. /**
  39369. * Use this class to create coordinated animations on multiple targets
  39370. */
  39371. export class AnimationGroup implements IDisposable {
  39372. /** The name of the animation group */
  39373. name: string;
  39374. private _scene;
  39375. private _targetedAnimations;
  39376. private _animatables;
  39377. private _from;
  39378. private _to;
  39379. private _isStarted;
  39380. private _isPaused;
  39381. private _speedRatio;
  39382. private _loopAnimation;
  39383. private _isAdditive;
  39384. /**
  39385. * Gets or sets the unique id of the node
  39386. */
  39387. uniqueId: number;
  39388. /**
  39389. * This observable will notify when one animation have ended
  39390. */
  39391. onAnimationEndObservable: Observable<TargetedAnimation>;
  39392. /**
  39393. * Observer raised when one animation loops
  39394. */
  39395. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39396. /**
  39397. * Observer raised when all animations have looped
  39398. */
  39399. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39400. /**
  39401. * This observable will notify when all animations have ended.
  39402. */
  39403. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39404. /**
  39405. * This observable will notify when all animations have paused.
  39406. */
  39407. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39408. /**
  39409. * This observable will notify when all animations are playing.
  39410. */
  39411. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39412. /**
  39413. * Gets the first frame
  39414. */
  39415. get from(): number;
  39416. /**
  39417. * Gets the last frame
  39418. */
  39419. get to(): number;
  39420. /**
  39421. * Define if the animations are started
  39422. */
  39423. get isStarted(): boolean;
  39424. /**
  39425. * Gets a value indicating that the current group is playing
  39426. */
  39427. get isPlaying(): boolean;
  39428. /**
  39429. * Gets or sets the speed ratio to use for all animations
  39430. */
  39431. get speedRatio(): number;
  39432. /**
  39433. * Gets or sets the speed ratio to use for all animations
  39434. */
  39435. set speedRatio(value: number);
  39436. /**
  39437. * Gets or sets if all animations should loop or not
  39438. */
  39439. get loopAnimation(): boolean;
  39440. set loopAnimation(value: boolean);
  39441. /**
  39442. * Gets or sets if all animations should be evaluated additively
  39443. */
  39444. get isAdditive(): boolean;
  39445. set isAdditive(value: boolean);
  39446. /**
  39447. * Gets the targeted animations for this animation group
  39448. */
  39449. get targetedAnimations(): Array<TargetedAnimation>;
  39450. /**
  39451. * returning the list of animatables controlled by this animation group.
  39452. */
  39453. get animatables(): Array<Animatable>;
  39454. /**
  39455. * Gets the list of target animations
  39456. */
  39457. get children(): TargetedAnimation[];
  39458. /**
  39459. * Instantiates a new Animation Group.
  39460. * This helps managing several animations at once.
  39461. * @see https://doc.babylonjs.com/how_to/group
  39462. * @param name Defines the name of the group
  39463. * @param scene Defines the scene the group belongs to
  39464. */
  39465. constructor(
  39466. /** The name of the animation group */
  39467. name: string, scene?: Nullable<Scene>);
  39468. /**
  39469. * Add an animation (with its target) in the group
  39470. * @param animation defines the animation we want to add
  39471. * @param target defines the target of the animation
  39472. * @returns the TargetedAnimation object
  39473. */
  39474. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39475. /**
  39476. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39477. * It can add constant keys at begin or end
  39478. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39479. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39480. * @returns the animation group
  39481. */
  39482. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39483. private _animationLoopCount;
  39484. private _animationLoopFlags;
  39485. private _processLoop;
  39486. /**
  39487. * Start all animations on given targets
  39488. * @param loop defines if animations must loop
  39489. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39490. * @param from defines the from key (optional)
  39491. * @param to defines the to key (optional)
  39492. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39493. * @returns the current animation group
  39494. */
  39495. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39496. /**
  39497. * Pause all animations
  39498. * @returns the animation group
  39499. */
  39500. pause(): AnimationGroup;
  39501. /**
  39502. * Play all animations to initial state
  39503. * This function will start() the animations if they were not started or will restart() them if they were paused
  39504. * @param loop defines if animations must loop
  39505. * @returns the animation group
  39506. */
  39507. play(loop?: boolean): AnimationGroup;
  39508. /**
  39509. * Reset all animations to initial state
  39510. * @returns the animation group
  39511. */
  39512. reset(): AnimationGroup;
  39513. /**
  39514. * Restart animations from key 0
  39515. * @returns the animation group
  39516. */
  39517. restart(): AnimationGroup;
  39518. /**
  39519. * Stop all animations
  39520. * @returns the animation group
  39521. */
  39522. stop(): AnimationGroup;
  39523. /**
  39524. * Set animation weight for all animatables
  39525. * @param weight defines the weight to use
  39526. * @return the animationGroup
  39527. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39528. */
  39529. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39530. /**
  39531. * Synchronize and normalize all animatables with a source animatable
  39532. * @param root defines the root animatable to synchronize with
  39533. * @return the animationGroup
  39534. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39535. */
  39536. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39537. /**
  39538. * Goes to a specific frame in this animation group
  39539. * @param frame the frame number to go to
  39540. * @return the animationGroup
  39541. */
  39542. goToFrame(frame: number): AnimationGroup;
  39543. /**
  39544. * Dispose all associated resources
  39545. */
  39546. dispose(): void;
  39547. private _checkAnimationGroupEnded;
  39548. /**
  39549. * Clone the current animation group and returns a copy
  39550. * @param newName defines the name of the new group
  39551. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39552. * @returns the new aniamtion group
  39553. */
  39554. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39555. /**
  39556. * Serializes the animationGroup to an object
  39557. * @returns Serialized object
  39558. */
  39559. serialize(): any;
  39560. /**
  39561. * Returns a new AnimationGroup object parsed from the source provided.
  39562. * @param parsedAnimationGroup defines the source
  39563. * @param scene defines the scene that will receive the animationGroup
  39564. * @returns a new AnimationGroup
  39565. */
  39566. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39567. /**
  39568. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39569. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39570. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39571. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39572. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39573. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39574. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39575. */
  39576. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39577. /**
  39578. * Returns the string "AnimationGroup"
  39579. * @returns "AnimationGroup"
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Creates a detailled string about the object
  39584. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39585. * @returns a string representing the object
  39586. */
  39587. toString(fullDetails?: boolean): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/scene" {
  39591. import { Nullable } from "babylonjs/types";
  39592. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39593. import { Observable } from "babylonjs/Misc/observable";
  39594. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39595. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39596. import { Geometry } from "babylonjs/Meshes/geometry";
  39597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39600. import { Mesh } from "babylonjs/Meshes/mesh";
  39601. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39602. import { Bone } from "babylonjs/Bones/bone";
  39603. import { Skeleton } from "babylonjs/Bones/skeleton";
  39604. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39605. import { Camera } from "babylonjs/Cameras/camera";
  39606. import { AbstractScene } from "babylonjs/abstractScene";
  39607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39609. import { Material } from "babylonjs/Materials/material";
  39610. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39611. import { Effect } from "babylonjs/Materials/effect";
  39612. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39613. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39614. import { Light } from "babylonjs/Lights/light";
  39615. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39616. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39617. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39618. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39620. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39621. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39622. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39623. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39624. import { Engine } from "babylonjs/Engines/engine";
  39625. import { Node } from "babylonjs/node";
  39626. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39627. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39628. import { WebRequest } from "babylonjs/Misc/webRequest";
  39629. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39630. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39631. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39632. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39633. import { Plane } from "babylonjs/Maths/math.plane";
  39634. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39635. import { Ray } from "babylonjs/Culling/ray";
  39636. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39637. import { Animation } from "babylonjs/Animations/animation";
  39638. import { Animatable } from "babylonjs/Animations/animatable";
  39639. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39641. import { Collider } from "babylonjs/Collisions/collider";
  39642. /**
  39643. * Define an interface for all classes that will hold resources
  39644. */
  39645. export interface IDisposable {
  39646. /**
  39647. * Releases all held resources
  39648. */
  39649. dispose(): void;
  39650. }
  39651. /** Interface defining initialization parameters for Scene class */
  39652. export interface SceneOptions {
  39653. /**
  39654. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39655. * It will improve performance when the number of geometries becomes important.
  39656. */
  39657. useGeometryUniqueIdsMap?: boolean;
  39658. /**
  39659. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39660. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39661. */
  39662. useMaterialMeshMap?: boolean;
  39663. /**
  39664. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39665. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39666. */
  39667. useClonedMeshMap?: boolean;
  39668. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39669. virtual?: boolean;
  39670. }
  39671. /**
  39672. * Represents a scene to be rendered by the engine.
  39673. * @see https://doc.babylonjs.com/features/scene
  39674. */
  39675. export class Scene extends AbstractScene implements IAnimatable {
  39676. /** The fog is deactivated */
  39677. static readonly FOGMODE_NONE: number;
  39678. /** The fog density is following an exponential function */
  39679. static readonly FOGMODE_EXP: number;
  39680. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39681. static readonly FOGMODE_EXP2: number;
  39682. /** The fog density is following a linear function. */
  39683. static readonly FOGMODE_LINEAR: number;
  39684. /**
  39685. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39686. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39687. */
  39688. static MinDeltaTime: number;
  39689. /**
  39690. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39692. */
  39693. static MaxDeltaTime: number;
  39694. /**
  39695. * Factory used to create the default material.
  39696. * @param name The name of the material to create
  39697. * @param scene The scene to create the material for
  39698. * @returns The default material
  39699. */
  39700. static DefaultMaterialFactory(scene: Scene): Material;
  39701. /**
  39702. * Factory used to create the a collision coordinator.
  39703. * @returns The collision coordinator
  39704. */
  39705. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39706. /** @hidden */
  39707. _inputManager: InputManager;
  39708. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39709. cameraToUseForPointers: Nullable<Camera>;
  39710. /** @hidden */
  39711. readonly _isScene: boolean;
  39712. /** @hidden */
  39713. _blockEntityCollection: boolean;
  39714. /**
  39715. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39716. */
  39717. autoClear: boolean;
  39718. /**
  39719. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39720. */
  39721. autoClearDepthAndStencil: boolean;
  39722. /**
  39723. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39724. */
  39725. clearColor: Color4;
  39726. /**
  39727. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39728. */
  39729. ambientColor: Color3;
  39730. /**
  39731. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39732. * It should only be one of the following (if not the default embedded one):
  39733. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39734. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39735. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39736. * The material properties need to be setup according to the type of texture in use.
  39737. */
  39738. environmentBRDFTexture: BaseTexture;
  39739. /** @hidden */
  39740. protected _environmentTexture: Nullable<BaseTexture>;
  39741. /**
  39742. * Texture used in all pbr material as the reflection texture.
  39743. * As in the majority of the scene they are the same (exception for multi room and so on),
  39744. * this is easier to reference from here than from all the materials.
  39745. */
  39746. get environmentTexture(): Nullable<BaseTexture>;
  39747. /**
  39748. * Texture used in all pbr material as the reflection texture.
  39749. * As in the majority of the scene they are the same (exception for multi room and so on),
  39750. * this is easier to set here than in all the materials.
  39751. */
  39752. set environmentTexture(value: Nullable<BaseTexture>);
  39753. /** @hidden */
  39754. protected _environmentIntensity: number;
  39755. /**
  39756. * Intensity of the environment in all pbr material.
  39757. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39758. * As in the majority of the scene they are the same (exception for multi room and so on),
  39759. * this is easier to reference from here than from all the materials.
  39760. */
  39761. get environmentIntensity(): number;
  39762. /**
  39763. * Intensity of the environment in all pbr material.
  39764. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39765. * As in the majority of the scene they are the same (exception for multi room and so on),
  39766. * this is easier to set here than in all the materials.
  39767. */
  39768. set environmentIntensity(value: number);
  39769. /** @hidden */
  39770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39771. /**
  39772. * Default image processing configuration used either in the rendering
  39773. * Forward main pass or through the imageProcessingPostProcess if present.
  39774. * As in the majority of the scene they are the same (exception for multi camera),
  39775. * this is easier to reference from here than from all the materials and post process.
  39776. *
  39777. * No setter as we it is a shared configuration, you can set the values instead.
  39778. */
  39779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39780. private _forceWireframe;
  39781. /**
  39782. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39783. */
  39784. set forceWireframe(value: boolean);
  39785. get forceWireframe(): boolean;
  39786. private _skipFrustumClipping;
  39787. /**
  39788. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39789. */
  39790. set skipFrustumClipping(value: boolean);
  39791. get skipFrustumClipping(): boolean;
  39792. private _forcePointsCloud;
  39793. /**
  39794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39795. */
  39796. set forcePointsCloud(value: boolean);
  39797. get forcePointsCloud(): boolean;
  39798. /**
  39799. * Gets or sets the active clipplane 1
  39800. */
  39801. clipPlane: Nullable<Plane>;
  39802. /**
  39803. * Gets or sets the active clipplane 2
  39804. */
  39805. clipPlane2: Nullable<Plane>;
  39806. /**
  39807. * Gets or sets the active clipplane 3
  39808. */
  39809. clipPlane3: Nullable<Plane>;
  39810. /**
  39811. * Gets or sets the active clipplane 4
  39812. */
  39813. clipPlane4: Nullable<Plane>;
  39814. /**
  39815. * Gets or sets the active clipplane 5
  39816. */
  39817. clipPlane5: Nullable<Plane>;
  39818. /**
  39819. * Gets or sets the active clipplane 6
  39820. */
  39821. clipPlane6: Nullable<Plane>;
  39822. /**
  39823. * Gets or sets a boolean indicating if animations are enabled
  39824. */
  39825. animationsEnabled: boolean;
  39826. private _animationPropertiesOverride;
  39827. /**
  39828. * Gets or sets the animation properties override
  39829. */
  39830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39831. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39832. /**
  39833. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39834. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39835. */
  39836. useConstantAnimationDeltaTime: boolean;
  39837. /**
  39838. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39839. * Please note that it requires to run a ray cast through the scene on every frame
  39840. */
  39841. constantlyUpdateMeshUnderPointer: boolean;
  39842. /**
  39843. * Defines the HTML cursor to use when hovering over interactive elements
  39844. */
  39845. hoverCursor: string;
  39846. /**
  39847. * Defines the HTML default cursor to use (empty by default)
  39848. */
  39849. defaultCursor: string;
  39850. /**
  39851. * Defines whether cursors are handled by the scene.
  39852. */
  39853. doNotHandleCursors: boolean;
  39854. /**
  39855. * This is used to call preventDefault() on pointer down
  39856. * in order to block unwanted artifacts like system double clicks
  39857. */
  39858. preventDefaultOnPointerDown: boolean;
  39859. /**
  39860. * This is used to call preventDefault() on pointer up
  39861. * in order to block unwanted artifacts like system double clicks
  39862. */
  39863. preventDefaultOnPointerUp: boolean;
  39864. /**
  39865. * Gets or sets user defined metadata
  39866. */
  39867. metadata: any;
  39868. /**
  39869. * For internal use only. Please do not use.
  39870. */
  39871. reservedDataStore: any;
  39872. /**
  39873. * Gets the name of the plugin used to load this scene (null by default)
  39874. */
  39875. loadingPluginName: string;
  39876. /**
  39877. * Use this array to add regular expressions used to disable offline support for specific urls
  39878. */
  39879. disableOfflineSupportExceptionRules: RegExp[];
  39880. /**
  39881. * An event triggered when the scene is disposed.
  39882. */
  39883. onDisposeObservable: Observable<Scene>;
  39884. private _onDisposeObserver;
  39885. /** Sets a function to be executed when this scene is disposed. */
  39886. set onDispose(callback: () => void);
  39887. /**
  39888. * An event triggered before rendering the scene (right after animations and physics)
  39889. */
  39890. onBeforeRenderObservable: Observable<Scene>;
  39891. private _onBeforeRenderObserver;
  39892. /** Sets a function to be executed before rendering this scene */
  39893. set beforeRender(callback: Nullable<() => void>);
  39894. /**
  39895. * An event triggered after rendering the scene
  39896. */
  39897. onAfterRenderObservable: Observable<Scene>;
  39898. /**
  39899. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39900. */
  39901. onAfterRenderCameraObservable: Observable<Camera>;
  39902. private _onAfterRenderObserver;
  39903. /** Sets a function to be executed after rendering this scene */
  39904. set afterRender(callback: Nullable<() => void>);
  39905. /**
  39906. * An event triggered before animating the scene
  39907. */
  39908. onBeforeAnimationsObservable: Observable<Scene>;
  39909. /**
  39910. * An event triggered after animations processing
  39911. */
  39912. onAfterAnimationsObservable: Observable<Scene>;
  39913. /**
  39914. * An event triggered before draw calls are ready to be sent
  39915. */
  39916. onBeforeDrawPhaseObservable: Observable<Scene>;
  39917. /**
  39918. * An event triggered after draw calls have been sent
  39919. */
  39920. onAfterDrawPhaseObservable: Observable<Scene>;
  39921. /**
  39922. * An event triggered when the scene is ready
  39923. */
  39924. onReadyObservable: Observable<Scene>;
  39925. /**
  39926. * An event triggered before rendering a camera
  39927. */
  39928. onBeforeCameraRenderObservable: Observable<Camera>;
  39929. private _onBeforeCameraRenderObserver;
  39930. /** Sets a function to be executed before rendering a camera*/
  39931. set beforeCameraRender(callback: () => void);
  39932. /**
  39933. * An event triggered after rendering a camera
  39934. */
  39935. onAfterCameraRenderObservable: Observable<Camera>;
  39936. private _onAfterCameraRenderObserver;
  39937. /** Sets a function to be executed after rendering a camera*/
  39938. set afterCameraRender(callback: () => void);
  39939. /**
  39940. * An event triggered when active meshes evaluation is about to start
  39941. */
  39942. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39943. /**
  39944. * An event triggered when active meshes evaluation is done
  39945. */
  39946. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39947. /**
  39948. * An event triggered when particles rendering is about to start
  39949. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39950. */
  39951. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39952. /**
  39953. * An event triggered when particles rendering is done
  39954. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39955. */
  39956. onAfterParticlesRenderingObservable: Observable<Scene>;
  39957. /**
  39958. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39959. */
  39960. onDataLoadedObservable: Observable<Scene>;
  39961. /**
  39962. * An event triggered when a camera is created
  39963. */
  39964. onNewCameraAddedObservable: Observable<Camera>;
  39965. /**
  39966. * An event triggered when a camera is removed
  39967. */
  39968. onCameraRemovedObservable: Observable<Camera>;
  39969. /**
  39970. * An event triggered when a light is created
  39971. */
  39972. onNewLightAddedObservable: Observable<Light>;
  39973. /**
  39974. * An event triggered when a light is removed
  39975. */
  39976. onLightRemovedObservable: Observable<Light>;
  39977. /**
  39978. * An event triggered when a geometry is created
  39979. */
  39980. onNewGeometryAddedObservable: Observable<Geometry>;
  39981. /**
  39982. * An event triggered when a geometry is removed
  39983. */
  39984. onGeometryRemovedObservable: Observable<Geometry>;
  39985. /**
  39986. * An event triggered when a transform node is created
  39987. */
  39988. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39989. /**
  39990. * An event triggered when a transform node is removed
  39991. */
  39992. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39993. /**
  39994. * An event triggered when a mesh is created
  39995. */
  39996. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39997. /**
  39998. * An event triggered when a mesh is removed
  39999. */
  40000. onMeshRemovedObservable: Observable<AbstractMesh>;
  40001. /**
  40002. * An event triggered when a skeleton is created
  40003. */
  40004. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40005. /**
  40006. * An event triggered when a skeleton is removed
  40007. */
  40008. onSkeletonRemovedObservable: Observable<Skeleton>;
  40009. /**
  40010. * An event triggered when a material is created
  40011. */
  40012. onNewMaterialAddedObservable: Observable<Material>;
  40013. /**
  40014. * An event triggered when a material is removed
  40015. */
  40016. onMaterialRemovedObservable: Observable<Material>;
  40017. /**
  40018. * An event triggered when a texture is created
  40019. */
  40020. onNewTextureAddedObservable: Observable<BaseTexture>;
  40021. /**
  40022. * An event triggered when a texture is removed
  40023. */
  40024. onTextureRemovedObservable: Observable<BaseTexture>;
  40025. /**
  40026. * An event triggered when render targets are about to be rendered
  40027. * Can happen multiple times per frame.
  40028. */
  40029. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40030. /**
  40031. * An event triggered when render targets were rendered.
  40032. * Can happen multiple times per frame.
  40033. */
  40034. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40035. /**
  40036. * An event triggered before calculating deterministic simulation step
  40037. */
  40038. onBeforeStepObservable: Observable<Scene>;
  40039. /**
  40040. * An event triggered after calculating deterministic simulation step
  40041. */
  40042. onAfterStepObservable: Observable<Scene>;
  40043. /**
  40044. * An event triggered when the activeCamera property is updated
  40045. */
  40046. onActiveCameraChanged: Observable<Scene>;
  40047. /**
  40048. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40049. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40050. * 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)
  40051. */
  40052. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40053. /**
  40054. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40055. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40056. * 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)
  40057. */
  40058. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40059. /**
  40060. * This Observable will when a mesh has been imported into the scene.
  40061. */
  40062. onMeshImportedObservable: Observable<AbstractMesh>;
  40063. /**
  40064. * This Observable will when an animation file has been imported into the scene.
  40065. */
  40066. onAnimationFileImportedObservable: Observable<Scene>;
  40067. /**
  40068. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40069. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40070. */
  40071. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40072. /** @hidden */
  40073. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40074. /**
  40075. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40076. */
  40077. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40078. /**
  40079. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40080. */
  40081. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40082. /**
  40083. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40084. */
  40085. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40086. /** Callback called when a pointer move is detected */
  40087. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40088. /** Callback called when a pointer down is detected */
  40089. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40090. /** Callback called when a pointer up is detected */
  40091. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40092. /** Callback called when a pointer pick is detected */
  40093. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40094. /**
  40095. * 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).
  40096. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40097. */
  40098. onPrePointerObservable: Observable<PointerInfoPre>;
  40099. /**
  40100. * Observable event triggered each time an input event is received from the rendering canvas
  40101. */
  40102. onPointerObservable: Observable<PointerInfo>;
  40103. /**
  40104. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40105. */
  40106. get unTranslatedPointer(): Vector2;
  40107. /**
  40108. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40109. */
  40110. static get DragMovementThreshold(): number;
  40111. static set DragMovementThreshold(value: number);
  40112. /**
  40113. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40114. */
  40115. static get LongPressDelay(): number;
  40116. static set LongPressDelay(value: number);
  40117. /**
  40118. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40119. */
  40120. static get DoubleClickDelay(): number;
  40121. static set DoubleClickDelay(value: number);
  40122. /** If you need to check double click without raising a single click at first click, enable this flag */
  40123. static get ExclusiveDoubleClickMode(): boolean;
  40124. static set ExclusiveDoubleClickMode(value: boolean);
  40125. /** @hidden */
  40126. _mirroredCameraPosition: Nullable<Vector3>;
  40127. /**
  40128. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40129. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40130. */
  40131. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40132. /**
  40133. * Observable event triggered each time an keyboard event is received from the hosting window
  40134. */
  40135. onKeyboardObservable: Observable<KeyboardInfo>;
  40136. private _useRightHandedSystem;
  40137. /**
  40138. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40139. */
  40140. set useRightHandedSystem(value: boolean);
  40141. get useRightHandedSystem(): boolean;
  40142. private _timeAccumulator;
  40143. private _currentStepId;
  40144. private _currentInternalStep;
  40145. /**
  40146. * Sets the step Id used by deterministic lock step
  40147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40148. * @param newStepId defines the step Id
  40149. */
  40150. setStepId(newStepId: number): void;
  40151. /**
  40152. * Gets the step Id used by deterministic lock step
  40153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40154. * @returns the step Id
  40155. */
  40156. getStepId(): number;
  40157. /**
  40158. * Gets the internal step used by deterministic lock step
  40159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40160. * @returns the internal step
  40161. */
  40162. getInternalStep(): number;
  40163. private _fogEnabled;
  40164. /**
  40165. * Gets or sets a boolean indicating if fog is enabled on this scene
  40166. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40167. * (Default is true)
  40168. */
  40169. set fogEnabled(value: boolean);
  40170. get fogEnabled(): boolean;
  40171. private _fogMode;
  40172. /**
  40173. * Gets or sets the fog mode to use
  40174. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40175. * | mode | value |
  40176. * | --- | --- |
  40177. * | FOGMODE_NONE | 0 |
  40178. * | FOGMODE_EXP | 1 |
  40179. * | FOGMODE_EXP2 | 2 |
  40180. * | FOGMODE_LINEAR | 3 |
  40181. */
  40182. set fogMode(value: number);
  40183. get fogMode(): number;
  40184. /**
  40185. * Gets or sets the fog color to use
  40186. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40187. * (Default is Color3(0.2, 0.2, 0.3))
  40188. */
  40189. fogColor: Color3;
  40190. /**
  40191. * Gets or sets the fog density to use
  40192. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40193. * (Default is 0.1)
  40194. */
  40195. fogDensity: number;
  40196. /**
  40197. * Gets or sets the fog start distance to use
  40198. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40199. * (Default is 0)
  40200. */
  40201. fogStart: number;
  40202. /**
  40203. * Gets or sets the fog end distance to use
  40204. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40205. * (Default is 1000)
  40206. */
  40207. fogEnd: number;
  40208. /**
  40209. * Flag indicating that the frame buffer binding is handled by another component
  40210. */
  40211. prePass: boolean;
  40212. private _shadowsEnabled;
  40213. /**
  40214. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40215. */
  40216. set shadowsEnabled(value: boolean);
  40217. get shadowsEnabled(): boolean;
  40218. private _lightsEnabled;
  40219. /**
  40220. * Gets or sets a boolean indicating if lights are enabled on this scene
  40221. */
  40222. set lightsEnabled(value: boolean);
  40223. get lightsEnabled(): boolean;
  40224. /** All of the active cameras added to this scene. */
  40225. activeCameras: Camera[];
  40226. /** @hidden */
  40227. _activeCamera: Nullable<Camera>;
  40228. /** Gets or sets the current active camera */
  40229. get activeCamera(): Nullable<Camera>;
  40230. set activeCamera(value: Nullable<Camera>);
  40231. private _defaultMaterial;
  40232. /** The default material used on meshes when no material is affected */
  40233. get defaultMaterial(): Material;
  40234. /** The default material used on meshes when no material is affected */
  40235. set defaultMaterial(value: Material);
  40236. private _texturesEnabled;
  40237. /**
  40238. * Gets or sets a boolean indicating if textures are enabled on this scene
  40239. */
  40240. set texturesEnabled(value: boolean);
  40241. get texturesEnabled(): boolean;
  40242. /**
  40243. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40244. */
  40245. physicsEnabled: boolean;
  40246. /**
  40247. * Gets or sets a boolean indicating if particles are enabled on this scene
  40248. */
  40249. particlesEnabled: boolean;
  40250. /**
  40251. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40252. */
  40253. spritesEnabled: boolean;
  40254. private _skeletonsEnabled;
  40255. /**
  40256. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40257. */
  40258. set skeletonsEnabled(value: boolean);
  40259. get skeletonsEnabled(): boolean;
  40260. /**
  40261. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40262. */
  40263. lensFlaresEnabled: boolean;
  40264. /**
  40265. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40266. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40267. */
  40268. collisionsEnabled: boolean;
  40269. private _collisionCoordinator;
  40270. /** @hidden */
  40271. get collisionCoordinator(): ICollisionCoordinator;
  40272. /**
  40273. * Defines the gravity applied to this scene (used only for collisions)
  40274. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40275. */
  40276. gravity: Vector3;
  40277. /**
  40278. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40279. */
  40280. postProcessesEnabled: boolean;
  40281. /**
  40282. * The list of postprocesses added to the scene
  40283. */
  40284. postProcesses: PostProcess[];
  40285. /**
  40286. * Gets the current postprocess manager
  40287. */
  40288. postProcessManager: PostProcessManager;
  40289. /**
  40290. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40291. */
  40292. renderTargetsEnabled: boolean;
  40293. /**
  40294. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40295. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40296. */
  40297. dumpNextRenderTargets: boolean;
  40298. /**
  40299. * The list of user defined render targets added to the scene
  40300. */
  40301. customRenderTargets: RenderTargetTexture[];
  40302. /**
  40303. * Defines if texture loading must be delayed
  40304. * If true, textures will only be loaded when they need to be rendered
  40305. */
  40306. useDelayedTextureLoading: boolean;
  40307. /**
  40308. * Gets the list of meshes imported to the scene through SceneLoader
  40309. */
  40310. importedMeshesFiles: String[];
  40311. /**
  40312. * Gets or sets a boolean indicating if probes are enabled on this scene
  40313. */
  40314. probesEnabled: boolean;
  40315. /**
  40316. * Gets or sets the current offline provider to use to store scene data
  40317. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40318. */
  40319. offlineProvider: IOfflineProvider;
  40320. /**
  40321. * Gets or sets the action manager associated with the scene
  40322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40323. */
  40324. actionManager: AbstractActionManager;
  40325. private _meshesForIntersections;
  40326. /**
  40327. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40328. */
  40329. proceduralTexturesEnabled: boolean;
  40330. private _engine;
  40331. private _totalVertices;
  40332. /** @hidden */
  40333. _activeIndices: PerfCounter;
  40334. /** @hidden */
  40335. _activeParticles: PerfCounter;
  40336. /** @hidden */
  40337. _activeBones: PerfCounter;
  40338. private _animationRatio;
  40339. /** @hidden */
  40340. _animationTimeLast: number;
  40341. /** @hidden */
  40342. _animationTime: number;
  40343. /**
  40344. * Gets or sets a general scale for animation speed
  40345. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40346. */
  40347. animationTimeScale: number;
  40348. /** @hidden */
  40349. _cachedMaterial: Nullable<Material>;
  40350. /** @hidden */
  40351. _cachedEffect: Nullable<Effect>;
  40352. /** @hidden */
  40353. _cachedVisibility: Nullable<number>;
  40354. private _renderId;
  40355. private _frameId;
  40356. private _executeWhenReadyTimeoutId;
  40357. private _intermediateRendering;
  40358. private _viewUpdateFlag;
  40359. private _projectionUpdateFlag;
  40360. /** @hidden */
  40361. _toBeDisposed: Nullable<IDisposable>[];
  40362. private _activeRequests;
  40363. /** @hidden */
  40364. _pendingData: any[];
  40365. private _isDisposed;
  40366. /**
  40367. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40368. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40369. */
  40370. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40371. private _activeMeshes;
  40372. private _processedMaterials;
  40373. private _renderTargets;
  40374. /** @hidden */
  40375. _activeParticleSystems: SmartArray<IParticleSystem>;
  40376. private _activeSkeletons;
  40377. private _softwareSkinnedMeshes;
  40378. private _renderingManager;
  40379. /** @hidden */
  40380. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40381. private _transformMatrix;
  40382. private _sceneUbo;
  40383. /** @hidden */
  40384. _viewMatrix: Matrix;
  40385. private _projectionMatrix;
  40386. /** @hidden */
  40387. _forcedViewPosition: Nullable<Vector3>;
  40388. /** @hidden */
  40389. _frustumPlanes: Plane[];
  40390. /**
  40391. * Gets the list of frustum planes (built from the active camera)
  40392. */
  40393. get frustumPlanes(): Plane[];
  40394. /**
  40395. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40396. * This is useful if there are more lights that the maximum simulteanous authorized
  40397. */
  40398. requireLightSorting: boolean;
  40399. /** @hidden */
  40400. readonly useMaterialMeshMap: boolean;
  40401. /** @hidden */
  40402. readonly useClonedMeshMap: boolean;
  40403. private _externalData;
  40404. private _uid;
  40405. /**
  40406. * @hidden
  40407. * Backing store of defined scene components.
  40408. */
  40409. _components: ISceneComponent[];
  40410. /**
  40411. * @hidden
  40412. * Backing store of defined scene components.
  40413. */
  40414. _serializableComponents: ISceneSerializableComponent[];
  40415. /**
  40416. * List of components to register on the next registration step.
  40417. */
  40418. private _transientComponents;
  40419. /**
  40420. * Registers the transient components if needed.
  40421. */
  40422. private _registerTransientComponents;
  40423. /**
  40424. * @hidden
  40425. * Add a component to the scene.
  40426. * Note that the ccomponent could be registered on th next frame if this is called after
  40427. * the register component stage.
  40428. * @param component Defines the component to add to the scene
  40429. */
  40430. _addComponent(component: ISceneComponent): void;
  40431. /**
  40432. * @hidden
  40433. * Gets a component from the scene.
  40434. * @param name defines the name of the component to retrieve
  40435. * @returns the component or null if not present
  40436. */
  40437. _getComponent(name: string): Nullable<ISceneComponent>;
  40438. /**
  40439. * @hidden
  40440. * Defines the actions happening before camera updates.
  40441. */
  40442. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40443. /**
  40444. * @hidden
  40445. * Defines the actions happening before clear the canvas.
  40446. */
  40447. _beforeClearStage: Stage<SimpleStageAction>;
  40448. /**
  40449. * @hidden
  40450. * Defines the actions when collecting render targets for the frame.
  40451. */
  40452. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40453. /**
  40454. * @hidden
  40455. * Defines the actions happening for one camera in the frame.
  40456. */
  40457. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40458. /**
  40459. * @hidden
  40460. * Defines the actions happening during the per mesh ready checks.
  40461. */
  40462. _isReadyForMeshStage: Stage<MeshStageAction>;
  40463. /**
  40464. * @hidden
  40465. * Defines the actions happening before evaluate active mesh checks.
  40466. */
  40467. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40468. /**
  40469. * @hidden
  40470. * Defines the actions happening during the evaluate sub mesh checks.
  40471. */
  40472. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40473. /**
  40474. * @hidden
  40475. * Defines the actions happening during the active mesh stage.
  40476. */
  40477. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40478. /**
  40479. * @hidden
  40480. * Defines the actions happening during the per camera render target step.
  40481. */
  40482. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40483. /**
  40484. * @hidden
  40485. * Defines the actions happening just before the active camera is drawing.
  40486. */
  40487. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40488. /**
  40489. * @hidden
  40490. * Defines the actions happening just before a render target is drawing.
  40491. */
  40492. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40493. /**
  40494. * @hidden
  40495. * Defines the actions happening just before a rendering group is drawing.
  40496. */
  40497. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40498. /**
  40499. * @hidden
  40500. * Defines the actions happening just before a mesh is drawing.
  40501. */
  40502. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40503. /**
  40504. * @hidden
  40505. * Defines the actions happening just after a mesh has been drawn.
  40506. */
  40507. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40508. /**
  40509. * @hidden
  40510. * Defines the actions happening just after a rendering group has been drawn.
  40511. */
  40512. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40513. /**
  40514. * @hidden
  40515. * Defines the actions happening just after the active camera has been drawn.
  40516. */
  40517. _afterCameraDrawStage: Stage<CameraStageAction>;
  40518. /**
  40519. * @hidden
  40520. * Defines the actions happening just after a render target has been drawn.
  40521. */
  40522. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40523. /**
  40524. * @hidden
  40525. * Defines the actions happening just after rendering all cameras and computing intersections.
  40526. */
  40527. _afterRenderStage: Stage<SimpleStageAction>;
  40528. /**
  40529. * @hidden
  40530. * Defines the actions happening when a pointer move event happens.
  40531. */
  40532. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40533. /**
  40534. * @hidden
  40535. * Defines the actions happening when a pointer down event happens.
  40536. */
  40537. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40538. /**
  40539. * @hidden
  40540. * Defines the actions happening when a pointer up event happens.
  40541. */
  40542. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40543. /**
  40544. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40545. */
  40546. private geometriesByUniqueId;
  40547. /**
  40548. * Creates a new Scene
  40549. * @param engine defines the engine to use to render this scene
  40550. * @param options defines the scene options
  40551. */
  40552. constructor(engine: Engine, options?: SceneOptions);
  40553. /**
  40554. * Gets a string idenfifying the name of the class
  40555. * @returns "Scene" string
  40556. */
  40557. getClassName(): string;
  40558. private _defaultMeshCandidates;
  40559. /**
  40560. * @hidden
  40561. */
  40562. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40563. private _defaultSubMeshCandidates;
  40564. /**
  40565. * @hidden
  40566. */
  40567. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40568. /**
  40569. * Sets the default candidate providers for the scene.
  40570. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40571. * and getCollidingSubMeshCandidates to their default function
  40572. */
  40573. setDefaultCandidateProviders(): void;
  40574. /**
  40575. * Gets the mesh that is currently under the pointer
  40576. */
  40577. get meshUnderPointer(): Nullable<AbstractMesh>;
  40578. /**
  40579. * Gets or sets the current on-screen X position of the pointer
  40580. */
  40581. get pointerX(): number;
  40582. set pointerX(value: number);
  40583. /**
  40584. * Gets or sets the current on-screen Y position of the pointer
  40585. */
  40586. get pointerY(): number;
  40587. set pointerY(value: number);
  40588. /**
  40589. * Gets the cached material (ie. the latest rendered one)
  40590. * @returns the cached material
  40591. */
  40592. getCachedMaterial(): Nullable<Material>;
  40593. /**
  40594. * Gets the cached effect (ie. the latest rendered one)
  40595. * @returns the cached effect
  40596. */
  40597. getCachedEffect(): Nullable<Effect>;
  40598. /**
  40599. * Gets the cached visibility state (ie. the latest rendered one)
  40600. * @returns the cached visibility state
  40601. */
  40602. getCachedVisibility(): Nullable<number>;
  40603. /**
  40604. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40605. * @param material defines the current material
  40606. * @param effect defines the current effect
  40607. * @param visibility defines the current visibility state
  40608. * @returns true if one parameter is not cached
  40609. */
  40610. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40611. /**
  40612. * Gets the engine associated with the scene
  40613. * @returns an Engine
  40614. */
  40615. getEngine(): Engine;
  40616. /**
  40617. * Gets the total number of vertices rendered per frame
  40618. * @returns the total number of vertices rendered per frame
  40619. */
  40620. getTotalVertices(): number;
  40621. /**
  40622. * Gets the performance counter for total vertices
  40623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40624. */
  40625. get totalVerticesPerfCounter(): PerfCounter;
  40626. /**
  40627. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40628. * @returns the total number of active indices rendered per frame
  40629. */
  40630. getActiveIndices(): number;
  40631. /**
  40632. * Gets the performance counter for active indices
  40633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40634. */
  40635. get totalActiveIndicesPerfCounter(): PerfCounter;
  40636. /**
  40637. * Gets the total number of active particles rendered per frame
  40638. * @returns the total number of active particles rendered per frame
  40639. */
  40640. getActiveParticles(): number;
  40641. /**
  40642. * Gets the performance counter for active particles
  40643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40644. */
  40645. get activeParticlesPerfCounter(): PerfCounter;
  40646. /**
  40647. * Gets the total number of active bones rendered per frame
  40648. * @returns the total number of active bones rendered per frame
  40649. */
  40650. getActiveBones(): number;
  40651. /**
  40652. * Gets the performance counter for active bones
  40653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40654. */
  40655. get activeBonesPerfCounter(): PerfCounter;
  40656. /**
  40657. * Gets the array of active meshes
  40658. * @returns an array of AbstractMesh
  40659. */
  40660. getActiveMeshes(): SmartArray<AbstractMesh>;
  40661. /**
  40662. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40663. * @returns a number
  40664. */
  40665. getAnimationRatio(): number;
  40666. /**
  40667. * Gets an unique Id for the current render phase
  40668. * @returns a number
  40669. */
  40670. getRenderId(): number;
  40671. /**
  40672. * Gets an unique Id for the current frame
  40673. * @returns a number
  40674. */
  40675. getFrameId(): number;
  40676. /** Call this function if you want to manually increment the render Id*/
  40677. incrementRenderId(): void;
  40678. private _createUbo;
  40679. /**
  40680. * Use this method to simulate a pointer move on a mesh
  40681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40684. * @returns the current scene
  40685. */
  40686. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40687. /**
  40688. * Use this method to simulate a pointer down on a mesh
  40689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40692. * @returns the current scene
  40693. */
  40694. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40695. /**
  40696. * Use this method to simulate a pointer up on a mesh
  40697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40701. * @returns the current scene
  40702. */
  40703. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40704. /**
  40705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40707. * @returns true if the pointer was captured
  40708. */
  40709. isPointerCaptured(pointerId?: number): boolean;
  40710. /**
  40711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40712. * @param attachUp defines if you want to attach events to pointerup
  40713. * @param attachDown defines if you want to attach events to pointerdown
  40714. * @param attachMove defines if you want to attach events to pointermove
  40715. */
  40716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40717. /** Detaches all event handlers*/
  40718. detachControl(): void;
  40719. /**
  40720. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40721. * Delay loaded resources are not taking in account
  40722. * @return true if all required resources are ready
  40723. */
  40724. isReady(): boolean;
  40725. /** Resets all cached information relative to material (including effect and visibility) */
  40726. resetCachedMaterial(): void;
  40727. /**
  40728. * Registers a function to be called before every frame render
  40729. * @param func defines the function to register
  40730. */
  40731. registerBeforeRender(func: () => void): void;
  40732. /**
  40733. * Unregisters a function called before every frame render
  40734. * @param func defines the function to unregister
  40735. */
  40736. unregisterBeforeRender(func: () => void): void;
  40737. /**
  40738. * Registers a function to be called after every frame render
  40739. * @param func defines the function to register
  40740. */
  40741. registerAfterRender(func: () => void): void;
  40742. /**
  40743. * Unregisters a function called after every frame render
  40744. * @param func defines the function to unregister
  40745. */
  40746. unregisterAfterRender(func: () => void): void;
  40747. private _executeOnceBeforeRender;
  40748. /**
  40749. * The provided function will run before render once and will be disposed afterwards.
  40750. * A timeout delay can be provided so that the function will be executed in N ms.
  40751. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40752. * @param func The function to be executed.
  40753. * @param timeout optional delay in ms
  40754. */
  40755. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40756. /** @hidden */
  40757. _addPendingData(data: any): void;
  40758. /** @hidden */
  40759. _removePendingData(data: any): void;
  40760. /**
  40761. * Returns the number of items waiting to be loaded
  40762. * @returns the number of items waiting to be loaded
  40763. */
  40764. getWaitingItemsCount(): number;
  40765. /**
  40766. * Returns a boolean indicating if the scene is still loading data
  40767. */
  40768. get isLoading(): boolean;
  40769. /**
  40770. * Registers a function to be executed when the scene is ready
  40771. * @param {Function} func - the function to be executed
  40772. */
  40773. executeWhenReady(func: () => void): void;
  40774. /**
  40775. * Returns a promise that resolves when the scene is ready
  40776. * @returns A promise that resolves when the scene is ready
  40777. */
  40778. whenReadyAsync(): Promise<void>;
  40779. /** @hidden */
  40780. _checkIsReady(): void;
  40781. /**
  40782. * Gets all animatable attached to the scene
  40783. */
  40784. get animatables(): Animatable[];
  40785. /**
  40786. * Resets the last animation time frame.
  40787. * Useful to override when animations start running when loading a scene for the first time.
  40788. */
  40789. resetLastAnimationTimeFrame(): void;
  40790. /**
  40791. * Gets the current view matrix
  40792. * @returns a Matrix
  40793. */
  40794. getViewMatrix(): Matrix;
  40795. /**
  40796. * Gets the current projection matrix
  40797. * @returns a Matrix
  40798. */
  40799. getProjectionMatrix(): Matrix;
  40800. /**
  40801. * Gets the current transform matrix
  40802. * @returns a Matrix made of View * Projection
  40803. */
  40804. getTransformMatrix(): Matrix;
  40805. /**
  40806. * Sets the current transform matrix
  40807. * @param viewL defines the View matrix to use
  40808. * @param projectionL defines the Projection matrix to use
  40809. * @param viewR defines the right View matrix to use (if provided)
  40810. * @param projectionR defines the right Projection matrix to use (if provided)
  40811. */
  40812. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40813. /**
  40814. * Gets the uniform buffer used to store scene data
  40815. * @returns a UniformBuffer
  40816. */
  40817. getSceneUniformBuffer(): UniformBuffer;
  40818. /**
  40819. * Gets an unique (relatively to the current scene) Id
  40820. * @returns an unique number for the scene
  40821. */
  40822. getUniqueId(): number;
  40823. /**
  40824. * Add a mesh to the list of scene's meshes
  40825. * @param newMesh defines the mesh to add
  40826. * @param recursive if all child meshes should also be added to the scene
  40827. */
  40828. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40829. /**
  40830. * Remove a mesh for the list of scene's meshes
  40831. * @param toRemove defines the mesh to remove
  40832. * @param recursive if all child meshes should also be removed from the scene
  40833. * @returns the index where the mesh was in the mesh list
  40834. */
  40835. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40836. /**
  40837. * Add a transform node to the list of scene's transform nodes
  40838. * @param newTransformNode defines the transform node to add
  40839. */
  40840. addTransformNode(newTransformNode: TransformNode): void;
  40841. /**
  40842. * Remove a transform node for the list of scene's transform nodes
  40843. * @param toRemove defines the transform node to remove
  40844. * @returns the index where the transform node was in the transform node list
  40845. */
  40846. removeTransformNode(toRemove: TransformNode): number;
  40847. /**
  40848. * Remove a skeleton for the list of scene's skeletons
  40849. * @param toRemove defines the skeleton to remove
  40850. * @returns the index where the skeleton was in the skeleton list
  40851. */
  40852. removeSkeleton(toRemove: Skeleton): number;
  40853. /**
  40854. * Remove a morph target for the list of scene's morph targets
  40855. * @param toRemove defines the morph target to remove
  40856. * @returns the index where the morph target was in the morph target list
  40857. */
  40858. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40859. /**
  40860. * Remove a light for the list of scene's lights
  40861. * @param toRemove defines the light to remove
  40862. * @returns the index where the light was in the light list
  40863. */
  40864. removeLight(toRemove: Light): number;
  40865. /**
  40866. * Remove a camera for the list of scene's cameras
  40867. * @param toRemove defines the camera to remove
  40868. * @returns the index where the camera was in the camera list
  40869. */
  40870. removeCamera(toRemove: Camera): number;
  40871. /**
  40872. * Remove a particle system for the list of scene's particle systems
  40873. * @param toRemove defines the particle system to remove
  40874. * @returns the index where the particle system was in the particle system list
  40875. */
  40876. removeParticleSystem(toRemove: IParticleSystem): number;
  40877. /**
  40878. * Remove a animation for the list of scene's animations
  40879. * @param toRemove defines the animation to remove
  40880. * @returns the index where the animation was in the animation list
  40881. */
  40882. removeAnimation(toRemove: Animation): number;
  40883. /**
  40884. * Will stop the animation of the given target
  40885. * @param target - the target
  40886. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40887. * @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)
  40888. */
  40889. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40890. /**
  40891. * Removes the given animation group from this scene.
  40892. * @param toRemove The animation group to remove
  40893. * @returns The index of the removed animation group
  40894. */
  40895. removeAnimationGroup(toRemove: AnimationGroup): number;
  40896. /**
  40897. * Removes the given multi-material from this scene.
  40898. * @param toRemove The multi-material to remove
  40899. * @returns The index of the removed multi-material
  40900. */
  40901. removeMultiMaterial(toRemove: MultiMaterial): number;
  40902. /**
  40903. * Removes the given material from this scene.
  40904. * @param toRemove The material to remove
  40905. * @returns The index of the removed material
  40906. */
  40907. removeMaterial(toRemove: Material): number;
  40908. /**
  40909. * Removes the given action manager from this scene.
  40910. * @param toRemove The action manager to remove
  40911. * @returns The index of the removed action manager
  40912. */
  40913. removeActionManager(toRemove: AbstractActionManager): number;
  40914. /**
  40915. * Removes the given texture from this scene.
  40916. * @param toRemove The texture to remove
  40917. * @returns The index of the removed texture
  40918. */
  40919. removeTexture(toRemove: BaseTexture): number;
  40920. /**
  40921. * Adds the given light to this scene
  40922. * @param newLight The light to add
  40923. */
  40924. addLight(newLight: Light): void;
  40925. /**
  40926. * Sorts the list list based on light priorities
  40927. */
  40928. sortLightsByPriority(): void;
  40929. /**
  40930. * Adds the given camera to this scene
  40931. * @param newCamera The camera to add
  40932. */
  40933. addCamera(newCamera: Camera): void;
  40934. /**
  40935. * Adds the given skeleton to this scene
  40936. * @param newSkeleton The skeleton to add
  40937. */
  40938. addSkeleton(newSkeleton: Skeleton): void;
  40939. /**
  40940. * Adds the given particle system to this scene
  40941. * @param newParticleSystem The particle system to add
  40942. */
  40943. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40944. /**
  40945. * Adds the given animation to this scene
  40946. * @param newAnimation The animation to add
  40947. */
  40948. addAnimation(newAnimation: Animation): void;
  40949. /**
  40950. * Adds the given animation group to this scene.
  40951. * @param newAnimationGroup The animation group to add
  40952. */
  40953. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40954. /**
  40955. * Adds the given multi-material to this scene
  40956. * @param newMultiMaterial The multi-material to add
  40957. */
  40958. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40959. /**
  40960. * Adds the given material to this scene
  40961. * @param newMaterial The material to add
  40962. */
  40963. addMaterial(newMaterial: Material): void;
  40964. /**
  40965. * Adds the given morph target to this scene
  40966. * @param newMorphTargetManager The morph target to add
  40967. */
  40968. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40969. /**
  40970. * Adds the given geometry to this scene
  40971. * @param newGeometry The geometry to add
  40972. */
  40973. addGeometry(newGeometry: Geometry): void;
  40974. /**
  40975. * Adds the given action manager to this scene
  40976. * @param newActionManager The action manager to add
  40977. */
  40978. addActionManager(newActionManager: AbstractActionManager): void;
  40979. /**
  40980. * Adds the given texture to this scene.
  40981. * @param newTexture The texture to add
  40982. */
  40983. addTexture(newTexture: BaseTexture): void;
  40984. /**
  40985. * Switch active camera
  40986. * @param newCamera defines the new active camera
  40987. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40988. */
  40989. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40990. /**
  40991. * sets the active camera of the scene using its ID
  40992. * @param id defines the camera's ID
  40993. * @return the new active camera or null if none found.
  40994. */
  40995. setActiveCameraByID(id: string): Nullable<Camera>;
  40996. /**
  40997. * sets the active camera of the scene using its name
  40998. * @param name defines the camera's name
  40999. * @returns the new active camera or null if none found.
  41000. */
  41001. setActiveCameraByName(name: string): Nullable<Camera>;
  41002. /**
  41003. * get an animation group using its name
  41004. * @param name defines the material's name
  41005. * @return the animation group or null if none found.
  41006. */
  41007. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41008. /**
  41009. * Get a material using its unique id
  41010. * @param uniqueId defines the material's unique id
  41011. * @return the material or null if none found.
  41012. */
  41013. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41014. /**
  41015. * get a material using its id
  41016. * @param id defines the material's ID
  41017. * @return the material or null if none found.
  41018. */
  41019. getMaterialByID(id: string): Nullable<Material>;
  41020. /**
  41021. * Gets a the last added material using a given id
  41022. * @param id defines the material's ID
  41023. * @return the last material with the given id or null if none found.
  41024. */
  41025. getLastMaterialByID(id: string): Nullable<Material>;
  41026. /**
  41027. * Gets a material using its name
  41028. * @param name defines the material's name
  41029. * @return the material or null if none found.
  41030. */
  41031. getMaterialByName(name: string): Nullable<Material>;
  41032. /**
  41033. * Get a texture using its unique id
  41034. * @param uniqueId defines the texture's unique id
  41035. * @return the texture or null if none found.
  41036. */
  41037. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41038. /**
  41039. * Gets a camera using its id
  41040. * @param id defines the id to look for
  41041. * @returns the camera or null if not found
  41042. */
  41043. getCameraByID(id: string): Nullable<Camera>;
  41044. /**
  41045. * Gets a camera using its unique id
  41046. * @param uniqueId defines the unique id to look for
  41047. * @returns the camera or null if not found
  41048. */
  41049. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41050. /**
  41051. * Gets a camera using its name
  41052. * @param name defines the camera's name
  41053. * @return the camera or null if none found.
  41054. */
  41055. getCameraByName(name: string): Nullable<Camera>;
  41056. /**
  41057. * Gets a bone using its id
  41058. * @param id defines the bone's id
  41059. * @return the bone or null if not found
  41060. */
  41061. getBoneByID(id: string): Nullable<Bone>;
  41062. /**
  41063. * Gets a bone using its id
  41064. * @param name defines the bone's name
  41065. * @return the bone or null if not found
  41066. */
  41067. getBoneByName(name: string): Nullable<Bone>;
  41068. /**
  41069. * Gets a light node using its name
  41070. * @param name defines the the light's name
  41071. * @return the light or null if none found.
  41072. */
  41073. getLightByName(name: string): Nullable<Light>;
  41074. /**
  41075. * Gets a light node using its id
  41076. * @param id defines the light's id
  41077. * @return the light or null if none found.
  41078. */
  41079. getLightByID(id: string): Nullable<Light>;
  41080. /**
  41081. * Gets a light node using its scene-generated unique ID
  41082. * @param uniqueId defines the light's unique id
  41083. * @return the light or null if none found.
  41084. */
  41085. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41086. /**
  41087. * Gets a particle system by id
  41088. * @param id defines the particle system id
  41089. * @return the corresponding system or null if none found
  41090. */
  41091. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41092. /**
  41093. * Gets a geometry using its ID
  41094. * @param id defines the geometry's id
  41095. * @return the geometry or null if none found.
  41096. */
  41097. getGeometryByID(id: string): Nullable<Geometry>;
  41098. private _getGeometryByUniqueID;
  41099. /**
  41100. * Add a new geometry to this scene
  41101. * @param geometry defines the geometry to be added to the scene.
  41102. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41103. * @return a boolean defining if the geometry was added or not
  41104. */
  41105. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41106. /**
  41107. * Removes an existing geometry
  41108. * @param geometry defines the geometry to be removed from the scene
  41109. * @return a boolean defining if the geometry was removed or not
  41110. */
  41111. removeGeometry(geometry: Geometry): boolean;
  41112. /**
  41113. * Gets the list of geometries attached to the scene
  41114. * @returns an array of Geometry
  41115. */
  41116. getGeometries(): Geometry[];
  41117. /**
  41118. * Gets the first added mesh found of a given ID
  41119. * @param id defines the id to search for
  41120. * @return the mesh found or null if not found at all
  41121. */
  41122. getMeshByID(id: string): Nullable<AbstractMesh>;
  41123. /**
  41124. * Gets a list of meshes using their id
  41125. * @param id defines the id to search for
  41126. * @returns a list of meshes
  41127. */
  41128. getMeshesByID(id: string): Array<AbstractMesh>;
  41129. /**
  41130. * Gets the first added transform node found of a given ID
  41131. * @param id defines the id to search for
  41132. * @return the found transform node or null if not found at all.
  41133. */
  41134. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41135. /**
  41136. * Gets a transform node with its auto-generated unique id
  41137. * @param uniqueId efines the unique id to search for
  41138. * @return the found transform node or null if not found at all.
  41139. */
  41140. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41141. /**
  41142. * Gets a list of transform nodes using their id
  41143. * @param id defines the id to search for
  41144. * @returns a list of transform nodes
  41145. */
  41146. getTransformNodesByID(id: string): Array<TransformNode>;
  41147. /**
  41148. * Gets a mesh with its auto-generated unique id
  41149. * @param uniqueId defines the unique id to search for
  41150. * @return the found mesh or null if not found at all.
  41151. */
  41152. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41153. /**
  41154. * Gets a the last added mesh using a given id
  41155. * @param id defines the id to search for
  41156. * @return the found mesh or null if not found at all.
  41157. */
  41158. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41159. /**
  41160. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41161. * @param id defines the id to search for
  41162. * @return the found node or null if not found at all
  41163. */
  41164. getLastEntryByID(id: string): Nullable<Node>;
  41165. /**
  41166. * Gets a node (Mesh, Camera, Light) using a given id
  41167. * @param id defines the id to search for
  41168. * @return the found node or null if not found at all
  41169. */
  41170. getNodeByID(id: string): Nullable<Node>;
  41171. /**
  41172. * Gets a node (Mesh, Camera, Light) using a given name
  41173. * @param name defines the name to search for
  41174. * @return the found node or null if not found at all.
  41175. */
  41176. getNodeByName(name: string): Nullable<Node>;
  41177. /**
  41178. * Gets a mesh using a given name
  41179. * @param name defines the name to search for
  41180. * @return the found mesh or null if not found at all.
  41181. */
  41182. getMeshByName(name: string): Nullable<AbstractMesh>;
  41183. /**
  41184. * Gets a transform node using a given name
  41185. * @param name defines the name to search for
  41186. * @return the found transform node or null if not found at all.
  41187. */
  41188. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41189. /**
  41190. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41191. * @param id defines the id to search for
  41192. * @return the found skeleton or null if not found at all.
  41193. */
  41194. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41195. /**
  41196. * Gets a skeleton using a given auto generated unique id
  41197. * @param uniqueId defines the unique id to search for
  41198. * @return the found skeleton or null if not found at all.
  41199. */
  41200. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41201. /**
  41202. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41203. * @param id defines the id to search for
  41204. * @return the found skeleton or null if not found at all.
  41205. */
  41206. getSkeletonById(id: string): Nullable<Skeleton>;
  41207. /**
  41208. * Gets a skeleton using a given name
  41209. * @param name defines the name to search for
  41210. * @return the found skeleton or null if not found at all.
  41211. */
  41212. getSkeletonByName(name: string): Nullable<Skeleton>;
  41213. /**
  41214. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41215. * @param id defines the id to search for
  41216. * @return the found morph target manager or null if not found at all.
  41217. */
  41218. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41219. /**
  41220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41221. * @param id defines the id to search for
  41222. * @return the found morph target or null if not found at all.
  41223. */
  41224. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41225. /**
  41226. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41227. * @param name defines the name to search for
  41228. * @return the found morph target or null if not found at all.
  41229. */
  41230. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41231. /**
  41232. * Gets a boolean indicating if the given mesh is active
  41233. * @param mesh defines the mesh to look for
  41234. * @returns true if the mesh is in the active list
  41235. */
  41236. isActiveMesh(mesh: AbstractMesh): boolean;
  41237. /**
  41238. * Return a unique id as a string which can serve as an identifier for the scene
  41239. */
  41240. get uid(): string;
  41241. /**
  41242. * Add an externaly attached data from its key.
  41243. * This method call will fail and return false, if such key already exists.
  41244. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41245. * @param key the unique key that identifies the data
  41246. * @param data the data object to associate to the key for this Engine instance
  41247. * @return true if no such key were already present and the data was added successfully, false otherwise
  41248. */
  41249. addExternalData<T>(key: string, data: T): boolean;
  41250. /**
  41251. * Get an externaly attached data from its key
  41252. * @param key the unique key that identifies the data
  41253. * @return the associated data, if present (can be null), or undefined if not present
  41254. */
  41255. getExternalData<T>(key: string): Nullable<T>;
  41256. /**
  41257. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41258. * @param key the unique key that identifies the data
  41259. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41260. * @return the associated data, can be null if the factory returned null.
  41261. */
  41262. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41263. /**
  41264. * Remove an externaly attached data from the Engine instance
  41265. * @param key the unique key that identifies the data
  41266. * @return true if the data was successfully removed, false if it doesn't exist
  41267. */
  41268. removeExternalData(key: string): boolean;
  41269. private _evaluateSubMesh;
  41270. /**
  41271. * Clear the processed materials smart array preventing retention point in material dispose.
  41272. */
  41273. freeProcessedMaterials(): void;
  41274. private _preventFreeActiveMeshesAndRenderingGroups;
  41275. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41276. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41277. * when disposing several meshes in a row or a hierarchy of meshes.
  41278. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41279. */
  41280. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41281. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41282. /**
  41283. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41284. */
  41285. freeActiveMeshes(): void;
  41286. /**
  41287. * Clear the info related to rendering groups preventing retention points during dispose.
  41288. */
  41289. freeRenderingGroups(): void;
  41290. /** @hidden */
  41291. _isInIntermediateRendering(): boolean;
  41292. /**
  41293. * Lambda returning the list of potentially active meshes.
  41294. */
  41295. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41296. /**
  41297. * Lambda returning the list of potentially active sub meshes.
  41298. */
  41299. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41300. /**
  41301. * Lambda returning the list of potentially intersecting sub meshes.
  41302. */
  41303. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41304. /**
  41305. * Lambda returning the list of potentially colliding sub meshes.
  41306. */
  41307. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41308. private _activeMeshesFrozen;
  41309. private _skipEvaluateActiveMeshesCompletely;
  41310. /**
  41311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41312. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41313. * @returns the current scene
  41314. */
  41315. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41316. /**
  41317. * Use this function to restart evaluating active meshes on every frame
  41318. * @returns the current scene
  41319. */
  41320. unfreezeActiveMeshes(): Scene;
  41321. private _evaluateActiveMeshes;
  41322. private _activeMesh;
  41323. /**
  41324. * Update the transform matrix to update from the current active camera
  41325. * @param force defines a boolean used to force the update even if cache is up to date
  41326. */
  41327. updateTransformMatrix(force?: boolean): void;
  41328. private _bindFrameBuffer;
  41329. /** @hidden */
  41330. _allowPostProcessClearColor: boolean;
  41331. /** @hidden */
  41332. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41333. private _processSubCameras;
  41334. private _checkIntersections;
  41335. /** @hidden */
  41336. _advancePhysicsEngineStep(step: number): void;
  41337. /**
  41338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41339. */
  41340. getDeterministicFrameTime: () => number;
  41341. /** @hidden */
  41342. _animate(): void;
  41343. /** Execute all animations (for a frame) */
  41344. animate(): void;
  41345. /**
  41346. * Render the scene
  41347. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41348. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41349. */
  41350. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41351. /**
  41352. * Freeze all materials
  41353. * A frozen material will not be updatable but should be faster to render
  41354. */
  41355. freezeMaterials(): void;
  41356. /**
  41357. * Unfreeze all materials
  41358. * A frozen material will not be updatable but should be faster to render
  41359. */
  41360. unfreezeMaterials(): void;
  41361. /**
  41362. * Releases all held ressources
  41363. */
  41364. dispose(): void;
  41365. /**
  41366. * Gets if the scene is already disposed
  41367. */
  41368. get isDisposed(): boolean;
  41369. /**
  41370. * Call this function to reduce memory footprint of the scene.
  41371. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41372. */
  41373. clearCachedVertexData(): void;
  41374. /**
  41375. * This function will remove the local cached buffer data from texture.
  41376. * It will save memory but will prevent the texture from being rebuilt
  41377. */
  41378. cleanCachedTextureBuffer(): void;
  41379. /**
  41380. * Get the world extend vectors with an optional filter
  41381. *
  41382. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41383. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41384. */
  41385. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41386. min: Vector3;
  41387. max: Vector3;
  41388. };
  41389. /**
  41390. * Creates a ray that can be used to pick in the scene
  41391. * @param x defines the x coordinate of the origin (on-screen)
  41392. * @param y defines the y coordinate of the origin (on-screen)
  41393. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41394. * @param camera defines the camera to use for the picking
  41395. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41396. * @returns a Ray
  41397. */
  41398. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41399. /**
  41400. * Creates a ray that can be used to pick in the scene
  41401. * @param x defines the x coordinate of the origin (on-screen)
  41402. * @param y defines the y coordinate of the origin (on-screen)
  41403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41404. * @param result defines the ray where to store the picking ray
  41405. * @param camera defines the camera to use for the picking
  41406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41407. * @returns the current scene
  41408. */
  41409. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41410. /**
  41411. * Creates a ray that can be used to pick in the scene
  41412. * @param x defines the x coordinate of the origin (on-screen)
  41413. * @param y defines the y coordinate of the origin (on-screen)
  41414. * @param camera defines the camera to use for the picking
  41415. * @returns a Ray
  41416. */
  41417. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41418. /**
  41419. * Creates a ray that can be used to pick in the scene
  41420. * @param x defines the x coordinate of the origin (on-screen)
  41421. * @param y defines the y coordinate of the origin (on-screen)
  41422. * @param result defines the ray where to store the picking ray
  41423. * @param camera defines the camera to use for the picking
  41424. * @returns the current scene
  41425. */
  41426. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41427. /** Launch a ray to try to pick a mesh in the scene
  41428. * @param x position on screen
  41429. * @param y position on screen
  41430. * @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
  41431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41432. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41434. * @returns a PickingInfo
  41435. */
  41436. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41437. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41438. * @param x position on screen
  41439. * @param y position on screen
  41440. * @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
  41441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41442. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41443. * @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)
  41444. */
  41445. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41446. /** Use the given ray to pick a mesh in the scene
  41447. * @param ray The ray to use to pick meshes
  41448. * @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
  41449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41451. * @returns a PickingInfo
  41452. */
  41453. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41454. /**
  41455. * Launch a ray to try to pick a mesh in the scene
  41456. * @param x X position on screen
  41457. * @param y Y position on screen
  41458. * @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
  41459. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41461. * @returns an array of PickingInfo
  41462. */
  41463. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41464. /**
  41465. * Launch a ray to try to pick a mesh in the scene
  41466. * @param ray Ray to use
  41467. * @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
  41468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41469. * @returns an array of PickingInfo
  41470. */
  41471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41472. /**
  41473. * Force the value of meshUnderPointer
  41474. * @param mesh defines the mesh to use
  41475. */
  41476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41477. /**
  41478. * Gets the mesh under the pointer
  41479. * @returns a Mesh or null if no mesh is under the pointer
  41480. */
  41481. getPointerOverMesh(): Nullable<AbstractMesh>;
  41482. /** @hidden */
  41483. _rebuildGeometries(): void;
  41484. /** @hidden */
  41485. _rebuildTextures(): void;
  41486. private _getByTags;
  41487. /**
  41488. * Get a list of meshes by tags
  41489. * @param tagsQuery defines the tags query to use
  41490. * @param forEach defines a predicate used to filter results
  41491. * @returns an array of Mesh
  41492. */
  41493. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41494. /**
  41495. * Get a list of cameras by tags
  41496. * @param tagsQuery defines the tags query to use
  41497. * @param forEach defines a predicate used to filter results
  41498. * @returns an array of Camera
  41499. */
  41500. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41501. /**
  41502. * Get a list of lights by tags
  41503. * @param tagsQuery defines the tags query to use
  41504. * @param forEach defines a predicate used to filter results
  41505. * @returns an array of Light
  41506. */
  41507. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41508. /**
  41509. * Get a list of materials by tags
  41510. * @param tagsQuery defines the tags query to use
  41511. * @param forEach defines a predicate used to filter results
  41512. * @returns an array of Material
  41513. */
  41514. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41515. /**
  41516. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41517. * This allowed control for front to back rendering or reversly depending of the special needs.
  41518. *
  41519. * @param renderingGroupId The rendering group id corresponding to its index
  41520. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41521. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41522. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41523. */
  41524. 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;
  41525. /**
  41526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41527. *
  41528. * @param renderingGroupId The rendering group id corresponding to its index
  41529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41530. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41531. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41532. */
  41533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41534. /**
  41535. * Gets the current auto clear configuration for one rendering group of the rendering
  41536. * manager.
  41537. * @param index the rendering group index to get the information for
  41538. * @returns The auto clear setup for the requested rendering group
  41539. */
  41540. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41541. private _blockMaterialDirtyMechanism;
  41542. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41543. get blockMaterialDirtyMechanism(): boolean;
  41544. set blockMaterialDirtyMechanism(value: boolean);
  41545. /**
  41546. * Will flag all materials as dirty to trigger new shader compilation
  41547. * @param flag defines the flag used to specify which material part must be marked as dirty
  41548. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41549. */
  41550. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41551. /** @hidden */
  41552. _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;
  41553. /** @hidden */
  41554. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41555. /** @hidden */
  41556. _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;
  41557. /** @hidden */
  41558. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41559. /** @hidden */
  41560. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41561. /** @hidden */
  41562. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41563. }
  41564. }
  41565. declare module "babylonjs/assetContainer" {
  41566. import { AbstractScene } from "babylonjs/abstractScene";
  41567. import { Scene } from "babylonjs/scene";
  41568. import { Mesh } from "babylonjs/Meshes/mesh";
  41569. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41570. import { Skeleton } from "babylonjs/Bones/skeleton";
  41571. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41572. import { Animatable } from "babylonjs/Animations/animatable";
  41573. import { Nullable } from "babylonjs/types";
  41574. import { Node } from "babylonjs/node";
  41575. /**
  41576. * Set of assets to keep when moving a scene into an asset container.
  41577. */
  41578. export class KeepAssets extends AbstractScene {
  41579. }
  41580. /**
  41581. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41582. */
  41583. export class InstantiatedEntries {
  41584. /**
  41585. * List of new root nodes (eg. nodes with no parent)
  41586. */
  41587. rootNodes: TransformNode[];
  41588. /**
  41589. * List of new skeletons
  41590. */
  41591. skeletons: Skeleton[];
  41592. /**
  41593. * List of new animation groups
  41594. */
  41595. animationGroups: AnimationGroup[];
  41596. }
  41597. /**
  41598. * Container with a set of assets that can be added or removed from a scene.
  41599. */
  41600. export class AssetContainer extends AbstractScene {
  41601. private _wasAddedToScene;
  41602. /**
  41603. * The scene the AssetContainer belongs to.
  41604. */
  41605. scene: Scene;
  41606. /**
  41607. * Instantiates an AssetContainer.
  41608. * @param scene The scene the AssetContainer belongs to.
  41609. */
  41610. constructor(scene: Scene);
  41611. /**
  41612. * Instantiate or clone all meshes and add the new ones to the scene.
  41613. * Skeletons and animation groups will all be cloned
  41614. * @param nameFunction defines an optional function used to get new names for clones
  41615. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41616. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41617. */
  41618. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41619. /**
  41620. * Adds all the assets from the container to the scene.
  41621. */
  41622. addAllToScene(): void;
  41623. /**
  41624. * Removes all the assets in the container from the scene
  41625. */
  41626. removeAllFromScene(): void;
  41627. /**
  41628. * Disposes all the assets in the container
  41629. */
  41630. dispose(): void;
  41631. private _moveAssets;
  41632. /**
  41633. * Removes all the assets contained in the scene and adds them to the container.
  41634. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41635. */
  41636. moveAllFromScene(keepAssets?: KeepAssets): void;
  41637. /**
  41638. * 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.
  41639. * @returns the root mesh
  41640. */
  41641. createRootMesh(): Mesh;
  41642. /**
  41643. * Merge animations (direct and animation groups) from this asset container into a scene
  41644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41645. * @param animatables set of animatables to retarget to a node from the scene
  41646. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41647. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41648. */
  41649. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41650. }
  41651. }
  41652. declare module "babylonjs/abstractScene" {
  41653. import { Scene } from "babylonjs/scene";
  41654. import { Nullable } from "babylonjs/types";
  41655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41657. import { Geometry } from "babylonjs/Meshes/geometry";
  41658. import { Skeleton } from "babylonjs/Bones/skeleton";
  41659. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41660. import { AssetContainer } from "babylonjs/assetContainer";
  41661. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41664. import { Material } from "babylonjs/Materials/material";
  41665. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41666. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41667. import { Camera } from "babylonjs/Cameras/camera";
  41668. import { Light } from "babylonjs/Lights/light";
  41669. import { Node } from "babylonjs/node";
  41670. import { Animation } from "babylonjs/Animations/animation";
  41671. /**
  41672. * Defines how the parser contract is defined.
  41673. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41674. */
  41675. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41676. /**
  41677. * Defines how the individual parser contract is defined.
  41678. * These parser can parse an individual asset
  41679. */
  41680. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41681. /**
  41682. * Base class of the scene acting as a container for the different elements composing a scene.
  41683. * This class is dynamically extended by the different components of the scene increasing
  41684. * flexibility and reducing coupling
  41685. */
  41686. export abstract class AbstractScene {
  41687. /**
  41688. * Stores the list of available parsers in the application.
  41689. */
  41690. private static _BabylonFileParsers;
  41691. /**
  41692. * Stores the list of available individual parsers in the application.
  41693. */
  41694. private static _IndividualBabylonFileParsers;
  41695. /**
  41696. * Adds a parser in the list of available ones
  41697. * @param name Defines the name of the parser
  41698. * @param parser Defines the parser to add
  41699. */
  41700. static AddParser(name: string, parser: BabylonFileParser): void;
  41701. /**
  41702. * Gets a general parser from the list of avaialble ones
  41703. * @param name Defines the name of the parser
  41704. * @returns the requested parser or null
  41705. */
  41706. static GetParser(name: string): Nullable<BabylonFileParser>;
  41707. /**
  41708. * Adds n individual parser in the list of available ones
  41709. * @param name Defines the name of the parser
  41710. * @param parser Defines the parser to add
  41711. */
  41712. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41713. /**
  41714. * Gets an individual parser from the list of avaialble ones
  41715. * @param name Defines the name of the parser
  41716. * @returns the requested parser or null
  41717. */
  41718. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41719. /**
  41720. * Parser json data and populate both a scene and its associated container object
  41721. * @param jsonData Defines the data to parse
  41722. * @param scene Defines the scene to parse the data for
  41723. * @param container Defines the container attached to the parsing sequence
  41724. * @param rootUrl Defines the root url of the data
  41725. */
  41726. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41727. /**
  41728. * Gets the list of root nodes (ie. nodes with no parent)
  41729. */
  41730. rootNodes: Node[];
  41731. /** All of the cameras added to this scene
  41732. * @see https://doc.babylonjs.com/babylon101/cameras
  41733. */
  41734. cameras: Camera[];
  41735. /**
  41736. * All of the lights added to this scene
  41737. * @see https://doc.babylonjs.com/babylon101/lights
  41738. */
  41739. lights: Light[];
  41740. /**
  41741. * All of the (abstract) meshes added to this scene
  41742. */
  41743. meshes: AbstractMesh[];
  41744. /**
  41745. * The list of skeletons added to the scene
  41746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41747. */
  41748. skeletons: Skeleton[];
  41749. /**
  41750. * All of the particle systems added to this scene
  41751. * @see https://doc.babylonjs.com/babylon101/particles
  41752. */
  41753. particleSystems: IParticleSystem[];
  41754. /**
  41755. * Gets a list of Animations associated with the scene
  41756. */
  41757. animations: Animation[];
  41758. /**
  41759. * All of the animation groups added to this scene
  41760. * @see https://doc.babylonjs.com/how_to/group
  41761. */
  41762. animationGroups: AnimationGroup[];
  41763. /**
  41764. * All of the multi-materials added to this scene
  41765. * @see https://doc.babylonjs.com/how_to/multi_materials
  41766. */
  41767. multiMaterials: MultiMaterial[];
  41768. /**
  41769. * All of the materials added to this scene
  41770. * In the context of a Scene, it is not supposed to be modified manually.
  41771. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41772. * Note also that the order of the Material within the array is not significant and might change.
  41773. * @see https://doc.babylonjs.com/babylon101/materials
  41774. */
  41775. materials: Material[];
  41776. /**
  41777. * The list of morph target managers added to the scene
  41778. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41779. */
  41780. morphTargetManagers: MorphTargetManager[];
  41781. /**
  41782. * The list of geometries used in the scene.
  41783. */
  41784. geometries: Geometry[];
  41785. /**
  41786. * All of the tranform nodes added to this scene
  41787. * In the context of a Scene, it is not supposed to be modified manually.
  41788. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41789. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41790. * @see https://doc.babylonjs.com/how_to/transformnode
  41791. */
  41792. transformNodes: TransformNode[];
  41793. /**
  41794. * ActionManagers available on the scene.
  41795. */
  41796. actionManagers: AbstractActionManager[];
  41797. /**
  41798. * Textures to keep.
  41799. */
  41800. textures: BaseTexture[];
  41801. /**
  41802. * Environment texture for the scene
  41803. */
  41804. environmentTexture: Nullable<BaseTexture>;
  41805. /**
  41806. * @returns all meshes, lights, cameras, transformNodes and bones
  41807. */
  41808. getNodes(): Array<Node>;
  41809. }
  41810. }
  41811. declare module "babylonjs/Audio/sound" {
  41812. import { Observable } from "babylonjs/Misc/observable";
  41813. import { Vector3 } from "babylonjs/Maths/math.vector";
  41814. import { Nullable } from "babylonjs/types";
  41815. import { Scene } from "babylonjs/scene";
  41816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41817. /**
  41818. * Interface used to define options for Sound class
  41819. */
  41820. export interface ISoundOptions {
  41821. /**
  41822. * Does the sound autoplay once loaded.
  41823. */
  41824. autoplay?: boolean;
  41825. /**
  41826. * Does the sound loop after it finishes playing once.
  41827. */
  41828. loop?: boolean;
  41829. /**
  41830. * Sound's volume
  41831. */
  41832. volume?: number;
  41833. /**
  41834. * Is it a spatial sound?
  41835. */
  41836. spatialSound?: boolean;
  41837. /**
  41838. * Maximum distance to hear that sound
  41839. */
  41840. maxDistance?: number;
  41841. /**
  41842. * Uses user defined attenuation function
  41843. */
  41844. useCustomAttenuation?: boolean;
  41845. /**
  41846. * Define the roll off factor of spatial sounds.
  41847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41848. */
  41849. rolloffFactor?: number;
  41850. /**
  41851. * Define the reference distance the sound should be heard perfectly.
  41852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41853. */
  41854. refDistance?: number;
  41855. /**
  41856. * Define the distance attenuation model the sound will follow.
  41857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41858. */
  41859. distanceModel?: string;
  41860. /**
  41861. * Defines the playback speed (1 by default)
  41862. */
  41863. playbackRate?: number;
  41864. /**
  41865. * Defines if the sound is from a streaming source
  41866. */
  41867. streaming?: boolean;
  41868. /**
  41869. * Defines an optional length (in seconds) inside the sound file
  41870. */
  41871. length?: number;
  41872. /**
  41873. * Defines an optional offset (in seconds) inside the sound file
  41874. */
  41875. offset?: number;
  41876. /**
  41877. * If true, URLs will not be required to state the audio file codec to use.
  41878. */
  41879. skipCodecCheck?: boolean;
  41880. }
  41881. /**
  41882. * Defines a sound that can be played in the application.
  41883. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41885. */
  41886. export class Sound {
  41887. /**
  41888. * The name of the sound in the scene.
  41889. */
  41890. name: string;
  41891. /**
  41892. * Does the sound autoplay once loaded.
  41893. */
  41894. autoplay: boolean;
  41895. /**
  41896. * Does the sound loop after it finishes playing once.
  41897. */
  41898. loop: boolean;
  41899. /**
  41900. * Does the sound use a custom attenuation curve to simulate the falloff
  41901. * happening when the source gets further away from the camera.
  41902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41903. */
  41904. useCustomAttenuation: boolean;
  41905. /**
  41906. * The sound track id this sound belongs to.
  41907. */
  41908. soundTrackId: number;
  41909. /**
  41910. * Is this sound currently played.
  41911. */
  41912. isPlaying: boolean;
  41913. /**
  41914. * Is this sound currently paused.
  41915. */
  41916. isPaused: boolean;
  41917. /**
  41918. * Does this sound enables spatial sound.
  41919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41920. */
  41921. spatialSound: boolean;
  41922. /**
  41923. * Define the reference distance the sound should be heard perfectly.
  41924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41925. */
  41926. refDistance: number;
  41927. /**
  41928. * Define the roll off factor of spatial sounds.
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41930. */
  41931. rolloffFactor: number;
  41932. /**
  41933. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41935. */
  41936. maxDistance: number;
  41937. /**
  41938. * Define the distance attenuation model the sound will follow.
  41939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41940. */
  41941. distanceModel: string;
  41942. /**
  41943. * @hidden
  41944. * Back Compat
  41945. **/
  41946. onended: () => any;
  41947. /**
  41948. * Gets or sets an object used to store user defined information for the sound.
  41949. */
  41950. metadata: any;
  41951. /**
  41952. * Observable event when the current playing sound finishes.
  41953. */
  41954. onEndedObservable: Observable<Sound>;
  41955. private _panningModel;
  41956. private _playbackRate;
  41957. private _streaming;
  41958. private _startTime;
  41959. private _startOffset;
  41960. private _position;
  41961. /** @hidden */
  41962. _positionInEmitterSpace: boolean;
  41963. private _localDirection;
  41964. private _volume;
  41965. private _isReadyToPlay;
  41966. private _isDirectional;
  41967. private _readyToPlayCallback;
  41968. private _audioBuffer;
  41969. private _soundSource;
  41970. private _streamingSource;
  41971. private _soundPanner;
  41972. private _soundGain;
  41973. private _inputAudioNode;
  41974. private _outputAudioNode;
  41975. private _coneInnerAngle;
  41976. private _coneOuterAngle;
  41977. private _coneOuterGain;
  41978. private _scene;
  41979. private _connectedTransformNode;
  41980. private _customAttenuationFunction;
  41981. private _registerFunc;
  41982. private _isOutputConnected;
  41983. private _htmlAudioElement;
  41984. private _urlType;
  41985. private _length?;
  41986. private _offset?;
  41987. /** @hidden */
  41988. static _SceneComponentInitialization: (scene: Scene) => void;
  41989. /**
  41990. * Create a sound and attach it to a scene
  41991. * @param name Name of your sound
  41992. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41993. * @param scene defines the scene the sound belongs to
  41994. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41995. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41996. */
  41997. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41998. /**
  41999. * Release the sound and its associated resources
  42000. */
  42001. dispose(): void;
  42002. /**
  42003. * Gets if the sounds is ready to be played or not.
  42004. * @returns true if ready, otherwise false
  42005. */
  42006. isReady(): boolean;
  42007. private _soundLoaded;
  42008. /**
  42009. * Sets the data of the sound from an audiobuffer
  42010. * @param audioBuffer The audioBuffer containing the data
  42011. */
  42012. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42013. /**
  42014. * Updates the current sounds options such as maxdistance, loop...
  42015. * @param options A JSON object containing values named as the object properties
  42016. */
  42017. updateOptions(options: ISoundOptions): void;
  42018. private _createSpatialParameters;
  42019. private _updateSpatialParameters;
  42020. /**
  42021. * Switch the panning model to HRTF:
  42022. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42024. */
  42025. switchPanningModelToHRTF(): void;
  42026. /**
  42027. * Switch the panning model to Equal Power:
  42028. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42030. */
  42031. switchPanningModelToEqualPower(): void;
  42032. private _switchPanningModel;
  42033. /**
  42034. * Connect this sound to a sound track audio node like gain...
  42035. * @param soundTrackAudioNode the sound track audio node to connect to
  42036. */
  42037. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42038. /**
  42039. * Transform this sound into a directional source
  42040. * @param coneInnerAngle Size of the inner cone in degree
  42041. * @param coneOuterAngle Size of the outer cone in degree
  42042. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42043. */
  42044. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42045. /**
  42046. * Gets or sets the inner angle for the directional cone.
  42047. */
  42048. get directionalConeInnerAngle(): number;
  42049. /**
  42050. * Gets or sets the inner angle for the directional cone.
  42051. */
  42052. set directionalConeInnerAngle(value: number);
  42053. /**
  42054. * Gets or sets the outer angle for the directional cone.
  42055. */
  42056. get directionalConeOuterAngle(): number;
  42057. /**
  42058. * Gets or sets the outer angle for the directional cone.
  42059. */
  42060. set directionalConeOuterAngle(value: number);
  42061. /**
  42062. * Sets the position of the emitter if spatial sound is enabled
  42063. * @param newPosition Defines the new posisiton
  42064. */
  42065. setPosition(newPosition: Vector3): void;
  42066. /**
  42067. * Sets the local direction of the emitter if spatial sound is enabled
  42068. * @param newLocalDirection Defines the new local direction
  42069. */
  42070. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42071. private _updateDirection;
  42072. /** @hidden */
  42073. updateDistanceFromListener(): void;
  42074. /**
  42075. * Sets a new custom attenuation function for the sound.
  42076. * @param callback Defines the function used for the attenuation
  42077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42078. */
  42079. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42080. /**
  42081. * Play the sound
  42082. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42083. * @param offset (optional) Start the sound at a specific time in seconds
  42084. * @param length (optional) Sound duration (in seconds)
  42085. */
  42086. play(time?: number, offset?: number, length?: number): void;
  42087. private _onended;
  42088. /**
  42089. * Stop the sound
  42090. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42091. */
  42092. stop(time?: number): void;
  42093. /**
  42094. * Put the sound in pause
  42095. */
  42096. pause(): void;
  42097. /**
  42098. * Sets a dedicated volume for this sounds
  42099. * @param newVolume Define the new volume of the sound
  42100. * @param time Define time for gradual change to new volume
  42101. */
  42102. setVolume(newVolume: number, time?: number): void;
  42103. /**
  42104. * Set the sound play back rate
  42105. * @param newPlaybackRate Define the playback rate the sound should be played at
  42106. */
  42107. setPlaybackRate(newPlaybackRate: number): void;
  42108. /**
  42109. * Gets the volume of the sound.
  42110. * @returns the volume of the sound
  42111. */
  42112. getVolume(): number;
  42113. /**
  42114. * Attach the sound to a dedicated mesh
  42115. * @param transformNode The transform node to connect the sound with
  42116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42117. */
  42118. attachToMesh(transformNode: TransformNode): void;
  42119. /**
  42120. * Detach the sound from the previously attached mesh
  42121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42122. */
  42123. detachFromMesh(): void;
  42124. private _onRegisterAfterWorldMatrixUpdate;
  42125. /**
  42126. * Clone the current sound in the scene.
  42127. * @returns the new sound clone
  42128. */
  42129. clone(): Nullable<Sound>;
  42130. /**
  42131. * Gets the current underlying audio buffer containing the data
  42132. * @returns the audio buffer
  42133. */
  42134. getAudioBuffer(): Nullable<AudioBuffer>;
  42135. /**
  42136. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42137. * @returns the source node
  42138. */
  42139. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42140. /**
  42141. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42142. * @returns the gain node
  42143. */
  42144. getSoundGain(): Nullable<GainNode>;
  42145. /**
  42146. * Serializes the Sound in a JSON representation
  42147. * @returns the JSON representation of the sound
  42148. */
  42149. serialize(): any;
  42150. /**
  42151. * Parse a JSON representation of a sound to innstantiate in a given scene
  42152. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42153. * @param scene Define the scene the new parsed sound should be created in
  42154. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42155. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42156. * @returns the newly parsed sound
  42157. */
  42158. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42159. }
  42160. }
  42161. declare module "babylonjs/Actions/directAudioActions" {
  42162. import { Action } from "babylonjs/Actions/action";
  42163. import { Condition } from "babylonjs/Actions/condition";
  42164. import { Sound } from "babylonjs/Audio/sound";
  42165. /**
  42166. * This defines an action helpful to play a defined sound on a triggered action.
  42167. */
  42168. export class PlaySoundAction extends Action {
  42169. private _sound;
  42170. /**
  42171. * Instantiate the action
  42172. * @param triggerOptions defines the trigger options
  42173. * @param sound defines the sound to play
  42174. * @param condition defines the trigger related conditions
  42175. */
  42176. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42177. /** @hidden */
  42178. _prepare(): void;
  42179. /**
  42180. * Execute the action and play the sound.
  42181. */
  42182. execute(): void;
  42183. /**
  42184. * Serializes the actions and its related information.
  42185. * @param parent defines the object to serialize in
  42186. * @returns the serialized object
  42187. */
  42188. serialize(parent: any): any;
  42189. }
  42190. /**
  42191. * This defines an action helpful to stop a defined sound on a triggered action.
  42192. */
  42193. export class StopSoundAction extends Action {
  42194. private _sound;
  42195. /**
  42196. * Instantiate the action
  42197. * @param triggerOptions defines the trigger options
  42198. * @param sound defines the sound to stop
  42199. * @param condition defines the trigger related conditions
  42200. */
  42201. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42202. /** @hidden */
  42203. _prepare(): void;
  42204. /**
  42205. * Execute the action and stop the sound.
  42206. */
  42207. execute(): void;
  42208. /**
  42209. * Serializes the actions and its related information.
  42210. * @param parent defines the object to serialize in
  42211. * @returns the serialized object
  42212. */
  42213. serialize(parent: any): any;
  42214. }
  42215. }
  42216. declare module "babylonjs/Actions/interpolateValueAction" {
  42217. import { Action } from "babylonjs/Actions/action";
  42218. import { Condition } from "babylonjs/Actions/condition";
  42219. import { Observable } from "babylonjs/Misc/observable";
  42220. /**
  42221. * This defines an action responsible to change the value of a property
  42222. * by interpolating between its current value and the newly set one once triggered.
  42223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42224. */
  42225. export class InterpolateValueAction extends Action {
  42226. /**
  42227. * Defines the path of the property where the value should be interpolated
  42228. */
  42229. propertyPath: string;
  42230. /**
  42231. * Defines the target value at the end of the interpolation.
  42232. */
  42233. value: any;
  42234. /**
  42235. * Defines the time it will take for the property to interpolate to the value.
  42236. */
  42237. duration: number;
  42238. /**
  42239. * Defines if the other scene animations should be stopped when the action has been triggered
  42240. */
  42241. stopOtherAnimations?: boolean;
  42242. /**
  42243. * Defines a callback raised once the interpolation animation has been done.
  42244. */
  42245. onInterpolationDone?: () => void;
  42246. /**
  42247. * Observable triggered once the interpolation animation has been done.
  42248. */
  42249. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42250. private _target;
  42251. private _effectiveTarget;
  42252. private _property;
  42253. /**
  42254. * Instantiate the action
  42255. * @param triggerOptions defines the trigger options
  42256. * @param target defines the object containing the value to interpolate
  42257. * @param propertyPath defines the path to the property in the target object
  42258. * @param value defines the target value at the end of the interpolation
  42259. * @param duration deines the time it will take for the property to interpolate to the value.
  42260. * @param condition defines the trigger related conditions
  42261. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42262. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42263. */
  42264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42265. /** @hidden */
  42266. _prepare(): void;
  42267. /**
  42268. * Execute the action starts the value interpolation.
  42269. */
  42270. execute(): void;
  42271. /**
  42272. * Serializes the actions and its related information.
  42273. * @param parent defines the object to serialize in
  42274. * @returns the serialized object
  42275. */
  42276. serialize(parent: any): any;
  42277. }
  42278. }
  42279. declare module "babylonjs/Actions/index" {
  42280. export * from "babylonjs/Actions/abstractActionManager";
  42281. export * from "babylonjs/Actions/action";
  42282. export * from "babylonjs/Actions/actionEvent";
  42283. export * from "babylonjs/Actions/actionManager";
  42284. export * from "babylonjs/Actions/condition";
  42285. export * from "babylonjs/Actions/directActions";
  42286. export * from "babylonjs/Actions/directAudioActions";
  42287. export * from "babylonjs/Actions/interpolateValueAction";
  42288. }
  42289. declare module "babylonjs/Animations/index" {
  42290. export * from "babylonjs/Animations/animatable";
  42291. export * from "babylonjs/Animations/animation";
  42292. export * from "babylonjs/Animations/animationGroup";
  42293. export * from "babylonjs/Animations/animationPropertiesOverride";
  42294. export * from "babylonjs/Animations/easing";
  42295. export * from "babylonjs/Animations/runtimeAnimation";
  42296. export * from "babylonjs/Animations/animationEvent";
  42297. export * from "babylonjs/Animations/animationGroup";
  42298. export * from "babylonjs/Animations/animationKey";
  42299. export * from "babylonjs/Animations/animationRange";
  42300. export * from "babylonjs/Animations/animatable.interface";
  42301. }
  42302. declare module "babylonjs/Audio/soundTrack" {
  42303. import { Sound } from "babylonjs/Audio/sound";
  42304. import { Analyser } from "babylonjs/Audio/analyser";
  42305. import { Scene } from "babylonjs/scene";
  42306. /**
  42307. * Options allowed during the creation of a sound track.
  42308. */
  42309. export interface ISoundTrackOptions {
  42310. /**
  42311. * The volume the sound track should take during creation
  42312. */
  42313. volume?: number;
  42314. /**
  42315. * Define if the sound track is the main sound track of the scene
  42316. */
  42317. mainTrack?: boolean;
  42318. }
  42319. /**
  42320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42321. * It will be also used in a future release to apply effects on a specific track.
  42322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42323. */
  42324. export class SoundTrack {
  42325. /**
  42326. * The unique identifier of the sound track in the scene.
  42327. */
  42328. id: number;
  42329. /**
  42330. * The list of sounds included in the sound track.
  42331. */
  42332. soundCollection: Array<Sound>;
  42333. private _outputAudioNode;
  42334. private _scene;
  42335. private _connectedAnalyser;
  42336. private _options;
  42337. private _isInitialized;
  42338. /**
  42339. * Creates a new sound track.
  42340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42341. * @param scene Define the scene the sound track belongs to
  42342. * @param options
  42343. */
  42344. constructor(scene: Scene, options?: ISoundTrackOptions);
  42345. private _initializeSoundTrackAudioGraph;
  42346. /**
  42347. * Release the sound track and its associated resources
  42348. */
  42349. dispose(): void;
  42350. /**
  42351. * Adds a sound to this sound track
  42352. * @param sound define the cound to add
  42353. * @ignoreNaming
  42354. */
  42355. AddSound(sound: Sound): void;
  42356. /**
  42357. * Removes a sound to this sound track
  42358. * @param sound define the cound to remove
  42359. * @ignoreNaming
  42360. */
  42361. RemoveSound(sound: Sound): void;
  42362. /**
  42363. * Set a global volume for the full sound track.
  42364. * @param newVolume Define the new volume of the sound track
  42365. */
  42366. setVolume(newVolume: number): void;
  42367. /**
  42368. * Switch the panning model to HRTF:
  42369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42371. */
  42372. switchPanningModelToHRTF(): void;
  42373. /**
  42374. * Switch the panning model to Equal Power:
  42375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42377. */
  42378. switchPanningModelToEqualPower(): void;
  42379. /**
  42380. * Connect the sound track to an audio analyser allowing some amazing
  42381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42383. * @param analyser The analyser to connect to the engine
  42384. */
  42385. connectToAnalyser(analyser: Analyser): void;
  42386. }
  42387. }
  42388. declare module "babylonjs/Audio/audioSceneComponent" {
  42389. import { Sound } from "babylonjs/Audio/sound";
  42390. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42391. import { Nullable } from "babylonjs/types";
  42392. import { Vector3 } from "babylonjs/Maths/math.vector";
  42393. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42394. import { Scene } from "babylonjs/scene";
  42395. import { AbstractScene } from "babylonjs/abstractScene";
  42396. import "babylonjs/Audio/audioEngine";
  42397. module "babylonjs/abstractScene" {
  42398. interface AbstractScene {
  42399. /**
  42400. * The list of sounds used in the scene.
  42401. */
  42402. sounds: Nullable<Array<Sound>>;
  42403. }
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _mainSoundTrack: SoundTrack;
  42412. /**
  42413. * The main sound track played by the scene.
  42414. * It cotains your primary collection of sounds.
  42415. */
  42416. mainSoundTrack: SoundTrack;
  42417. /**
  42418. * The list of sound tracks added to the scene
  42419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42420. */
  42421. soundTracks: Nullable<Array<SoundTrack>>;
  42422. /**
  42423. * Gets a sound using a given name
  42424. * @param name defines the name to search for
  42425. * @return the found sound or null if not found at all.
  42426. */
  42427. getSoundByName(name: string): Nullable<Sound>;
  42428. /**
  42429. * Gets or sets if audio support is enabled
  42430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42431. */
  42432. audioEnabled: boolean;
  42433. /**
  42434. * Gets or sets if audio will be output to headphones
  42435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42436. */
  42437. headphone: boolean;
  42438. /**
  42439. * Gets or sets custom audio listener position provider
  42440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42441. */
  42442. audioListenerPositionProvider: Nullable<() => Vector3>;
  42443. /**
  42444. * Gets or sets a refresh rate when using 3D audio positioning
  42445. */
  42446. audioPositioningRefreshRate: number;
  42447. }
  42448. }
  42449. /**
  42450. * Defines the sound scene component responsible to manage any sounds
  42451. * in a given scene.
  42452. */
  42453. export class AudioSceneComponent implements ISceneSerializableComponent {
  42454. /**
  42455. * The component name helpfull to identify the component in the list of scene components.
  42456. */
  42457. readonly name: string;
  42458. /**
  42459. * The scene the component belongs to.
  42460. */
  42461. scene: Scene;
  42462. private _audioEnabled;
  42463. /**
  42464. * Gets whether audio is enabled or not.
  42465. * Please use related enable/disable method to switch state.
  42466. */
  42467. get audioEnabled(): boolean;
  42468. private _headphone;
  42469. /**
  42470. * Gets whether audio is outputing to headphone or not.
  42471. * Please use the according Switch methods to change output.
  42472. */
  42473. get headphone(): boolean;
  42474. /**
  42475. * Gets or sets a refresh rate when using 3D audio positioning
  42476. */
  42477. audioPositioningRefreshRate: number;
  42478. private _audioListenerPositionProvider;
  42479. /**
  42480. * Gets the current audio listener position provider
  42481. */
  42482. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42483. /**
  42484. * Sets a custom listener position for all sounds in the scene
  42485. * By default, this is the position of the first active camera
  42486. */
  42487. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42488. /**
  42489. * Creates a new instance of the component for the given scene
  42490. * @param scene Defines the scene to register the component in
  42491. */
  42492. constructor(scene: Scene);
  42493. /**
  42494. * Registers the component in a given scene
  42495. */
  42496. register(): void;
  42497. /**
  42498. * Rebuilds the elements related to this component in case of
  42499. * context lost for instance.
  42500. */
  42501. rebuild(): void;
  42502. /**
  42503. * Serializes the component data to the specified json object
  42504. * @param serializationObject The object to serialize to
  42505. */
  42506. serialize(serializationObject: any): void;
  42507. /**
  42508. * Adds all the elements from the container to the scene
  42509. * @param container the container holding the elements
  42510. */
  42511. addFromContainer(container: AbstractScene): void;
  42512. /**
  42513. * Removes all the elements in the container from the scene
  42514. * @param container contains the elements to remove
  42515. * @param dispose if the removed element should be disposed (default: false)
  42516. */
  42517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42518. /**
  42519. * Disposes the component and the associated ressources.
  42520. */
  42521. dispose(): void;
  42522. /**
  42523. * Disables audio in the associated scene.
  42524. */
  42525. disableAudio(): void;
  42526. /**
  42527. * Enables audio in the associated scene.
  42528. */
  42529. enableAudio(): void;
  42530. /**
  42531. * Switch audio to headphone output.
  42532. */
  42533. switchAudioModeForHeadphones(): void;
  42534. /**
  42535. * Switch audio to normal speakers.
  42536. */
  42537. switchAudioModeForNormalSpeakers(): void;
  42538. private _cachedCameraDirection;
  42539. private _cachedCameraPosition;
  42540. private _lastCheck;
  42541. private _afterRender;
  42542. }
  42543. }
  42544. declare module "babylonjs/Audio/weightedsound" {
  42545. import { Sound } from "babylonjs/Audio/sound";
  42546. /**
  42547. * Wraps one or more Sound objects and selects one with random weight for playback.
  42548. */
  42549. export class WeightedSound {
  42550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42551. loop: boolean;
  42552. private _coneInnerAngle;
  42553. private _coneOuterAngle;
  42554. private _volume;
  42555. /** A Sound is currently playing. */
  42556. isPlaying: boolean;
  42557. /** A Sound is currently paused. */
  42558. isPaused: boolean;
  42559. private _sounds;
  42560. private _weights;
  42561. private _currentIndex?;
  42562. /**
  42563. * Creates a new WeightedSound from the list of sounds given.
  42564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42565. * @param sounds Array of Sounds that will be selected from.
  42566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42567. */
  42568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42569. /**
  42570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42571. */
  42572. get directionalConeInnerAngle(): number;
  42573. /**
  42574. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42575. */
  42576. set directionalConeInnerAngle(value: number);
  42577. /**
  42578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42580. */
  42581. get directionalConeOuterAngle(): number;
  42582. /**
  42583. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42584. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42585. */
  42586. set directionalConeOuterAngle(value: number);
  42587. /**
  42588. * Playback volume.
  42589. */
  42590. get volume(): number;
  42591. /**
  42592. * Playback volume.
  42593. */
  42594. set volume(value: number);
  42595. private _onended;
  42596. /**
  42597. * Suspend playback
  42598. */
  42599. pause(): void;
  42600. /**
  42601. * Stop playback
  42602. */
  42603. stop(): void;
  42604. /**
  42605. * Start playback.
  42606. * @param startOffset Position the clip head at a specific time in seconds.
  42607. */
  42608. play(startOffset?: number): void;
  42609. }
  42610. }
  42611. declare module "babylonjs/Audio/index" {
  42612. export * from "babylonjs/Audio/analyser";
  42613. export * from "babylonjs/Audio/audioEngine";
  42614. export * from "babylonjs/Audio/audioSceneComponent";
  42615. export * from "babylonjs/Audio/sound";
  42616. export * from "babylonjs/Audio/soundTrack";
  42617. export * from "babylonjs/Audio/weightedsound";
  42618. }
  42619. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42620. import { Behavior } from "babylonjs/Behaviors/behavior";
  42621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42622. import { BackEase } from "babylonjs/Animations/easing";
  42623. /**
  42624. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42625. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42626. */
  42627. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42628. /**
  42629. * Gets the name of the behavior.
  42630. */
  42631. get name(): string;
  42632. /**
  42633. * The easing function used by animations
  42634. */
  42635. static EasingFunction: BackEase;
  42636. /**
  42637. * The easing mode used by animations
  42638. */
  42639. static EasingMode: number;
  42640. /**
  42641. * The duration of the animation, in milliseconds
  42642. */
  42643. transitionDuration: number;
  42644. /**
  42645. * Length of the distance animated by the transition when lower radius is reached
  42646. */
  42647. lowerRadiusTransitionRange: number;
  42648. /**
  42649. * Length of the distance animated by the transition when upper radius is reached
  42650. */
  42651. upperRadiusTransitionRange: number;
  42652. private _autoTransitionRange;
  42653. /**
  42654. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42655. */
  42656. get autoTransitionRange(): boolean;
  42657. /**
  42658. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42659. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42660. */
  42661. set autoTransitionRange(value: boolean);
  42662. private _attachedCamera;
  42663. private _onAfterCheckInputsObserver;
  42664. private _onMeshTargetChangedObserver;
  42665. /**
  42666. * Initializes the behavior.
  42667. */
  42668. init(): void;
  42669. /**
  42670. * Attaches the behavior to its arc rotate camera.
  42671. * @param camera Defines the camera to attach the behavior to
  42672. */
  42673. attach(camera: ArcRotateCamera): void;
  42674. /**
  42675. * Detaches the behavior from its current arc rotate camera.
  42676. */
  42677. detach(): void;
  42678. private _radiusIsAnimating;
  42679. private _radiusBounceTransition;
  42680. private _animatables;
  42681. private _cachedWheelPrecision;
  42682. /**
  42683. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42684. * @param radiusLimit The limit to check against.
  42685. * @return Bool to indicate if at limit.
  42686. */
  42687. private _isRadiusAtLimit;
  42688. /**
  42689. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42690. * @param radiusDelta The delta by which to animate to. Can be negative.
  42691. */
  42692. private _applyBoundRadiusAnimation;
  42693. /**
  42694. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42695. */
  42696. protected _clearAnimationLocks(): void;
  42697. /**
  42698. * Stops and removes all animations that have been applied to the camera
  42699. */
  42700. stopAllAnimations(): void;
  42701. }
  42702. }
  42703. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42704. import { Behavior } from "babylonjs/Behaviors/behavior";
  42705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42706. import { ExponentialEase } from "babylonjs/Animations/easing";
  42707. import { Nullable } from "babylonjs/types";
  42708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42709. import { Vector3 } from "babylonjs/Maths/math.vector";
  42710. /**
  42711. * 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.
  42712. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42713. */
  42714. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42715. /**
  42716. * Gets the name of the behavior.
  42717. */
  42718. get name(): string;
  42719. private _mode;
  42720. private _radiusScale;
  42721. private _positionScale;
  42722. private _defaultElevation;
  42723. private _elevationReturnTime;
  42724. private _elevationReturnWaitTime;
  42725. private _zoomStopsAnimation;
  42726. private _framingTime;
  42727. /**
  42728. * The easing function used by animations
  42729. */
  42730. static EasingFunction: ExponentialEase;
  42731. /**
  42732. * The easing mode used by animations
  42733. */
  42734. static EasingMode: number;
  42735. /**
  42736. * Sets the current mode used by the behavior
  42737. */
  42738. set mode(mode: number);
  42739. /**
  42740. * Gets current mode used by the behavior.
  42741. */
  42742. get mode(): number;
  42743. /**
  42744. * Sets the scale applied to the radius (1 by default)
  42745. */
  42746. set radiusScale(radius: number);
  42747. /**
  42748. * Gets the scale applied to the radius
  42749. */
  42750. get radiusScale(): number;
  42751. /**
  42752. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42753. */
  42754. set positionScale(scale: number);
  42755. /**
  42756. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42757. */
  42758. get positionScale(): number;
  42759. /**
  42760. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42761. * behaviour is triggered, in radians.
  42762. */
  42763. set defaultElevation(elevation: number);
  42764. /**
  42765. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42766. * behaviour is triggered, in radians.
  42767. */
  42768. get defaultElevation(): number;
  42769. /**
  42770. * Sets the time (in milliseconds) taken to return to the default beta position.
  42771. * Negative value indicates camera should not return to default.
  42772. */
  42773. set elevationReturnTime(speed: number);
  42774. /**
  42775. * Gets the time (in milliseconds) taken to return to the default beta position.
  42776. * Negative value indicates camera should not return to default.
  42777. */
  42778. get elevationReturnTime(): number;
  42779. /**
  42780. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42781. */
  42782. set elevationReturnWaitTime(time: number);
  42783. /**
  42784. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42785. */
  42786. get elevationReturnWaitTime(): number;
  42787. /**
  42788. * Sets the flag that indicates if user zooming should stop animation.
  42789. */
  42790. set zoomStopsAnimation(flag: boolean);
  42791. /**
  42792. * Gets the flag that indicates if user zooming should stop animation.
  42793. */
  42794. get zoomStopsAnimation(): boolean;
  42795. /**
  42796. * Sets the transition time when framing the mesh, in milliseconds
  42797. */
  42798. set framingTime(time: number);
  42799. /**
  42800. * Gets the transition time when framing the mesh, in milliseconds
  42801. */
  42802. get framingTime(): number;
  42803. /**
  42804. * Define if the behavior should automatically change the configured
  42805. * camera limits and sensibilities.
  42806. */
  42807. autoCorrectCameraLimitsAndSensibility: boolean;
  42808. private _onPrePointerObservableObserver;
  42809. private _onAfterCheckInputsObserver;
  42810. private _onMeshTargetChangedObserver;
  42811. private _attachedCamera;
  42812. private _isPointerDown;
  42813. private _lastInteractionTime;
  42814. /**
  42815. * Initializes the behavior.
  42816. */
  42817. init(): void;
  42818. /**
  42819. * Attaches the behavior to its arc rotate camera.
  42820. * @param camera Defines the camera to attach the behavior to
  42821. */
  42822. attach(camera: ArcRotateCamera): void;
  42823. /**
  42824. * Detaches the behavior from its current arc rotate camera.
  42825. */
  42826. detach(): void;
  42827. private _animatables;
  42828. private _betaIsAnimating;
  42829. private _betaTransition;
  42830. private _radiusTransition;
  42831. private _vectorTransition;
  42832. /**
  42833. * Targets the given mesh and updates zoom level accordingly.
  42834. * @param mesh The mesh to target.
  42835. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42836. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42837. */
  42838. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42839. /**
  42840. * Targets the given mesh with its children and updates zoom level accordingly.
  42841. * @param mesh The mesh to target.
  42842. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42843. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42844. */
  42845. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42846. /**
  42847. * Targets the given meshes with their children and updates zoom level accordingly.
  42848. * @param meshes The mesh to target.
  42849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42851. */
  42852. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42853. /**
  42854. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42855. * @param minimumWorld Determines the smaller position of the bounding box extend
  42856. * @param maximumWorld Determines the bigger position of the bounding box extend
  42857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42859. */
  42860. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42861. /**
  42862. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42863. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42864. * frustum width.
  42865. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42866. * to fully enclose the mesh in the viewing frustum.
  42867. */
  42868. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42869. /**
  42870. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42871. * is automatically returned to its default position (expected to be above ground plane).
  42872. */
  42873. private _maintainCameraAboveGround;
  42874. /**
  42875. * Returns the frustum slope based on the canvas ratio and camera FOV
  42876. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42877. */
  42878. private _getFrustumSlope;
  42879. /**
  42880. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42881. */
  42882. private _clearAnimationLocks;
  42883. /**
  42884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42885. */
  42886. private _applyUserInteraction;
  42887. /**
  42888. * Stops and removes all animations that have been applied to the camera
  42889. */
  42890. stopAllAnimations(): void;
  42891. /**
  42892. * Gets a value indicating if the user is moving the camera
  42893. */
  42894. get isUserIsMoving(): boolean;
  42895. /**
  42896. * The camera can move all the way towards the mesh.
  42897. */
  42898. static IgnoreBoundsSizeMode: number;
  42899. /**
  42900. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42901. */
  42902. static FitFrustumSidesMode: number;
  42903. }
  42904. }
  42905. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42906. import { Nullable } from "babylonjs/types";
  42907. import { Camera } from "babylonjs/Cameras/camera";
  42908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42909. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42910. /**
  42911. * Base class for Camera Pointer Inputs.
  42912. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42913. * for example usage.
  42914. */
  42915. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42916. /**
  42917. * Defines the camera the input is attached to.
  42918. */
  42919. abstract camera: Camera;
  42920. /**
  42921. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42922. */
  42923. protected _altKey: boolean;
  42924. protected _ctrlKey: boolean;
  42925. protected _metaKey: boolean;
  42926. protected _shiftKey: boolean;
  42927. /**
  42928. * Which mouse buttons were pressed at time of last mouse event.
  42929. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42930. */
  42931. protected _buttonsPressed: number;
  42932. /**
  42933. * Defines the buttons associated with the input to handle camera move.
  42934. */
  42935. buttons: number[];
  42936. /**
  42937. * Attach the input controls to a specific dom element to get the input from.
  42938. * @param element Defines the element the controls should be listened from
  42939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42940. */
  42941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42942. /**
  42943. * Detach the current controls from the specified dom element.
  42944. * @param element Defines the element to stop listening the inputs from
  42945. */
  42946. detachControl(element: Nullable<HTMLElement>): void;
  42947. /**
  42948. * Gets the class name of the current input.
  42949. * @returns the class name
  42950. */
  42951. getClassName(): string;
  42952. /**
  42953. * Get the friendly name associated with the input class.
  42954. * @returns the input friendly name
  42955. */
  42956. getSimpleName(): string;
  42957. /**
  42958. * Called on pointer POINTERDOUBLETAP event.
  42959. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42960. */
  42961. protected onDoubleTap(type: string): void;
  42962. /**
  42963. * Called on pointer POINTERMOVE event if only a single touch is active.
  42964. * Override this method to provide functionality.
  42965. */
  42966. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42967. /**
  42968. * Called on pointer POINTERMOVE event if multiple touches are active.
  42969. * Override this method to provide functionality.
  42970. */
  42971. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42972. /**
  42973. * Called on JS contextmenu event.
  42974. * Override this method to provide functionality.
  42975. */
  42976. protected onContextMenu(evt: PointerEvent): void;
  42977. /**
  42978. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42979. * press.
  42980. * Override this method to provide functionality.
  42981. */
  42982. protected onButtonDown(evt: PointerEvent): void;
  42983. /**
  42984. * Called each time a new POINTERUP event occurs. Ie, for each button
  42985. * release.
  42986. * Override this method to provide functionality.
  42987. */
  42988. protected onButtonUp(evt: PointerEvent): void;
  42989. /**
  42990. * Called when window becomes inactive.
  42991. * Override this method to provide functionality.
  42992. */
  42993. protected onLostFocus(): void;
  42994. private _pointerInput;
  42995. private _observer;
  42996. private _onLostFocus;
  42997. private pointA;
  42998. private pointB;
  42999. }
  43000. }
  43001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43004. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43005. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43006. /**
  43007. * Manage the pointers inputs to control an arc rotate camera.
  43008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43009. */
  43010. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43011. /**
  43012. * Defines the camera the input is attached to.
  43013. */
  43014. camera: ArcRotateCamera;
  43015. /**
  43016. * Gets the class name of the current input.
  43017. * @returns the class name
  43018. */
  43019. getClassName(): string;
  43020. /**
  43021. * Defines the buttons associated with the input to handle camera move.
  43022. */
  43023. buttons: number[];
  43024. /**
  43025. * Defines the pointer angular sensibility along the X axis or how fast is
  43026. * the camera rotating.
  43027. */
  43028. angularSensibilityX: number;
  43029. /**
  43030. * Defines the pointer angular sensibility along the Y axis or how fast is
  43031. * the camera rotating.
  43032. */
  43033. angularSensibilityY: number;
  43034. /**
  43035. * Defines the pointer pinch precision or how fast is the camera zooming.
  43036. */
  43037. pinchPrecision: number;
  43038. /**
  43039. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43040. * from 0.
  43041. * It defines the percentage of current camera.radius to use as delta when
  43042. * pinch zoom is used.
  43043. */
  43044. pinchDeltaPercentage: number;
  43045. /**
  43046. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43047. * that any object in the plane at the camera's target point will scale
  43048. * perfectly with finger motion.
  43049. * Overrides pinchDeltaPercentage and pinchPrecision.
  43050. */
  43051. useNaturalPinchZoom: boolean;
  43052. /**
  43053. * Defines the pointer panning sensibility or how fast is the camera moving.
  43054. */
  43055. panningSensibility: number;
  43056. /**
  43057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43058. */
  43059. multiTouchPanning: boolean;
  43060. /**
  43061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43062. * zoom (pinch) through multitouch.
  43063. */
  43064. multiTouchPanAndZoom: boolean;
  43065. /**
  43066. * Revers pinch action direction.
  43067. */
  43068. pinchInwards: boolean;
  43069. private _isPanClick;
  43070. private _twoFingerActivityCount;
  43071. private _isPinching;
  43072. /**
  43073. * Called on pointer POINTERMOVE event if only a single touch is active.
  43074. */
  43075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43076. /**
  43077. * Called on pointer POINTERDOUBLETAP event.
  43078. */
  43079. protected onDoubleTap(type: string): void;
  43080. /**
  43081. * Called on pointer POINTERMOVE event if multiple touches are active.
  43082. */
  43083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43084. /**
  43085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43086. * press.
  43087. */
  43088. protected onButtonDown(evt: PointerEvent): void;
  43089. /**
  43090. * Called each time a new POINTERUP event occurs. Ie, for each button
  43091. * release.
  43092. */
  43093. protected onButtonUp(evt: PointerEvent): void;
  43094. /**
  43095. * Called when window becomes inactive.
  43096. */
  43097. protected onLostFocus(): void;
  43098. }
  43099. }
  43100. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43101. import { Nullable } from "babylonjs/types";
  43102. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43104. /**
  43105. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43107. */
  43108. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43109. /**
  43110. * Defines the camera the input is attached to.
  43111. */
  43112. camera: ArcRotateCamera;
  43113. /**
  43114. * Defines the list of key codes associated with the up action (increase alpha)
  43115. */
  43116. keysUp: number[];
  43117. /**
  43118. * Defines the list of key codes associated with the down action (decrease alpha)
  43119. */
  43120. keysDown: number[];
  43121. /**
  43122. * Defines the list of key codes associated with the left action (increase beta)
  43123. */
  43124. keysLeft: number[];
  43125. /**
  43126. * Defines the list of key codes associated with the right action (decrease beta)
  43127. */
  43128. keysRight: number[];
  43129. /**
  43130. * Defines the list of key codes associated with the reset action.
  43131. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43132. */
  43133. keysReset: number[];
  43134. /**
  43135. * Defines the panning sensibility of the inputs.
  43136. * (How fast is the camera panning)
  43137. */
  43138. panningSensibility: number;
  43139. /**
  43140. * Defines the zooming sensibility of the inputs.
  43141. * (How fast is the camera zooming)
  43142. */
  43143. zoomingSensibility: number;
  43144. /**
  43145. * Defines whether maintaining the alt key down switch the movement mode from
  43146. * orientation to zoom.
  43147. */
  43148. useAltToZoom: boolean;
  43149. /**
  43150. * Rotation speed of the camera
  43151. */
  43152. angularSpeed: number;
  43153. private _keys;
  43154. private _ctrlPressed;
  43155. private _altPressed;
  43156. private _onCanvasBlurObserver;
  43157. private _onKeyboardObserver;
  43158. private _engine;
  43159. private _scene;
  43160. /**
  43161. * Attach the input controls to a specific dom element to get the input from.
  43162. * @param element Defines the element the controls should be listened from
  43163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43164. */
  43165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43166. /**
  43167. * Detach the current controls from the specified dom element.
  43168. * @param element Defines the element to stop listening the inputs from
  43169. */
  43170. detachControl(element: Nullable<HTMLElement>): void;
  43171. /**
  43172. * Update the current camera state depending on the inputs that have been used this frame.
  43173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43174. */
  43175. checkInputs(): void;
  43176. /**
  43177. * Gets the class name of the current intput.
  43178. * @returns the class name
  43179. */
  43180. getClassName(): string;
  43181. /**
  43182. * Get the friendly name associated with the input class.
  43183. * @returns the input friendly name
  43184. */
  43185. getSimpleName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43189. import { Nullable } from "babylonjs/types";
  43190. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43192. /**
  43193. * Manage the mouse wheel inputs to control an arc rotate camera.
  43194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43195. */
  43196. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43197. /**
  43198. * Defines the camera the input is attached to.
  43199. */
  43200. camera: ArcRotateCamera;
  43201. /**
  43202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43203. */
  43204. wheelPrecision: number;
  43205. /**
  43206. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43207. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43208. */
  43209. wheelDeltaPercentage: number;
  43210. private _wheel;
  43211. private _observer;
  43212. private computeDeltaFromMouseWheelLegacyEvent;
  43213. /**
  43214. * Attach the input controls to a specific dom element to get the input from.
  43215. * @param element Defines the element the controls should be listened from
  43216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43217. */
  43218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43219. /**
  43220. * Detach the current controls from the specified dom element.
  43221. * @param element Defines the element to stop listening the inputs from
  43222. */
  43223. detachControl(element: Nullable<HTMLElement>): void;
  43224. /**
  43225. * Gets the class name of the current intput.
  43226. * @returns the class name
  43227. */
  43228. getClassName(): string;
  43229. /**
  43230. * Get the friendly name associated with the input class.
  43231. * @returns the input friendly name
  43232. */
  43233. getSimpleName(): string;
  43234. }
  43235. }
  43236. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43237. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43238. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43239. /**
  43240. * Default Inputs manager for the ArcRotateCamera.
  43241. * It groups all the default supported inputs for ease of use.
  43242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43243. */
  43244. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43245. /**
  43246. * Instantiates a new ArcRotateCameraInputsManager.
  43247. * @param camera Defines the camera the inputs belong to
  43248. */
  43249. constructor(camera: ArcRotateCamera);
  43250. /**
  43251. * Add mouse wheel input support to the input manager.
  43252. * @returns the current input manager
  43253. */
  43254. addMouseWheel(): ArcRotateCameraInputsManager;
  43255. /**
  43256. * Add pointers input support to the input manager.
  43257. * @returns the current input manager
  43258. */
  43259. addPointers(): ArcRotateCameraInputsManager;
  43260. /**
  43261. * Add keyboard input support to the input manager.
  43262. * @returns the current input manager
  43263. */
  43264. addKeyboard(): ArcRotateCameraInputsManager;
  43265. }
  43266. }
  43267. declare module "babylonjs/Cameras/arcRotateCamera" {
  43268. import { Observable } from "babylonjs/Misc/observable";
  43269. import { Nullable } from "babylonjs/types";
  43270. import { Scene } from "babylonjs/scene";
  43271. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43273. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43274. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43275. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43276. import { Camera } from "babylonjs/Cameras/camera";
  43277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43278. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43279. import { Collider } from "babylonjs/Collisions/collider";
  43280. /**
  43281. * This represents an orbital type of camera.
  43282. *
  43283. * 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.
  43284. * 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.
  43285. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43286. */
  43287. export class ArcRotateCamera extends TargetCamera {
  43288. /**
  43289. * Defines the rotation angle of the camera along the longitudinal axis.
  43290. */
  43291. alpha: number;
  43292. /**
  43293. * Defines the rotation angle of the camera along the latitudinal axis.
  43294. */
  43295. beta: number;
  43296. /**
  43297. * Defines the radius of the camera from it s target point.
  43298. */
  43299. radius: number;
  43300. protected _target: Vector3;
  43301. protected _targetHost: Nullable<AbstractMesh>;
  43302. /**
  43303. * Defines the target point of the camera.
  43304. * The camera looks towards it form the radius distance.
  43305. */
  43306. get target(): Vector3;
  43307. set target(value: Vector3);
  43308. /**
  43309. * Define the current local position of the camera in the scene
  43310. */
  43311. get position(): Vector3;
  43312. set position(newPosition: Vector3);
  43313. protected _upVector: Vector3;
  43314. protected _upToYMatrix: Matrix;
  43315. protected _YToUpMatrix: Matrix;
  43316. /**
  43317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43320. */
  43321. set upVector(vec: Vector3);
  43322. get upVector(): Vector3;
  43323. /**
  43324. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43325. */
  43326. setMatUp(): void;
  43327. /**
  43328. * Current inertia value on the longitudinal axis.
  43329. * The bigger this number the longer it will take for the camera to stop.
  43330. */
  43331. inertialAlphaOffset: number;
  43332. /**
  43333. * Current inertia value on the latitudinal axis.
  43334. * The bigger this number the longer it will take for the camera to stop.
  43335. */
  43336. inertialBetaOffset: number;
  43337. /**
  43338. * Current inertia value on the radius axis.
  43339. * The bigger this number the longer it will take for the camera to stop.
  43340. */
  43341. inertialRadiusOffset: number;
  43342. /**
  43343. * Minimum allowed angle on the longitudinal axis.
  43344. * This can help limiting how the Camera is able to move in the scene.
  43345. */
  43346. lowerAlphaLimit: Nullable<number>;
  43347. /**
  43348. * Maximum allowed angle on the longitudinal axis.
  43349. * This can help limiting how the Camera is able to move in the scene.
  43350. */
  43351. upperAlphaLimit: Nullable<number>;
  43352. /**
  43353. * Minimum allowed angle on the latitudinal axis.
  43354. * This can help limiting how the Camera is able to move in the scene.
  43355. */
  43356. lowerBetaLimit: number;
  43357. /**
  43358. * Maximum allowed angle on the latitudinal axis.
  43359. * This can help limiting how the Camera is able to move in the scene.
  43360. */
  43361. upperBetaLimit: number;
  43362. /**
  43363. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43364. * This can help limiting how the Camera is able to move in the scene.
  43365. */
  43366. lowerRadiusLimit: Nullable<number>;
  43367. /**
  43368. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43369. * This can help limiting how the Camera is able to move in the scene.
  43370. */
  43371. upperRadiusLimit: Nullable<number>;
  43372. /**
  43373. * Defines the current inertia value used during panning of the camera along the X axis.
  43374. */
  43375. inertialPanningX: number;
  43376. /**
  43377. * Defines the current inertia value used during panning of the camera along the Y axis.
  43378. */
  43379. inertialPanningY: number;
  43380. /**
  43381. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43382. * Basically if your fingers moves away from more than this distance you will be considered
  43383. * in pinch mode.
  43384. */
  43385. pinchToPanMaxDistance: number;
  43386. /**
  43387. * Defines the maximum distance the camera can pan.
  43388. * This could help keeping the cammera always in your scene.
  43389. */
  43390. panningDistanceLimit: Nullable<number>;
  43391. /**
  43392. * Defines the target of the camera before paning.
  43393. */
  43394. panningOriginTarget: Vector3;
  43395. /**
  43396. * Defines the value of the inertia used during panning.
  43397. * 0 would mean stop inertia and one would mean no decelleration at all.
  43398. */
  43399. panningInertia: number;
  43400. /**
  43401. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43402. */
  43403. get angularSensibilityX(): number;
  43404. set angularSensibilityX(value: number);
  43405. /**
  43406. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43407. */
  43408. get angularSensibilityY(): number;
  43409. set angularSensibilityY(value: number);
  43410. /**
  43411. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43412. */
  43413. get pinchPrecision(): number;
  43414. set pinchPrecision(value: number);
  43415. /**
  43416. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43417. * It will be used instead of pinchDeltaPrecision if different from 0.
  43418. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43419. */
  43420. get pinchDeltaPercentage(): number;
  43421. set pinchDeltaPercentage(value: number);
  43422. /**
  43423. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43424. * and pinch delta percentage.
  43425. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43426. * that any object in the plane at the camera's target point will scale
  43427. * perfectly with finger motion.
  43428. */
  43429. get useNaturalPinchZoom(): boolean;
  43430. set useNaturalPinchZoom(value: boolean);
  43431. /**
  43432. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43433. */
  43434. get panningSensibility(): number;
  43435. set panningSensibility(value: number);
  43436. /**
  43437. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43438. */
  43439. get keysUp(): number[];
  43440. set keysUp(value: number[]);
  43441. /**
  43442. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43443. */
  43444. get keysDown(): number[];
  43445. set keysDown(value: number[]);
  43446. /**
  43447. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43448. */
  43449. get keysLeft(): number[];
  43450. set keysLeft(value: number[]);
  43451. /**
  43452. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43453. */
  43454. get keysRight(): number[];
  43455. set keysRight(value: number[]);
  43456. /**
  43457. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43458. */
  43459. get wheelPrecision(): number;
  43460. set wheelPrecision(value: number);
  43461. /**
  43462. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43463. * It will be used instead of pinchDeltaPrecision if different from 0.
  43464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43465. */
  43466. get wheelDeltaPercentage(): number;
  43467. set wheelDeltaPercentage(value: number);
  43468. /**
  43469. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43470. */
  43471. zoomOnFactor: number;
  43472. /**
  43473. * Defines a screen offset for the camera position.
  43474. */
  43475. targetScreenOffset: Vector2;
  43476. /**
  43477. * Allows the camera to be completely reversed.
  43478. * If false the camera can not arrive upside down.
  43479. */
  43480. allowUpsideDown: boolean;
  43481. /**
  43482. * Define if double tap/click is used to restore the previously saved state of the camera.
  43483. */
  43484. useInputToRestoreState: boolean;
  43485. /** @hidden */
  43486. _viewMatrix: Matrix;
  43487. /** @hidden */
  43488. _useCtrlForPanning: boolean;
  43489. /** @hidden */
  43490. _panningMouseButton: number;
  43491. /**
  43492. * Defines the input associated to the camera.
  43493. */
  43494. inputs: ArcRotateCameraInputsManager;
  43495. /** @hidden */
  43496. _reset: () => void;
  43497. /**
  43498. * Defines the allowed panning axis.
  43499. */
  43500. panningAxis: Vector3;
  43501. protected _localDirection: Vector3;
  43502. protected _transformedDirection: Vector3;
  43503. private _bouncingBehavior;
  43504. /**
  43505. * Gets the bouncing behavior of the camera if it has been enabled.
  43506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43507. */
  43508. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43509. /**
  43510. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43512. */
  43513. get useBouncingBehavior(): boolean;
  43514. set useBouncingBehavior(value: boolean);
  43515. private _framingBehavior;
  43516. /**
  43517. * Gets the framing behavior of the camera if it has been enabled.
  43518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43519. */
  43520. get framingBehavior(): Nullable<FramingBehavior>;
  43521. /**
  43522. * Defines if the framing behavior of the camera is enabled on the camera.
  43523. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43524. */
  43525. get useFramingBehavior(): boolean;
  43526. set useFramingBehavior(value: boolean);
  43527. private _autoRotationBehavior;
  43528. /**
  43529. * Gets the auto rotation behavior of the camera if it has been enabled.
  43530. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43531. */
  43532. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43533. /**
  43534. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43535. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43536. */
  43537. get useAutoRotationBehavior(): boolean;
  43538. set useAutoRotationBehavior(value: boolean);
  43539. /**
  43540. * Observable triggered when the mesh target has been changed on the camera.
  43541. */
  43542. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43543. /**
  43544. * Event raised when the camera is colliding with a mesh.
  43545. */
  43546. onCollide: (collidedMesh: AbstractMesh) => void;
  43547. /**
  43548. * Defines whether the camera should check collision with the objects oh the scene.
  43549. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43550. */
  43551. checkCollisions: boolean;
  43552. /**
  43553. * Defines the collision radius of the camera.
  43554. * This simulates a sphere around the camera.
  43555. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43556. */
  43557. collisionRadius: Vector3;
  43558. protected _collider: Collider;
  43559. protected _previousPosition: Vector3;
  43560. protected _collisionVelocity: Vector3;
  43561. protected _newPosition: Vector3;
  43562. protected _previousAlpha: number;
  43563. protected _previousBeta: number;
  43564. protected _previousRadius: number;
  43565. protected _collisionTriggered: boolean;
  43566. protected _targetBoundingCenter: Nullable<Vector3>;
  43567. private _computationVector;
  43568. /**
  43569. * Instantiates a new ArcRotateCamera in a given scene
  43570. * @param name Defines the name of the camera
  43571. * @param alpha Defines the camera rotation along the logitudinal axis
  43572. * @param beta Defines the camera rotation along the latitudinal axis
  43573. * @param radius Defines the camera distance from its target
  43574. * @param target Defines the camera target
  43575. * @param scene Defines the scene the camera belongs to
  43576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43577. */
  43578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43579. /** @hidden */
  43580. _initCache(): void;
  43581. /** @hidden */
  43582. _updateCache(ignoreParentClass?: boolean): void;
  43583. protected _getTargetPosition(): Vector3;
  43584. private _storedAlpha;
  43585. private _storedBeta;
  43586. private _storedRadius;
  43587. private _storedTarget;
  43588. private _storedTargetScreenOffset;
  43589. /**
  43590. * Stores the current state of the camera (alpha, beta, radius and target)
  43591. * @returns the camera itself
  43592. */
  43593. storeState(): Camera;
  43594. /**
  43595. * @hidden
  43596. * Restored camera state. You must call storeState() first
  43597. */
  43598. _restoreStateValues(): boolean;
  43599. /** @hidden */
  43600. _isSynchronizedViewMatrix(): boolean;
  43601. /**
  43602. * Attached controls to the current camera.
  43603. * @param element Defines the element the controls should be listened from
  43604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43605. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43606. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43607. */
  43608. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43609. /**
  43610. * Detach the current controls from the camera.
  43611. * The camera will stop reacting to inputs.
  43612. * @param element Defines the element to stop listening the inputs from
  43613. */
  43614. detachControl(element: HTMLElement): void;
  43615. /** @hidden */
  43616. _checkInputs(): void;
  43617. protected _checkLimits(): void;
  43618. /**
  43619. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43620. */
  43621. rebuildAnglesAndRadius(): void;
  43622. /**
  43623. * Use a position to define the current camera related information like alpha, beta and radius
  43624. * @param position Defines the position to set the camera at
  43625. */
  43626. setPosition(position: Vector3): void;
  43627. /**
  43628. * Defines the target the camera should look at.
  43629. * This will automatically adapt alpha beta and radius to fit within the new target.
  43630. * @param target Defines the new target as a Vector or a mesh
  43631. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43632. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43633. */
  43634. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43635. /** @hidden */
  43636. _getViewMatrix(): Matrix;
  43637. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43638. /**
  43639. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43640. * @param meshes Defines the mesh to zoom on
  43641. * @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)
  43642. */
  43643. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43644. /**
  43645. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43646. * The target will be changed but the radius
  43647. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43648. * @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)
  43649. */
  43650. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43651. min: Vector3;
  43652. max: Vector3;
  43653. distance: number;
  43654. }, doNotUpdateMaxZ?: boolean): void;
  43655. /**
  43656. * @override
  43657. * Override Camera.createRigCamera
  43658. */
  43659. createRigCamera(name: string, cameraIndex: number): Camera;
  43660. /**
  43661. * @hidden
  43662. * @override
  43663. * Override Camera._updateRigCameras
  43664. */
  43665. _updateRigCameras(): void;
  43666. /**
  43667. * Destroy the camera and release the current resources hold by it.
  43668. */
  43669. dispose(): void;
  43670. /**
  43671. * Gets the current object class name.
  43672. * @return the class name
  43673. */
  43674. getClassName(): string;
  43675. }
  43676. }
  43677. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43678. import { Behavior } from "babylonjs/Behaviors/behavior";
  43679. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43680. /**
  43681. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43683. */
  43684. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43685. /**
  43686. * Gets the name of the behavior.
  43687. */
  43688. get name(): string;
  43689. private _zoomStopsAnimation;
  43690. private _idleRotationSpeed;
  43691. private _idleRotationWaitTime;
  43692. private _idleRotationSpinupTime;
  43693. /**
  43694. * Sets the flag that indicates if user zooming should stop animation.
  43695. */
  43696. set zoomStopsAnimation(flag: boolean);
  43697. /**
  43698. * Gets the flag that indicates if user zooming should stop animation.
  43699. */
  43700. get zoomStopsAnimation(): boolean;
  43701. /**
  43702. * Sets the default speed at which the camera rotates around the model.
  43703. */
  43704. set idleRotationSpeed(speed: number);
  43705. /**
  43706. * Gets the default speed at which the camera rotates around the model.
  43707. */
  43708. get idleRotationSpeed(): number;
  43709. /**
  43710. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43711. */
  43712. set idleRotationWaitTime(time: number);
  43713. /**
  43714. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43715. */
  43716. get idleRotationWaitTime(): number;
  43717. /**
  43718. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43719. */
  43720. set idleRotationSpinupTime(time: number);
  43721. /**
  43722. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43723. */
  43724. get idleRotationSpinupTime(): number;
  43725. /**
  43726. * Gets a value indicating if the camera is currently rotating because of this behavior
  43727. */
  43728. get rotationInProgress(): boolean;
  43729. private _onPrePointerObservableObserver;
  43730. private _onAfterCheckInputsObserver;
  43731. private _attachedCamera;
  43732. private _isPointerDown;
  43733. private _lastFrameTime;
  43734. private _lastInteractionTime;
  43735. private _cameraRotationSpeed;
  43736. /**
  43737. * Initializes the behavior.
  43738. */
  43739. init(): void;
  43740. /**
  43741. * Attaches the behavior to its arc rotate camera.
  43742. * @param camera Defines the camera to attach the behavior to
  43743. */
  43744. attach(camera: ArcRotateCamera): void;
  43745. /**
  43746. * Detaches the behavior from its current arc rotate camera.
  43747. */
  43748. detach(): void;
  43749. /**
  43750. * Returns true if user is scrolling.
  43751. * @return true if user is scrolling.
  43752. */
  43753. private _userIsZooming;
  43754. private _lastFrameRadius;
  43755. private _shouldAnimationStopForInteraction;
  43756. /**
  43757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43758. */
  43759. private _applyUserInteraction;
  43760. private _userIsMoving;
  43761. }
  43762. }
  43763. declare module "babylonjs/Behaviors/Cameras/index" {
  43764. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43765. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43766. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43767. }
  43768. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43769. import { Mesh } from "babylonjs/Meshes/mesh";
  43770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43771. import { Behavior } from "babylonjs/Behaviors/behavior";
  43772. /**
  43773. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43774. */
  43775. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43776. private ui;
  43777. /**
  43778. * The name of the behavior
  43779. */
  43780. name: string;
  43781. /**
  43782. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43783. */
  43784. distanceAwayFromFace: number;
  43785. /**
  43786. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43787. */
  43788. distanceAwayFromBottomOfFace: number;
  43789. private _faceVectors;
  43790. private _target;
  43791. private _scene;
  43792. private _onRenderObserver;
  43793. private _tmpMatrix;
  43794. private _tmpVector;
  43795. /**
  43796. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43797. * @param ui The transform node that should be attched to the mesh
  43798. */
  43799. constructor(ui: TransformNode);
  43800. /**
  43801. * Initializes the behavior
  43802. */
  43803. init(): void;
  43804. private _closestFace;
  43805. private _zeroVector;
  43806. private _lookAtTmpMatrix;
  43807. private _lookAtToRef;
  43808. /**
  43809. * Attaches the AttachToBoxBehavior to the passed in mesh
  43810. * @param target The mesh that the specified node will be attached to
  43811. */
  43812. attach(target: Mesh): void;
  43813. /**
  43814. * Detaches the behavior from the mesh
  43815. */
  43816. detach(): void;
  43817. }
  43818. }
  43819. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43820. import { Behavior } from "babylonjs/Behaviors/behavior";
  43821. import { Mesh } from "babylonjs/Meshes/mesh";
  43822. /**
  43823. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43824. */
  43825. export class FadeInOutBehavior implements Behavior<Mesh> {
  43826. /**
  43827. * Time in milliseconds to delay before fading in (Default: 0)
  43828. */
  43829. delay: number;
  43830. /**
  43831. * Time in milliseconds for the mesh to fade in (Default: 300)
  43832. */
  43833. fadeInTime: number;
  43834. private _millisecondsPerFrame;
  43835. private _hovered;
  43836. private _hoverValue;
  43837. private _ownerNode;
  43838. /**
  43839. * Instatiates the FadeInOutBehavior
  43840. */
  43841. constructor();
  43842. /**
  43843. * The name of the behavior
  43844. */
  43845. get name(): string;
  43846. /**
  43847. * Initializes the behavior
  43848. */
  43849. init(): void;
  43850. /**
  43851. * Attaches the fade behavior on the passed in mesh
  43852. * @param ownerNode The mesh that will be faded in/out once attached
  43853. */
  43854. attach(ownerNode: Mesh): void;
  43855. /**
  43856. * Detaches the behavior from the mesh
  43857. */
  43858. detach(): void;
  43859. /**
  43860. * Triggers the mesh to begin fading in or out
  43861. * @param value if the object should fade in or out (true to fade in)
  43862. */
  43863. fadeIn(value: boolean): void;
  43864. private _update;
  43865. private _setAllVisibility;
  43866. }
  43867. }
  43868. declare module "babylonjs/Misc/pivotTools" {
  43869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43870. /**
  43871. * Class containing a set of static utilities functions for managing Pivots
  43872. * @hidden
  43873. */
  43874. export class PivotTools {
  43875. private static _PivotCached;
  43876. private static _OldPivotPoint;
  43877. private static _PivotTranslation;
  43878. private static _PivotTmpVector;
  43879. /** @hidden */
  43880. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43881. /** @hidden */
  43882. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43883. }
  43884. }
  43885. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43886. import { Scene } from "babylonjs/scene";
  43887. import { Vector4 } from "babylonjs/Maths/math.vector";
  43888. import { Mesh } from "babylonjs/Meshes/mesh";
  43889. import { Nullable } from "babylonjs/types";
  43890. import { Plane } from "babylonjs/Maths/math.plane";
  43891. /**
  43892. * Class containing static functions to help procedurally build meshes
  43893. */
  43894. export class PlaneBuilder {
  43895. /**
  43896. * Creates a plane mesh
  43897. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43898. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43899. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43903. * @param name defines the name of the mesh
  43904. * @param options defines the options used to create the mesh
  43905. * @param scene defines the hosting scene
  43906. * @returns the plane mesh
  43907. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43908. */
  43909. static CreatePlane(name: string, options: {
  43910. size?: number;
  43911. width?: number;
  43912. height?: number;
  43913. sideOrientation?: number;
  43914. frontUVs?: Vector4;
  43915. backUVs?: Vector4;
  43916. updatable?: boolean;
  43917. sourcePlane?: Plane;
  43918. }, scene?: Nullable<Scene>): Mesh;
  43919. }
  43920. }
  43921. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43922. import { Behavior } from "babylonjs/Behaviors/behavior";
  43923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43924. import { Observable } from "babylonjs/Misc/observable";
  43925. import { Vector3 } from "babylonjs/Maths/math.vector";
  43926. import { Ray } from "babylonjs/Culling/ray";
  43927. import "babylonjs/Meshes/Builders/planeBuilder";
  43928. /**
  43929. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43930. */
  43931. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43932. private static _AnyMouseID;
  43933. /**
  43934. * Abstract mesh the behavior is set on
  43935. */
  43936. attachedNode: AbstractMesh;
  43937. private _dragPlane;
  43938. private _scene;
  43939. private _pointerObserver;
  43940. private _beforeRenderObserver;
  43941. private static _planeScene;
  43942. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43943. /**
  43944. * 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)
  43945. */
  43946. maxDragAngle: number;
  43947. /**
  43948. * @hidden
  43949. */
  43950. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43951. /**
  43952. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43953. */
  43954. currentDraggingPointerID: number;
  43955. /**
  43956. * The last position where the pointer hit the drag plane in world space
  43957. */
  43958. lastDragPosition: Vector3;
  43959. /**
  43960. * If the behavior is currently in a dragging state
  43961. */
  43962. dragging: boolean;
  43963. /**
  43964. * 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)
  43965. */
  43966. dragDeltaRatio: number;
  43967. /**
  43968. * If the drag plane orientation should be updated during the dragging (Default: true)
  43969. */
  43970. updateDragPlane: boolean;
  43971. private _debugMode;
  43972. private _moving;
  43973. /**
  43974. * Fires each time the attached mesh is dragged with the pointer
  43975. * * delta between last drag position and current drag position in world space
  43976. * * dragDistance along the drag axis
  43977. * * dragPlaneNormal normal of the current drag plane used during the drag
  43978. * * dragPlanePoint in world space where the drag intersects the drag plane
  43979. */
  43980. onDragObservable: Observable<{
  43981. delta: Vector3;
  43982. dragPlanePoint: Vector3;
  43983. dragPlaneNormal: Vector3;
  43984. dragDistance: number;
  43985. pointerId: number;
  43986. }>;
  43987. /**
  43988. * Fires each time a drag begins (eg. mouse down on mesh)
  43989. */
  43990. onDragStartObservable: Observable<{
  43991. dragPlanePoint: Vector3;
  43992. pointerId: number;
  43993. }>;
  43994. /**
  43995. * Fires each time a drag ends (eg. mouse release after drag)
  43996. */
  43997. onDragEndObservable: Observable<{
  43998. dragPlanePoint: Vector3;
  43999. pointerId: number;
  44000. }>;
  44001. /**
  44002. * If the attached mesh should be moved when dragged
  44003. */
  44004. moveAttached: boolean;
  44005. /**
  44006. * If the drag behavior will react to drag events (Default: true)
  44007. */
  44008. enabled: boolean;
  44009. /**
  44010. * If pointer events should start and release the drag (Default: true)
  44011. */
  44012. startAndReleaseDragOnPointerEvents: boolean;
  44013. /**
  44014. * If camera controls should be detached during the drag
  44015. */
  44016. detachCameraControls: boolean;
  44017. /**
  44018. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44019. */
  44020. useObjectOrientationForDragging: boolean;
  44021. private _options;
  44022. /**
  44023. * Gets the options used by the behavior
  44024. */
  44025. get options(): {
  44026. dragAxis?: Vector3;
  44027. dragPlaneNormal?: Vector3;
  44028. };
  44029. /**
  44030. * Sets the options used by the behavior
  44031. */
  44032. set options(options: {
  44033. dragAxis?: Vector3;
  44034. dragPlaneNormal?: Vector3;
  44035. });
  44036. /**
  44037. * Creates a pointer drag behavior that can be attached to a mesh
  44038. * @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)
  44039. */
  44040. constructor(options?: {
  44041. dragAxis?: Vector3;
  44042. dragPlaneNormal?: Vector3;
  44043. });
  44044. /**
  44045. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44046. */
  44047. validateDrag: (targetPosition: Vector3) => boolean;
  44048. /**
  44049. * The name of the behavior
  44050. */
  44051. get name(): string;
  44052. /**
  44053. * Initializes the behavior
  44054. */
  44055. init(): void;
  44056. private _tmpVector;
  44057. private _alternatePickedPoint;
  44058. private _worldDragAxis;
  44059. private _targetPosition;
  44060. private _attachedElement;
  44061. /**
  44062. * Attaches the drag behavior the passed in mesh
  44063. * @param ownerNode The mesh that will be dragged around once attached
  44064. * @param predicate Predicate to use for pick filtering
  44065. */
  44066. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44067. /**
  44068. * Force relase the drag action by code.
  44069. */
  44070. releaseDrag(): void;
  44071. private _startDragRay;
  44072. private _lastPointerRay;
  44073. /**
  44074. * Simulates the start of a pointer drag event on the behavior
  44075. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44076. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44077. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44078. */
  44079. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44080. private _startDrag;
  44081. private _dragDelta;
  44082. private _moveDrag;
  44083. private _pickWithRayOnDragPlane;
  44084. private _pointA;
  44085. private _pointB;
  44086. private _pointC;
  44087. private _lineA;
  44088. private _lineB;
  44089. private _localAxis;
  44090. private _lookAt;
  44091. private _updateDragPlanePosition;
  44092. /**
  44093. * Detaches the behavior from the mesh
  44094. */
  44095. detach(): void;
  44096. }
  44097. }
  44098. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44099. import { Mesh } from "babylonjs/Meshes/mesh";
  44100. import { Behavior } from "babylonjs/Behaviors/behavior";
  44101. /**
  44102. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44103. */
  44104. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44105. private _dragBehaviorA;
  44106. private _dragBehaviorB;
  44107. private _startDistance;
  44108. private _initialScale;
  44109. private _targetScale;
  44110. private _ownerNode;
  44111. private _sceneRenderObserver;
  44112. /**
  44113. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44114. */
  44115. constructor();
  44116. /**
  44117. * The name of the behavior
  44118. */
  44119. get name(): string;
  44120. /**
  44121. * Initializes the behavior
  44122. */
  44123. init(): void;
  44124. private _getCurrentDistance;
  44125. /**
  44126. * Attaches the scale behavior the passed in mesh
  44127. * @param ownerNode The mesh that will be scaled around once attached
  44128. */
  44129. attach(ownerNode: Mesh): void;
  44130. /**
  44131. * Detaches the behavior from the mesh
  44132. */
  44133. detach(): void;
  44134. }
  44135. }
  44136. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44137. import { Behavior } from "babylonjs/Behaviors/behavior";
  44138. import { Mesh } from "babylonjs/Meshes/mesh";
  44139. import { Observable } from "babylonjs/Misc/observable";
  44140. /**
  44141. * 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
  44142. */
  44143. export class SixDofDragBehavior implements Behavior<Mesh> {
  44144. private static _virtualScene;
  44145. private _ownerNode;
  44146. private _sceneRenderObserver;
  44147. private _scene;
  44148. private _targetPosition;
  44149. private _virtualOriginMesh;
  44150. private _virtualDragMesh;
  44151. private _pointerObserver;
  44152. private _moving;
  44153. private _startingOrientation;
  44154. private _attachedElement;
  44155. /**
  44156. * 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)
  44157. */
  44158. private zDragFactor;
  44159. /**
  44160. * If the object should rotate to face the drag origin
  44161. */
  44162. rotateDraggedObject: boolean;
  44163. /**
  44164. * If the behavior is currently in a dragging state
  44165. */
  44166. dragging: boolean;
  44167. /**
  44168. * 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)
  44169. */
  44170. dragDeltaRatio: number;
  44171. /**
  44172. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44173. */
  44174. currentDraggingPointerID: number;
  44175. /**
  44176. * If camera controls should be detached during the drag
  44177. */
  44178. detachCameraControls: boolean;
  44179. /**
  44180. * Fires each time a drag starts
  44181. */
  44182. onDragStartObservable: Observable<{}>;
  44183. /**
  44184. * Fires each time a drag ends (eg. mouse release after drag)
  44185. */
  44186. onDragEndObservable: Observable<{}>;
  44187. /**
  44188. * 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
  44189. */
  44190. constructor();
  44191. /**
  44192. * The name of the behavior
  44193. */
  44194. get name(): string;
  44195. /**
  44196. * Initializes the behavior
  44197. */
  44198. init(): void;
  44199. /**
  44200. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44201. */
  44202. private get _pointerCamera();
  44203. /**
  44204. * Attaches the scale behavior the passed in mesh
  44205. * @param ownerNode The mesh that will be scaled around once attached
  44206. */
  44207. attach(ownerNode: Mesh): void;
  44208. /**
  44209. * Detaches the behavior from the mesh
  44210. */
  44211. detach(): void;
  44212. }
  44213. }
  44214. declare module "babylonjs/Behaviors/Meshes/index" {
  44215. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44216. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44217. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44218. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44219. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44220. }
  44221. declare module "babylonjs/Behaviors/index" {
  44222. export * from "babylonjs/Behaviors/behavior";
  44223. export * from "babylonjs/Behaviors/Cameras/index";
  44224. export * from "babylonjs/Behaviors/Meshes/index";
  44225. }
  44226. declare module "babylonjs/Bones/boneIKController" {
  44227. import { Bone } from "babylonjs/Bones/bone";
  44228. import { Vector3 } from "babylonjs/Maths/math.vector";
  44229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44230. import { Nullable } from "babylonjs/types";
  44231. /**
  44232. * Class used to apply inverse kinematics to bones
  44233. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44234. */
  44235. export class BoneIKController {
  44236. private static _tmpVecs;
  44237. private static _tmpQuat;
  44238. private static _tmpMats;
  44239. /**
  44240. * Gets or sets the target mesh
  44241. */
  44242. targetMesh: AbstractMesh;
  44243. /** Gets or sets the mesh used as pole */
  44244. poleTargetMesh: AbstractMesh;
  44245. /**
  44246. * Gets or sets the bone used as pole
  44247. */
  44248. poleTargetBone: Nullable<Bone>;
  44249. /**
  44250. * Gets or sets the target position
  44251. */
  44252. targetPosition: Vector3;
  44253. /**
  44254. * Gets or sets the pole target position
  44255. */
  44256. poleTargetPosition: Vector3;
  44257. /**
  44258. * Gets or sets the pole target local offset
  44259. */
  44260. poleTargetLocalOffset: Vector3;
  44261. /**
  44262. * Gets or sets the pole angle
  44263. */
  44264. poleAngle: number;
  44265. /**
  44266. * Gets or sets the mesh associated with the controller
  44267. */
  44268. mesh: AbstractMesh;
  44269. /**
  44270. * 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)
  44271. */
  44272. slerpAmount: number;
  44273. private _bone1Quat;
  44274. private _bone1Mat;
  44275. private _bone2Ang;
  44276. private _bone1;
  44277. private _bone2;
  44278. private _bone1Length;
  44279. private _bone2Length;
  44280. private _maxAngle;
  44281. private _maxReach;
  44282. private _rightHandedSystem;
  44283. private _bendAxis;
  44284. private _slerping;
  44285. private _adjustRoll;
  44286. /**
  44287. * Gets or sets maximum allowed angle
  44288. */
  44289. get maxAngle(): number;
  44290. set maxAngle(value: number);
  44291. /**
  44292. * Creates a new BoneIKController
  44293. * @param mesh defines the mesh to control
  44294. * @param bone defines the bone to control
  44295. * @param options defines options to set up the controller
  44296. */
  44297. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44298. targetMesh?: AbstractMesh;
  44299. poleTargetMesh?: AbstractMesh;
  44300. poleTargetBone?: Bone;
  44301. poleTargetLocalOffset?: Vector3;
  44302. poleAngle?: number;
  44303. bendAxis?: Vector3;
  44304. maxAngle?: number;
  44305. slerpAmount?: number;
  44306. });
  44307. private _setMaxAngle;
  44308. /**
  44309. * Force the controller to update the bones
  44310. */
  44311. update(): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Bones/boneLookController" {
  44315. import { Vector3 } from "babylonjs/Maths/math.vector";
  44316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44317. import { Bone } from "babylonjs/Bones/bone";
  44318. import { Space } from "babylonjs/Maths/math.axis";
  44319. /**
  44320. * Class used to make a bone look toward a point in space
  44321. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44322. */
  44323. export class BoneLookController {
  44324. private static _tmpVecs;
  44325. private static _tmpQuat;
  44326. private static _tmpMats;
  44327. /**
  44328. * The target Vector3 that the bone will look at
  44329. */
  44330. target: Vector3;
  44331. /**
  44332. * The mesh that the bone is attached to
  44333. */
  44334. mesh: AbstractMesh;
  44335. /**
  44336. * The bone that will be looking to the target
  44337. */
  44338. bone: Bone;
  44339. /**
  44340. * The up axis of the coordinate system that is used when the bone is rotated
  44341. */
  44342. upAxis: Vector3;
  44343. /**
  44344. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44345. */
  44346. upAxisSpace: Space;
  44347. /**
  44348. * Used to make an adjustment to the yaw of the bone
  44349. */
  44350. adjustYaw: number;
  44351. /**
  44352. * Used to make an adjustment to the pitch of the bone
  44353. */
  44354. adjustPitch: number;
  44355. /**
  44356. * Used to make an adjustment to the roll of the bone
  44357. */
  44358. adjustRoll: number;
  44359. /**
  44360. * 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)
  44361. */
  44362. slerpAmount: number;
  44363. private _minYaw;
  44364. private _maxYaw;
  44365. private _minPitch;
  44366. private _maxPitch;
  44367. private _minYawSin;
  44368. private _minYawCos;
  44369. private _maxYawSin;
  44370. private _maxYawCos;
  44371. private _midYawConstraint;
  44372. private _minPitchTan;
  44373. private _maxPitchTan;
  44374. private _boneQuat;
  44375. private _slerping;
  44376. private _transformYawPitch;
  44377. private _transformYawPitchInv;
  44378. private _firstFrameSkipped;
  44379. private _yawRange;
  44380. private _fowardAxis;
  44381. /**
  44382. * Gets or sets the minimum yaw angle that the bone can look to
  44383. */
  44384. get minYaw(): number;
  44385. set minYaw(value: number);
  44386. /**
  44387. * Gets or sets the maximum yaw angle that the bone can look to
  44388. */
  44389. get maxYaw(): number;
  44390. set maxYaw(value: number);
  44391. /**
  44392. * Gets or sets the minimum pitch angle that the bone can look to
  44393. */
  44394. get minPitch(): number;
  44395. set minPitch(value: number);
  44396. /**
  44397. * Gets or sets the maximum pitch angle that the bone can look to
  44398. */
  44399. get maxPitch(): number;
  44400. set maxPitch(value: number);
  44401. /**
  44402. * Create a BoneLookController
  44403. * @param mesh the mesh that the bone belongs to
  44404. * @param bone the bone that will be looking to the target
  44405. * @param target the target Vector3 to look at
  44406. * @param options optional settings:
  44407. * * maxYaw: the maximum angle the bone will yaw to
  44408. * * minYaw: the minimum angle the bone will yaw to
  44409. * * maxPitch: the maximum angle the bone will pitch to
  44410. * * minPitch: the minimum angle the bone will yaw to
  44411. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44412. * * upAxis: the up axis of the coordinate system
  44413. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44414. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44415. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44416. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44417. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44418. * * adjustRoll: used to make an adjustment to the roll of the bone
  44419. **/
  44420. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44421. maxYaw?: number;
  44422. minYaw?: number;
  44423. maxPitch?: number;
  44424. minPitch?: number;
  44425. slerpAmount?: number;
  44426. upAxis?: Vector3;
  44427. upAxisSpace?: Space;
  44428. yawAxis?: Vector3;
  44429. pitchAxis?: Vector3;
  44430. adjustYaw?: number;
  44431. adjustPitch?: number;
  44432. adjustRoll?: number;
  44433. });
  44434. /**
  44435. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44436. */
  44437. update(): void;
  44438. private _getAngleDiff;
  44439. private _getAngleBetween;
  44440. private _isAngleBetween;
  44441. }
  44442. }
  44443. declare module "babylonjs/Bones/index" {
  44444. export * from "babylonjs/Bones/bone";
  44445. export * from "babylonjs/Bones/boneIKController";
  44446. export * from "babylonjs/Bones/boneLookController";
  44447. export * from "babylonjs/Bones/skeleton";
  44448. }
  44449. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44450. import { Nullable } from "babylonjs/types";
  44451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44454. /**
  44455. * Manage the gamepad inputs to control an arc rotate camera.
  44456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44457. */
  44458. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44459. /**
  44460. * Defines the camera the input is attached to.
  44461. */
  44462. camera: ArcRotateCamera;
  44463. /**
  44464. * Defines the gamepad the input is gathering event from.
  44465. */
  44466. gamepad: Nullable<Gamepad>;
  44467. /**
  44468. * Defines the gamepad rotation sensiblity.
  44469. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44470. */
  44471. gamepadRotationSensibility: number;
  44472. /**
  44473. * Defines the gamepad move sensiblity.
  44474. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44475. */
  44476. gamepadMoveSensibility: number;
  44477. private _yAxisScale;
  44478. /**
  44479. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44480. */
  44481. get invertYAxis(): boolean;
  44482. set invertYAxis(value: boolean);
  44483. private _onGamepadConnectedObserver;
  44484. private _onGamepadDisconnectedObserver;
  44485. /**
  44486. * Attach the input controls to a specific dom element to get the input from.
  44487. * @param element Defines the element the controls should be listened from
  44488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44489. */
  44490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44491. /**
  44492. * Detach the current controls from the specified dom element.
  44493. * @param element Defines the element to stop listening the inputs from
  44494. */
  44495. detachControl(element: Nullable<HTMLElement>): void;
  44496. /**
  44497. * Update the current camera state depending on the inputs that have been used this frame.
  44498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44499. */
  44500. checkInputs(): void;
  44501. /**
  44502. * Gets the class name of the current intput.
  44503. * @returns the class name
  44504. */
  44505. getClassName(): string;
  44506. /**
  44507. * Get the friendly name associated with the input class.
  44508. * @returns the input friendly name
  44509. */
  44510. getSimpleName(): string;
  44511. }
  44512. }
  44513. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44514. import { Nullable } from "babylonjs/types";
  44515. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44516. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44517. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44518. interface ArcRotateCameraInputsManager {
  44519. /**
  44520. * Add orientation input support to the input manager.
  44521. * @returns the current input manager
  44522. */
  44523. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44524. }
  44525. }
  44526. /**
  44527. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44528. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44529. */
  44530. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44531. /**
  44532. * Defines the camera the input is attached to.
  44533. */
  44534. camera: ArcRotateCamera;
  44535. /**
  44536. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44537. */
  44538. alphaCorrection: number;
  44539. /**
  44540. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44541. */
  44542. gammaCorrection: number;
  44543. private _alpha;
  44544. private _gamma;
  44545. private _dirty;
  44546. private _deviceOrientationHandler;
  44547. /**
  44548. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44549. */
  44550. constructor();
  44551. /**
  44552. * Attach the input controls to a specific dom element to get the input from.
  44553. * @param element Defines the element the controls should be listened from
  44554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44555. */
  44556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44557. /** @hidden */
  44558. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44559. /**
  44560. * Update the current camera state depending on the inputs that have been used this frame.
  44561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44562. */
  44563. checkInputs(): void;
  44564. /**
  44565. * Detach the current controls from the specified dom element.
  44566. * @param element Defines the element to stop listening the inputs from
  44567. */
  44568. detachControl(element: Nullable<HTMLElement>): void;
  44569. /**
  44570. * Gets the class name of the current intput.
  44571. * @returns the class name
  44572. */
  44573. getClassName(): string;
  44574. /**
  44575. * Get the friendly name associated with the input class.
  44576. * @returns the input friendly name
  44577. */
  44578. getSimpleName(): string;
  44579. }
  44580. }
  44581. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44582. import { Nullable } from "babylonjs/types";
  44583. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44584. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44585. /**
  44586. * Listen to mouse events to control the camera.
  44587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44588. */
  44589. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44590. /**
  44591. * Defines the camera the input is attached to.
  44592. */
  44593. camera: FlyCamera;
  44594. /**
  44595. * Defines if touch is enabled. (Default is true.)
  44596. */
  44597. touchEnabled: boolean;
  44598. /**
  44599. * Defines the buttons associated with the input to handle camera rotation.
  44600. */
  44601. buttons: number[];
  44602. /**
  44603. * Assign buttons for Yaw control.
  44604. */
  44605. buttonsYaw: number[];
  44606. /**
  44607. * Assign buttons for Pitch control.
  44608. */
  44609. buttonsPitch: number[];
  44610. /**
  44611. * Assign buttons for Roll control.
  44612. */
  44613. buttonsRoll: number[];
  44614. /**
  44615. * Detect if any button is being pressed while mouse is moved.
  44616. * -1 = Mouse locked.
  44617. * 0 = Left button.
  44618. * 1 = Middle Button.
  44619. * 2 = Right Button.
  44620. */
  44621. activeButton: number;
  44622. /**
  44623. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44624. * Higher values reduce its sensitivity.
  44625. */
  44626. angularSensibility: number;
  44627. private _mousemoveCallback;
  44628. private _observer;
  44629. private _rollObserver;
  44630. private previousPosition;
  44631. private noPreventDefault;
  44632. private element;
  44633. /**
  44634. * Listen to mouse events to control the camera.
  44635. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44637. */
  44638. constructor(touchEnabled?: boolean);
  44639. /**
  44640. * Attach the mouse control to the HTML DOM element.
  44641. * @param element Defines the element that listens to the input events.
  44642. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44645. /**
  44646. * Detach the current controls from the specified dom element.
  44647. * @param element Defines the element to stop listening the inputs from
  44648. */
  44649. detachControl(element: Nullable<HTMLElement>): void;
  44650. /**
  44651. * Gets the class name of the current input.
  44652. * @returns the class name.
  44653. */
  44654. getClassName(): string;
  44655. /**
  44656. * Get the friendly name associated with the input class.
  44657. * @returns the input's friendly name.
  44658. */
  44659. getSimpleName(): string;
  44660. private _pointerInput;
  44661. private _onMouseMove;
  44662. /**
  44663. * Rotate camera by mouse offset.
  44664. */
  44665. private rotateCamera;
  44666. }
  44667. }
  44668. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44669. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44670. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44671. /**
  44672. * Default Inputs manager for the FlyCamera.
  44673. * It groups all the default supported inputs for ease of use.
  44674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44675. */
  44676. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44677. /**
  44678. * Instantiates a new FlyCameraInputsManager.
  44679. * @param camera Defines the camera the inputs belong to.
  44680. */
  44681. constructor(camera: FlyCamera);
  44682. /**
  44683. * Add keyboard input support to the input manager.
  44684. * @returns the new FlyCameraKeyboardMoveInput().
  44685. */
  44686. addKeyboard(): FlyCameraInputsManager;
  44687. /**
  44688. * Add mouse input support to the input manager.
  44689. * @param touchEnabled Enable touch screen support.
  44690. * @returns the new FlyCameraMouseInput().
  44691. */
  44692. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44693. }
  44694. }
  44695. declare module "babylonjs/Cameras/flyCamera" {
  44696. import { Scene } from "babylonjs/scene";
  44697. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44699. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44700. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44701. /**
  44702. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44703. * such as in a 3D Space Shooter or a Flight Simulator.
  44704. */
  44705. export class FlyCamera extends TargetCamera {
  44706. /**
  44707. * Define the collision ellipsoid of the camera.
  44708. * This is helpful for simulating a camera body, like a player's body.
  44709. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44710. */
  44711. ellipsoid: Vector3;
  44712. /**
  44713. * Define an offset for the position of the ellipsoid around the camera.
  44714. * This can be helpful if the camera is attached away from the player's body center,
  44715. * such as at its head.
  44716. */
  44717. ellipsoidOffset: Vector3;
  44718. /**
  44719. * Enable or disable collisions of the camera with the rest of the scene objects.
  44720. */
  44721. checkCollisions: boolean;
  44722. /**
  44723. * Enable or disable gravity on the camera.
  44724. */
  44725. applyGravity: boolean;
  44726. /**
  44727. * Define the current direction the camera is moving to.
  44728. */
  44729. cameraDirection: Vector3;
  44730. /**
  44731. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44732. * This overrides and empties cameraRotation.
  44733. */
  44734. rotationQuaternion: Quaternion;
  44735. /**
  44736. * Track Roll to maintain the wanted Rolling when looking around.
  44737. */
  44738. _trackRoll: number;
  44739. /**
  44740. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44741. */
  44742. rollCorrect: number;
  44743. /**
  44744. * Mimic a banked turn, Rolling the camera when Yawing.
  44745. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44746. */
  44747. bankedTurn: boolean;
  44748. /**
  44749. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44750. */
  44751. bankedTurnLimit: number;
  44752. /**
  44753. * Value of 0 disables the banked Roll.
  44754. * Value of 1 is equal to the Yaw angle in radians.
  44755. */
  44756. bankedTurnMultiplier: number;
  44757. /**
  44758. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44759. */
  44760. inputs: FlyCameraInputsManager;
  44761. /**
  44762. * Gets the input sensibility for mouse input.
  44763. * Higher values reduce sensitivity.
  44764. */
  44765. get angularSensibility(): number;
  44766. /**
  44767. * Sets the input sensibility for a mouse input.
  44768. * Higher values reduce sensitivity.
  44769. */
  44770. set angularSensibility(value: number);
  44771. /**
  44772. * Get the keys for camera movement forward.
  44773. */
  44774. get keysForward(): number[];
  44775. /**
  44776. * Set the keys for camera movement forward.
  44777. */
  44778. set keysForward(value: number[]);
  44779. /**
  44780. * Get the keys for camera movement backward.
  44781. */
  44782. get keysBackward(): number[];
  44783. set keysBackward(value: number[]);
  44784. /**
  44785. * Get the keys for camera movement up.
  44786. */
  44787. get keysUp(): number[];
  44788. /**
  44789. * Set the keys for camera movement up.
  44790. */
  44791. set keysUp(value: number[]);
  44792. /**
  44793. * Get the keys for camera movement down.
  44794. */
  44795. get keysDown(): number[];
  44796. /**
  44797. * Set the keys for camera movement down.
  44798. */
  44799. set keysDown(value: number[]);
  44800. /**
  44801. * Get the keys for camera movement left.
  44802. */
  44803. get keysLeft(): number[];
  44804. /**
  44805. * Set the keys for camera movement left.
  44806. */
  44807. set keysLeft(value: number[]);
  44808. /**
  44809. * Set the keys for camera movement right.
  44810. */
  44811. get keysRight(): number[];
  44812. /**
  44813. * Set the keys for camera movement right.
  44814. */
  44815. set keysRight(value: number[]);
  44816. /**
  44817. * Event raised when the camera collides with a mesh in the scene.
  44818. */
  44819. onCollide: (collidedMesh: AbstractMesh) => void;
  44820. private _collider;
  44821. private _needMoveForGravity;
  44822. private _oldPosition;
  44823. private _diffPosition;
  44824. private _newPosition;
  44825. /** @hidden */
  44826. _localDirection: Vector3;
  44827. /** @hidden */
  44828. _transformedDirection: Vector3;
  44829. /**
  44830. * Instantiates a FlyCamera.
  44831. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44832. * such as in a 3D Space Shooter or a Flight Simulator.
  44833. * @param name Define the name of the camera in the scene.
  44834. * @param position Define the starting position of the camera in the scene.
  44835. * @param scene Define the scene the camera belongs to.
  44836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44837. */
  44838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44839. /**
  44840. * Attach a control to the HTML DOM element.
  44841. * @param element Defines the element that listens to the input events.
  44842. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44843. */
  44844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44845. /**
  44846. * Detach a control from the HTML DOM element.
  44847. * The camera will stop reacting to that input.
  44848. * @param element Defines the element that listens to the input events.
  44849. */
  44850. detachControl(element: HTMLElement): void;
  44851. private _collisionMask;
  44852. /**
  44853. * Get the mask that the camera ignores in collision events.
  44854. */
  44855. get collisionMask(): number;
  44856. /**
  44857. * Set the mask that the camera ignores in collision events.
  44858. */
  44859. set collisionMask(mask: number);
  44860. /** @hidden */
  44861. _collideWithWorld(displacement: Vector3): void;
  44862. /** @hidden */
  44863. private _onCollisionPositionChange;
  44864. /** @hidden */
  44865. _checkInputs(): void;
  44866. /** @hidden */
  44867. _decideIfNeedsToMove(): boolean;
  44868. /** @hidden */
  44869. _updatePosition(): void;
  44870. /**
  44871. * Restore the Roll to its target value at the rate specified.
  44872. * @param rate - Higher means slower restoring.
  44873. * @hidden
  44874. */
  44875. restoreRoll(rate: number): void;
  44876. /**
  44877. * Destroy the camera and release the current resources held by it.
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * Get the current object class name.
  44882. * @returns the class name.
  44883. */
  44884. getClassName(): string;
  44885. }
  44886. }
  44887. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44888. import { Nullable } from "babylonjs/types";
  44889. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44890. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44891. /**
  44892. * Listen to keyboard events to control the camera.
  44893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44894. */
  44895. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44896. /**
  44897. * Defines the camera the input is attached to.
  44898. */
  44899. camera: FlyCamera;
  44900. /**
  44901. * The list of keyboard keys used to control the forward move of the camera.
  44902. */
  44903. keysForward: number[];
  44904. /**
  44905. * The list of keyboard keys used to control the backward move of the camera.
  44906. */
  44907. keysBackward: number[];
  44908. /**
  44909. * The list of keyboard keys used to control the forward move of the camera.
  44910. */
  44911. keysUp: number[];
  44912. /**
  44913. * The list of keyboard keys used to control the backward move of the camera.
  44914. */
  44915. keysDown: number[];
  44916. /**
  44917. * The list of keyboard keys used to control the right strafe move of the camera.
  44918. */
  44919. keysRight: number[];
  44920. /**
  44921. * The list of keyboard keys used to control the left strafe move of the camera.
  44922. */
  44923. keysLeft: number[];
  44924. private _keys;
  44925. private _onCanvasBlurObserver;
  44926. private _onKeyboardObserver;
  44927. private _engine;
  44928. private _scene;
  44929. /**
  44930. * Attach the input controls to a specific dom element to get the input from.
  44931. * @param element Defines the element the controls should be listened from
  44932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44933. */
  44934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44935. /**
  44936. * Detach the current controls from the specified dom element.
  44937. * @param element Defines the element to stop listening the inputs from
  44938. */
  44939. detachControl(element: Nullable<HTMLElement>): void;
  44940. /**
  44941. * Gets the class name of the current intput.
  44942. * @returns the class name
  44943. */
  44944. getClassName(): string;
  44945. /** @hidden */
  44946. _onLostFocus(e: FocusEvent): void;
  44947. /**
  44948. * Get the friendly name associated with the input class.
  44949. * @returns the input friendly name
  44950. */
  44951. getSimpleName(): string;
  44952. /**
  44953. * Update the current camera state depending on the inputs that have been used this frame.
  44954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44955. */
  44956. checkInputs(): void;
  44957. }
  44958. }
  44959. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44960. import { Nullable } from "babylonjs/types";
  44961. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44963. /**
  44964. * Manage the mouse wheel inputs to control a follow camera.
  44965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44966. */
  44967. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44968. /**
  44969. * Defines the camera the input is attached to.
  44970. */
  44971. camera: FollowCamera;
  44972. /**
  44973. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44974. */
  44975. axisControlRadius: boolean;
  44976. /**
  44977. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44978. */
  44979. axisControlHeight: boolean;
  44980. /**
  44981. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44982. */
  44983. axisControlRotation: boolean;
  44984. /**
  44985. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44986. * relation to mouseWheel events.
  44987. */
  44988. wheelPrecision: number;
  44989. /**
  44990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44992. */
  44993. wheelDeltaPercentage: number;
  44994. private _wheel;
  44995. private _observer;
  44996. /**
  44997. * Attach the input controls to a specific dom element to get the input from.
  44998. * @param element Defines the element the controls should be listened from
  44999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45000. */
  45001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45002. /**
  45003. * Detach the current controls from the specified dom element.
  45004. * @param element Defines the element to stop listening the inputs from
  45005. */
  45006. detachControl(element: Nullable<HTMLElement>): void;
  45007. /**
  45008. * Gets the class name of the current intput.
  45009. * @returns the class name
  45010. */
  45011. getClassName(): string;
  45012. /**
  45013. * Get the friendly name associated with the input class.
  45014. * @returns the input friendly name
  45015. */
  45016. getSimpleName(): string;
  45017. }
  45018. }
  45019. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45020. import { Nullable } from "babylonjs/types";
  45021. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45022. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45023. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45024. /**
  45025. * Manage the pointers inputs to control an follow camera.
  45026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45027. */
  45028. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45029. /**
  45030. * Defines the camera the input is attached to.
  45031. */
  45032. camera: FollowCamera;
  45033. /**
  45034. * Gets the class name of the current input.
  45035. * @returns the class name
  45036. */
  45037. getClassName(): string;
  45038. /**
  45039. * Defines the pointer angular sensibility along the X axis or how fast is
  45040. * the camera rotating.
  45041. * A negative number will reverse the axis direction.
  45042. */
  45043. angularSensibilityX: number;
  45044. /**
  45045. * Defines the pointer angular sensibility along the Y axis or how fast is
  45046. * the camera rotating.
  45047. * A negative number will reverse the axis direction.
  45048. */
  45049. angularSensibilityY: number;
  45050. /**
  45051. * Defines the pointer pinch precision or how fast is the camera zooming.
  45052. * A negative number will reverse the axis direction.
  45053. */
  45054. pinchPrecision: number;
  45055. /**
  45056. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45057. * from 0.
  45058. * It defines the percentage of current camera.radius to use as delta when
  45059. * pinch zoom is used.
  45060. */
  45061. pinchDeltaPercentage: number;
  45062. /**
  45063. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45064. */
  45065. axisXControlRadius: boolean;
  45066. /**
  45067. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45068. */
  45069. axisXControlHeight: boolean;
  45070. /**
  45071. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45072. */
  45073. axisXControlRotation: boolean;
  45074. /**
  45075. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45076. */
  45077. axisYControlRadius: boolean;
  45078. /**
  45079. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45080. */
  45081. axisYControlHeight: boolean;
  45082. /**
  45083. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45084. */
  45085. axisYControlRotation: boolean;
  45086. /**
  45087. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45088. */
  45089. axisPinchControlRadius: boolean;
  45090. /**
  45091. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45092. */
  45093. axisPinchControlHeight: boolean;
  45094. /**
  45095. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45096. */
  45097. axisPinchControlRotation: boolean;
  45098. /**
  45099. * Log error messages if basic misconfiguration has occurred.
  45100. */
  45101. warningEnable: boolean;
  45102. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45103. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45104. private _warningCounter;
  45105. private _warning;
  45106. }
  45107. }
  45108. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45109. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45110. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45111. /**
  45112. * Default Inputs manager for the FollowCamera.
  45113. * It groups all the default supported inputs for ease of use.
  45114. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45115. */
  45116. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45117. /**
  45118. * Instantiates a new FollowCameraInputsManager.
  45119. * @param camera Defines the camera the inputs belong to
  45120. */
  45121. constructor(camera: FollowCamera);
  45122. /**
  45123. * Add keyboard input support to the input manager.
  45124. * @returns the current input manager
  45125. */
  45126. addKeyboard(): FollowCameraInputsManager;
  45127. /**
  45128. * Add mouse wheel input support to the input manager.
  45129. * @returns the current input manager
  45130. */
  45131. addMouseWheel(): FollowCameraInputsManager;
  45132. /**
  45133. * Add pointers input support to the input manager.
  45134. * @returns the current input manager
  45135. */
  45136. addPointers(): FollowCameraInputsManager;
  45137. /**
  45138. * Add orientation input support to the input manager.
  45139. * @returns the current input manager
  45140. */
  45141. addVRDeviceOrientation(): FollowCameraInputsManager;
  45142. }
  45143. }
  45144. declare module "babylonjs/Cameras/followCamera" {
  45145. import { Nullable } from "babylonjs/types";
  45146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45147. import { Scene } from "babylonjs/scene";
  45148. import { Vector3 } from "babylonjs/Maths/math.vector";
  45149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45150. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45151. /**
  45152. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45153. * an arc rotate version arcFollowCamera are available.
  45154. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45155. */
  45156. export class FollowCamera extends TargetCamera {
  45157. /**
  45158. * Distance the follow camera should follow an object at
  45159. */
  45160. radius: number;
  45161. /**
  45162. * Minimum allowed distance of the camera to the axis of rotation
  45163. * (The camera can not get closer).
  45164. * This can help limiting how the Camera is able to move in the scene.
  45165. */
  45166. lowerRadiusLimit: Nullable<number>;
  45167. /**
  45168. * Maximum allowed distance of the camera to the axis of rotation
  45169. * (The camera can not get further).
  45170. * This can help limiting how the Camera is able to move in the scene.
  45171. */
  45172. upperRadiusLimit: Nullable<number>;
  45173. /**
  45174. * Define a rotation offset between the camera and the object it follows
  45175. */
  45176. rotationOffset: number;
  45177. /**
  45178. * Minimum allowed angle to camera position relative to target object.
  45179. * This can help limiting how the Camera is able to move in the scene.
  45180. */
  45181. lowerRotationOffsetLimit: Nullable<number>;
  45182. /**
  45183. * Maximum allowed angle to camera position relative to target object.
  45184. * This can help limiting how the Camera is able to move in the scene.
  45185. */
  45186. upperRotationOffsetLimit: Nullable<number>;
  45187. /**
  45188. * Define a height offset between the camera and the object it follows.
  45189. * It can help following an object from the top (like a car chaing a plane)
  45190. */
  45191. heightOffset: number;
  45192. /**
  45193. * Minimum allowed height of camera position relative to target object.
  45194. * This can help limiting how the Camera is able to move in the scene.
  45195. */
  45196. lowerHeightOffsetLimit: Nullable<number>;
  45197. /**
  45198. * Maximum allowed height of camera position relative to target object.
  45199. * This can help limiting how the Camera is able to move in the scene.
  45200. */
  45201. upperHeightOffsetLimit: Nullable<number>;
  45202. /**
  45203. * Define how fast the camera can accelerate to follow it s target.
  45204. */
  45205. cameraAcceleration: number;
  45206. /**
  45207. * Define the speed limit of the camera following an object.
  45208. */
  45209. maxCameraSpeed: number;
  45210. /**
  45211. * Define the target of the camera.
  45212. */
  45213. lockedTarget: Nullable<AbstractMesh>;
  45214. /**
  45215. * Defines the input associated with the camera.
  45216. */
  45217. inputs: FollowCameraInputsManager;
  45218. /**
  45219. * Instantiates the follow camera.
  45220. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45221. * @param name Define the name of the camera in the scene
  45222. * @param position Define the position of the camera
  45223. * @param scene Define the scene the camera belong to
  45224. * @param lockedTarget Define the target of the camera
  45225. */
  45226. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45227. private _follow;
  45228. /**
  45229. * Attached controls to the current camera.
  45230. * @param element Defines the element the controls should be listened from
  45231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45232. */
  45233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45234. /**
  45235. * Detach the current controls from the camera.
  45236. * The camera will stop reacting to inputs.
  45237. * @param element Defines the element to stop listening the inputs from
  45238. */
  45239. detachControl(element: HTMLElement): void;
  45240. /** @hidden */
  45241. _checkInputs(): void;
  45242. private _checkLimits;
  45243. /**
  45244. * Gets the camera class name.
  45245. * @returns the class name
  45246. */
  45247. getClassName(): string;
  45248. }
  45249. /**
  45250. * Arc Rotate version of the follow camera.
  45251. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45252. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45253. */
  45254. export class ArcFollowCamera extends TargetCamera {
  45255. /** The longitudinal angle of the camera */
  45256. alpha: number;
  45257. /** The latitudinal angle of the camera */
  45258. beta: number;
  45259. /** The radius of the camera from its target */
  45260. radius: number;
  45261. /** Define the camera target (the mesh it should follow) */
  45262. target: Nullable<AbstractMesh>;
  45263. private _cartesianCoordinates;
  45264. /**
  45265. * Instantiates a new ArcFollowCamera
  45266. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45267. * @param name Define the name of the camera
  45268. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45269. * @param beta Define the rotation angle of the camera around the elevation axis
  45270. * @param radius Define the radius of the camera from its target point
  45271. * @param target Define the target of the camera
  45272. * @param scene Define the scene the camera belongs to
  45273. */
  45274. constructor(name: string,
  45275. /** The longitudinal angle of the camera */
  45276. alpha: number,
  45277. /** The latitudinal angle of the camera */
  45278. beta: number,
  45279. /** The radius of the camera from its target */
  45280. radius: number,
  45281. /** Define the camera target (the mesh it should follow) */
  45282. target: Nullable<AbstractMesh>, scene: Scene);
  45283. private _follow;
  45284. /** @hidden */
  45285. _checkInputs(): void;
  45286. /**
  45287. * Returns the class name of the object.
  45288. * It is mostly used internally for serialization purposes.
  45289. */
  45290. getClassName(): string;
  45291. }
  45292. }
  45293. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45294. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45295. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45296. import { Nullable } from "babylonjs/types";
  45297. /**
  45298. * Manage the keyboard inputs to control the movement of a follow camera.
  45299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45300. */
  45301. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45302. /**
  45303. * Defines the camera the input is attached to.
  45304. */
  45305. camera: FollowCamera;
  45306. /**
  45307. * Defines the list of key codes associated with the up action (increase heightOffset)
  45308. */
  45309. keysHeightOffsetIncr: number[];
  45310. /**
  45311. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45312. */
  45313. keysHeightOffsetDecr: number[];
  45314. /**
  45315. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45316. */
  45317. keysHeightOffsetModifierAlt: boolean;
  45318. /**
  45319. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45320. */
  45321. keysHeightOffsetModifierCtrl: boolean;
  45322. /**
  45323. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45324. */
  45325. keysHeightOffsetModifierShift: boolean;
  45326. /**
  45327. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45328. */
  45329. keysRotationOffsetIncr: number[];
  45330. /**
  45331. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45332. */
  45333. keysRotationOffsetDecr: number[];
  45334. /**
  45335. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45336. */
  45337. keysRotationOffsetModifierAlt: boolean;
  45338. /**
  45339. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45340. */
  45341. keysRotationOffsetModifierCtrl: boolean;
  45342. /**
  45343. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45344. */
  45345. keysRotationOffsetModifierShift: boolean;
  45346. /**
  45347. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45348. */
  45349. keysRadiusIncr: number[];
  45350. /**
  45351. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45352. */
  45353. keysRadiusDecr: number[];
  45354. /**
  45355. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45356. */
  45357. keysRadiusModifierAlt: boolean;
  45358. /**
  45359. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45360. */
  45361. keysRadiusModifierCtrl: boolean;
  45362. /**
  45363. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45364. */
  45365. keysRadiusModifierShift: boolean;
  45366. /**
  45367. * Defines the rate of change of heightOffset.
  45368. */
  45369. heightSensibility: number;
  45370. /**
  45371. * Defines the rate of change of rotationOffset.
  45372. */
  45373. rotationSensibility: number;
  45374. /**
  45375. * Defines the rate of change of radius.
  45376. */
  45377. radiusSensibility: number;
  45378. private _keys;
  45379. private _ctrlPressed;
  45380. private _altPressed;
  45381. private _shiftPressed;
  45382. private _onCanvasBlurObserver;
  45383. private _onKeyboardObserver;
  45384. private _engine;
  45385. private _scene;
  45386. /**
  45387. * Attach the input controls to a specific dom element to get the input from.
  45388. * @param element Defines the element the controls should be listened from
  45389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45390. */
  45391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45392. /**
  45393. * Detach the current controls from the specified dom element.
  45394. * @param element Defines the element to stop listening the inputs from
  45395. */
  45396. detachControl(element: Nullable<HTMLElement>): void;
  45397. /**
  45398. * Update the current camera state depending on the inputs that have been used this frame.
  45399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45400. */
  45401. checkInputs(): void;
  45402. /**
  45403. * Gets the class name of the current input.
  45404. * @returns the class name
  45405. */
  45406. getClassName(): string;
  45407. /**
  45408. * Get the friendly name associated with the input class.
  45409. * @returns the input friendly name
  45410. */
  45411. getSimpleName(): string;
  45412. /**
  45413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45414. * allow modification of the heightOffset value.
  45415. */
  45416. private _modifierHeightOffset;
  45417. /**
  45418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45419. * allow modification of the rotationOffset value.
  45420. */
  45421. private _modifierRotationOffset;
  45422. /**
  45423. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45424. * allow modification of the radius value.
  45425. */
  45426. private _modifierRadius;
  45427. }
  45428. }
  45429. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45430. import { Nullable } from "babylonjs/types";
  45431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45432. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45433. import { Observable } from "babylonjs/Misc/observable";
  45434. module "babylonjs/Cameras/freeCameraInputsManager" {
  45435. interface FreeCameraInputsManager {
  45436. /**
  45437. * @hidden
  45438. */
  45439. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45440. /**
  45441. * Add orientation input support to the input manager.
  45442. * @returns the current input manager
  45443. */
  45444. addDeviceOrientation(): FreeCameraInputsManager;
  45445. }
  45446. }
  45447. /**
  45448. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45449. * Screen rotation is taken into account.
  45450. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45451. */
  45452. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45453. private _camera;
  45454. private _screenOrientationAngle;
  45455. private _constantTranform;
  45456. private _screenQuaternion;
  45457. private _alpha;
  45458. private _beta;
  45459. private _gamma;
  45460. /**
  45461. * Can be used to detect if a device orientation sensor is available on a device
  45462. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45463. * @returns a promise that will resolve on orientation change
  45464. */
  45465. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45466. /**
  45467. * @hidden
  45468. */
  45469. _onDeviceOrientationChangedObservable: Observable<void>;
  45470. /**
  45471. * Instantiates a new input
  45472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45473. */
  45474. constructor();
  45475. /**
  45476. * Define the camera controlled by the input.
  45477. */
  45478. get camera(): FreeCamera;
  45479. set camera(camera: FreeCamera);
  45480. /**
  45481. * Attach the input controls to a specific dom element to get the input from.
  45482. * @param element Defines the element the controls should be listened from
  45483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45484. */
  45485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45486. private _orientationChanged;
  45487. private _deviceOrientation;
  45488. /**
  45489. * Detach the current controls from the specified dom element.
  45490. * @param element Defines the element to stop listening the inputs from
  45491. */
  45492. detachControl(element: Nullable<HTMLElement>): void;
  45493. /**
  45494. * Update the current camera state depending on the inputs that have been used this frame.
  45495. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45496. */
  45497. checkInputs(): void;
  45498. /**
  45499. * Gets the class name of the current intput.
  45500. * @returns the class name
  45501. */
  45502. getClassName(): string;
  45503. /**
  45504. * Get the friendly name associated with the input class.
  45505. * @returns the input friendly name
  45506. */
  45507. getSimpleName(): string;
  45508. }
  45509. }
  45510. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45511. import { Nullable } from "babylonjs/types";
  45512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45514. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45515. /**
  45516. * Manage the gamepad inputs to control a free camera.
  45517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45518. */
  45519. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45520. /**
  45521. * Define the camera the input is attached to.
  45522. */
  45523. camera: FreeCamera;
  45524. /**
  45525. * Define the Gamepad controlling the input
  45526. */
  45527. gamepad: Nullable<Gamepad>;
  45528. /**
  45529. * Defines the gamepad rotation sensiblity.
  45530. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45531. */
  45532. gamepadAngularSensibility: number;
  45533. /**
  45534. * Defines the gamepad move sensiblity.
  45535. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45536. */
  45537. gamepadMoveSensibility: number;
  45538. private _yAxisScale;
  45539. /**
  45540. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45541. */
  45542. get invertYAxis(): boolean;
  45543. set invertYAxis(value: boolean);
  45544. private _onGamepadConnectedObserver;
  45545. private _onGamepadDisconnectedObserver;
  45546. private _cameraTransform;
  45547. private _deltaTransform;
  45548. private _vector3;
  45549. private _vector2;
  45550. /**
  45551. * Attach the input controls to a specific dom element to get the input from.
  45552. * @param element Defines the element the controls should be listened from
  45553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45554. */
  45555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45556. /**
  45557. * Detach the current controls from the specified dom element.
  45558. * @param element Defines the element to stop listening the inputs from
  45559. */
  45560. detachControl(element: Nullable<HTMLElement>): void;
  45561. /**
  45562. * Update the current camera state depending on the inputs that have been used this frame.
  45563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45564. */
  45565. checkInputs(): void;
  45566. /**
  45567. * Gets the class name of the current intput.
  45568. * @returns the class name
  45569. */
  45570. getClassName(): string;
  45571. /**
  45572. * Get the friendly name associated with the input class.
  45573. * @returns the input friendly name
  45574. */
  45575. getSimpleName(): string;
  45576. }
  45577. }
  45578. declare module "babylonjs/Misc/virtualJoystick" {
  45579. import { Nullable } from "babylonjs/types";
  45580. import { Vector3 } from "babylonjs/Maths/math.vector";
  45581. /**
  45582. * Defines the potential axis of a Joystick
  45583. */
  45584. export enum JoystickAxis {
  45585. /** X axis */
  45586. X = 0,
  45587. /** Y axis */
  45588. Y = 1,
  45589. /** Z axis */
  45590. Z = 2
  45591. }
  45592. /**
  45593. * Represents the different customization options available
  45594. * for VirtualJoystick
  45595. */
  45596. interface VirtualJoystickCustomizations {
  45597. /**
  45598. * Size of the joystick's puck
  45599. */
  45600. puckSize: number;
  45601. /**
  45602. * Size of the joystick's container
  45603. */
  45604. containerSize: number;
  45605. /**
  45606. * Color of the joystick && puck
  45607. */
  45608. color: string;
  45609. /**
  45610. * Image URL for the joystick's puck
  45611. */
  45612. puckImage?: string;
  45613. /**
  45614. * Image URL for the joystick's container
  45615. */
  45616. containerImage?: string;
  45617. /**
  45618. * Defines the unmoving position of the joystick container
  45619. */
  45620. position?: {
  45621. x: number;
  45622. y: number;
  45623. };
  45624. /**
  45625. * Defines whether or not the joystick container is always visible
  45626. */
  45627. alwaysVisible: boolean;
  45628. /**
  45629. * Defines whether or not to limit the movement of the puck to the joystick's container
  45630. */
  45631. limitToContainer: boolean;
  45632. }
  45633. /**
  45634. * Class used to define virtual joystick (used in touch mode)
  45635. */
  45636. export class VirtualJoystick {
  45637. /**
  45638. * Gets or sets a boolean indicating that left and right values must be inverted
  45639. */
  45640. reverseLeftRight: boolean;
  45641. /**
  45642. * Gets or sets a boolean indicating that up and down values must be inverted
  45643. */
  45644. reverseUpDown: boolean;
  45645. /**
  45646. * Gets the offset value for the position (ie. the change of the position value)
  45647. */
  45648. deltaPosition: Vector3;
  45649. /**
  45650. * Gets a boolean indicating if the virtual joystick was pressed
  45651. */
  45652. pressed: boolean;
  45653. /**
  45654. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45655. */
  45656. static Canvas: Nullable<HTMLCanvasElement>;
  45657. /**
  45658. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45659. */
  45660. limitToContainer: boolean;
  45661. private static _globalJoystickIndex;
  45662. private static _alwaysVisibleSticks;
  45663. private static vjCanvasContext;
  45664. private static vjCanvasWidth;
  45665. private static vjCanvasHeight;
  45666. private static halfWidth;
  45667. private static _GetDefaultOptions;
  45668. private _action;
  45669. private _axisTargetedByLeftAndRight;
  45670. private _axisTargetedByUpAndDown;
  45671. private _joystickSensibility;
  45672. private _inversedSensibility;
  45673. private _joystickPointerID;
  45674. private _joystickColor;
  45675. private _joystickPointerPos;
  45676. private _joystickPreviousPointerPos;
  45677. private _joystickPointerStartPos;
  45678. private _deltaJoystickVector;
  45679. private _leftJoystick;
  45680. private _touches;
  45681. private _joystickPosition;
  45682. private _alwaysVisible;
  45683. private _puckImage;
  45684. private _containerImage;
  45685. private _joystickPuckSize;
  45686. private _joystickContainerSize;
  45687. private _clearPuckSize;
  45688. private _clearContainerSize;
  45689. private _clearPuckSizeOffset;
  45690. private _clearContainerSizeOffset;
  45691. private _onPointerDownHandlerRef;
  45692. private _onPointerMoveHandlerRef;
  45693. private _onPointerUpHandlerRef;
  45694. private _onResize;
  45695. /**
  45696. * Creates a new virtual joystick
  45697. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45698. * @param customizations Defines the options we want to customize the VirtualJoystick
  45699. */
  45700. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45701. /**
  45702. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45703. * @param newJoystickSensibility defines the new sensibility
  45704. */
  45705. setJoystickSensibility(newJoystickSensibility: number): void;
  45706. private _onPointerDown;
  45707. private _onPointerMove;
  45708. private _onPointerUp;
  45709. /**
  45710. * Change the color of the virtual joystick
  45711. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45712. */
  45713. setJoystickColor(newColor: string): void;
  45714. /**
  45715. * Size of the joystick's container
  45716. */
  45717. set containerSize(newSize: number);
  45718. get containerSize(): number;
  45719. /**
  45720. * Size of the joystick's puck
  45721. */
  45722. set puckSize(newSize: number);
  45723. get puckSize(): number;
  45724. /**
  45725. * Clears the set position of the joystick
  45726. */
  45727. clearPosition(): void;
  45728. /**
  45729. * Defines whether or not the joystick container is always visible
  45730. */
  45731. set alwaysVisible(value: boolean);
  45732. get alwaysVisible(): boolean;
  45733. /**
  45734. * Sets the constant position of the Joystick container
  45735. * @param x X axis coordinate
  45736. * @param y Y axis coordinate
  45737. */
  45738. setPosition(x: number, y: number): void;
  45739. /**
  45740. * Defines a callback to call when the joystick is touched
  45741. * @param action defines the callback
  45742. */
  45743. setActionOnTouch(action: () => any): void;
  45744. /**
  45745. * Defines which axis you'd like to control for left & right
  45746. * @param axis defines the axis to use
  45747. */
  45748. setAxisForLeftRight(axis: JoystickAxis): void;
  45749. /**
  45750. * Defines which axis you'd like to control for up & down
  45751. * @param axis defines the axis to use
  45752. */
  45753. setAxisForUpDown(axis: JoystickAxis): void;
  45754. /**
  45755. * Clears the canvas from the previous puck / container draw
  45756. */
  45757. private _clearPreviousDraw;
  45758. /**
  45759. * Loads `urlPath` to be used for the container's image
  45760. * @param urlPath defines the urlPath of an image to use
  45761. */
  45762. setContainerImage(urlPath: string): void;
  45763. /**
  45764. * Loads `urlPath` to be used for the puck's image
  45765. * @param urlPath defines the urlPath of an image to use
  45766. */
  45767. setPuckImage(urlPath: string): void;
  45768. /**
  45769. * Draws the Virtual Joystick's container
  45770. */
  45771. private _drawContainer;
  45772. /**
  45773. * Draws the Virtual Joystick's puck
  45774. */
  45775. private _drawPuck;
  45776. private _drawVirtualJoystick;
  45777. /**
  45778. * Release internal HTML canvas
  45779. */
  45780. releaseCanvas(): void;
  45781. }
  45782. }
  45783. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45784. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45785. import { Nullable } from "babylonjs/types";
  45786. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45788. module "babylonjs/Cameras/freeCameraInputsManager" {
  45789. interface FreeCameraInputsManager {
  45790. /**
  45791. * Add virtual joystick input support to the input manager.
  45792. * @returns the current input manager
  45793. */
  45794. addVirtualJoystick(): FreeCameraInputsManager;
  45795. }
  45796. }
  45797. /**
  45798. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45800. */
  45801. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45802. /**
  45803. * Defines the camera the input is attached to.
  45804. */
  45805. camera: FreeCamera;
  45806. private _leftjoystick;
  45807. private _rightjoystick;
  45808. /**
  45809. * Gets the left stick of the virtual joystick.
  45810. * @returns The virtual Joystick
  45811. */
  45812. getLeftJoystick(): VirtualJoystick;
  45813. /**
  45814. * Gets the right stick of the virtual joystick.
  45815. * @returns The virtual Joystick
  45816. */
  45817. getRightJoystick(): VirtualJoystick;
  45818. /**
  45819. * Update the current camera state depending on the inputs that have been used this frame.
  45820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45821. */
  45822. checkInputs(): void;
  45823. /**
  45824. * Attach the input controls to a specific dom element to get the input from.
  45825. * @param element Defines the element the controls should be listened from
  45826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45827. */
  45828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45829. /**
  45830. * Detach the current controls from the specified dom element.
  45831. * @param element Defines the element to stop listening the inputs from
  45832. */
  45833. detachControl(element: Nullable<HTMLElement>): void;
  45834. /**
  45835. * Gets the class name of the current intput.
  45836. * @returns the class name
  45837. */
  45838. getClassName(): string;
  45839. /**
  45840. * Get the friendly name associated with the input class.
  45841. * @returns the input friendly name
  45842. */
  45843. getSimpleName(): string;
  45844. }
  45845. }
  45846. declare module "babylonjs/Cameras/Inputs/index" {
  45847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45848. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45849. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45850. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45851. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45852. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45853. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45854. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45855. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45856. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45857. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45858. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45859. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45860. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45861. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45862. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45863. }
  45864. declare module "babylonjs/Cameras/touchCamera" {
  45865. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45866. import { Scene } from "babylonjs/scene";
  45867. import { Vector3 } from "babylonjs/Maths/math.vector";
  45868. /**
  45869. * This represents a FPS type of camera controlled by touch.
  45870. * This is like a universal camera minus the Gamepad controls.
  45871. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45872. */
  45873. export class TouchCamera extends FreeCamera {
  45874. /**
  45875. * Defines the touch sensibility for rotation.
  45876. * The higher the faster.
  45877. */
  45878. get touchAngularSensibility(): number;
  45879. set touchAngularSensibility(value: number);
  45880. /**
  45881. * Defines the touch sensibility for move.
  45882. * The higher the faster.
  45883. */
  45884. get touchMoveSensibility(): number;
  45885. set touchMoveSensibility(value: number);
  45886. /**
  45887. * Instantiates a new touch camera.
  45888. * This represents a FPS type of camera controlled by touch.
  45889. * This is like a universal camera minus the Gamepad controls.
  45890. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45891. * @param name Define the name of the camera in the scene
  45892. * @param position Define the start position of the camera in the scene
  45893. * @param scene Define the scene the camera belongs to
  45894. */
  45895. constructor(name: string, position: Vector3, scene: Scene);
  45896. /**
  45897. * Gets the current object class name.
  45898. * @return the class name
  45899. */
  45900. getClassName(): string;
  45901. /** @hidden */
  45902. _setupInputs(): void;
  45903. }
  45904. }
  45905. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45907. import { Scene } from "babylonjs/scene";
  45908. import { Vector3 } from "babylonjs/Maths/math.vector";
  45909. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45910. import { Axis } from "babylonjs/Maths/math.axis";
  45911. /**
  45912. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45913. * being tilted forward or back and left or right.
  45914. */
  45915. export class DeviceOrientationCamera extends FreeCamera {
  45916. private _initialQuaternion;
  45917. private _quaternionCache;
  45918. private _tmpDragQuaternion;
  45919. private _disablePointerInputWhenUsingDeviceOrientation;
  45920. /**
  45921. * Creates a new device orientation camera
  45922. * @param name The name of the camera
  45923. * @param position The start position camera
  45924. * @param scene The scene the camera belongs to
  45925. */
  45926. constructor(name: string, position: Vector3, scene: Scene);
  45927. /**
  45928. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45929. */
  45930. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45931. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45932. private _dragFactor;
  45933. /**
  45934. * Enabled turning on the y axis when the orientation sensor is active
  45935. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45936. */
  45937. enableHorizontalDragging(dragFactor?: number): void;
  45938. /**
  45939. * Gets the current instance class name ("DeviceOrientationCamera").
  45940. * This helps avoiding instanceof at run time.
  45941. * @returns the class name
  45942. */
  45943. getClassName(): string;
  45944. /**
  45945. * @hidden
  45946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45947. */
  45948. _checkInputs(): void;
  45949. /**
  45950. * Reset the camera to its default orientation on the specified axis only.
  45951. * @param axis The axis to reset
  45952. */
  45953. resetToCurrentRotation(axis?: Axis): void;
  45954. }
  45955. }
  45956. declare module "babylonjs/Gamepads/xboxGamepad" {
  45957. import { Observable } from "babylonjs/Misc/observable";
  45958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45959. /**
  45960. * Defines supported buttons for XBox360 compatible gamepads
  45961. */
  45962. export enum Xbox360Button {
  45963. /** A */
  45964. A = 0,
  45965. /** B */
  45966. B = 1,
  45967. /** X */
  45968. X = 2,
  45969. /** Y */
  45970. Y = 3,
  45971. /** Left button */
  45972. LB = 4,
  45973. /** Right button */
  45974. RB = 5,
  45975. /** Back */
  45976. Back = 8,
  45977. /** Start */
  45978. Start = 9,
  45979. /** Left stick */
  45980. LeftStick = 10,
  45981. /** Right stick */
  45982. RightStick = 11
  45983. }
  45984. /** Defines values for XBox360 DPad */
  45985. export enum Xbox360Dpad {
  45986. /** Up */
  45987. Up = 12,
  45988. /** Down */
  45989. Down = 13,
  45990. /** Left */
  45991. Left = 14,
  45992. /** Right */
  45993. Right = 15
  45994. }
  45995. /**
  45996. * Defines a XBox360 gamepad
  45997. */
  45998. export class Xbox360Pad extends Gamepad {
  45999. private _leftTrigger;
  46000. private _rightTrigger;
  46001. private _onlefttriggerchanged;
  46002. private _onrighttriggerchanged;
  46003. private _onbuttondown;
  46004. private _onbuttonup;
  46005. private _ondpaddown;
  46006. private _ondpadup;
  46007. /** Observable raised when a button is pressed */
  46008. onButtonDownObservable: Observable<Xbox360Button>;
  46009. /** Observable raised when a button is released */
  46010. onButtonUpObservable: Observable<Xbox360Button>;
  46011. /** Observable raised when a pad is pressed */
  46012. onPadDownObservable: Observable<Xbox360Dpad>;
  46013. /** Observable raised when a pad is released */
  46014. onPadUpObservable: Observable<Xbox360Dpad>;
  46015. private _buttonA;
  46016. private _buttonB;
  46017. private _buttonX;
  46018. private _buttonY;
  46019. private _buttonBack;
  46020. private _buttonStart;
  46021. private _buttonLB;
  46022. private _buttonRB;
  46023. private _buttonLeftStick;
  46024. private _buttonRightStick;
  46025. private _dPadUp;
  46026. private _dPadDown;
  46027. private _dPadLeft;
  46028. private _dPadRight;
  46029. private _isXboxOnePad;
  46030. /**
  46031. * Creates a new XBox360 gamepad object
  46032. * @param id defines the id of this gamepad
  46033. * @param index defines its index
  46034. * @param gamepad defines the internal HTML gamepad object
  46035. * @param xboxOne defines if it is a XBox One gamepad
  46036. */
  46037. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46038. /**
  46039. * Defines the callback to call when left trigger is pressed
  46040. * @param callback defines the callback to use
  46041. */
  46042. onlefttriggerchanged(callback: (value: number) => void): void;
  46043. /**
  46044. * Defines the callback to call when right trigger is pressed
  46045. * @param callback defines the callback to use
  46046. */
  46047. onrighttriggerchanged(callback: (value: number) => void): void;
  46048. /**
  46049. * Gets the left trigger value
  46050. */
  46051. get leftTrigger(): number;
  46052. /**
  46053. * Sets the left trigger value
  46054. */
  46055. set leftTrigger(newValue: number);
  46056. /**
  46057. * Gets the right trigger value
  46058. */
  46059. get rightTrigger(): number;
  46060. /**
  46061. * Sets the right trigger value
  46062. */
  46063. set rightTrigger(newValue: number);
  46064. /**
  46065. * Defines the callback to call when a button is pressed
  46066. * @param callback defines the callback to use
  46067. */
  46068. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46069. /**
  46070. * Defines the callback to call when a button is released
  46071. * @param callback defines the callback to use
  46072. */
  46073. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46074. /**
  46075. * Defines the callback to call when a pad is pressed
  46076. * @param callback defines the callback to use
  46077. */
  46078. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46079. /**
  46080. * Defines the callback to call when a pad is released
  46081. * @param callback defines the callback to use
  46082. */
  46083. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46084. private _setButtonValue;
  46085. private _setDPadValue;
  46086. /**
  46087. * Gets the value of the `A` button
  46088. */
  46089. get buttonA(): number;
  46090. /**
  46091. * Sets the value of the `A` button
  46092. */
  46093. set buttonA(value: number);
  46094. /**
  46095. * Gets the value of the `B` button
  46096. */
  46097. get buttonB(): number;
  46098. /**
  46099. * Sets the value of the `B` button
  46100. */
  46101. set buttonB(value: number);
  46102. /**
  46103. * Gets the value of the `X` button
  46104. */
  46105. get buttonX(): number;
  46106. /**
  46107. * Sets the value of the `X` button
  46108. */
  46109. set buttonX(value: number);
  46110. /**
  46111. * Gets the value of the `Y` button
  46112. */
  46113. get buttonY(): number;
  46114. /**
  46115. * Sets the value of the `Y` button
  46116. */
  46117. set buttonY(value: number);
  46118. /**
  46119. * Gets the value of the `Start` button
  46120. */
  46121. get buttonStart(): number;
  46122. /**
  46123. * Sets the value of the `Start` button
  46124. */
  46125. set buttonStart(value: number);
  46126. /**
  46127. * Gets the value of the `Back` button
  46128. */
  46129. get buttonBack(): number;
  46130. /**
  46131. * Sets the value of the `Back` button
  46132. */
  46133. set buttonBack(value: number);
  46134. /**
  46135. * Gets the value of the `Left` button
  46136. */
  46137. get buttonLB(): number;
  46138. /**
  46139. * Sets the value of the `Left` button
  46140. */
  46141. set buttonLB(value: number);
  46142. /**
  46143. * Gets the value of the `Right` button
  46144. */
  46145. get buttonRB(): number;
  46146. /**
  46147. * Sets the value of the `Right` button
  46148. */
  46149. set buttonRB(value: number);
  46150. /**
  46151. * Gets the value of the Left joystick
  46152. */
  46153. get buttonLeftStick(): number;
  46154. /**
  46155. * Sets the value of the Left joystick
  46156. */
  46157. set buttonLeftStick(value: number);
  46158. /**
  46159. * Gets the value of the Right joystick
  46160. */
  46161. get buttonRightStick(): number;
  46162. /**
  46163. * Sets the value of the Right joystick
  46164. */
  46165. set buttonRightStick(value: number);
  46166. /**
  46167. * Gets the value of D-pad up
  46168. */
  46169. get dPadUp(): number;
  46170. /**
  46171. * Sets the value of D-pad up
  46172. */
  46173. set dPadUp(value: number);
  46174. /**
  46175. * Gets the value of D-pad down
  46176. */
  46177. get dPadDown(): number;
  46178. /**
  46179. * Sets the value of D-pad down
  46180. */
  46181. set dPadDown(value: number);
  46182. /**
  46183. * Gets the value of D-pad left
  46184. */
  46185. get dPadLeft(): number;
  46186. /**
  46187. * Sets the value of D-pad left
  46188. */
  46189. set dPadLeft(value: number);
  46190. /**
  46191. * Gets the value of D-pad right
  46192. */
  46193. get dPadRight(): number;
  46194. /**
  46195. * Sets the value of D-pad right
  46196. */
  46197. set dPadRight(value: number);
  46198. /**
  46199. * Force the gamepad to synchronize with device values
  46200. */
  46201. update(): void;
  46202. /**
  46203. * Disposes the gamepad
  46204. */
  46205. dispose(): void;
  46206. }
  46207. }
  46208. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46209. import { Observable } from "babylonjs/Misc/observable";
  46210. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46211. /**
  46212. * Defines supported buttons for DualShock compatible gamepads
  46213. */
  46214. export enum DualShockButton {
  46215. /** Cross */
  46216. Cross = 0,
  46217. /** Circle */
  46218. Circle = 1,
  46219. /** Square */
  46220. Square = 2,
  46221. /** Triangle */
  46222. Triangle = 3,
  46223. /** L1 */
  46224. L1 = 4,
  46225. /** R1 */
  46226. R1 = 5,
  46227. /** Share */
  46228. Share = 8,
  46229. /** Options */
  46230. Options = 9,
  46231. /** Left stick */
  46232. LeftStick = 10,
  46233. /** Right stick */
  46234. RightStick = 11
  46235. }
  46236. /** Defines values for DualShock DPad */
  46237. export enum DualShockDpad {
  46238. /** Up */
  46239. Up = 12,
  46240. /** Down */
  46241. Down = 13,
  46242. /** Left */
  46243. Left = 14,
  46244. /** Right */
  46245. Right = 15
  46246. }
  46247. /**
  46248. * Defines a DualShock gamepad
  46249. */
  46250. export class DualShockPad extends Gamepad {
  46251. private _leftTrigger;
  46252. private _rightTrigger;
  46253. private _onlefttriggerchanged;
  46254. private _onrighttriggerchanged;
  46255. private _onbuttondown;
  46256. private _onbuttonup;
  46257. private _ondpaddown;
  46258. private _ondpadup;
  46259. /** Observable raised when a button is pressed */
  46260. onButtonDownObservable: Observable<DualShockButton>;
  46261. /** Observable raised when a button is released */
  46262. onButtonUpObservable: Observable<DualShockButton>;
  46263. /** Observable raised when a pad is pressed */
  46264. onPadDownObservable: Observable<DualShockDpad>;
  46265. /** Observable raised when a pad is released */
  46266. onPadUpObservable: Observable<DualShockDpad>;
  46267. private _buttonCross;
  46268. private _buttonCircle;
  46269. private _buttonSquare;
  46270. private _buttonTriangle;
  46271. private _buttonShare;
  46272. private _buttonOptions;
  46273. private _buttonL1;
  46274. private _buttonR1;
  46275. private _buttonLeftStick;
  46276. private _buttonRightStick;
  46277. private _dPadUp;
  46278. private _dPadDown;
  46279. private _dPadLeft;
  46280. private _dPadRight;
  46281. /**
  46282. * Creates a new DualShock gamepad object
  46283. * @param id defines the id of this gamepad
  46284. * @param index defines its index
  46285. * @param gamepad defines the internal HTML gamepad object
  46286. */
  46287. constructor(id: string, index: number, gamepad: any);
  46288. /**
  46289. * Defines the callback to call when left trigger is pressed
  46290. * @param callback defines the callback to use
  46291. */
  46292. onlefttriggerchanged(callback: (value: number) => void): void;
  46293. /**
  46294. * Defines the callback to call when right trigger is pressed
  46295. * @param callback defines the callback to use
  46296. */
  46297. onrighttriggerchanged(callback: (value: number) => void): void;
  46298. /**
  46299. * Gets the left trigger value
  46300. */
  46301. get leftTrigger(): number;
  46302. /**
  46303. * Sets the left trigger value
  46304. */
  46305. set leftTrigger(newValue: number);
  46306. /**
  46307. * Gets the right trigger value
  46308. */
  46309. get rightTrigger(): number;
  46310. /**
  46311. * Sets the right trigger value
  46312. */
  46313. set rightTrigger(newValue: number);
  46314. /**
  46315. * Defines the callback to call when a button is pressed
  46316. * @param callback defines the callback to use
  46317. */
  46318. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46319. /**
  46320. * Defines the callback to call when a button is released
  46321. * @param callback defines the callback to use
  46322. */
  46323. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46324. /**
  46325. * Defines the callback to call when a pad is pressed
  46326. * @param callback defines the callback to use
  46327. */
  46328. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46329. /**
  46330. * Defines the callback to call when a pad is released
  46331. * @param callback defines the callback to use
  46332. */
  46333. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46334. private _setButtonValue;
  46335. private _setDPadValue;
  46336. /**
  46337. * Gets the value of the `Cross` button
  46338. */
  46339. get buttonCross(): number;
  46340. /**
  46341. * Sets the value of the `Cross` button
  46342. */
  46343. set buttonCross(value: number);
  46344. /**
  46345. * Gets the value of the `Circle` button
  46346. */
  46347. get buttonCircle(): number;
  46348. /**
  46349. * Sets the value of the `Circle` button
  46350. */
  46351. set buttonCircle(value: number);
  46352. /**
  46353. * Gets the value of the `Square` button
  46354. */
  46355. get buttonSquare(): number;
  46356. /**
  46357. * Sets the value of the `Square` button
  46358. */
  46359. set buttonSquare(value: number);
  46360. /**
  46361. * Gets the value of the `Triangle` button
  46362. */
  46363. get buttonTriangle(): number;
  46364. /**
  46365. * Sets the value of the `Triangle` button
  46366. */
  46367. set buttonTriangle(value: number);
  46368. /**
  46369. * Gets the value of the `Options` button
  46370. */
  46371. get buttonOptions(): number;
  46372. /**
  46373. * Sets the value of the `Options` button
  46374. */
  46375. set buttonOptions(value: number);
  46376. /**
  46377. * Gets the value of the `Share` button
  46378. */
  46379. get buttonShare(): number;
  46380. /**
  46381. * Sets the value of the `Share` button
  46382. */
  46383. set buttonShare(value: number);
  46384. /**
  46385. * Gets the value of the `L1` button
  46386. */
  46387. get buttonL1(): number;
  46388. /**
  46389. * Sets the value of the `L1` button
  46390. */
  46391. set buttonL1(value: number);
  46392. /**
  46393. * Gets the value of the `R1` button
  46394. */
  46395. get buttonR1(): number;
  46396. /**
  46397. * Sets the value of the `R1` button
  46398. */
  46399. set buttonR1(value: number);
  46400. /**
  46401. * Gets the value of the Left joystick
  46402. */
  46403. get buttonLeftStick(): number;
  46404. /**
  46405. * Sets the value of the Left joystick
  46406. */
  46407. set buttonLeftStick(value: number);
  46408. /**
  46409. * Gets the value of the Right joystick
  46410. */
  46411. get buttonRightStick(): number;
  46412. /**
  46413. * Sets the value of the Right joystick
  46414. */
  46415. set buttonRightStick(value: number);
  46416. /**
  46417. * Gets the value of D-pad up
  46418. */
  46419. get dPadUp(): number;
  46420. /**
  46421. * Sets the value of D-pad up
  46422. */
  46423. set dPadUp(value: number);
  46424. /**
  46425. * Gets the value of D-pad down
  46426. */
  46427. get dPadDown(): number;
  46428. /**
  46429. * Sets the value of D-pad down
  46430. */
  46431. set dPadDown(value: number);
  46432. /**
  46433. * Gets the value of D-pad left
  46434. */
  46435. get dPadLeft(): number;
  46436. /**
  46437. * Sets the value of D-pad left
  46438. */
  46439. set dPadLeft(value: number);
  46440. /**
  46441. * Gets the value of D-pad right
  46442. */
  46443. get dPadRight(): number;
  46444. /**
  46445. * Sets the value of D-pad right
  46446. */
  46447. set dPadRight(value: number);
  46448. /**
  46449. * Force the gamepad to synchronize with device values
  46450. */
  46451. update(): void;
  46452. /**
  46453. * Disposes the gamepad
  46454. */
  46455. dispose(): void;
  46456. }
  46457. }
  46458. declare module "babylonjs/Gamepads/gamepadManager" {
  46459. import { Observable } from "babylonjs/Misc/observable";
  46460. import { Nullable } from "babylonjs/types";
  46461. import { Scene } from "babylonjs/scene";
  46462. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46463. /**
  46464. * Manager for handling gamepads
  46465. */
  46466. export class GamepadManager {
  46467. private _scene?;
  46468. private _babylonGamepads;
  46469. private _oneGamepadConnected;
  46470. /** @hidden */
  46471. _isMonitoring: boolean;
  46472. private _gamepadEventSupported;
  46473. private _gamepadSupport?;
  46474. /**
  46475. * observable to be triggered when the gamepad controller has been connected
  46476. */
  46477. onGamepadConnectedObservable: Observable<Gamepad>;
  46478. /**
  46479. * observable to be triggered when the gamepad controller has been disconnected
  46480. */
  46481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46482. private _onGamepadConnectedEvent;
  46483. private _onGamepadDisconnectedEvent;
  46484. /**
  46485. * Initializes the gamepad manager
  46486. * @param _scene BabylonJS scene
  46487. */
  46488. constructor(_scene?: Scene | undefined);
  46489. /**
  46490. * The gamepads in the game pad manager
  46491. */
  46492. get gamepads(): Gamepad[];
  46493. /**
  46494. * Get the gamepad controllers based on type
  46495. * @param type The type of gamepad controller
  46496. * @returns Nullable gamepad
  46497. */
  46498. getGamepadByType(type?: number): Nullable<Gamepad>;
  46499. /**
  46500. * Disposes the gamepad manager
  46501. */
  46502. dispose(): void;
  46503. private _addNewGamepad;
  46504. private _startMonitoringGamepads;
  46505. private _stopMonitoringGamepads;
  46506. /** @hidden */
  46507. _checkGamepadsStatus(): void;
  46508. private _updateGamepadObjects;
  46509. }
  46510. }
  46511. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46512. import { Nullable } from "babylonjs/types";
  46513. import { Scene } from "babylonjs/scene";
  46514. import { ISceneComponent } from "babylonjs/sceneComponent";
  46515. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46516. module "babylonjs/scene" {
  46517. interface Scene {
  46518. /** @hidden */
  46519. _gamepadManager: Nullable<GamepadManager>;
  46520. /**
  46521. * Gets the gamepad manager associated with the scene
  46522. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46523. */
  46524. gamepadManager: GamepadManager;
  46525. }
  46526. }
  46527. module "babylonjs/Cameras/freeCameraInputsManager" {
  46528. /**
  46529. * Interface representing a free camera inputs manager
  46530. */
  46531. interface FreeCameraInputsManager {
  46532. /**
  46533. * Adds gamepad input support to the FreeCameraInputsManager.
  46534. * @returns the FreeCameraInputsManager
  46535. */
  46536. addGamepad(): FreeCameraInputsManager;
  46537. }
  46538. }
  46539. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46540. /**
  46541. * Interface representing an arc rotate camera inputs manager
  46542. */
  46543. interface ArcRotateCameraInputsManager {
  46544. /**
  46545. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46546. * @returns the camera inputs manager
  46547. */
  46548. addGamepad(): ArcRotateCameraInputsManager;
  46549. }
  46550. }
  46551. /**
  46552. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46553. */
  46554. export class GamepadSystemSceneComponent implements ISceneComponent {
  46555. /**
  46556. * The component name helpfull to identify the component in the list of scene components.
  46557. */
  46558. readonly name: string;
  46559. /**
  46560. * The scene the component belongs to.
  46561. */
  46562. scene: Scene;
  46563. /**
  46564. * Creates a new instance of the component for the given scene
  46565. * @param scene Defines the scene to register the component in
  46566. */
  46567. constructor(scene: Scene);
  46568. /**
  46569. * Registers the component in a given scene
  46570. */
  46571. register(): void;
  46572. /**
  46573. * Rebuilds the elements related to this component in case of
  46574. * context lost for instance.
  46575. */
  46576. rebuild(): void;
  46577. /**
  46578. * Disposes the component and the associated ressources
  46579. */
  46580. dispose(): void;
  46581. private _beforeCameraUpdate;
  46582. }
  46583. }
  46584. declare module "babylonjs/Cameras/universalCamera" {
  46585. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46586. import { Scene } from "babylonjs/scene";
  46587. import { Vector3 } from "babylonjs/Maths/math.vector";
  46588. import "babylonjs/Gamepads/gamepadSceneComponent";
  46589. /**
  46590. * 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,
  46591. * which still works and will still be found in many Playgrounds.
  46592. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46593. */
  46594. export class UniversalCamera extends TouchCamera {
  46595. /**
  46596. * Defines the gamepad rotation sensiblity.
  46597. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46598. */
  46599. get gamepadAngularSensibility(): number;
  46600. set gamepadAngularSensibility(value: number);
  46601. /**
  46602. * Defines the gamepad move sensiblity.
  46603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46604. */
  46605. get gamepadMoveSensibility(): number;
  46606. set gamepadMoveSensibility(value: number);
  46607. /**
  46608. * 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,
  46609. * which still works and will still be found in many Playgrounds.
  46610. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46611. * @param name Define the name of the camera in the scene
  46612. * @param position Define the start position of the camera in the scene
  46613. * @param scene Define the scene the camera belongs to
  46614. */
  46615. constructor(name: string, position: Vector3, scene: Scene);
  46616. /**
  46617. * Gets the current object class name.
  46618. * @return the class name
  46619. */
  46620. getClassName(): string;
  46621. }
  46622. }
  46623. declare module "babylonjs/Cameras/gamepadCamera" {
  46624. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { Vector3 } from "babylonjs/Maths/math.vector";
  46627. /**
  46628. * This represents a FPS type of camera. This is only here for back compat purpose.
  46629. * Please use the UniversalCamera instead as both are identical.
  46630. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46631. */
  46632. export class GamepadCamera extends UniversalCamera {
  46633. /**
  46634. * Instantiates a new Gamepad Camera
  46635. * This represents a FPS type of camera. This is only here for back compat purpose.
  46636. * Please use the UniversalCamera instead as both are identical.
  46637. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46638. * @param name Define the name of the camera in the scene
  46639. * @param position Define the start position of the camera in the scene
  46640. * @param scene Define the scene the camera belongs to
  46641. */
  46642. constructor(name: string, position: Vector3, scene: Scene);
  46643. /**
  46644. * Gets the current object class name.
  46645. * @return the class name
  46646. */
  46647. getClassName(): string;
  46648. }
  46649. }
  46650. declare module "babylonjs/Shaders/pass.fragment" {
  46651. /** @hidden */
  46652. export var passPixelShader: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/passCube.fragment" {
  46658. /** @hidden */
  46659. export var passCubePixelShader: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/PostProcesses/passPostProcess" {
  46665. import { Nullable } from "babylonjs/types";
  46666. import { Camera } from "babylonjs/Cameras/camera";
  46667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46668. import { Engine } from "babylonjs/Engines/engine";
  46669. import "babylonjs/Shaders/pass.fragment";
  46670. import "babylonjs/Shaders/passCube.fragment";
  46671. /**
  46672. * PassPostProcess which produces an output the same as it's input
  46673. */
  46674. export class PassPostProcess extends PostProcess {
  46675. /**
  46676. * Creates the PassPostProcess
  46677. * @param name The name of the effect.
  46678. * @param options The required width/height ratio to downsize to before computing the render pass.
  46679. * @param camera The camera to apply the render pass to.
  46680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46681. * @param engine The engine which the post process will be applied. (default: current engine)
  46682. * @param reusable If the post process can be reused on the same frame. (default: false)
  46683. * @param textureType The type of texture to be used when performing the post processing.
  46684. * @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)
  46685. */
  46686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46687. }
  46688. /**
  46689. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46690. */
  46691. export class PassCubePostProcess extends PostProcess {
  46692. private _face;
  46693. /**
  46694. * Gets or sets the cube face to display.
  46695. * * 0 is +X
  46696. * * 1 is -X
  46697. * * 2 is +Y
  46698. * * 3 is -Y
  46699. * * 4 is +Z
  46700. * * 5 is -Z
  46701. */
  46702. get face(): number;
  46703. set face(value: number);
  46704. /**
  46705. * Creates the PassCubePostProcess
  46706. * @param name The name of the effect.
  46707. * @param options The required width/height ratio to downsize to before computing the render pass.
  46708. * @param camera The camera to apply the render pass to.
  46709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46710. * @param engine The engine which the post process will be applied. (default: current engine)
  46711. * @param reusable If the post process can be reused on the same frame. (default: false)
  46712. * @param textureType The type of texture to be used when performing the post processing.
  46713. * @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)
  46714. */
  46715. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46716. }
  46717. }
  46718. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46719. /** @hidden */
  46720. export var anaglyphPixelShader: {
  46721. name: string;
  46722. shader: string;
  46723. };
  46724. }
  46725. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46726. import { Engine } from "babylonjs/Engines/engine";
  46727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46728. import { Camera } from "babylonjs/Cameras/camera";
  46729. import "babylonjs/Shaders/anaglyph.fragment";
  46730. /**
  46731. * Postprocess used to generate anaglyphic rendering
  46732. */
  46733. export class AnaglyphPostProcess extends PostProcess {
  46734. private _passedProcess;
  46735. /**
  46736. * Creates a new AnaglyphPostProcess
  46737. * @param name defines postprocess name
  46738. * @param options defines creation options or target ratio scale
  46739. * @param rigCameras defines cameras using this postprocess
  46740. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46741. * @param engine defines hosting engine
  46742. * @param reusable defines if the postprocess will be reused multiple times per frame
  46743. */
  46744. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46745. }
  46746. }
  46747. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46749. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46750. import { Scene } from "babylonjs/scene";
  46751. import { Vector3 } from "babylonjs/Maths/math.vector";
  46752. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46753. /**
  46754. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46755. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46756. */
  46757. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46758. /**
  46759. * Creates a new AnaglyphArcRotateCamera
  46760. * @param name defines camera name
  46761. * @param alpha defines alpha angle (in radians)
  46762. * @param beta defines beta angle (in radians)
  46763. * @param radius defines radius
  46764. * @param target defines camera target
  46765. * @param interaxialDistance defines distance between each color axis
  46766. * @param scene defines the hosting scene
  46767. */
  46768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46769. /**
  46770. * Gets camera class name
  46771. * @returns AnaglyphArcRotateCamera
  46772. */
  46773. getClassName(): string;
  46774. }
  46775. }
  46776. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46777. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46778. import { Scene } from "babylonjs/scene";
  46779. import { Vector3 } from "babylonjs/Maths/math.vector";
  46780. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46781. /**
  46782. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46783. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46784. */
  46785. export class AnaglyphFreeCamera extends FreeCamera {
  46786. /**
  46787. * Creates a new AnaglyphFreeCamera
  46788. * @param name defines camera name
  46789. * @param position defines initial position
  46790. * @param interaxialDistance defines distance between each color axis
  46791. * @param scene defines the hosting scene
  46792. */
  46793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46794. /**
  46795. * Gets camera class name
  46796. * @returns AnaglyphFreeCamera
  46797. */
  46798. getClassName(): string;
  46799. }
  46800. }
  46801. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46802. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46803. import { Scene } from "babylonjs/scene";
  46804. import { Vector3 } from "babylonjs/Maths/math.vector";
  46805. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46806. /**
  46807. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46809. */
  46810. export class AnaglyphGamepadCamera extends GamepadCamera {
  46811. /**
  46812. * Creates a new AnaglyphGamepadCamera
  46813. * @param name defines camera name
  46814. * @param position defines initial position
  46815. * @param interaxialDistance defines distance between each color axis
  46816. * @param scene defines the hosting scene
  46817. */
  46818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46819. /**
  46820. * Gets camera class name
  46821. * @returns AnaglyphGamepadCamera
  46822. */
  46823. getClassName(): string;
  46824. }
  46825. }
  46826. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46827. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46828. import { Scene } from "babylonjs/scene";
  46829. import { Vector3 } from "babylonjs/Maths/math.vector";
  46830. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46831. /**
  46832. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46833. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46834. */
  46835. export class AnaglyphUniversalCamera extends UniversalCamera {
  46836. /**
  46837. * Creates a new AnaglyphUniversalCamera
  46838. * @param name defines camera name
  46839. * @param position defines initial position
  46840. * @param interaxialDistance defines distance between each color axis
  46841. * @param scene defines the hosting scene
  46842. */
  46843. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46844. /**
  46845. * Gets camera class name
  46846. * @returns AnaglyphUniversalCamera
  46847. */
  46848. getClassName(): string;
  46849. }
  46850. }
  46851. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46852. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46854. import { Scene } from "babylonjs/scene";
  46855. import { Vector3 } from "babylonjs/Maths/math.vector";
  46856. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46857. /**
  46858. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46859. * @see https://doc.babylonjs.com/features/cameras
  46860. */
  46861. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46862. /**
  46863. * Creates a new StereoscopicArcRotateCamera
  46864. * @param name defines camera name
  46865. * @param alpha defines alpha angle (in radians)
  46866. * @param beta defines beta angle (in radians)
  46867. * @param radius defines radius
  46868. * @param target defines camera target
  46869. * @param interaxialDistance defines distance between each color axis
  46870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46871. * @param scene defines the hosting scene
  46872. */
  46873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46874. /**
  46875. * Gets camera class name
  46876. * @returns StereoscopicArcRotateCamera
  46877. */
  46878. getClassName(): string;
  46879. }
  46880. }
  46881. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46882. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46883. import { Scene } from "babylonjs/scene";
  46884. import { Vector3 } from "babylonjs/Maths/math.vector";
  46885. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46886. /**
  46887. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46888. * @see https://doc.babylonjs.com/features/cameras
  46889. */
  46890. export class StereoscopicFreeCamera extends FreeCamera {
  46891. /**
  46892. * Creates a new StereoscopicFreeCamera
  46893. * @param name defines camera name
  46894. * @param position defines initial position
  46895. * @param interaxialDistance defines distance between each color axis
  46896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46897. * @param scene defines the hosting scene
  46898. */
  46899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46900. /**
  46901. * Gets camera class name
  46902. * @returns StereoscopicFreeCamera
  46903. */
  46904. getClassName(): string;
  46905. }
  46906. }
  46907. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46908. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46909. import { Scene } from "babylonjs/scene";
  46910. import { Vector3 } from "babylonjs/Maths/math.vector";
  46911. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46912. /**
  46913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46914. * @see https://doc.babylonjs.com/features/cameras
  46915. */
  46916. export class StereoscopicGamepadCamera extends GamepadCamera {
  46917. /**
  46918. * Creates a new StereoscopicGamepadCamera
  46919. * @param name defines camera name
  46920. * @param position defines initial position
  46921. * @param interaxialDistance defines distance between each color axis
  46922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46923. * @param scene defines the hosting scene
  46924. */
  46925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46926. /**
  46927. * Gets camera class name
  46928. * @returns StereoscopicGamepadCamera
  46929. */
  46930. getClassName(): string;
  46931. }
  46932. }
  46933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46935. import { Scene } from "babylonjs/scene";
  46936. import { Vector3 } from "babylonjs/Maths/math.vector";
  46937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46938. /**
  46939. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46940. * @see https://doc.babylonjs.com/features/cameras
  46941. */
  46942. export class StereoscopicUniversalCamera extends UniversalCamera {
  46943. /**
  46944. * Creates a new StereoscopicUniversalCamera
  46945. * @param name defines camera name
  46946. * @param position defines initial position
  46947. * @param interaxialDistance defines distance between each color axis
  46948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46949. * @param scene defines the hosting scene
  46950. */
  46951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46952. /**
  46953. * Gets camera class name
  46954. * @returns StereoscopicUniversalCamera
  46955. */
  46956. getClassName(): string;
  46957. }
  46958. }
  46959. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46960. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46961. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46962. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46964. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46965. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46966. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46968. }
  46969. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46970. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46971. import { Scene } from "babylonjs/scene";
  46972. import { Vector3 } from "babylonjs/Maths/math.vector";
  46973. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46974. /**
  46975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46978. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46979. */
  46980. export class VirtualJoysticksCamera extends FreeCamera {
  46981. /**
  46982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46985. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46986. * @param name Define the name of the camera in the scene
  46987. * @param position Define the start position of the camera in the scene
  46988. * @param scene Define the scene the camera belongs to
  46989. */
  46990. constructor(name: string, position: Vector3, scene: Scene);
  46991. /**
  46992. * Gets the current object class name.
  46993. * @return the class name
  46994. */
  46995. getClassName(): string;
  46996. }
  46997. }
  46998. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46999. import { Matrix } from "babylonjs/Maths/math.vector";
  47000. /**
  47001. * This represents all the required metrics to create a VR camera.
  47002. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47003. */
  47004. export class VRCameraMetrics {
  47005. /**
  47006. * Define the horizontal resolution off the screen.
  47007. */
  47008. hResolution: number;
  47009. /**
  47010. * Define the vertical resolution off the screen.
  47011. */
  47012. vResolution: number;
  47013. /**
  47014. * Define the horizontal screen size.
  47015. */
  47016. hScreenSize: number;
  47017. /**
  47018. * Define the vertical screen size.
  47019. */
  47020. vScreenSize: number;
  47021. /**
  47022. * Define the vertical screen center position.
  47023. */
  47024. vScreenCenter: number;
  47025. /**
  47026. * Define the distance of the eyes to the screen.
  47027. */
  47028. eyeToScreenDistance: number;
  47029. /**
  47030. * Define the distance between both lenses
  47031. */
  47032. lensSeparationDistance: number;
  47033. /**
  47034. * Define the distance between both viewer's eyes.
  47035. */
  47036. interpupillaryDistance: number;
  47037. /**
  47038. * Define the distortion factor of the VR postprocess.
  47039. * Please, touch with care.
  47040. */
  47041. distortionK: number[];
  47042. /**
  47043. * Define the chromatic aberration correction factors for the VR post process.
  47044. */
  47045. chromaAbCorrection: number[];
  47046. /**
  47047. * Define the scale factor of the post process.
  47048. * The smaller the better but the slower.
  47049. */
  47050. postProcessScaleFactor: number;
  47051. /**
  47052. * Define an offset for the lens center.
  47053. */
  47054. lensCenterOffset: number;
  47055. /**
  47056. * Define if the current vr camera should compensate the distortion of the lense or not.
  47057. */
  47058. compensateDistortion: boolean;
  47059. /**
  47060. * Defines if multiview should be enabled when rendering (Default: false)
  47061. */
  47062. multiviewEnabled: boolean;
  47063. /**
  47064. * Gets the rendering aspect ratio based on the provided resolutions.
  47065. */
  47066. get aspectRatio(): number;
  47067. /**
  47068. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47069. */
  47070. get aspectRatioFov(): number;
  47071. /**
  47072. * @hidden
  47073. */
  47074. get leftHMatrix(): Matrix;
  47075. /**
  47076. * @hidden
  47077. */
  47078. get rightHMatrix(): Matrix;
  47079. /**
  47080. * @hidden
  47081. */
  47082. get leftPreViewMatrix(): Matrix;
  47083. /**
  47084. * @hidden
  47085. */
  47086. get rightPreViewMatrix(): Matrix;
  47087. /**
  47088. * Get the default VRMetrics based on the most generic setup.
  47089. * @returns the default vr metrics
  47090. */
  47091. static GetDefault(): VRCameraMetrics;
  47092. }
  47093. }
  47094. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47095. /** @hidden */
  47096. export var vrDistortionCorrectionPixelShader: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47102. import { Camera } from "babylonjs/Cameras/camera";
  47103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47105. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47106. /**
  47107. * VRDistortionCorrectionPostProcess used for mobile VR
  47108. */
  47109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47110. private _isRightEye;
  47111. private _distortionFactors;
  47112. private _postProcessScaleFactor;
  47113. private _lensCenterOffset;
  47114. private _scaleIn;
  47115. private _scaleFactor;
  47116. private _lensCenter;
  47117. /**
  47118. * Initializes the VRDistortionCorrectionPostProcess
  47119. * @param name The name of the effect.
  47120. * @param camera The camera to apply the render pass to.
  47121. * @param isRightEye If this is for the right eye distortion
  47122. * @param vrMetrics All the required metrics for the VR camera
  47123. */
  47124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47125. }
  47126. }
  47127. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47128. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47130. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47131. import { Scene } from "babylonjs/scene";
  47132. import { Vector3 } from "babylonjs/Maths/math.vector";
  47133. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47134. import "babylonjs/Cameras/RigModes/vrRigMode";
  47135. /**
  47136. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47137. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47138. */
  47139. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47140. /**
  47141. * Creates a new VRDeviceOrientationArcRotateCamera
  47142. * @param name defines camera name
  47143. * @param alpha defines the camera rotation along the logitudinal axis
  47144. * @param beta defines the camera rotation along the latitudinal axis
  47145. * @param radius defines the camera distance from its target
  47146. * @param target defines the camera target
  47147. * @param scene defines the scene the camera belongs to
  47148. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47149. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47150. */
  47151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47152. /**
  47153. * Gets camera class name
  47154. * @returns VRDeviceOrientationArcRotateCamera
  47155. */
  47156. getClassName(): string;
  47157. }
  47158. }
  47159. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47160. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47161. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47162. import { Scene } from "babylonjs/scene";
  47163. import { Vector3 } from "babylonjs/Maths/math.vector";
  47164. import "babylonjs/Cameras/RigModes/vrRigMode";
  47165. /**
  47166. * Camera used to simulate VR rendering (based on FreeCamera)
  47167. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47168. */
  47169. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47170. /**
  47171. * Creates a new VRDeviceOrientationFreeCamera
  47172. * @param name defines camera name
  47173. * @param position defines the start position of the camera
  47174. * @param scene defines the scene the camera belongs to
  47175. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47176. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47177. */
  47178. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47179. /**
  47180. * Gets camera class name
  47181. * @returns VRDeviceOrientationFreeCamera
  47182. */
  47183. getClassName(): string;
  47184. }
  47185. }
  47186. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47187. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47189. import { Scene } from "babylonjs/scene";
  47190. import { Vector3 } from "babylonjs/Maths/math.vector";
  47191. import "babylonjs/Gamepads/gamepadSceneComponent";
  47192. /**
  47193. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47194. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47195. */
  47196. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47197. /**
  47198. * Creates a new VRDeviceOrientationGamepadCamera
  47199. * @param name defines camera name
  47200. * @param position defines the start position of the camera
  47201. * @param scene defines the scene the camera belongs to
  47202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47204. */
  47205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47206. /**
  47207. * Gets camera class name
  47208. * @returns VRDeviceOrientationGamepadCamera
  47209. */
  47210. getClassName(): string;
  47211. }
  47212. }
  47213. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47214. import { Scene } from "babylonjs/scene";
  47215. import { Texture } from "babylonjs/Materials/Textures/texture";
  47216. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47217. /**
  47218. * A class extending Texture allowing drawing on a texture
  47219. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47220. */
  47221. export class DynamicTexture extends Texture {
  47222. private _generateMipMaps;
  47223. private _canvas;
  47224. private _context;
  47225. /**
  47226. * Creates a DynamicTexture
  47227. * @param name defines the name of the texture
  47228. * @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
  47229. * @param scene defines the scene where you want the texture
  47230. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47231. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47232. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47233. */
  47234. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47235. /**
  47236. * Get the current class name of the texture useful for serialization or dynamic coding.
  47237. * @returns "DynamicTexture"
  47238. */
  47239. getClassName(): string;
  47240. /**
  47241. * Gets the current state of canRescale
  47242. */
  47243. get canRescale(): boolean;
  47244. private _recreate;
  47245. /**
  47246. * Scales the texture
  47247. * @param ratio the scale factor to apply to both width and height
  47248. */
  47249. scale(ratio: number): void;
  47250. /**
  47251. * Resizes the texture
  47252. * @param width the new width
  47253. * @param height the new height
  47254. */
  47255. scaleTo(width: number, height: number): void;
  47256. /**
  47257. * Gets the context of the canvas used by the texture
  47258. * @returns the canvas context of the dynamic texture
  47259. */
  47260. getContext(): CanvasRenderingContext2D;
  47261. /**
  47262. * Clears the texture
  47263. */
  47264. clear(): void;
  47265. /**
  47266. * Updates the texture
  47267. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47268. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47269. */
  47270. update(invertY?: boolean, premulAlpha?: boolean): void;
  47271. /**
  47272. * Draws text onto the texture
  47273. * @param text defines the text to be drawn
  47274. * @param x defines the placement of the text from the left
  47275. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47276. * @param font defines the font to be used with font-style, font-size, font-name
  47277. * @param color defines the color used for the text
  47278. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47280. * @param update defines whether texture is immediately update (default is true)
  47281. */
  47282. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47283. /**
  47284. * Clones the texture
  47285. * @returns the clone of the texture.
  47286. */
  47287. clone(): DynamicTexture;
  47288. /**
  47289. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47290. * @returns a serialized dynamic texture object
  47291. */
  47292. serialize(): any;
  47293. private _IsCanvasElement;
  47294. /** @hidden */
  47295. _rebuild(): void;
  47296. }
  47297. }
  47298. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47299. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47301. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47302. /** @hidden */
  47303. export var imageProcessingPixelShader: {
  47304. name: string;
  47305. shader: string;
  47306. };
  47307. }
  47308. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47309. import { Nullable } from "babylonjs/types";
  47310. import { Color4 } from "babylonjs/Maths/math.color";
  47311. import { Camera } from "babylonjs/Cameras/camera";
  47312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47314. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47316. import { Engine } from "babylonjs/Engines/engine";
  47317. import "babylonjs/Shaders/imageProcessing.fragment";
  47318. import "babylonjs/Shaders/postprocess.vertex";
  47319. /**
  47320. * ImageProcessingPostProcess
  47321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47322. */
  47323. export class ImageProcessingPostProcess extends PostProcess {
  47324. /**
  47325. * Default configuration related to image processing available in the PBR Material.
  47326. */
  47327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47328. /**
  47329. * Gets the image processing configuration used either in this material.
  47330. */
  47331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47332. /**
  47333. * Sets the Default image processing configuration used either in the this material.
  47334. *
  47335. * If sets to null, the scene one is in use.
  47336. */
  47337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47338. /**
  47339. * Keep track of the image processing observer to allow dispose and replace.
  47340. */
  47341. private _imageProcessingObserver;
  47342. /**
  47343. * Attaches a new image processing configuration to the PBR Material.
  47344. * @param configuration
  47345. */
  47346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47347. /**
  47348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47349. */
  47350. get colorCurves(): Nullable<ColorCurves>;
  47351. /**
  47352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47353. */
  47354. set colorCurves(value: Nullable<ColorCurves>);
  47355. /**
  47356. * Gets wether the color curves effect is enabled.
  47357. */
  47358. get colorCurvesEnabled(): boolean;
  47359. /**
  47360. * Sets wether the color curves effect is enabled.
  47361. */
  47362. set colorCurvesEnabled(value: boolean);
  47363. /**
  47364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47365. */
  47366. get colorGradingTexture(): Nullable<BaseTexture>;
  47367. /**
  47368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47369. */
  47370. set colorGradingTexture(value: Nullable<BaseTexture>);
  47371. /**
  47372. * Gets wether the color grading effect is enabled.
  47373. */
  47374. get colorGradingEnabled(): boolean;
  47375. /**
  47376. * Gets wether the color grading effect is enabled.
  47377. */
  47378. set colorGradingEnabled(value: boolean);
  47379. /**
  47380. * Gets exposure used in the effect.
  47381. */
  47382. get exposure(): number;
  47383. /**
  47384. * Sets exposure used in the effect.
  47385. */
  47386. set exposure(value: number);
  47387. /**
  47388. * Gets wether tonemapping is enabled or not.
  47389. */
  47390. get toneMappingEnabled(): boolean;
  47391. /**
  47392. * Sets wether tonemapping is enabled or not
  47393. */
  47394. set toneMappingEnabled(value: boolean);
  47395. /**
  47396. * Gets the type of tone mapping effect.
  47397. */
  47398. get toneMappingType(): number;
  47399. /**
  47400. * Sets the type of tone mapping effect.
  47401. */
  47402. set toneMappingType(value: number);
  47403. /**
  47404. * Gets contrast used in the effect.
  47405. */
  47406. get contrast(): number;
  47407. /**
  47408. * Sets contrast used in the effect.
  47409. */
  47410. set contrast(value: number);
  47411. /**
  47412. * Gets Vignette stretch size.
  47413. */
  47414. get vignetteStretch(): number;
  47415. /**
  47416. * Sets Vignette stretch size.
  47417. */
  47418. set vignetteStretch(value: number);
  47419. /**
  47420. * Gets Vignette centre X Offset.
  47421. */
  47422. get vignetteCentreX(): number;
  47423. /**
  47424. * Sets Vignette centre X Offset.
  47425. */
  47426. set vignetteCentreX(value: number);
  47427. /**
  47428. * Gets Vignette centre Y Offset.
  47429. */
  47430. get vignetteCentreY(): number;
  47431. /**
  47432. * Sets Vignette centre Y Offset.
  47433. */
  47434. set vignetteCentreY(value: number);
  47435. /**
  47436. * Gets Vignette weight or intensity of the vignette effect.
  47437. */
  47438. get vignetteWeight(): number;
  47439. /**
  47440. * Sets Vignette weight or intensity of the vignette effect.
  47441. */
  47442. set vignetteWeight(value: number);
  47443. /**
  47444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47445. * if vignetteEnabled is set to true.
  47446. */
  47447. get vignetteColor(): Color4;
  47448. /**
  47449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47450. * if vignetteEnabled is set to true.
  47451. */
  47452. set vignetteColor(value: Color4);
  47453. /**
  47454. * Gets Camera field of view used by the Vignette effect.
  47455. */
  47456. get vignetteCameraFov(): number;
  47457. /**
  47458. * Sets Camera field of view used by the Vignette effect.
  47459. */
  47460. set vignetteCameraFov(value: number);
  47461. /**
  47462. * Gets the vignette blend mode allowing different kind of effect.
  47463. */
  47464. get vignetteBlendMode(): number;
  47465. /**
  47466. * Sets the vignette blend mode allowing different kind of effect.
  47467. */
  47468. set vignetteBlendMode(value: number);
  47469. /**
  47470. * Gets wether the vignette effect is enabled.
  47471. */
  47472. get vignetteEnabled(): boolean;
  47473. /**
  47474. * Sets wether the vignette effect is enabled.
  47475. */
  47476. set vignetteEnabled(value: boolean);
  47477. private _fromLinearSpace;
  47478. /**
  47479. * Gets wether the input of the processing is in Gamma or Linear Space.
  47480. */
  47481. get fromLinearSpace(): boolean;
  47482. /**
  47483. * Sets wether the input of the processing is in Gamma or Linear Space.
  47484. */
  47485. set fromLinearSpace(value: boolean);
  47486. /**
  47487. * Defines cache preventing GC.
  47488. */
  47489. private _defines;
  47490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47491. /**
  47492. * "ImageProcessingPostProcess"
  47493. * @returns "ImageProcessingPostProcess"
  47494. */
  47495. getClassName(): string;
  47496. protected _updateParameters(): void;
  47497. dispose(camera?: Camera): void;
  47498. }
  47499. }
  47500. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47501. import { Scene } from "babylonjs/scene";
  47502. import { Color3 } from "babylonjs/Maths/math.color";
  47503. import { Mesh } from "babylonjs/Meshes/mesh";
  47504. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47505. import { Nullable } from "babylonjs/types";
  47506. /**
  47507. * Class containing static functions to help procedurally build meshes
  47508. */
  47509. export class GroundBuilder {
  47510. /**
  47511. * Creates a ground mesh
  47512. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47513. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47515. * @param name defines the name of the mesh
  47516. * @param options defines the options used to create the mesh
  47517. * @param scene defines the hosting scene
  47518. * @returns the ground mesh
  47519. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47520. */
  47521. static CreateGround(name: string, options: {
  47522. width?: number;
  47523. height?: number;
  47524. subdivisions?: number;
  47525. subdivisionsX?: number;
  47526. subdivisionsY?: number;
  47527. updatable?: boolean;
  47528. }, scene: any): Mesh;
  47529. /**
  47530. * Creates a tiled ground mesh
  47531. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47532. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47533. * * 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
  47534. * * 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
  47535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47536. * @param name defines the name of the mesh
  47537. * @param options defines the options used to create the mesh
  47538. * @param scene defines the hosting scene
  47539. * @returns the tiled ground mesh
  47540. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47541. */
  47542. static CreateTiledGround(name: string, options: {
  47543. xmin: number;
  47544. zmin: number;
  47545. xmax: number;
  47546. zmax: number;
  47547. subdivisions?: {
  47548. w: number;
  47549. h: number;
  47550. };
  47551. precision?: {
  47552. w: number;
  47553. h: number;
  47554. };
  47555. updatable?: boolean;
  47556. }, scene?: Nullable<Scene>): Mesh;
  47557. /**
  47558. * Creates a ground mesh from a height map
  47559. * * The parameter `url` sets the URL of the height map image resource.
  47560. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47561. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47562. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47563. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47564. * * 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.
  47565. * * 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).
  47566. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47568. * @param name defines the name of the mesh
  47569. * @param url defines the url to the height map
  47570. * @param options defines the options used to create the mesh
  47571. * @param scene defines the hosting scene
  47572. * @returns the ground mesh
  47573. * @see https://doc.babylonjs.com/babylon101/height_map
  47574. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47575. */
  47576. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47577. width?: number;
  47578. height?: number;
  47579. subdivisions?: number;
  47580. minHeight?: number;
  47581. maxHeight?: number;
  47582. colorFilter?: Color3;
  47583. alphaFilter?: number;
  47584. updatable?: boolean;
  47585. onReady?: (mesh: GroundMesh) => void;
  47586. }, scene?: Nullable<Scene>): GroundMesh;
  47587. }
  47588. }
  47589. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47590. import { Vector4 } from "babylonjs/Maths/math.vector";
  47591. import { Mesh } from "babylonjs/Meshes/mesh";
  47592. /**
  47593. * Class containing static functions to help procedurally build meshes
  47594. */
  47595. export class TorusBuilder {
  47596. /**
  47597. * Creates a torus mesh
  47598. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47599. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47600. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47604. * @param name defines the name of the mesh
  47605. * @param options defines the options used to create the mesh
  47606. * @param scene defines the hosting scene
  47607. * @returns the torus mesh
  47608. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47609. */
  47610. static CreateTorus(name: string, options: {
  47611. diameter?: number;
  47612. thickness?: number;
  47613. tessellation?: number;
  47614. updatable?: boolean;
  47615. sideOrientation?: number;
  47616. frontUVs?: Vector4;
  47617. backUVs?: Vector4;
  47618. }, scene: any): Mesh;
  47619. }
  47620. }
  47621. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47622. import { Vector4 } from "babylonjs/Maths/math.vector";
  47623. import { Color4 } from "babylonjs/Maths/math.color";
  47624. import { Mesh } from "babylonjs/Meshes/mesh";
  47625. /**
  47626. * Class containing static functions to help procedurally build meshes
  47627. */
  47628. export class CylinderBuilder {
  47629. /**
  47630. * Creates a cylinder or a cone mesh
  47631. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47632. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47633. * * 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.
  47634. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47635. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47636. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47637. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47638. * * 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).
  47639. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47640. * * 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).
  47641. * * 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
  47642. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47643. * * 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
  47644. * * 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.
  47645. * * If `enclose` is false, a ring surface is one element.
  47646. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47647. * * 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
  47648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47651. * @param name defines the name of the mesh
  47652. * @param options defines the options used to create the mesh
  47653. * @param scene defines the hosting scene
  47654. * @returns the cylinder mesh
  47655. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47656. */
  47657. static CreateCylinder(name: string, options: {
  47658. height?: number;
  47659. diameterTop?: number;
  47660. diameterBottom?: number;
  47661. diameter?: number;
  47662. tessellation?: number;
  47663. subdivisions?: number;
  47664. arc?: number;
  47665. faceColors?: Color4[];
  47666. faceUV?: Vector4[];
  47667. updatable?: boolean;
  47668. hasRings?: boolean;
  47669. enclose?: boolean;
  47670. cap?: number;
  47671. sideOrientation?: number;
  47672. frontUVs?: Vector4;
  47673. backUVs?: Vector4;
  47674. }, scene: any): Mesh;
  47675. }
  47676. }
  47677. declare module "babylonjs/XR/webXRTypes" {
  47678. import { Nullable } from "babylonjs/types";
  47679. import { IDisposable } from "babylonjs/scene";
  47680. /**
  47681. * States of the webXR experience
  47682. */
  47683. export enum WebXRState {
  47684. /**
  47685. * Transitioning to being in XR mode
  47686. */
  47687. ENTERING_XR = 0,
  47688. /**
  47689. * Transitioning to non XR mode
  47690. */
  47691. EXITING_XR = 1,
  47692. /**
  47693. * In XR mode and presenting
  47694. */
  47695. IN_XR = 2,
  47696. /**
  47697. * Not entered XR mode
  47698. */
  47699. NOT_IN_XR = 3
  47700. }
  47701. /**
  47702. * Abstraction of the XR render target
  47703. */
  47704. export interface WebXRRenderTarget extends IDisposable {
  47705. /**
  47706. * xrpresent context of the canvas which can be used to display/mirror xr content
  47707. */
  47708. canvasContext: WebGLRenderingContext;
  47709. /**
  47710. * xr layer for the canvas
  47711. */
  47712. xrLayer: Nullable<XRWebGLLayer>;
  47713. /**
  47714. * Initializes the xr layer for the session
  47715. * @param xrSession xr session
  47716. * @returns a promise that will resolve once the XR Layer has been created
  47717. */
  47718. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47719. }
  47720. }
  47721. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47722. import { Nullable } from "babylonjs/types";
  47723. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47724. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47725. import { Observable } from "babylonjs/Misc/observable";
  47726. /**
  47727. * COnfiguration object for WebXR output canvas
  47728. */
  47729. export class WebXRManagedOutputCanvasOptions {
  47730. /**
  47731. * An optional canvas in case you wish to create it yourself and provide it here.
  47732. * If not provided, a new canvas will be created
  47733. */
  47734. canvasElement?: HTMLCanvasElement;
  47735. /**
  47736. * Options for this XR Layer output
  47737. */
  47738. canvasOptions?: XRWebGLLayerOptions;
  47739. /**
  47740. * CSS styling for a newly created canvas (if not provided)
  47741. */
  47742. newCanvasCssStyle?: string;
  47743. /**
  47744. * Get the default values of the configuration object
  47745. * @returns default values of this configuration object
  47746. */
  47747. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47748. }
  47749. /**
  47750. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47751. */
  47752. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47753. private _options;
  47754. private _canvas;
  47755. private _engine;
  47756. private _originalCanvasSize;
  47757. /**
  47758. * Rendering context of the canvas which can be used to display/mirror xr content
  47759. */
  47760. canvasContext: WebGLRenderingContext;
  47761. /**
  47762. * xr layer for the canvas
  47763. */
  47764. xrLayer: Nullable<XRWebGLLayer>;
  47765. /**
  47766. * Obseervers registered here will be triggered when the xr layer was initialized
  47767. */
  47768. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47769. /**
  47770. * Initializes the canvas to be added/removed upon entering/exiting xr
  47771. * @param _xrSessionManager The XR Session manager
  47772. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47773. */
  47774. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47775. /**
  47776. * Disposes of the object
  47777. */
  47778. dispose(): void;
  47779. /**
  47780. * Initializes the xr layer for the session
  47781. * @param xrSession xr session
  47782. * @returns a promise that will resolve once the XR Layer has been created
  47783. */
  47784. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47785. private _addCanvas;
  47786. private _removeCanvas;
  47787. private _setCanvasSize;
  47788. private _setManagedOutputCanvas;
  47789. }
  47790. }
  47791. declare module "babylonjs/XR/webXRSessionManager" {
  47792. import { Observable } from "babylonjs/Misc/observable";
  47793. import { Nullable } from "babylonjs/types";
  47794. import { IDisposable, Scene } from "babylonjs/scene";
  47795. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47796. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47797. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47798. /**
  47799. * Manages an XRSession to work with Babylon's engine
  47800. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47801. */
  47802. export class WebXRSessionManager implements IDisposable {
  47803. /** The scene which the session should be created for */
  47804. scene: Scene;
  47805. private _referenceSpace;
  47806. private _rttProvider;
  47807. private _sessionEnded;
  47808. private _xrNavigator;
  47809. private baseLayer;
  47810. /**
  47811. * The base reference space from which the session started. good if you want to reset your
  47812. * reference space
  47813. */
  47814. baseReferenceSpace: XRReferenceSpace;
  47815. /**
  47816. * Current XR frame
  47817. */
  47818. currentFrame: Nullable<XRFrame>;
  47819. /** WebXR timestamp updated every frame */
  47820. currentTimestamp: number;
  47821. /**
  47822. * Used just in case of a failure to initialize an immersive session.
  47823. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47824. */
  47825. defaultHeightCompensation: number;
  47826. /**
  47827. * Fires every time a new xrFrame arrives which can be used to update the camera
  47828. */
  47829. onXRFrameObservable: Observable<XRFrame>;
  47830. /**
  47831. * Fires when the reference space changed
  47832. */
  47833. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47834. /**
  47835. * Fires when the xr session is ended either by the device or manually done
  47836. */
  47837. onXRSessionEnded: Observable<any>;
  47838. /**
  47839. * Fires when the xr session is ended either by the device or manually done
  47840. */
  47841. onXRSessionInit: Observable<XRSession>;
  47842. /**
  47843. * Underlying xr session
  47844. */
  47845. session: XRSession;
  47846. /**
  47847. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47848. * or get the offset the player is currently at.
  47849. */
  47850. viewerReferenceSpace: XRReferenceSpace;
  47851. /**
  47852. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47853. * @param scene The scene which the session should be created for
  47854. */
  47855. constructor(
  47856. /** The scene which the session should be created for */
  47857. scene: Scene);
  47858. /**
  47859. * The current reference space used in this session. This reference space can constantly change!
  47860. * It is mainly used to offset the camera's position.
  47861. */
  47862. get referenceSpace(): XRReferenceSpace;
  47863. /**
  47864. * Set a new reference space and triggers the observable
  47865. */
  47866. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47867. /**
  47868. * Disposes of the session manager
  47869. */
  47870. dispose(): void;
  47871. /**
  47872. * Stops the xrSession and restores the render loop
  47873. * @returns Promise which resolves after it exits XR
  47874. */
  47875. exitXRAsync(): Promise<void>;
  47876. /**
  47877. * Gets the correct render target texture to be rendered this frame for this eye
  47878. * @param eye the eye for which to get the render target
  47879. * @returns the render target for the specified eye
  47880. */
  47881. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47882. /**
  47883. * Creates a WebXRRenderTarget object for the XR session
  47884. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47885. * @param options optional options to provide when creating a new render target
  47886. * @returns a WebXR render target to which the session can render
  47887. */
  47888. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47889. /**
  47890. * Initializes the manager
  47891. * After initialization enterXR can be called to start an XR session
  47892. * @returns Promise which resolves after it is initialized
  47893. */
  47894. initializeAsync(): Promise<void>;
  47895. /**
  47896. * Initializes an xr session
  47897. * @param xrSessionMode mode to initialize
  47898. * @param xrSessionInit defines optional and required values to pass to the session builder
  47899. * @returns a promise which will resolve once the session has been initialized
  47900. */
  47901. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47902. /**
  47903. * Checks if a session would be supported for the creation options specified
  47904. * @param sessionMode session mode to check if supported eg. immersive-vr
  47905. * @returns A Promise that resolves to true if supported and false if not
  47906. */
  47907. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47908. /**
  47909. * Resets the reference space to the one started the session
  47910. */
  47911. resetReferenceSpace(): void;
  47912. /**
  47913. * Starts rendering to the xr layer
  47914. */
  47915. runXRRenderLoop(): void;
  47916. /**
  47917. * Sets the reference space on the xr session
  47918. * @param referenceSpaceType space to set
  47919. * @returns a promise that will resolve once the reference space has been set
  47920. */
  47921. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47922. /**
  47923. * Updates the render state of the session
  47924. * @param state state to set
  47925. * @returns a promise that resolves once the render state has been updated
  47926. */
  47927. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47928. /**
  47929. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47930. * @param sessionMode defines the session to test
  47931. * @returns a promise with boolean as final value
  47932. */
  47933. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47934. private _createRenderTargetTexture;
  47935. }
  47936. }
  47937. declare module "babylonjs/XR/webXRCamera" {
  47938. import { Matrix } from "babylonjs/Maths/math.vector";
  47939. import { Scene } from "babylonjs/scene";
  47940. import { Camera } from "babylonjs/Cameras/camera";
  47941. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47942. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47943. /**
  47944. * WebXR Camera which holds the views for the xrSession
  47945. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47946. */
  47947. export class WebXRCamera extends FreeCamera {
  47948. private _xrSessionManager;
  47949. private _firstFrame;
  47950. private _referenceQuaternion;
  47951. private _referencedPosition;
  47952. private _xrInvPositionCache;
  47953. private _xrInvQuaternionCache;
  47954. /**
  47955. * Should position compensation execute on first frame.
  47956. * This is used when copying the position from a native (non XR) camera
  47957. */
  47958. compensateOnFirstFrame: boolean;
  47959. /**
  47960. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47961. * @param name the name of the camera
  47962. * @param scene the scene to add the camera to
  47963. * @param _xrSessionManager a constructed xr session manager
  47964. */
  47965. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47966. /**
  47967. * Return the user's height, unrelated to the current ground.
  47968. * This will be the y position of this camera, when ground level is 0.
  47969. */
  47970. get realWorldHeight(): number;
  47971. /** @hidden */
  47972. _updateForDualEyeDebugging(): void;
  47973. /**
  47974. * Sets this camera's transformation based on a non-vr camera
  47975. * @param otherCamera the non-vr camera to copy the transformation from
  47976. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47977. */
  47978. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47979. /**
  47980. * Gets the current instance class name ("WebXRCamera").
  47981. * @returns the class name
  47982. */
  47983. getClassName(): string;
  47984. /**
  47985. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47986. */
  47987. _getViewMatrix(): Matrix;
  47988. private _rotate180;
  47989. private _updateFromXRSession;
  47990. private _updateNumberOfRigCameras;
  47991. private _updateReferenceSpace;
  47992. private _updateReferenceSpaceOffset;
  47993. }
  47994. }
  47995. declare module "babylonjs/XR/webXRFeaturesManager" {
  47996. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47997. import { IDisposable } from "babylonjs/scene";
  47998. /**
  47999. * Defining the interface required for a (webxr) feature
  48000. */
  48001. export interface IWebXRFeature extends IDisposable {
  48002. /**
  48003. * Is this feature attached
  48004. */
  48005. attached: boolean;
  48006. /**
  48007. * Should auto-attach be disabled?
  48008. */
  48009. disableAutoAttach: boolean;
  48010. /**
  48011. * Attach the feature to the session
  48012. * Will usually be called by the features manager
  48013. *
  48014. * @param force should attachment be forced (even when already attached)
  48015. * @returns true if successful.
  48016. */
  48017. attach(force?: boolean): boolean;
  48018. /**
  48019. * Detach the feature from the session
  48020. * Will usually be called by the features manager
  48021. *
  48022. * @returns true if successful.
  48023. */
  48024. detach(): boolean;
  48025. }
  48026. /**
  48027. * A list of the currently available features without referencing them
  48028. */
  48029. export class WebXRFeatureName {
  48030. /**
  48031. * The name of the anchor system feature
  48032. */
  48033. static ANCHOR_SYSTEM: string;
  48034. /**
  48035. * The name of the background remover feature
  48036. */
  48037. static BACKGROUND_REMOVER: string;
  48038. /**
  48039. * The name of the hit test feature
  48040. */
  48041. static HIT_TEST: string;
  48042. /**
  48043. * physics impostors for xr controllers feature
  48044. */
  48045. static PHYSICS_CONTROLLERS: string;
  48046. /**
  48047. * The name of the plane detection feature
  48048. */
  48049. static PLANE_DETECTION: string;
  48050. /**
  48051. * The name of the pointer selection feature
  48052. */
  48053. static POINTER_SELECTION: string;
  48054. /**
  48055. * The name of the teleportation feature
  48056. */
  48057. static TELEPORTATION: string;
  48058. }
  48059. /**
  48060. * Defining the constructor of a feature. Used to register the modules.
  48061. */
  48062. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48063. /**
  48064. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48065. * It is mainly used in AR sessions.
  48066. *
  48067. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48068. */
  48069. export class WebXRFeaturesManager implements IDisposable {
  48070. private _xrSessionManager;
  48071. private static readonly _AvailableFeatures;
  48072. private _features;
  48073. /**
  48074. * constructs a new features manages.
  48075. *
  48076. * @param _xrSessionManager an instance of WebXRSessionManager
  48077. */
  48078. constructor(_xrSessionManager: WebXRSessionManager);
  48079. /**
  48080. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48081. * Mainly used internally.
  48082. *
  48083. * @param featureName the name of the feature to register
  48084. * @param constructorFunction the function used to construct the module
  48085. * @param version the (babylon) version of the module
  48086. * @param stable is that a stable version of this module
  48087. */
  48088. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48089. /**
  48090. * Returns a constructor of a specific feature.
  48091. *
  48092. * @param featureName the name of the feature to construct
  48093. * @param version the version of the feature to load
  48094. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48095. * @param options optional options provided to the module.
  48096. * @returns a function that, when called, will return a new instance of this feature
  48097. */
  48098. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48099. /**
  48100. * Can be used to return the list of features currently registered
  48101. *
  48102. * @returns an Array of available features
  48103. */
  48104. static GetAvailableFeatures(): string[];
  48105. /**
  48106. * Gets the versions available for a specific feature
  48107. * @param featureName the name of the feature
  48108. * @returns an array with the available versions
  48109. */
  48110. static GetAvailableVersions(featureName: string): string[];
  48111. /**
  48112. * Return the latest unstable version of this feature
  48113. * @param featureName the name of the feature to search
  48114. * @returns the version number. if not found will return -1
  48115. */
  48116. static GetLatestVersionOfFeature(featureName: string): number;
  48117. /**
  48118. * Return the latest stable version of this feature
  48119. * @param featureName the name of the feature to search
  48120. * @returns the version number. if not found will return -1
  48121. */
  48122. static GetStableVersionOfFeature(featureName: string): number;
  48123. /**
  48124. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48125. * Can be used during a session to start a feature
  48126. * @param featureName the name of feature to attach
  48127. */
  48128. attachFeature(featureName: string): void;
  48129. /**
  48130. * Can be used inside a session or when the session ends to detach a specific feature
  48131. * @param featureName the name of the feature to detach
  48132. */
  48133. detachFeature(featureName: string): void;
  48134. /**
  48135. * Used to disable an already-enabled feature
  48136. * The feature will be disposed and will be recreated once enabled.
  48137. * @param featureName the feature to disable
  48138. * @returns true if disable was successful
  48139. */
  48140. disableFeature(featureName: string | {
  48141. Name: string;
  48142. }): boolean;
  48143. /**
  48144. * dispose this features manager
  48145. */
  48146. dispose(): void;
  48147. /**
  48148. * 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.
  48149. * 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.
  48150. *
  48151. * @param featureName the name of the feature to load or the class of the feature
  48152. * @param version optional version to load. if not provided the latest version will be enabled
  48153. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48154. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48155. * @returns a new constructed feature or throws an error if feature not found.
  48156. */
  48157. enableFeature(featureName: string | {
  48158. Name: string;
  48159. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48160. /**
  48161. * get the implementation of an enabled feature.
  48162. * @param featureName the name of the feature to load
  48163. * @returns the feature class, if found
  48164. */
  48165. getEnabledFeature(featureName: string): IWebXRFeature;
  48166. /**
  48167. * Get the list of enabled features
  48168. * @returns an array of enabled features
  48169. */
  48170. getEnabledFeatures(): string[];
  48171. }
  48172. }
  48173. declare module "babylonjs/XR/webXRExperienceHelper" {
  48174. import { Observable } from "babylonjs/Misc/observable";
  48175. import { IDisposable, Scene } from "babylonjs/scene";
  48176. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48177. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48178. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48179. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48180. /**
  48181. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48182. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48183. */
  48184. export class WebXRExperienceHelper implements IDisposable {
  48185. private scene;
  48186. private _nonVRCamera;
  48187. private _originalSceneAutoClear;
  48188. private _supported;
  48189. /**
  48190. * Camera used to render xr content
  48191. */
  48192. camera: WebXRCamera;
  48193. /** A features manager for this xr session */
  48194. featuresManager: WebXRFeaturesManager;
  48195. /**
  48196. * Observers registered here will be triggered after the camera's initial transformation is set
  48197. * This can be used to set a different ground level or an extra rotation.
  48198. *
  48199. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48200. * to the position set after this observable is done executing.
  48201. */
  48202. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48203. /**
  48204. * Fires when the state of the experience helper has changed
  48205. */
  48206. onStateChangedObservable: Observable<WebXRState>;
  48207. /** Session manager used to keep track of xr session */
  48208. sessionManager: WebXRSessionManager;
  48209. /**
  48210. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48211. */
  48212. state: WebXRState;
  48213. /**
  48214. * Creates a WebXRExperienceHelper
  48215. * @param scene The scene the helper should be created in
  48216. */
  48217. private constructor();
  48218. /**
  48219. * Creates the experience helper
  48220. * @param scene the scene to attach the experience helper to
  48221. * @returns a promise for the experience helper
  48222. */
  48223. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48224. /**
  48225. * Disposes of the experience helper
  48226. */
  48227. dispose(): void;
  48228. /**
  48229. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48230. * @param sessionMode options for the XR session
  48231. * @param referenceSpaceType frame of reference of the XR session
  48232. * @param renderTarget the output canvas that will be used to enter XR mode
  48233. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48234. * @returns promise that resolves after xr mode has entered
  48235. */
  48236. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48237. /**
  48238. * Exits XR mode and returns the scene to its original state
  48239. * @returns promise that resolves after xr mode has exited
  48240. */
  48241. exitXRAsync(): Promise<void>;
  48242. private _nonXRToXRCamera;
  48243. private _setState;
  48244. }
  48245. }
  48246. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48247. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48248. import { Observable } from "babylonjs/Misc/observable";
  48249. import { IDisposable } from "babylonjs/scene";
  48250. /**
  48251. * X-Y values for axes in WebXR
  48252. */
  48253. export interface IWebXRMotionControllerAxesValue {
  48254. /**
  48255. * The value of the x axis
  48256. */
  48257. x: number;
  48258. /**
  48259. * The value of the y-axis
  48260. */
  48261. y: number;
  48262. }
  48263. /**
  48264. * changed / previous values for the values of this component
  48265. */
  48266. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48267. /**
  48268. * current (this frame) value
  48269. */
  48270. current: T;
  48271. /**
  48272. * previous (last change) value
  48273. */
  48274. previous: T;
  48275. }
  48276. /**
  48277. * Represents changes in the component between current frame and last values recorded
  48278. */
  48279. export interface IWebXRMotionControllerComponentChanges {
  48280. /**
  48281. * will be populated with previous and current values if axes changed
  48282. */
  48283. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48284. /**
  48285. * will be populated with previous and current values if pressed changed
  48286. */
  48287. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48288. /**
  48289. * will be populated with previous and current values if touched changed
  48290. */
  48291. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48292. /**
  48293. * will be populated with previous and current values if value changed
  48294. */
  48295. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48296. }
  48297. /**
  48298. * This class represents a single component (for example button or thumbstick) of a motion controller
  48299. */
  48300. export class WebXRControllerComponent implements IDisposable {
  48301. /**
  48302. * the id of this component
  48303. */
  48304. id: string;
  48305. /**
  48306. * the type of the component
  48307. */
  48308. type: MotionControllerComponentType;
  48309. private _buttonIndex;
  48310. private _axesIndices;
  48311. private _axes;
  48312. private _changes;
  48313. private _currentValue;
  48314. private _hasChanges;
  48315. private _pressed;
  48316. private _touched;
  48317. /**
  48318. * button component type
  48319. */
  48320. static BUTTON_TYPE: MotionControllerComponentType;
  48321. /**
  48322. * squeeze component type
  48323. */
  48324. static SQUEEZE_TYPE: MotionControllerComponentType;
  48325. /**
  48326. * Thumbstick component type
  48327. */
  48328. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48329. /**
  48330. * Touchpad component type
  48331. */
  48332. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48333. /**
  48334. * trigger component type
  48335. */
  48336. static TRIGGER_TYPE: MotionControllerComponentType;
  48337. /**
  48338. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48339. * the axes data changes
  48340. */
  48341. onAxisValueChangedObservable: Observable<{
  48342. x: number;
  48343. y: number;
  48344. }>;
  48345. /**
  48346. * Observers registered here will be triggered when the state of a button changes
  48347. * State change is either pressed / touched / value
  48348. */
  48349. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48350. /**
  48351. * Creates a new component for a motion controller.
  48352. * It is created by the motion controller itself
  48353. *
  48354. * @param id the id of this component
  48355. * @param type the type of the component
  48356. * @param _buttonIndex index in the buttons array of the gamepad
  48357. * @param _axesIndices indices of the values in the axes array of the gamepad
  48358. */
  48359. constructor(
  48360. /**
  48361. * the id of this component
  48362. */
  48363. id: string,
  48364. /**
  48365. * the type of the component
  48366. */
  48367. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48368. /**
  48369. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48370. */
  48371. get axes(): IWebXRMotionControllerAxesValue;
  48372. /**
  48373. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48374. */
  48375. get changes(): IWebXRMotionControllerComponentChanges;
  48376. /**
  48377. * Return whether or not the component changed the last frame
  48378. */
  48379. get hasChanges(): boolean;
  48380. /**
  48381. * is the button currently pressed
  48382. */
  48383. get pressed(): boolean;
  48384. /**
  48385. * is the button currently touched
  48386. */
  48387. get touched(): boolean;
  48388. /**
  48389. * Get the current value of this component
  48390. */
  48391. get value(): number;
  48392. /**
  48393. * Dispose this component
  48394. */
  48395. dispose(): void;
  48396. /**
  48397. * Are there axes correlating to this component
  48398. * @return true is axes data is available
  48399. */
  48400. isAxes(): boolean;
  48401. /**
  48402. * Is this component a button (hence - pressable)
  48403. * @returns true if can be pressed
  48404. */
  48405. isButton(): boolean;
  48406. /**
  48407. * update this component using the gamepad object it is in. Called on every frame
  48408. * @param nativeController the native gamepad controller object
  48409. */
  48410. update(nativeController: IMinimalMotionControllerObject): void;
  48411. }
  48412. }
  48413. declare module "babylonjs/Loading/sceneLoader" {
  48414. import { Observable } from "babylonjs/Misc/observable";
  48415. import { Nullable } from "babylonjs/types";
  48416. import { Scene } from "babylonjs/scene";
  48417. import { Engine } from "babylonjs/Engines/engine";
  48418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48419. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48420. import { AssetContainer } from "babylonjs/assetContainer";
  48421. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48422. import { Skeleton } from "babylonjs/Bones/skeleton";
  48423. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48424. import { WebRequest } from "babylonjs/Misc/webRequest";
  48425. /**
  48426. * Interface used to represent data loading progression
  48427. */
  48428. export interface ISceneLoaderProgressEvent {
  48429. /**
  48430. * Defines if data length to load can be evaluated
  48431. */
  48432. readonly lengthComputable: boolean;
  48433. /**
  48434. * Defines the loaded data length
  48435. */
  48436. readonly loaded: number;
  48437. /**
  48438. * Defines the data length to load
  48439. */
  48440. readonly total: number;
  48441. }
  48442. /**
  48443. * Interface used by SceneLoader plugins to define supported file extensions
  48444. */
  48445. export interface ISceneLoaderPluginExtensions {
  48446. /**
  48447. * Defines the list of supported extensions
  48448. */
  48449. [extension: string]: {
  48450. isBinary: boolean;
  48451. };
  48452. }
  48453. /**
  48454. * Interface used by SceneLoader plugin factory
  48455. */
  48456. export interface ISceneLoaderPluginFactory {
  48457. /**
  48458. * Defines the name of the factory
  48459. */
  48460. name: string;
  48461. /**
  48462. * Function called to create a new plugin
  48463. * @return the new plugin
  48464. */
  48465. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48466. /**
  48467. * The callback that returns true if the data can be directly loaded.
  48468. * @param data string containing the file data
  48469. * @returns if the data can be loaded directly
  48470. */
  48471. canDirectLoad?(data: string): boolean;
  48472. }
  48473. /**
  48474. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48475. */
  48476. export interface ISceneLoaderPluginBase {
  48477. /**
  48478. * The friendly name of this plugin.
  48479. */
  48480. name: string;
  48481. /**
  48482. * The file extensions supported by this plugin.
  48483. */
  48484. extensions: string | ISceneLoaderPluginExtensions;
  48485. /**
  48486. * The callback called when loading from a url.
  48487. * @param scene scene loading this url
  48488. * @param url url to load
  48489. * @param onSuccess callback called when the file successfully loads
  48490. * @param onProgress callback called while file is loading (if the server supports this mode)
  48491. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48492. * @param onError callback called when the file fails to load
  48493. * @returns a file request object
  48494. */
  48495. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48496. /**
  48497. * The callback called when loading from a file object.
  48498. * @param scene scene loading this file
  48499. * @param file defines the file to load
  48500. * @param onSuccess defines the callback to call when data is loaded
  48501. * @param onProgress defines the callback to call during loading process
  48502. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48503. * @param onError defines the callback to call when an error occurs
  48504. * @returns a file request object
  48505. */
  48506. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48507. /**
  48508. * The callback that returns true if the data can be directly loaded.
  48509. * @param data string containing the file data
  48510. * @returns if the data can be loaded directly
  48511. */
  48512. canDirectLoad?(data: string): boolean;
  48513. /**
  48514. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48515. * @param scene scene loading this data
  48516. * @param data string containing the data
  48517. * @returns data to pass to the plugin
  48518. */
  48519. directLoad?(scene: Scene, data: string): any;
  48520. /**
  48521. * The callback that allows custom handling of the root url based on the response url.
  48522. * @param rootUrl the original root url
  48523. * @param responseURL the response url if available
  48524. * @returns the new root url
  48525. */
  48526. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48527. }
  48528. /**
  48529. * Interface used to define a SceneLoader plugin
  48530. */
  48531. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48532. /**
  48533. * Import meshes into a scene.
  48534. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48535. * @param scene The scene to import into
  48536. * @param data The data to import
  48537. * @param rootUrl The root url for scene and resources
  48538. * @param meshes The meshes array to import into
  48539. * @param particleSystems The particle systems array to import into
  48540. * @param skeletons The skeletons array to import into
  48541. * @param onError The callback when import fails
  48542. * @returns True if successful or false otherwise
  48543. */
  48544. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48545. /**
  48546. * Load into a scene.
  48547. * @param scene The scene to load into
  48548. * @param data The data to import
  48549. * @param rootUrl The root url for scene and resources
  48550. * @param onError The callback when import fails
  48551. * @returns True if successful or false otherwise
  48552. */
  48553. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48554. /**
  48555. * Load into an asset container.
  48556. * @param scene The scene to load into
  48557. * @param data The data to import
  48558. * @param rootUrl The root url for scene and resources
  48559. * @param onError The callback when import fails
  48560. * @returns The loaded asset container
  48561. */
  48562. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48563. }
  48564. /**
  48565. * Interface used to define an async SceneLoader plugin
  48566. */
  48567. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48568. /**
  48569. * Import meshes into a scene.
  48570. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48571. * @param scene The scene to import into
  48572. * @param data The data to import
  48573. * @param rootUrl The root url for scene and resources
  48574. * @param onProgress The callback when the load progresses
  48575. * @param fileName Defines the name of the file to load
  48576. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48577. */
  48578. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48579. meshes: AbstractMesh[];
  48580. particleSystems: IParticleSystem[];
  48581. skeletons: Skeleton[];
  48582. animationGroups: AnimationGroup[];
  48583. }>;
  48584. /**
  48585. * Load into a scene.
  48586. * @param scene The scene to load into
  48587. * @param data The data to import
  48588. * @param rootUrl The root url for scene and resources
  48589. * @param onProgress The callback when the load progresses
  48590. * @param fileName Defines the name of the file to load
  48591. * @returns Nothing
  48592. */
  48593. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48594. /**
  48595. * Load into an asset container.
  48596. * @param scene The scene to load into
  48597. * @param data The data to import
  48598. * @param rootUrl The root url for scene and resources
  48599. * @param onProgress The callback when the load progresses
  48600. * @param fileName Defines the name of the file to load
  48601. * @returns The loaded asset container
  48602. */
  48603. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48604. }
  48605. /**
  48606. * Mode that determines how to handle old animation groups before loading new ones.
  48607. */
  48608. export enum SceneLoaderAnimationGroupLoadingMode {
  48609. /**
  48610. * Reset all old animations to initial state then dispose them.
  48611. */
  48612. Clean = 0,
  48613. /**
  48614. * Stop all old animations.
  48615. */
  48616. Stop = 1,
  48617. /**
  48618. * Restart old animations from first frame.
  48619. */
  48620. Sync = 2,
  48621. /**
  48622. * Old animations remains untouched.
  48623. */
  48624. NoSync = 3
  48625. }
  48626. /**
  48627. * Class used to load scene from various file formats using registered plugins
  48628. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48629. */
  48630. export class SceneLoader {
  48631. /**
  48632. * No logging while loading
  48633. */
  48634. static readonly NO_LOGGING: number;
  48635. /**
  48636. * Minimal logging while loading
  48637. */
  48638. static readonly MINIMAL_LOGGING: number;
  48639. /**
  48640. * Summary logging while loading
  48641. */
  48642. static readonly SUMMARY_LOGGING: number;
  48643. /**
  48644. * Detailled logging while loading
  48645. */
  48646. static readonly DETAILED_LOGGING: number;
  48647. /**
  48648. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48649. */
  48650. static get ForceFullSceneLoadingForIncremental(): boolean;
  48651. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48652. /**
  48653. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48654. */
  48655. static get ShowLoadingScreen(): boolean;
  48656. static set ShowLoadingScreen(value: boolean);
  48657. /**
  48658. * Defines the current logging level (while loading the scene)
  48659. * @ignorenaming
  48660. */
  48661. static get loggingLevel(): number;
  48662. static set loggingLevel(value: number);
  48663. /**
  48664. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48665. */
  48666. static get CleanBoneMatrixWeights(): boolean;
  48667. static set CleanBoneMatrixWeights(value: boolean);
  48668. /**
  48669. * Event raised when a plugin is used to load a scene
  48670. */
  48671. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48672. private static _registeredPlugins;
  48673. private static _getDefaultPlugin;
  48674. private static _getPluginForExtension;
  48675. private static _getPluginForDirectLoad;
  48676. private static _getPluginForFilename;
  48677. private static _getDirectLoad;
  48678. private static _loadData;
  48679. private static _getFileInfo;
  48680. /**
  48681. * Gets a plugin that can load the given extension
  48682. * @param extension defines the extension to load
  48683. * @returns a plugin or null if none works
  48684. */
  48685. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48686. /**
  48687. * Gets a boolean indicating that the given extension can be loaded
  48688. * @param extension defines the extension to load
  48689. * @returns true if the extension is supported
  48690. */
  48691. static IsPluginForExtensionAvailable(extension: string): boolean;
  48692. /**
  48693. * Adds a new plugin to the list of registered plugins
  48694. * @param plugin defines the plugin to add
  48695. */
  48696. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48697. /**
  48698. * Import meshes into a scene
  48699. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48700. * @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)
  48701. * @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)
  48702. * @param scene the instance of BABYLON.Scene to append to
  48703. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48704. * @param onProgress a callback with a progress event for each file being loaded
  48705. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48706. * @param pluginExtension the extension used to determine the plugin
  48707. * @returns The loaded plugin
  48708. */
  48709. 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>;
  48710. /**
  48711. * Import meshes into a scene
  48712. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48713. * @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)
  48714. * @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)
  48715. * @param scene the instance of BABYLON.Scene to append to
  48716. * @param onProgress a callback with a progress event for each file being loaded
  48717. * @param pluginExtension the extension used to determine the plugin
  48718. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48719. */
  48720. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48721. meshes: AbstractMesh[];
  48722. particleSystems: IParticleSystem[];
  48723. skeletons: Skeleton[];
  48724. animationGroups: AnimationGroup[];
  48725. }>;
  48726. /**
  48727. * Load a scene
  48728. * @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)
  48729. * @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)
  48730. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48731. * @param onSuccess a callback with the scene when import succeeds
  48732. * @param onProgress a callback with a progress event for each file being loaded
  48733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48734. * @param pluginExtension the extension used to determine the plugin
  48735. * @returns The loaded plugin
  48736. */
  48737. 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>;
  48738. /**
  48739. * Load a scene
  48740. * @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)
  48741. * @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)
  48742. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48743. * @param onProgress a callback with a progress event for each file being loaded
  48744. * @param pluginExtension the extension used to determine the plugin
  48745. * @returns The loaded scene
  48746. */
  48747. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48748. /**
  48749. * Append a scene
  48750. * @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)
  48751. * @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)
  48752. * @param scene is the instance of BABYLON.Scene to append to
  48753. * @param onSuccess a callback with the scene when import succeeds
  48754. * @param onProgress a callback with a progress event for each file being loaded
  48755. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48756. * @param pluginExtension the extension used to determine the plugin
  48757. * @returns The loaded plugin
  48758. */
  48759. 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>;
  48760. /**
  48761. * Append a scene
  48762. * @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)
  48763. * @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)
  48764. * @param scene is the instance of BABYLON.Scene to append to
  48765. * @param onProgress a callback with a progress event for each file being loaded
  48766. * @param pluginExtension the extension used to determine the plugin
  48767. * @returns The given scene
  48768. */
  48769. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48770. /**
  48771. * Load a scene into an asset container
  48772. * @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)
  48773. * @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)
  48774. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48775. * @param onSuccess a callback with the scene when import succeeds
  48776. * @param onProgress a callback with a progress event for each file being loaded
  48777. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48778. * @param pluginExtension the extension used to determine the plugin
  48779. * @returns The loaded plugin
  48780. */
  48781. 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>;
  48782. /**
  48783. * Load a scene into an asset container
  48784. * @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)
  48785. * @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)
  48786. * @param scene is the instance of Scene to append to
  48787. * @param onProgress a callback with a progress event for each file being loaded
  48788. * @param pluginExtension the extension used to determine the plugin
  48789. * @returns The loaded asset container
  48790. */
  48791. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48792. /**
  48793. * Import animations from a file into a scene
  48794. * @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)
  48795. * @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)
  48796. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48797. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48798. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48799. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48800. * @param onSuccess a callback with the scene when import succeeds
  48801. * @param onProgress a callback with a progress event for each file being loaded
  48802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48803. * @param pluginExtension the extension used to determine the plugin
  48804. */
  48805. 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;
  48806. /**
  48807. * Import animations from a file into a scene
  48808. * @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)
  48809. * @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)
  48810. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48811. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48812. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48813. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48814. * @param onSuccess a callback with the scene when import succeeds
  48815. * @param onProgress a callback with a progress event for each file being loaded
  48816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48817. * @param pluginExtension the extension used to determine the plugin
  48818. * @returns the updated scene with imported animations
  48819. */
  48820. 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>;
  48821. }
  48822. }
  48823. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48824. import { IDisposable, Scene } from "babylonjs/scene";
  48825. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48826. import { Observable } from "babylonjs/Misc/observable";
  48827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48828. import { Nullable } from "babylonjs/types";
  48829. /**
  48830. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48831. */
  48832. export type MotionControllerHandedness = "none" | "left" | "right";
  48833. /**
  48834. * The type of components available in motion controllers.
  48835. * This is not the name of the component.
  48836. */
  48837. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48838. /**
  48839. * The state of a controller component
  48840. */
  48841. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48842. /**
  48843. * The schema of motion controller layout.
  48844. * No object will be initialized using this interface
  48845. * This is used just to define the profile.
  48846. */
  48847. export interface IMotionControllerLayout {
  48848. /**
  48849. * Path to load the assets. Usually relative to the base path
  48850. */
  48851. assetPath: string;
  48852. /**
  48853. * Available components (unsorted)
  48854. */
  48855. components: {
  48856. /**
  48857. * A map of component Ids
  48858. */
  48859. [componentId: string]: {
  48860. /**
  48861. * The type of input the component outputs
  48862. */
  48863. type: MotionControllerComponentType;
  48864. /**
  48865. * The indices of this component in the gamepad object
  48866. */
  48867. gamepadIndices: {
  48868. /**
  48869. * Index of button
  48870. */
  48871. button?: number;
  48872. /**
  48873. * If available, index of x-axis
  48874. */
  48875. xAxis?: number;
  48876. /**
  48877. * If available, index of y-axis
  48878. */
  48879. yAxis?: number;
  48880. };
  48881. /**
  48882. * The mesh's root node name
  48883. */
  48884. rootNodeName: string;
  48885. /**
  48886. * Animation definitions for this model
  48887. */
  48888. visualResponses: {
  48889. [stateKey: string]: {
  48890. /**
  48891. * What property will be animated
  48892. */
  48893. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48894. /**
  48895. * What states influence this visual response
  48896. */
  48897. states: MotionControllerComponentStateType[];
  48898. /**
  48899. * Type of animation - movement or visibility
  48900. */
  48901. valueNodeProperty: "transform" | "visibility";
  48902. /**
  48903. * Base node name to move. Its position will be calculated according to the min and max nodes
  48904. */
  48905. valueNodeName?: string;
  48906. /**
  48907. * Minimum movement node
  48908. */
  48909. minNodeName?: string;
  48910. /**
  48911. * Max movement node
  48912. */
  48913. maxNodeName?: string;
  48914. };
  48915. };
  48916. /**
  48917. * If touch enabled, what is the name of node to display user feedback
  48918. */
  48919. touchPointNodeName?: string;
  48920. };
  48921. };
  48922. /**
  48923. * Is it xr standard mapping or not
  48924. */
  48925. gamepadMapping: "" | "xr-standard";
  48926. /**
  48927. * Base root node of this entire model
  48928. */
  48929. rootNodeName: string;
  48930. /**
  48931. * Defines the main button component id
  48932. */
  48933. selectComponentId: string;
  48934. }
  48935. /**
  48936. * A definition for the layout map in the input profile
  48937. */
  48938. export interface IMotionControllerLayoutMap {
  48939. /**
  48940. * Layouts with handedness type as a key
  48941. */
  48942. [handedness: string]: IMotionControllerLayout;
  48943. }
  48944. /**
  48945. * The XR Input profile schema
  48946. * Profiles can be found here:
  48947. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48948. */
  48949. export interface IMotionControllerProfile {
  48950. /**
  48951. * fallback profiles for this profileId
  48952. */
  48953. fallbackProfileIds: string[];
  48954. /**
  48955. * The layout map, with handedness as key
  48956. */
  48957. layouts: IMotionControllerLayoutMap;
  48958. /**
  48959. * The id of this profile
  48960. * correlates to the profile(s) in the xrInput.profiles array
  48961. */
  48962. profileId: string;
  48963. }
  48964. /**
  48965. * A helper-interface for the 3 meshes needed for controller button animation
  48966. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48967. */
  48968. export interface IMotionControllerButtonMeshMap {
  48969. /**
  48970. * the mesh that defines the pressed value mesh position.
  48971. * This is used to find the max-position of this button
  48972. */
  48973. pressedMesh: AbstractMesh;
  48974. /**
  48975. * the mesh that defines the unpressed value mesh position.
  48976. * This is used to find the min (or initial) position of this button
  48977. */
  48978. unpressedMesh: AbstractMesh;
  48979. /**
  48980. * The mesh that will be changed when value changes
  48981. */
  48982. valueMesh: AbstractMesh;
  48983. }
  48984. /**
  48985. * A helper-interface for the 3 meshes needed for controller axis animation.
  48986. * This will be expanded when touchpad animations are fully supported
  48987. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48988. */
  48989. export interface IMotionControllerMeshMap {
  48990. /**
  48991. * the mesh that defines the maximum value mesh position.
  48992. */
  48993. maxMesh?: AbstractMesh;
  48994. /**
  48995. * the mesh that defines the minimum value mesh position.
  48996. */
  48997. minMesh?: AbstractMesh;
  48998. /**
  48999. * The mesh that will be changed when axis value changes
  49000. */
  49001. valueMesh: AbstractMesh;
  49002. }
  49003. /**
  49004. * The elements needed for change-detection of the gamepad objects in motion controllers
  49005. */
  49006. export interface IMinimalMotionControllerObject {
  49007. /**
  49008. * Available axes of this controller
  49009. */
  49010. axes: number[];
  49011. /**
  49012. * An array of available buttons
  49013. */
  49014. buttons: Array<{
  49015. /**
  49016. * Value of the button/trigger
  49017. */
  49018. value: number;
  49019. /**
  49020. * If the button/trigger is currently touched
  49021. */
  49022. touched: boolean;
  49023. /**
  49024. * If the button/trigger is currently pressed
  49025. */
  49026. pressed: boolean;
  49027. }>;
  49028. /**
  49029. * EXPERIMENTAL haptic support.
  49030. */
  49031. hapticActuators?: Array<{
  49032. pulse: (value: number, duration: number) => Promise<boolean>;
  49033. }>;
  49034. }
  49035. /**
  49036. * An Abstract Motion controller
  49037. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49038. * Each component has an observable to check for changes in value and state
  49039. */
  49040. export abstract class WebXRAbstractMotionController implements IDisposable {
  49041. protected scene: Scene;
  49042. protected layout: IMotionControllerLayout;
  49043. /**
  49044. * The gamepad object correlating to this controller
  49045. */
  49046. gamepadObject: IMinimalMotionControllerObject;
  49047. /**
  49048. * handedness (left/right/none) of this controller
  49049. */
  49050. handedness: MotionControllerHandedness;
  49051. private _initComponent;
  49052. private _modelReady;
  49053. /**
  49054. * A map of components (WebXRControllerComponent) in this motion controller
  49055. * Components have a ComponentType and can also have both button and axis definitions
  49056. */
  49057. readonly components: {
  49058. [id: string]: WebXRControllerComponent;
  49059. };
  49060. /**
  49061. * Disable the model's animation. Can be set at any time.
  49062. */
  49063. disableAnimation: boolean;
  49064. /**
  49065. * Observers registered here will be triggered when the model of this controller is done loading
  49066. */
  49067. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49068. /**
  49069. * The profile id of this motion controller
  49070. */
  49071. abstract profileId: string;
  49072. /**
  49073. * The root mesh of the model. It is null if the model was not yet initialized
  49074. */
  49075. rootMesh: Nullable<AbstractMesh>;
  49076. /**
  49077. * constructs a new abstract motion controller
  49078. * @param scene the scene to which the model of the controller will be added
  49079. * @param layout The profile layout to load
  49080. * @param gamepadObject The gamepad object correlating to this controller
  49081. * @param handedness handedness (left/right/none) of this controller
  49082. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49083. */
  49084. constructor(scene: Scene, layout: IMotionControllerLayout,
  49085. /**
  49086. * The gamepad object correlating to this controller
  49087. */
  49088. gamepadObject: IMinimalMotionControllerObject,
  49089. /**
  49090. * handedness (left/right/none) of this controller
  49091. */
  49092. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49093. /**
  49094. * Dispose this controller, the model mesh and all its components
  49095. */
  49096. dispose(): void;
  49097. /**
  49098. * Returns all components of specific type
  49099. * @param type the type to search for
  49100. * @return an array of components with this type
  49101. */
  49102. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49103. /**
  49104. * get a component based an its component id as defined in layout.components
  49105. * @param id the id of the component
  49106. * @returns the component correlates to the id or undefined if not found
  49107. */
  49108. getComponent(id: string): WebXRControllerComponent;
  49109. /**
  49110. * Get the list of components available in this motion controller
  49111. * @returns an array of strings correlating to available components
  49112. */
  49113. getComponentIds(): string[];
  49114. /**
  49115. * Get the first component of specific type
  49116. * @param type type of component to find
  49117. * @return a controller component or null if not found
  49118. */
  49119. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49120. /**
  49121. * Get the main (Select) component of this controller as defined in the layout
  49122. * @returns the main component of this controller
  49123. */
  49124. getMainComponent(): WebXRControllerComponent;
  49125. /**
  49126. * Loads the model correlating to this controller
  49127. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49128. * @returns A promise fulfilled with the result of the model loading
  49129. */
  49130. loadModel(): Promise<boolean>;
  49131. /**
  49132. * Update this model using the current XRFrame
  49133. * @param xrFrame the current xr frame to use and update the model
  49134. */
  49135. updateFromXRFrame(xrFrame: XRFrame): void;
  49136. /**
  49137. * Backwards compatibility due to a deeply-integrated typo
  49138. */
  49139. get handness(): XREye;
  49140. /**
  49141. * Pulse (vibrate) this controller
  49142. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49143. * Consecutive calls to this function will cancel the last pulse call
  49144. *
  49145. * @param value the strength of the pulse in 0.0...1.0 range
  49146. * @param duration Duration of the pulse in milliseconds
  49147. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49148. * @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
  49149. */
  49150. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49151. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49152. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49153. /**
  49154. * Moves the axis on the controller mesh based on its current state
  49155. * @param axis the index of the axis
  49156. * @param axisValue the value of the axis which determines the meshes new position
  49157. * @hidden
  49158. */
  49159. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49160. /**
  49161. * Update the model itself with the current frame data
  49162. * @param xrFrame the frame to use for updating the model mesh
  49163. */
  49164. protected updateModel(xrFrame: XRFrame): void;
  49165. /**
  49166. * Get the filename and path for this controller's model
  49167. * @returns a map of filename and path
  49168. */
  49169. protected abstract _getFilenameAndPath(): {
  49170. filename: string;
  49171. path: string;
  49172. };
  49173. /**
  49174. * This function is called before the mesh is loaded. It checks for loading constraints.
  49175. * For example, this function can check if the GLB loader is available
  49176. * If this function returns false, the generic controller will be loaded instead
  49177. * @returns Is the client ready to load the mesh
  49178. */
  49179. protected abstract _getModelLoadingConstraints(): boolean;
  49180. /**
  49181. * This function will be called after the model was successfully loaded and can be used
  49182. * for mesh transformations before it is available for the user
  49183. * @param meshes the loaded meshes
  49184. */
  49185. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49186. /**
  49187. * Set the root mesh for this controller. Important for the WebXR controller class
  49188. * @param meshes the loaded meshes
  49189. */
  49190. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49191. /**
  49192. * A function executed each frame that updates the mesh (if needed)
  49193. * @param xrFrame the current xrFrame
  49194. */
  49195. protected abstract _updateModel(xrFrame: XRFrame): void;
  49196. private _getGenericFilenameAndPath;
  49197. private _getGenericParentMesh;
  49198. }
  49199. }
  49200. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49201. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49203. import { Scene } from "babylonjs/scene";
  49204. /**
  49205. * A generic trigger-only motion controller for WebXR
  49206. */
  49207. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49208. /**
  49209. * Static version of the profile id of this controller
  49210. */
  49211. static ProfileId: string;
  49212. profileId: string;
  49213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49214. protected _getFilenameAndPath(): {
  49215. filename: string;
  49216. path: string;
  49217. };
  49218. protected _getModelLoadingConstraints(): boolean;
  49219. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49221. protected _updateModel(): void;
  49222. }
  49223. }
  49224. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49225. import { Vector4 } from "babylonjs/Maths/math.vector";
  49226. import { Mesh } from "babylonjs/Meshes/mesh";
  49227. import { Scene } from "babylonjs/scene";
  49228. import { Nullable } from "babylonjs/types";
  49229. /**
  49230. * Class containing static functions to help procedurally build meshes
  49231. */
  49232. export class SphereBuilder {
  49233. /**
  49234. * Creates a sphere mesh
  49235. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49236. * * 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`)
  49237. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49238. * * 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
  49239. * * 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)
  49240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49243. * @param name defines the name of the mesh
  49244. * @param options defines the options used to create the mesh
  49245. * @param scene defines the hosting scene
  49246. * @returns the sphere mesh
  49247. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49248. */
  49249. static CreateSphere(name: string, options: {
  49250. segments?: number;
  49251. diameter?: number;
  49252. diameterX?: number;
  49253. diameterY?: number;
  49254. diameterZ?: number;
  49255. arc?: number;
  49256. slice?: number;
  49257. sideOrientation?: number;
  49258. frontUVs?: Vector4;
  49259. backUVs?: Vector4;
  49260. updatable?: boolean;
  49261. }, scene?: Nullable<Scene>): Mesh;
  49262. }
  49263. }
  49264. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49266. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49267. import { Scene } from "babylonjs/scene";
  49268. /**
  49269. * A profiled motion controller has its profile loaded from an online repository.
  49270. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49271. */
  49272. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49273. private _repositoryUrl;
  49274. private _buttonMeshMapping;
  49275. private _touchDots;
  49276. /**
  49277. * The profile ID of this controller. Will be populated when the controller initializes.
  49278. */
  49279. profileId: string;
  49280. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49281. dispose(): void;
  49282. protected _getFilenameAndPath(): {
  49283. filename: string;
  49284. path: string;
  49285. };
  49286. protected _getModelLoadingConstraints(): boolean;
  49287. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49288. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49289. protected _updateModel(_xrFrame: XRFrame): void;
  49290. }
  49291. }
  49292. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49293. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49294. import { Scene } from "babylonjs/scene";
  49295. /**
  49296. * A construction function type to create a new controller based on an xrInput object
  49297. */
  49298. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49299. /**
  49300. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49301. *
  49302. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49303. * it should be replaced with auto-loaded controllers.
  49304. *
  49305. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49306. */
  49307. export class WebXRMotionControllerManager {
  49308. private static _AvailableControllers;
  49309. private static _Fallbacks;
  49310. private static _ProfileLoadingPromises;
  49311. private static _ProfilesList;
  49312. /**
  49313. * The base URL of the online controller repository. Can be changed at any time.
  49314. */
  49315. static BaseRepositoryUrl: string;
  49316. /**
  49317. * Which repository gets priority - local or online
  49318. */
  49319. static PrioritizeOnlineRepository: boolean;
  49320. /**
  49321. * Use the online repository, or use only locally-defined controllers
  49322. */
  49323. static UseOnlineRepository: boolean;
  49324. /**
  49325. * Clear the cache used for profile loading and reload when requested again
  49326. */
  49327. static ClearProfilesCache(): void;
  49328. /**
  49329. * Register the default fallbacks.
  49330. * This function is called automatically when this file is imported.
  49331. */
  49332. static DefaultFallbacks(): void;
  49333. /**
  49334. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49335. * @param profileId the profile to which a fallback needs to be found
  49336. * @return an array with corresponding fallback profiles
  49337. */
  49338. static FindFallbackWithProfileId(profileId: string): string[];
  49339. /**
  49340. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49341. * The order of search:
  49342. *
  49343. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49344. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49345. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49346. * 4) return the generic trigger controller if none were found
  49347. *
  49348. * @param xrInput the xrInput to which a new controller is initialized
  49349. * @param scene the scene to which the model will be added
  49350. * @param forceProfile force a certain profile for this controller
  49351. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49352. */
  49353. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49354. /**
  49355. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49356. *
  49357. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49358. *
  49359. * @param type the profile type to register
  49360. * @param constructFunction the function to be called when loading this profile
  49361. */
  49362. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49363. /**
  49364. * Register a fallback to a specific profile.
  49365. * @param profileId the profileId that will receive the fallbacks
  49366. * @param fallbacks A list of fallback profiles
  49367. */
  49368. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49369. /**
  49370. * Will update the list of profiles available in the repository
  49371. * @return a promise that resolves to a map of profiles available online
  49372. */
  49373. static UpdateProfilesList(): Promise<{
  49374. [profile: string]: string;
  49375. }>;
  49376. private static _LoadProfileFromRepository;
  49377. private static _LoadProfilesFromAvailableControllers;
  49378. }
  49379. }
  49380. declare module "babylonjs/XR/webXRInputSource" {
  49381. import { Observable } from "babylonjs/Misc/observable";
  49382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49383. import { Ray } from "babylonjs/Culling/ray";
  49384. import { Scene } from "babylonjs/scene";
  49385. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49386. /**
  49387. * Configuration options for the WebXR controller creation
  49388. */
  49389. export interface IWebXRControllerOptions {
  49390. /**
  49391. * Should the controller mesh be animated when a user interacts with it
  49392. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49393. */
  49394. disableMotionControllerAnimation?: boolean;
  49395. /**
  49396. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49397. */
  49398. doNotLoadControllerMesh?: boolean;
  49399. /**
  49400. * Force a specific controller type for this controller.
  49401. * This can be used when creating your own profile or when testing different controllers
  49402. */
  49403. forceControllerProfile?: string;
  49404. /**
  49405. * Defines a rendering group ID for meshes that will be loaded.
  49406. * This is for the default controllers only.
  49407. */
  49408. renderingGroupId?: number;
  49409. }
  49410. /**
  49411. * Represents an XR controller
  49412. */
  49413. export class WebXRInputSource {
  49414. private _scene;
  49415. /** The underlying input source for the controller */
  49416. inputSource: XRInputSource;
  49417. private _options;
  49418. private _tmpVector;
  49419. private _uniqueId;
  49420. /**
  49421. * 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
  49422. */
  49423. grip?: AbstractMesh;
  49424. /**
  49425. * If available, this is the gamepad object related to this controller.
  49426. * Using this object it is possible to get click events and trackpad changes of the
  49427. * webxr controller that is currently being used.
  49428. */
  49429. motionController?: WebXRAbstractMotionController;
  49430. /**
  49431. * Event that fires when the controller is removed/disposed.
  49432. * The object provided as event data is this controller, after associated assets were disposed.
  49433. * uniqueId is still available.
  49434. */
  49435. onDisposeObservable: Observable<WebXRInputSource>;
  49436. /**
  49437. * Will be triggered when the mesh associated with the motion controller is done loading.
  49438. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49439. * A shortened version of controller -> motion controller -> on mesh loaded.
  49440. */
  49441. onMeshLoadedObservable: Observable<AbstractMesh>;
  49442. /**
  49443. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49444. */
  49445. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49446. /**
  49447. * Pointer which can be used to select objects or attach a visible laser to
  49448. */
  49449. pointer: AbstractMesh;
  49450. /**
  49451. * Creates the input source object
  49452. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49453. * @param _scene the scene which the controller should be associated to
  49454. * @param inputSource the underlying input source for the controller
  49455. * @param _options options for this controller creation
  49456. */
  49457. constructor(_scene: Scene,
  49458. /** The underlying input source for the controller */
  49459. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49460. /**
  49461. * Get this controllers unique id
  49462. */
  49463. get uniqueId(): string;
  49464. /**
  49465. * Disposes of the object
  49466. */
  49467. dispose(): void;
  49468. /**
  49469. * Gets a world space ray coming from the pointer or grip
  49470. * @param result the resulting ray
  49471. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49472. */
  49473. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49474. /**
  49475. * Updates the controller pose based on the given XRFrame
  49476. * @param xrFrame xr frame to update the pose with
  49477. * @param referenceSpace reference space to use
  49478. */
  49479. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49480. }
  49481. }
  49482. declare module "babylonjs/XR/webXRInput" {
  49483. import { Observable } from "babylonjs/Misc/observable";
  49484. import { IDisposable } from "babylonjs/scene";
  49485. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49486. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49487. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49488. /**
  49489. * The schema for initialization options of the XR Input class
  49490. */
  49491. export interface IWebXRInputOptions {
  49492. /**
  49493. * If set to true no model will be automatically loaded
  49494. */
  49495. doNotLoadControllerMeshes?: boolean;
  49496. /**
  49497. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49498. * If not found, the xr input profile data will be used.
  49499. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49500. */
  49501. forceInputProfile?: string;
  49502. /**
  49503. * Do not send a request to the controller repository to load the profile.
  49504. *
  49505. * Instead, use the controllers available in babylon itself.
  49506. */
  49507. disableOnlineControllerRepository?: boolean;
  49508. /**
  49509. * A custom URL for the controllers repository
  49510. */
  49511. customControllersRepositoryURL?: string;
  49512. /**
  49513. * Should the controller model's components not move according to the user input
  49514. */
  49515. disableControllerAnimation?: boolean;
  49516. /**
  49517. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49518. */
  49519. controllerOptions?: IWebXRControllerOptions;
  49520. }
  49521. /**
  49522. * XR input used to track XR inputs such as controllers/rays
  49523. */
  49524. export class WebXRInput implements IDisposable {
  49525. /**
  49526. * the xr session manager for this session
  49527. */
  49528. xrSessionManager: WebXRSessionManager;
  49529. /**
  49530. * the WebXR camera for this session. Mainly used for teleportation
  49531. */
  49532. xrCamera: WebXRCamera;
  49533. private readonly options;
  49534. /**
  49535. * XR controllers being tracked
  49536. */
  49537. controllers: Array<WebXRInputSource>;
  49538. private _frameObserver;
  49539. private _sessionEndedObserver;
  49540. private _sessionInitObserver;
  49541. /**
  49542. * Event when a controller has been connected/added
  49543. */
  49544. onControllerAddedObservable: Observable<WebXRInputSource>;
  49545. /**
  49546. * Event when a controller has been removed/disconnected
  49547. */
  49548. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49549. /**
  49550. * Initializes the WebXRInput
  49551. * @param xrSessionManager the xr session manager for this session
  49552. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49553. * @param options = initialization options for this xr input
  49554. */
  49555. constructor(
  49556. /**
  49557. * the xr session manager for this session
  49558. */
  49559. xrSessionManager: WebXRSessionManager,
  49560. /**
  49561. * the WebXR camera for this session. Mainly used for teleportation
  49562. */
  49563. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49564. private _onInputSourcesChange;
  49565. private _addAndRemoveControllers;
  49566. /**
  49567. * Disposes of the object
  49568. */
  49569. dispose(): void;
  49570. }
  49571. }
  49572. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49573. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49574. import { Observable, EventState } from "babylonjs/Misc/observable";
  49575. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49576. /**
  49577. * This is the base class for all WebXR features.
  49578. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49579. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49580. */
  49581. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49582. protected _xrSessionManager: WebXRSessionManager;
  49583. private _attached;
  49584. private _removeOnDetach;
  49585. /**
  49586. * Should auto-attach be disabled?
  49587. */
  49588. disableAutoAttach: boolean;
  49589. /**
  49590. * Construct a new (abstract) WebXR feature
  49591. * @param _xrSessionManager the xr session manager for this feature
  49592. */
  49593. constructor(_xrSessionManager: WebXRSessionManager);
  49594. /**
  49595. * Is this feature attached
  49596. */
  49597. get attached(): boolean;
  49598. /**
  49599. * attach this feature
  49600. *
  49601. * @param force should attachment be forced (even when already attached)
  49602. * @returns true if successful, false is failed or already attached
  49603. */
  49604. attach(force?: boolean): boolean;
  49605. /**
  49606. * detach this feature.
  49607. *
  49608. * @returns true if successful, false if failed or already detached
  49609. */
  49610. detach(): boolean;
  49611. /**
  49612. * Dispose this feature and all of the resources attached
  49613. */
  49614. dispose(): void;
  49615. /**
  49616. * This is used to register callbacks that will automatically be removed when detach is called.
  49617. * @param observable the observable to which the observer will be attached
  49618. * @param callback the callback to register
  49619. */
  49620. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49621. /**
  49622. * Code in this function will be executed on each xrFrame received from the browser.
  49623. * This function will not execute after the feature is detached.
  49624. * @param _xrFrame the current frame
  49625. */
  49626. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49627. }
  49628. }
  49629. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49630. import { IDisposable, Scene } from "babylonjs/scene";
  49631. import { Nullable } from "babylonjs/types";
  49632. import { Observable } from "babylonjs/Misc/observable";
  49633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49634. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49635. import { Camera } from "babylonjs/Cameras/camera";
  49636. /**
  49637. * Renders a layer on top of an existing scene
  49638. */
  49639. export class UtilityLayerRenderer implements IDisposable {
  49640. /** the original scene that will be rendered on top of */
  49641. originalScene: Scene;
  49642. private _pointerCaptures;
  49643. private _lastPointerEvents;
  49644. private static _DefaultUtilityLayer;
  49645. private static _DefaultKeepDepthUtilityLayer;
  49646. private _sharedGizmoLight;
  49647. private _renderCamera;
  49648. /**
  49649. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49650. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49651. * @returns the camera that is used when rendering the utility layer
  49652. */
  49653. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49654. /**
  49655. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49656. * @param cam the camera that should be used when rendering the utility layer
  49657. */
  49658. setRenderCamera(cam: Nullable<Camera>): void;
  49659. /**
  49660. * @hidden
  49661. * Light which used by gizmos to get light shading
  49662. */
  49663. _getSharedGizmoLight(): HemisphericLight;
  49664. /**
  49665. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49666. */
  49667. pickUtilitySceneFirst: boolean;
  49668. /**
  49669. * 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)
  49670. */
  49671. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49672. /**
  49673. * 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)
  49674. */
  49675. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49676. /**
  49677. * The scene that is rendered on top of the original scene
  49678. */
  49679. utilityLayerScene: Scene;
  49680. /**
  49681. * If the utility layer should automatically be rendered on top of existing scene
  49682. */
  49683. shouldRender: boolean;
  49684. /**
  49685. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49686. */
  49687. onlyCheckPointerDownEvents: boolean;
  49688. /**
  49689. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49690. */
  49691. processAllEvents: boolean;
  49692. /**
  49693. * Observable raised when the pointer move from the utility layer scene to the main scene
  49694. */
  49695. onPointerOutObservable: Observable<number>;
  49696. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49697. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49698. private _afterRenderObserver;
  49699. private _sceneDisposeObserver;
  49700. private _originalPointerObserver;
  49701. /**
  49702. * Instantiates a UtilityLayerRenderer
  49703. * @param originalScene the original scene that will be rendered on top of
  49704. * @param handleEvents boolean indicating if the utility layer should handle events
  49705. */
  49706. constructor(
  49707. /** the original scene that will be rendered on top of */
  49708. originalScene: Scene, handleEvents?: boolean);
  49709. private _notifyObservers;
  49710. /**
  49711. * Renders the utility layers scene on top of the original scene
  49712. */
  49713. render(): void;
  49714. /**
  49715. * Disposes of the renderer
  49716. */
  49717. dispose(): void;
  49718. private _updateCamera;
  49719. }
  49720. }
  49721. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49722. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49724. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49725. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49726. import { Scene } from "babylonjs/scene";
  49727. import { Nullable } from "babylonjs/types";
  49728. import { Color3 } from "babylonjs/Maths/math.color";
  49729. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49730. /**
  49731. * Options interface for the pointer selection module
  49732. */
  49733. export interface IWebXRControllerPointerSelectionOptions {
  49734. /**
  49735. * if provided, this scene will be used to render meshes.
  49736. */
  49737. customUtilityLayerScene?: Scene;
  49738. /**
  49739. * 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)
  49740. * If not disabled, the last picked point will be used to execute a pointer up event
  49741. * If disabled, pointer up event will be triggered right after the pointer down event.
  49742. * Used in screen and gaze target ray mode only
  49743. */
  49744. disablePointerUpOnTouchOut: boolean;
  49745. /**
  49746. * For gaze mode (time to select instead of press)
  49747. */
  49748. forceGazeMode: boolean;
  49749. /**
  49750. * 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
  49751. * to start a new countdown to the pointer down event.
  49752. * Defaults to 1.
  49753. */
  49754. gazeModePointerMovedFactor?: number;
  49755. /**
  49756. * Different button type to use instead of the main component
  49757. */
  49758. overrideButtonId?: string;
  49759. /**
  49760. * use this rendering group id for the meshes (optional)
  49761. */
  49762. renderingGroupId?: number;
  49763. /**
  49764. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49765. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49766. * 3000 means 3 seconds between pointing at something and selecting it
  49767. */
  49768. timeToSelect?: number;
  49769. /**
  49770. * Should meshes created here be added to a utility layer or the main scene
  49771. */
  49772. useUtilityLayer?: boolean;
  49773. /**
  49774. * the xr input to use with this pointer selection
  49775. */
  49776. xrInput: WebXRInput;
  49777. }
  49778. /**
  49779. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49780. */
  49781. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49782. private readonly _options;
  49783. private static _idCounter;
  49784. private _attachController;
  49785. private _controllers;
  49786. private _scene;
  49787. private _tmpVectorForPickCompare;
  49788. /**
  49789. * The module's name
  49790. */
  49791. static readonly Name: string;
  49792. /**
  49793. * The (Babylon) version of this module.
  49794. * This is an integer representing the implementation version.
  49795. * This number does not correspond to the WebXR specs version
  49796. */
  49797. static readonly Version: number;
  49798. /**
  49799. * Disable lighting on the laser pointer (so it will always be visible)
  49800. */
  49801. disablePointerLighting: boolean;
  49802. /**
  49803. * Disable lighting on the selection mesh (so it will always be visible)
  49804. */
  49805. disableSelectionMeshLighting: boolean;
  49806. /**
  49807. * Should the laser pointer be displayed
  49808. */
  49809. displayLaserPointer: boolean;
  49810. /**
  49811. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49812. */
  49813. displaySelectionMesh: boolean;
  49814. /**
  49815. * This color will be set to the laser pointer when selection is triggered
  49816. */
  49817. laserPointerPickedColor: Color3;
  49818. /**
  49819. * Default color of the laser pointer
  49820. */
  49821. laserPointerDefaultColor: Color3;
  49822. /**
  49823. * default color of the selection ring
  49824. */
  49825. selectionMeshDefaultColor: Color3;
  49826. /**
  49827. * This color will be applied to the selection ring when selection is triggered
  49828. */
  49829. selectionMeshPickedColor: Color3;
  49830. /**
  49831. * Optional filter to be used for ray selection. This predicate shares behavior with
  49832. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49833. */
  49834. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49835. /**
  49836. * constructs a new background remover module
  49837. * @param _xrSessionManager the session manager for this module
  49838. * @param _options read-only options to be used in this module
  49839. */
  49840. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49841. /**
  49842. * attach this feature
  49843. * Will usually be called by the features manager
  49844. *
  49845. * @returns true if successful.
  49846. */
  49847. attach(): boolean;
  49848. /**
  49849. * detach this feature.
  49850. * Will usually be called by the features manager
  49851. *
  49852. * @returns true if successful.
  49853. */
  49854. detach(): boolean;
  49855. /**
  49856. * Will get the mesh under a specific pointer.
  49857. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49858. * @param controllerId the controllerId to check
  49859. * @returns The mesh under pointer or null if no mesh is under the pointer
  49860. */
  49861. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49862. /**
  49863. * Get the xr controller that correlates to the pointer id in the pointer event
  49864. *
  49865. * @param id the pointer id to search for
  49866. * @returns the controller that correlates to this id or null if not found
  49867. */
  49868. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49869. protected _onXRFrame(_xrFrame: XRFrame): void;
  49870. private _attachGazeMode;
  49871. private _attachScreenRayMode;
  49872. private _attachTrackedPointerRayMode;
  49873. private _convertNormalToDirectionOfRay;
  49874. private _detachController;
  49875. private _generateNewMeshPair;
  49876. private _pickingMoved;
  49877. private _updatePointerDistance;
  49878. /** @hidden */
  49879. get lasterPointerDefaultColor(): Color3;
  49880. }
  49881. }
  49882. declare module "babylonjs/XR/webXREnterExitUI" {
  49883. import { Nullable } from "babylonjs/types";
  49884. import { Observable } from "babylonjs/Misc/observable";
  49885. import { IDisposable, Scene } from "babylonjs/scene";
  49886. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49887. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49888. /**
  49889. * Button which can be used to enter a different mode of XR
  49890. */
  49891. export class WebXREnterExitUIButton {
  49892. /** button element */
  49893. element: HTMLElement;
  49894. /** XR initialization options for the button */
  49895. sessionMode: XRSessionMode;
  49896. /** Reference space type */
  49897. referenceSpaceType: XRReferenceSpaceType;
  49898. /**
  49899. * Creates a WebXREnterExitUIButton
  49900. * @param element button element
  49901. * @param sessionMode XR initialization session mode
  49902. * @param referenceSpaceType the type of reference space to be used
  49903. */
  49904. constructor(
  49905. /** button element */
  49906. element: HTMLElement,
  49907. /** XR initialization options for the button */
  49908. sessionMode: XRSessionMode,
  49909. /** Reference space type */
  49910. referenceSpaceType: XRReferenceSpaceType);
  49911. /**
  49912. * Extendable function which can be used to update the button's visuals when the state changes
  49913. * @param activeButton the current active button in the UI
  49914. */
  49915. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49916. }
  49917. /**
  49918. * Options to create the webXR UI
  49919. */
  49920. export class WebXREnterExitUIOptions {
  49921. /**
  49922. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49923. */
  49924. customButtons?: Array<WebXREnterExitUIButton>;
  49925. /**
  49926. * A reference space type to use when creating the default button.
  49927. * Default is local-floor
  49928. */
  49929. referenceSpaceType?: XRReferenceSpaceType;
  49930. /**
  49931. * Context to enter xr with
  49932. */
  49933. renderTarget?: Nullable<WebXRRenderTarget>;
  49934. /**
  49935. * A session mode to use when creating the default button.
  49936. * Default is immersive-vr
  49937. */
  49938. sessionMode?: XRSessionMode;
  49939. /**
  49940. * A list of optional features to init the session with
  49941. */
  49942. optionalFeatures?: string[];
  49943. }
  49944. /**
  49945. * UI to allow the user to enter/exit XR mode
  49946. */
  49947. export class WebXREnterExitUI implements IDisposable {
  49948. private scene;
  49949. /** version of the options passed to this UI */
  49950. options: WebXREnterExitUIOptions;
  49951. private _activeButton;
  49952. private _buttons;
  49953. private _overlay;
  49954. /**
  49955. * Fired every time the active button is changed.
  49956. *
  49957. * When xr is entered via a button that launches xr that button will be the callback parameter
  49958. *
  49959. * When exiting xr the callback parameter will be null)
  49960. */
  49961. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49962. /**
  49963. *
  49964. * @param scene babylon scene object to use
  49965. * @param options (read-only) version of the options passed to this UI
  49966. */
  49967. private constructor();
  49968. /**
  49969. * Creates UI to allow the user to enter/exit XR mode
  49970. * @param scene the scene to add the ui to
  49971. * @param helper the xr experience helper to enter/exit xr with
  49972. * @param options options to configure the UI
  49973. * @returns the created ui
  49974. */
  49975. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49976. /**
  49977. * Disposes of the XR UI component
  49978. */
  49979. dispose(): void;
  49980. private _updateButtons;
  49981. }
  49982. }
  49983. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49984. import { Vector3 } from "babylonjs/Maths/math.vector";
  49985. import { Color4 } from "babylonjs/Maths/math.color";
  49986. import { Nullable } from "babylonjs/types";
  49987. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49988. import { Scene } from "babylonjs/scene";
  49989. /**
  49990. * Class containing static functions to help procedurally build meshes
  49991. */
  49992. export class LinesBuilder {
  49993. /**
  49994. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49995. * * 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
  49996. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49997. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49998. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49999. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50000. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50001. * * 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
  50002. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50005. * @param name defines the name of the new line system
  50006. * @param options defines the options used to create the line system
  50007. * @param scene defines the hosting scene
  50008. * @returns a new line system mesh
  50009. */
  50010. static CreateLineSystem(name: string, options: {
  50011. lines: Vector3[][];
  50012. updatable?: boolean;
  50013. instance?: Nullable<LinesMesh>;
  50014. colors?: Nullable<Color4[][]>;
  50015. useVertexAlpha?: boolean;
  50016. }, scene: Nullable<Scene>): LinesMesh;
  50017. /**
  50018. * Creates a line mesh
  50019. * 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
  50020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50021. * * The parameter `points` is an array successive Vector3
  50022. * * 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
  50023. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50025. * * When updating an instance, remember that only point positions can change, not the number of points
  50026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50028. * @param name defines the name of the new line system
  50029. * @param options defines the options used to create the line system
  50030. * @param scene defines the hosting scene
  50031. * @returns a new line mesh
  50032. */
  50033. static CreateLines(name: string, options: {
  50034. points: Vector3[];
  50035. updatable?: boolean;
  50036. instance?: Nullable<LinesMesh>;
  50037. colors?: Color4[];
  50038. useVertexAlpha?: boolean;
  50039. }, scene?: Nullable<Scene>): LinesMesh;
  50040. /**
  50041. * Creates a dashed line mesh
  50042. * * 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
  50043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50044. * * The parameter `points` is an array successive Vector3
  50045. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50046. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50047. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50048. * * 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
  50049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50050. * * When updating an instance, remember that only point positions can change, not the number of points
  50051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50052. * @param name defines the name of the mesh
  50053. * @param options defines the options used to create the mesh
  50054. * @param scene defines the hosting scene
  50055. * @returns the dashed line mesh
  50056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50057. */
  50058. static CreateDashedLines(name: string, options: {
  50059. points: Vector3[];
  50060. dashSize?: number;
  50061. gapSize?: number;
  50062. dashNb?: number;
  50063. updatable?: boolean;
  50064. instance?: LinesMesh;
  50065. useVertexAlpha?: boolean;
  50066. }, scene?: Nullable<Scene>): LinesMesh;
  50067. }
  50068. }
  50069. declare module "babylonjs/Misc/timer" {
  50070. import { Observable, Observer } from "babylonjs/Misc/observable";
  50071. import { Nullable } from "babylonjs/types";
  50072. import { IDisposable } from "babylonjs/scene";
  50073. /**
  50074. * Construction options for a timer
  50075. */
  50076. export interface ITimerOptions<T> {
  50077. /**
  50078. * Time-to-end
  50079. */
  50080. timeout: number;
  50081. /**
  50082. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50083. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50084. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50085. */
  50086. contextObservable: Observable<T>;
  50087. /**
  50088. * Optional parameters when adding an observer to the observable
  50089. */
  50090. observableParameters?: {
  50091. mask?: number;
  50092. insertFirst?: boolean;
  50093. scope?: any;
  50094. };
  50095. /**
  50096. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50097. */
  50098. breakCondition?: (data?: ITimerData<T>) => boolean;
  50099. /**
  50100. * Will be triggered when the time condition has met
  50101. */
  50102. onEnded?: (data: ITimerData<any>) => void;
  50103. /**
  50104. * Will be triggered when the break condition has met (prematurely ended)
  50105. */
  50106. onAborted?: (data: ITimerData<any>) => void;
  50107. /**
  50108. * Optional function to execute on each tick (or count)
  50109. */
  50110. onTick?: (data: ITimerData<any>) => void;
  50111. }
  50112. /**
  50113. * An interface defining the data sent by the timer
  50114. */
  50115. export interface ITimerData<T> {
  50116. /**
  50117. * When did it start
  50118. */
  50119. startTime: number;
  50120. /**
  50121. * Time now
  50122. */
  50123. currentTime: number;
  50124. /**
  50125. * Time passed since started
  50126. */
  50127. deltaTime: number;
  50128. /**
  50129. * How much is completed, in [0.0...1.0].
  50130. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50131. */
  50132. completeRate: number;
  50133. /**
  50134. * What the registered observable sent in the last count
  50135. */
  50136. payload: T;
  50137. }
  50138. /**
  50139. * The current state of the timer
  50140. */
  50141. export enum TimerState {
  50142. /**
  50143. * Timer initialized, not yet started
  50144. */
  50145. INIT = 0,
  50146. /**
  50147. * Timer started and counting
  50148. */
  50149. STARTED = 1,
  50150. /**
  50151. * Timer ended (whether aborted or time reached)
  50152. */
  50153. ENDED = 2
  50154. }
  50155. /**
  50156. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50157. *
  50158. * @param options options with which to initialize this timer
  50159. */
  50160. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50161. /**
  50162. * An advanced implementation of a timer class
  50163. */
  50164. export class AdvancedTimer<T = any> implements IDisposable {
  50165. /**
  50166. * Will notify each time the timer calculates the remaining time
  50167. */
  50168. onEachCountObservable: Observable<ITimerData<T>>;
  50169. /**
  50170. * Will trigger when the timer was aborted due to the break condition
  50171. */
  50172. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50173. /**
  50174. * Will trigger when the timer ended successfully
  50175. */
  50176. onTimerEndedObservable: Observable<ITimerData<T>>;
  50177. /**
  50178. * Will trigger when the timer state has changed
  50179. */
  50180. onStateChangedObservable: Observable<TimerState>;
  50181. private _observer;
  50182. private _contextObservable;
  50183. private _observableParameters;
  50184. private _startTime;
  50185. private _timer;
  50186. private _state;
  50187. private _breakCondition;
  50188. private _timeToEnd;
  50189. private _breakOnNextTick;
  50190. /**
  50191. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50192. * @param options construction options for this advanced timer
  50193. */
  50194. constructor(options: ITimerOptions<T>);
  50195. /**
  50196. * set a breaking condition for this timer. Default is to never break during count
  50197. * @param predicate the new break condition. Returns true to break, false otherwise
  50198. */
  50199. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50200. /**
  50201. * Reset ALL associated observables in this advanced timer
  50202. */
  50203. clearObservables(): void;
  50204. /**
  50205. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50206. *
  50207. * @param timeToEnd how much time to measure until timer ended
  50208. */
  50209. start(timeToEnd?: number): void;
  50210. /**
  50211. * Will force a stop on the next tick.
  50212. */
  50213. stop(): void;
  50214. /**
  50215. * Dispose this timer, clearing all resources
  50216. */
  50217. dispose(): void;
  50218. private _setState;
  50219. private _tick;
  50220. private _stop;
  50221. }
  50222. }
  50223. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50224. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50225. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50226. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50228. import { Vector3 } from "babylonjs/Maths/math.vector";
  50229. import { Material } from "babylonjs/Materials/material";
  50230. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50231. import { Scene } from "babylonjs/scene";
  50232. /**
  50233. * The options container for the teleportation module
  50234. */
  50235. export interface IWebXRTeleportationOptions {
  50236. /**
  50237. * if provided, this scene will be used to render meshes.
  50238. */
  50239. customUtilityLayerScene?: Scene;
  50240. /**
  50241. * Values to configure the default target mesh
  50242. */
  50243. defaultTargetMeshOptions?: {
  50244. /**
  50245. * Fill color of the teleportation area
  50246. */
  50247. teleportationFillColor?: string;
  50248. /**
  50249. * Border color for the teleportation area
  50250. */
  50251. teleportationBorderColor?: string;
  50252. /**
  50253. * Disable the mesh's animation sequence
  50254. */
  50255. disableAnimation?: boolean;
  50256. /**
  50257. * Disable lighting on the material or the ring and arrow
  50258. */
  50259. disableLighting?: boolean;
  50260. /**
  50261. * Override the default material of the torus and arrow
  50262. */
  50263. torusArrowMaterial?: Material;
  50264. };
  50265. /**
  50266. * A list of meshes to use as floor meshes.
  50267. * Meshes can be added and removed after initializing the feature using the
  50268. * addFloorMesh and removeFloorMesh functions
  50269. * If empty, rotation will still work
  50270. */
  50271. floorMeshes?: AbstractMesh[];
  50272. /**
  50273. * use this rendering group id for the meshes (optional)
  50274. */
  50275. renderingGroupId?: number;
  50276. /**
  50277. * Should teleportation move only to snap points
  50278. */
  50279. snapPointsOnly?: boolean;
  50280. /**
  50281. * An array of points to which the teleportation will snap to.
  50282. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50283. */
  50284. snapPositions?: Vector3[];
  50285. /**
  50286. * How close should the teleportation ray be in order to snap to position.
  50287. * Default to 0.8 units (meters)
  50288. */
  50289. snapToPositionRadius?: number;
  50290. /**
  50291. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50292. * If you want to support rotation, make sure your mesh has a direction indicator.
  50293. *
  50294. * When left untouched, the default mesh will be initialized.
  50295. */
  50296. teleportationTargetMesh?: AbstractMesh;
  50297. /**
  50298. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50299. */
  50300. timeToTeleport?: number;
  50301. /**
  50302. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50303. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50304. */
  50305. useMainComponentOnly?: boolean;
  50306. /**
  50307. * Should meshes created here be added to a utility layer or the main scene
  50308. */
  50309. useUtilityLayer?: boolean;
  50310. /**
  50311. * Babylon XR Input class for controller
  50312. */
  50313. xrInput: WebXRInput;
  50314. }
  50315. /**
  50316. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50317. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50318. * the input of the attached controllers.
  50319. */
  50320. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50321. private _options;
  50322. private _controllers;
  50323. private _currentTeleportationControllerId;
  50324. private _floorMeshes;
  50325. private _quadraticBezierCurve;
  50326. private _selectionFeature;
  50327. private _snapToPositions;
  50328. private _snappedToPoint;
  50329. private _teleportationRingMaterial?;
  50330. private _tmpRay;
  50331. private _tmpVector;
  50332. /**
  50333. * The module's name
  50334. */
  50335. static readonly Name: string;
  50336. /**
  50337. * The (Babylon) version of this module.
  50338. * This is an integer representing the implementation version.
  50339. * This number does not correspond to the webxr specs version
  50340. */
  50341. static readonly Version: number;
  50342. /**
  50343. * Is movement backwards enabled
  50344. */
  50345. backwardsMovementEnabled: boolean;
  50346. /**
  50347. * Distance to travel when moving backwards
  50348. */
  50349. backwardsTeleportationDistance: number;
  50350. /**
  50351. * The distance from the user to the inspection point in the direction of the controller
  50352. * A higher number will allow the user to move further
  50353. * defaults to 5 (meters, in xr units)
  50354. */
  50355. parabolicCheckRadius: number;
  50356. /**
  50357. * Should the module support parabolic ray on top of direct ray
  50358. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50359. * Very helpful when moving between floors / different heights
  50360. */
  50361. parabolicRayEnabled: boolean;
  50362. /**
  50363. * How much rotation should be applied when rotating right and left
  50364. */
  50365. rotationAngle: number;
  50366. /**
  50367. * Is rotation enabled when moving forward?
  50368. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50369. */
  50370. rotationEnabled: boolean;
  50371. /**
  50372. * constructs a new anchor system
  50373. * @param _xrSessionManager an instance of WebXRSessionManager
  50374. * @param _options configuration object for this feature
  50375. */
  50376. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50377. /**
  50378. * Get the snapPointsOnly flag
  50379. */
  50380. get snapPointsOnly(): boolean;
  50381. /**
  50382. * Sets the snapPointsOnly flag
  50383. * @param snapToPoints should teleportation be exclusively to snap points
  50384. */
  50385. set snapPointsOnly(snapToPoints: boolean);
  50386. /**
  50387. * Add a new mesh to the floor meshes array
  50388. * @param mesh the mesh to use as floor mesh
  50389. */
  50390. addFloorMesh(mesh: AbstractMesh): void;
  50391. /**
  50392. * Add a new snap-to point to fix teleportation to this position
  50393. * @param newSnapPoint The new Snap-To point
  50394. */
  50395. addSnapPoint(newSnapPoint: Vector3): void;
  50396. attach(): boolean;
  50397. detach(): boolean;
  50398. dispose(): void;
  50399. /**
  50400. * Remove a mesh from the floor meshes array
  50401. * @param mesh the mesh to remove
  50402. */
  50403. removeFloorMesh(mesh: AbstractMesh): void;
  50404. /**
  50405. * Remove a mesh from the floor meshes array using its name
  50406. * @param name the mesh name to remove
  50407. */
  50408. removeFloorMeshByName(name: string): void;
  50409. /**
  50410. * 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
  50411. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50412. * @returns was the point found and removed or not
  50413. */
  50414. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50415. /**
  50416. * This function sets a selection feature that will be disabled when
  50417. * the forward ray is shown and will be reattached when hidden.
  50418. * This is used to remove the selection rays when moving.
  50419. * @param selectionFeature the feature to disable when forward movement is enabled
  50420. */
  50421. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50422. protected _onXRFrame(_xrFrame: XRFrame): void;
  50423. private _attachController;
  50424. private _createDefaultTargetMesh;
  50425. private _detachController;
  50426. private _findClosestSnapPointWithRadius;
  50427. private _setTargetMeshPosition;
  50428. private _setTargetMeshVisibility;
  50429. private _showParabolicPath;
  50430. private _teleportForward;
  50431. }
  50432. }
  50433. declare module "babylonjs/XR/webXRDefaultExperience" {
  50434. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50435. import { Scene } from "babylonjs/scene";
  50436. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50437. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50438. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50439. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50441. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50442. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50443. /**
  50444. * Options for the default xr helper
  50445. */
  50446. export class WebXRDefaultExperienceOptions {
  50447. /**
  50448. * Enable or disable default UI to enter XR
  50449. */
  50450. disableDefaultUI?: boolean;
  50451. /**
  50452. * Should teleportation not initialize. defaults to false.
  50453. */
  50454. disableTeleportation?: boolean;
  50455. /**
  50456. * Floor meshes that will be used for teleport
  50457. */
  50458. floorMeshes?: Array<AbstractMesh>;
  50459. /**
  50460. * If set to true, the first frame will not be used to reset position
  50461. * The first frame is mainly used when copying transformation from the old camera
  50462. * Mainly used in AR
  50463. */
  50464. ignoreNativeCameraTransformation?: boolean;
  50465. /**
  50466. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50467. */
  50468. inputOptions?: IWebXRInputOptions;
  50469. /**
  50470. * optional configuration for the output canvas
  50471. */
  50472. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50473. /**
  50474. * optional UI options. This can be used among other to change session mode and reference space type
  50475. */
  50476. uiOptions?: WebXREnterExitUIOptions;
  50477. /**
  50478. * When loading teleportation and pointer select, use stable versions instead of latest.
  50479. */
  50480. useStablePlugins?: boolean;
  50481. /**
  50482. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50483. */
  50484. renderingGroupId?: number;
  50485. /**
  50486. * A list of optional features to init the session with
  50487. * If set to true, all features we support will be added
  50488. */
  50489. optionalFeatures?: boolean | string[];
  50490. }
  50491. /**
  50492. * Default experience which provides a similar setup to the previous webVRExperience
  50493. */
  50494. export class WebXRDefaultExperience {
  50495. /**
  50496. * Base experience
  50497. */
  50498. baseExperience: WebXRExperienceHelper;
  50499. /**
  50500. * Enables ui for entering/exiting xr
  50501. */
  50502. enterExitUI: WebXREnterExitUI;
  50503. /**
  50504. * Input experience extension
  50505. */
  50506. input: WebXRInput;
  50507. /**
  50508. * Enables laser pointer and selection
  50509. */
  50510. pointerSelection: WebXRControllerPointerSelection;
  50511. /**
  50512. * Default target xr should render to
  50513. */
  50514. renderTarget: WebXRRenderTarget;
  50515. /**
  50516. * Enables teleportation
  50517. */
  50518. teleportation: WebXRMotionControllerTeleportation;
  50519. private constructor();
  50520. /**
  50521. * Creates the default xr experience
  50522. * @param scene scene
  50523. * @param options options for basic configuration
  50524. * @returns resulting WebXRDefaultExperience
  50525. */
  50526. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50527. /**
  50528. * DIsposes of the experience helper
  50529. */
  50530. dispose(): void;
  50531. }
  50532. }
  50533. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50534. import { Observable } from "babylonjs/Misc/observable";
  50535. import { Nullable } from "babylonjs/types";
  50536. import { Camera } from "babylonjs/Cameras/camera";
  50537. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50538. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50539. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50540. import { Scene } from "babylonjs/scene";
  50541. import { Vector3 } from "babylonjs/Maths/math.vector";
  50542. import { Color3 } from "babylonjs/Maths/math.color";
  50543. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50545. import { Mesh } from "babylonjs/Meshes/mesh";
  50546. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50547. import { EasingFunction } from "babylonjs/Animations/easing";
  50548. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50549. import "babylonjs/Meshes/Builders/groundBuilder";
  50550. import "babylonjs/Meshes/Builders/torusBuilder";
  50551. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50552. import "babylonjs/Gamepads/gamepadSceneComponent";
  50553. import "babylonjs/Animations/animatable";
  50554. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50555. /**
  50556. * Options to modify the vr teleportation behavior.
  50557. */
  50558. export interface VRTeleportationOptions {
  50559. /**
  50560. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50561. */
  50562. floorMeshName?: string;
  50563. /**
  50564. * A list of meshes to be used as the teleportation floor. (default: empty)
  50565. */
  50566. floorMeshes?: Mesh[];
  50567. /**
  50568. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50569. */
  50570. teleportationMode?: number;
  50571. /**
  50572. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50573. */
  50574. teleportationTime?: number;
  50575. /**
  50576. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50577. */
  50578. teleportationSpeed?: number;
  50579. /**
  50580. * The easing function used in the animation or null for Linear. (default CircleEase)
  50581. */
  50582. easingFunction?: EasingFunction;
  50583. }
  50584. /**
  50585. * Options to modify the vr experience helper's behavior.
  50586. */
  50587. export interface VRExperienceHelperOptions extends WebVROptions {
  50588. /**
  50589. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50590. */
  50591. createDeviceOrientationCamera?: boolean;
  50592. /**
  50593. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50594. */
  50595. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50596. /**
  50597. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50598. */
  50599. laserToggle?: boolean;
  50600. /**
  50601. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50602. */
  50603. floorMeshes?: Mesh[];
  50604. /**
  50605. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50606. */
  50607. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50608. /**
  50609. * Defines if WebXR should be used instead of WebVR (if available)
  50610. */
  50611. useXR?: boolean;
  50612. }
  50613. /**
  50614. * Event containing information after VR has been entered
  50615. */
  50616. export class OnAfterEnteringVRObservableEvent {
  50617. /**
  50618. * If entering vr was successful
  50619. */
  50620. success: boolean;
  50621. }
  50622. /**
  50623. * Helps to quickly add VR support to an existing scene.
  50624. * See https://doc.babylonjs.com/how_to/webvr_helper
  50625. */
  50626. export class VRExperienceHelper {
  50627. /** Options to modify the vr experience helper's behavior. */
  50628. webVROptions: VRExperienceHelperOptions;
  50629. private _scene;
  50630. private _position;
  50631. private _btnVR;
  50632. private _btnVRDisplayed;
  50633. private _webVRsupported;
  50634. private _webVRready;
  50635. private _webVRrequesting;
  50636. private _webVRpresenting;
  50637. private _hasEnteredVR;
  50638. private _fullscreenVRpresenting;
  50639. private _inputElement;
  50640. private _webVRCamera;
  50641. private _vrDeviceOrientationCamera;
  50642. private _deviceOrientationCamera;
  50643. private _existingCamera;
  50644. private _onKeyDown;
  50645. private _onVrDisplayPresentChange;
  50646. private _onVRDisplayChanged;
  50647. private _onVRRequestPresentStart;
  50648. private _onVRRequestPresentComplete;
  50649. /**
  50650. * 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)
  50651. */
  50652. enableGazeEvenWhenNoPointerLock: boolean;
  50653. /**
  50654. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50655. */
  50656. exitVROnDoubleTap: boolean;
  50657. /**
  50658. * Observable raised right before entering VR.
  50659. */
  50660. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50661. /**
  50662. * Observable raised when entering VR has completed.
  50663. */
  50664. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50665. /**
  50666. * Observable raised when exiting VR.
  50667. */
  50668. onExitingVRObservable: Observable<VRExperienceHelper>;
  50669. /**
  50670. * Observable raised when controller mesh is loaded.
  50671. */
  50672. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50673. /** Return this.onEnteringVRObservable
  50674. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50675. */
  50676. get onEnteringVR(): Observable<VRExperienceHelper>;
  50677. /** Return this.onExitingVRObservable
  50678. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50679. */
  50680. get onExitingVR(): Observable<VRExperienceHelper>;
  50681. /** Return this.onControllerMeshLoadedObservable
  50682. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50683. */
  50684. get onControllerMeshLoaded(): Observable<WebVRController>;
  50685. private _rayLength;
  50686. private _useCustomVRButton;
  50687. private _teleportationRequested;
  50688. private _teleportActive;
  50689. private _floorMeshName;
  50690. private _floorMeshesCollection;
  50691. private _teleportationMode;
  50692. private _teleportationTime;
  50693. private _teleportationSpeed;
  50694. private _teleportationEasing;
  50695. private _rotationAllowed;
  50696. private _teleportBackwardsVector;
  50697. private _teleportationTarget;
  50698. private _isDefaultTeleportationTarget;
  50699. private _postProcessMove;
  50700. private _teleportationFillColor;
  50701. private _teleportationBorderColor;
  50702. private _rotationAngle;
  50703. private _haloCenter;
  50704. private _cameraGazer;
  50705. private _padSensibilityUp;
  50706. private _padSensibilityDown;
  50707. private _leftController;
  50708. private _rightController;
  50709. private _gazeColor;
  50710. private _laserColor;
  50711. private _pickedLaserColor;
  50712. private _pickedGazeColor;
  50713. /**
  50714. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50715. */
  50716. onNewMeshSelected: Observable<AbstractMesh>;
  50717. /**
  50718. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50719. * This observable will provide the mesh and the controller used to select the mesh
  50720. */
  50721. onMeshSelectedWithController: Observable<{
  50722. mesh: AbstractMesh;
  50723. controller: WebVRController;
  50724. }>;
  50725. /**
  50726. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50727. */
  50728. onNewMeshPicked: Observable<PickingInfo>;
  50729. private _circleEase;
  50730. /**
  50731. * Observable raised before camera teleportation
  50732. */
  50733. onBeforeCameraTeleport: Observable<Vector3>;
  50734. /**
  50735. * Observable raised after camera teleportation
  50736. */
  50737. onAfterCameraTeleport: Observable<Vector3>;
  50738. /**
  50739. * Observable raised when current selected mesh gets unselected
  50740. */
  50741. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50742. private _raySelectionPredicate;
  50743. /**
  50744. * To be optionaly changed by user to define custom ray selection
  50745. */
  50746. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50747. /**
  50748. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50749. */
  50750. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50751. /**
  50752. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50753. */
  50754. teleportationEnabled: boolean;
  50755. private _defaultHeight;
  50756. private _teleportationInitialized;
  50757. private _interactionsEnabled;
  50758. private _interactionsRequested;
  50759. private _displayGaze;
  50760. private _displayLaserPointer;
  50761. /**
  50762. * The mesh used to display where the user is going to teleport.
  50763. */
  50764. get teleportationTarget(): Mesh;
  50765. /**
  50766. * Sets the mesh to be used to display where the user is going to teleport.
  50767. */
  50768. set teleportationTarget(value: Mesh);
  50769. /**
  50770. * 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
  50771. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50772. * See https://doc.babylonjs.com/resources/baking_transformations
  50773. */
  50774. get gazeTrackerMesh(): Mesh;
  50775. set gazeTrackerMesh(value: Mesh);
  50776. /**
  50777. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50778. */
  50779. updateGazeTrackerScale: boolean;
  50780. /**
  50781. * If the gaze trackers color should be updated when selecting meshes
  50782. */
  50783. updateGazeTrackerColor: boolean;
  50784. /**
  50785. * If the controller laser color should be updated when selecting meshes
  50786. */
  50787. updateControllerLaserColor: boolean;
  50788. /**
  50789. * The gaze tracking mesh corresponding to the left controller
  50790. */
  50791. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50792. /**
  50793. * The gaze tracking mesh corresponding to the right controller
  50794. */
  50795. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50796. /**
  50797. * If the ray of the gaze should be displayed.
  50798. */
  50799. get displayGaze(): boolean;
  50800. /**
  50801. * Sets if the ray of the gaze should be displayed.
  50802. */
  50803. set displayGaze(value: boolean);
  50804. /**
  50805. * If the ray of the LaserPointer should be displayed.
  50806. */
  50807. get displayLaserPointer(): boolean;
  50808. /**
  50809. * Sets if the ray of the LaserPointer should be displayed.
  50810. */
  50811. set displayLaserPointer(value: boolean);
  50812. /**
  50813. * The deviceOrientationCamera used as the camera when not in VR.
  50814. */
  50815. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50816. /**
  50817. * Based on the current WebVR support, returns the current VR camera used.
  50818. */
  50819. get currentVRCamera(): Nullable<Camera>;
  50820. /**
  50821. * The webVRCamera which is used when in VR.
  50822. */
  50823. get webVRCamera(): WebVRFreeCamera;
  50824. /**
  50825. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50826. */
  50827. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50828. /**
  50829. * The html button that is used to trigger entering into VR.
  50830. */
  50831. get vrButton(): Nullable<HTMLButtonElement>;
  50832. private get _teleportationRequestInitiated();
  50833. /**
  50834. * Defines whether or not Pointer lock should be requested when switching to
  50835. * full screen.
  50836. */
  50837. requestPointerLockOnFullScreen: boolean;
  50838. /**
  50839. * If asking to force XR, this will be populated with the default xr experience
  50840. */
  50841. xr: WebXRDefaultExperience;
  50842. /**
  50843. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50844. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50845. */
  50846. xrTestDone: boolean;
  50847. /**
  50848. * Instantiates a VRExperienceHelper.
  50849. * Helps to quickly add VR support to an existing scene.
  50850. * @param scene The scene the VRExperienceHelper belongs to.
  50851. * @param webVROptions Options to modify the vr experience helper's behavior.
  50852. */
  50853. constructor(scene: Scene,
  50854. /** Options to modify the vr experience helper's behavior. */
  50855. webVROptions?: VRExperienceHelperOptions);
  50856. private completeVRInit;
  50857. private _onDefaultMeshLoaded;
  50858. private _onResize;
  50859. private _onFullscreenChange;
  50860. /**
  50861. * Gets a value indicating if we are currently in VR mode.
  50862. */
  50863. get isInVRMode(): boolean;
  50864. private onVrDisplayPresentChange;
  50865. private onVRDisplayChanged;
  50866. private moveButtonToBottomRight;
  50867. private displayVRButton;
  50868. private updateButtonVisibility;
  50869. private _cachedAngularSensibility;
  50870. /**
  50871. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50872. * Otherwise, will use the fullscreen API.
  50873. */
  50874. enterVR(): void;
  50875. /**
  50876. * Attempt to exit VR, or fullscreen.
  50877. */
  50878. exitVR(): void;
  50879. /**
  50880. * The position of the vr experience helper.
  50881. */
  50882. get position(): Vector3;
  50883. /**
  50884. * Sets the position of the vr experience helper.
  50885. */
  50886. set position(value: Vector3);
  50887. /**
  50888. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50889. */
  50890. enableInteractions(): void;
  50891. private get _noControllerIsActive();
  50892. private beforeRender;
  50893. private _isTeleportationFloor;
  50894. /**
  50895. * Adds a floor mesh to be used for teleportation.
  50896. * @param floorMesh the mesh to be used for teleportation.
  50897. */
  50898. addFloorMesh(floorMesh: Mesh): void;
  50899. /**
  50900. * Removes a floor mesh from being used for teleportation.
  50901. * @param floorMesh the mesh to be removed.
  50902. */
  50903. removeFloorMesh(floorMesh: Mesh): void;
  50904. /**
  50905. * Enables interactions and teleportation using the VR controllers and gaze.
  50906. * @param vrTeleportationOptions options to modify teleportation behavior.
  50907. */
  50908. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50909. private _onNewGamepadConnected;
  50910. private _tryEnableInteractionOnController;
  50911. private _onNewGamepadDisconnected;
  50912. private _enableInteractionOnController;
  50913. private _checkTeleportWithRay;
  50914. private _checkRotate;
  50915. private _checkTeleportBackwards;
  50916. private _enableTeleportationOnController;
  50917. private _createTeleportationCircles;
  50918. private _displayTeleportationTarget;
  50919. private _hideTeleportationTarget;
  50920. private _rotateCamera;
  50921. private _moveTeleportationSelectorTo;
  50922. private _workingVector;
  50923. private _workingQuaternion;
  50924. private _workingMatrix;
  50925. /**
  50926. * Time Constant Teleportation Mode
  50927. */
  50928. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50929. /**
  50930. * Speed Constant Teleportation Mode
  50931. */
  50932. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50933. /**
  50934. * Teleports the users feet to the desired location
  50935. * @param location The location where the user's feet should be placed
  50936. */
  50937. teleportCamera(location: Vector3): void;
  50938. private _convertNormalToDirectionOfRay;
  50939. private _castRayAndSelectObject;
  50940. private _notifySelectedMeshUnselected;
  50941. /**
  50942. * Permanently set new colors for the laser pointer
  50943. * @param color the new laser color
  50944. * @param pickedColor the new laser color when picked mesh detected
  50945. */
  50946. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50947. /**
  50948. * Set lighting enabled / disabled on the laser pointer of both controllers
  50949. * @param enabled should the lighting be enabled on the laser pointer
  50950. */
  50951. setLaserLightingState(enabled?: boolean): void;
  50952. /**
  50953. * Permanently set new colors for the gaze pointer
  50954. * @param color the new gaze color
  50955. * @param pickedColor the new gaze color when picked mesh detected
  50956. */
  50957. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50958. /**
  50959. * Sets the color of the laser ray from the vr controllers.
  50960. * @param color new color for the ray.
  50961. */
  50962. changeLaserColor(color: Color3): void;
  50963. /**
  50964. * Sets the color of the ray from the vr headsets gaze.
  50965. * @param color new color for the ray.
  50966. */
  50967. changeGazeColor(color: Color3): void;
  50968. /**
  50969. * Exits VR and disposes of the vr experience helper
  50970. */
  50971. dispose(): void;
  50972. /**
  50973. * Gets the name of the VRExperienceHelper class
  50974. * @returns "VRExperienceHelper"
  50975. */
  50976. getClassName(): string;
  50977. }
  50978. }
  50979. declare module "babylonjs/Cameras/VR/index" {
  50980. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50981. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50982. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50983. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50984. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50985. export * from "babylonjs/Cameras/VR/webVRCamera";
  50986. }
  50987. declare module "babylonjs/Cameras/RigModes/index" {
  50988. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50989. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50990. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50991. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50992. }
  50993. declare module "babylonjs/Cameras/index" {
  50994. export * from "babylonjs/Cameras/Inputs/index";
  50995. export * from "babylonjs/Cameras/cameraInputsManager";
  50996. export * from "babylonjs/Cameras/camera";
  50997. export * from "babylonjs/Cameras/targetCamera";
  50998. export * from "babylonjs/Cameras/freeCamera";
  50999. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51000. export * from "babylonjs/Cameras/touchCamera";
  51001. export * from "babylonjs/Cameras/arcRotateCamera";
  51002. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51003. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51004. export * from "babylonjs/Cameras/flyCamera";
  51005. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51006. export * from "babylonjs/Cameras/followCamera";
  51007. export * from "babylonjs/Cameras/followCameraInputsManager";
  51008. export * from "babylonjs/Cameras/gamepadCamera";
  51009. export * from "babylonjs/Cameras/Stereoscopic/index";
  51010. export * from "babylonjs/Cameras/universalCamera";
  51011. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51012. export * from "babylonjs/Cameras/VR/index";
  51013. export * from "babylonjs/Cameras/RigModes/index";
  51014. }
  51015. declare module "babylonjs/Collisions/index" {
  51016. export * from "babylonjs/Collisions/collider";
  51017. export * from "babylonjs/Collisions/collisionCoordinator";
  51018. export * from "babylonjs/Collisions/pickingInfo";
  51019. export * from "babylonjs/Collisions/intersectionInfo";
  51020. export * from "babylonjs/Collisions/meshCollisionData";
  51021. }
  51022. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51023. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51024. import { Vector3 } from "babylonjs/Maths/math.vector";
  51025. import { Ray } from "babylonjs/Culling/ray";
  51026. import { Plane } from "babylonjs/Maths/math.plane";
  51027. /**
  51028. * Contains an array of blocks representing the octree
  51029. */
  51030. export interface IOctreeContainer<T> {
  51031. /**
  51032. * Blocks within the octree
  51033. */
  51034. blocks: Array<OctreeBlock<T>>;
  51035. }
  51036. /**
  51037. * Class used to store a cell in an octree
  51038. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51039. */
  51040. export class OctreeBlock<T> {
  51041. /**
  51042. * Gets the content of the current block
  51043. */
  51044. entries: T[];
  51045. /**
  51046. * Gets the list of block children
  51047. */
  51048. blocks: Array<OctreeBlock<T>>;
  51049. private _depth;
  51050. private _maxDepth;
  51051. private _capacity;
  51052. private _minPoint;
  51053. private _maxPoint;
  51054. private _boundingVectors;
  51055. private _creationFunc;
  51056. /**
  51057. * Creates a new block
  51058. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51059. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51060. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51061. * @param depth defines the current depth of this block in the octree
  51062. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51063. * @param creationFunc defines a callback to call when an element is added to the block
  51064. */
  51065. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51066. /**
  51067. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51068. */
  51069. get capacity(): number;
  51070. /**
  51071. * Gets the minimum vector (in world space) of the block's bounding box
  51072. */
  51073. get minPoint(): Vector3;
  51074. /**
  51075. * Gets the maximum vector (in world space) of the block's bounding box
  51076. */
  51077. get maxPoint(): Vector3;
  51078. /**
  51079. * Add a new element to this block
  51080. * @param entry defines the element to add
  51081. */
  51082. addEntry(entry: T): void;
  51083. /**
  51084. * Remove an element from this block
  51085. * @param entry defines the element to remove
  51086. */
  51087. removeEntry(entry: T): void;
  51088. /**
  51089. * Add an array of elements to this block
  51090. * @param entries defines the array of elements to add
  51091. */
  51092. addEntries(entries: T[]): void;
  51093. /**
  51094. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51095. * @param frustumPlanes defines the frustum planes to test
  51096. * @param selection defines the array to store current content if selection is positive
  51097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51098. */
  51099. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51100. /**
  51101. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51102. * @param sphereCenter defines the bounding sphere center
  51103. * @param sphereRadius defines the bounding sphere radius
  51104. * @param selection defines the array to store current content if selection is positive
  51105. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51106. */
  51107. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51108. /**
  51109. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51110. * @param ray defines the ray to test with
  51111. * @param selection defines the array to store current content if selection is positive
  51112. */
  51113. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51114. /**
  51115. * Subdivide the content into child blocks (this block will then be empty)
  51116. */
  51117. createInnerBlocks(): void;
  51118. /**
  51119. * @hidden
  51120. */
  51121. 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;
  51122. }
  51123. }
  51124. declare module "babylonjs/Culling/Octrees/octree" {
  51125. import { SmartArray } from "babylonjs/Misc/smartArray";
  51126. import { Vector3 } from "babylonjs/Maths/math.vector";
  51127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51129. import { Ray } from "babylonjs/Culling/ray";
  51130. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51131. import { Plane } from "babylonjs/Maths/math.plane";
  51132. /**
  51133. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51134. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51135. */
  51136. export class Octree<T> {
  51137. /** 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.) */
  51138. maxDepth: number;
  51139. /**
  51140. * Blocks within the octree containing objects
  51141. */
  51142. blocks: Array<OctreeBlock<T>>;
  51143. /**
  51144. * Content stored in the octree
  51145. */
  51146. dynamicContent: T[];
  51147. private _maxBlockCapacity;
  51148. private _selectionContent;
  51149. private _creationFunc;
  51150. /**
  51151. * Creates a octree
  51152. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51153. * @param creationFunc function to be used to instatiate the octree
  51154. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51155. * @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.)
  51156. */
  51157. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51158. /** 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.) */
  51159. maxDepth?: number);
  51160. /**
  51161. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51162. * @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);
  51163. * @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);
  51164. * @param entries meshes to be added to the octree blocks
  51165. */
  51166. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51167. /**
  51168. * Adds a mesh to the octree
  51169. * @param entry Mesh to add to the octree
  51170. */
  51171. addMesh(entry: T): void;
  51172. /**
  51173. * Remove an element from the octree
  51174. * @param entry defines the element to remove
  51175. */
  51176. removeMesh(entry: T): void;
  51177. /**
  51178. * Selects an array of meshes within the frustum
  51179. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51180. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51181. * @returns array of meshes within the frustum
  51182. */
  51183. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51184. /**
  51185. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51186. * @param sphereCenter defines the bounding sphere center
  51187. * @param sphereRadius defines the bounding sphere radius
  51188. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51189. * @returns an array of objects that intersect the sphere
  51190. */
  51191. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51192. /**
  51193. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51194. * @param ray defines the ray to test with
  51195. * @returns array of intersected objects
  51196. */
  51197. intersectsRay(ray: Ray): SmartArray<T>;
  51198. /**
  51199. * Adds a mesh into the octree block if it intersects the block
  51200. */
  51201. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51202. /**
  51203. * Adds a submesh into the octree block if it intersects the block
  51204. */
  51205. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51206. }
  51207. }
  51208. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51209. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51210. import { Scene } from "babylonjs/scene";
  51211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51213. import { Ray } from "babylonjs/Culling/ray";
  51214. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51215. import { Collider } from "babylonjs/Collisions/collider";
  51216. module "babylonjs/scene" {
  51217. interface Scene {
  51218. /**
  51219. * @hidden
  51220. * Backing Filed
  51221. */
  51222. _selectionOctree: Octree<AbstractMesh>;
  51223. /**
  51224. * Gets the octree used to boost mesh selection (picking)
  51225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51226. */
  51227. selectionOctree: Octree<AbstractMesh>;
  51228. /**
  51229. * Creates or updates the octree used to boost selection (picking)
  51230. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51231. * @param maxCapacity defines the maximum capacity per leaf
  51232. * @param maxDepth defines the maximum depth of the octree
  51233. * @returns an octree of AbstractMesh
  51234. */
  51235. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51236. }
  51237. }
  51238. module "babylonjs/Meshes/abstractMesh" {
  51239. interface AbstractMesh {
  51240. /**
  51241. * @hidden
  51242. * Backing Field
  51243. */
  51244. _submeshesOctree: Octree<SubMesh>;
  51245. /**
  51246. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51247. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51248. * @param maxCapacity defines the maximum size of each block (64 by default)
  51249. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51250. * @returns the new octree
  51251. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51253. */
  51254. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51255. }
  51256. }
  51257. /**
  51258. * Defines the octree scene component responsible to manage any octrees
  51259. * in a given scene.
  51260. */
  51261. export class OctreeSceneComponent {
  51262. /**
  51263. * The component name help to identify the component in the list of scene components.
  51264. */
  51265. readonly name: string;
  51266. /**
  51267. * The scene the component belongs to.
  51268. */
  51269. scene: Scene;
  51270. /**
  51271. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51272. */
  51273. readonly checksIsEnabled: boolean;
  51274. /**
  51275. * Creates a new instance of the component for the given scene
  51276. * @param scene Defines the scene to register the component in
  51277. */
  51278. constructor(scene: Scene);
  51279. /**
  51280. * Registers the component in a given scene
  51281. */
  51282. register(): void;
  51283. /**
  51284. * Return the list of active meshes
  51285. * @returns the list of active meshes
  51286. */
  51287. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51288. /**
  51289. * Return the list of active sub meshes
  51290. * @param mesh The mesh to get the candidates sub meshes from
  51291. * @returns the list of active sub meshes
  51292. */
  51293. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51294. private _tempRay;
  51295. /**
  51296. * Return the list of sub meshes intersecting with a given local ray
  51297. * @param mesh defines the mesh to find the submesh for
  51298. * @param localRay defines the ray in local space
  51299. * @returns the list of intersecting sub meshes
  51300. */
  51301. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51302. /**
  51303. * Return the list of sub meshes colliding with a collider
  51304. * @param mesh defines the mesh to find the submesh for
  51305. * @param collider defines the collider to evaluate the collision against
  51306. * @returns the list of colliding sub meshes
  51307. */
  51308. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51309. /**
  51310. * Rebuilds the elements related to this component in case of
  51311. * context lost for instance.
  51312. */
  51313. rebuild(): void;
  51314. /**
  51315. * Disposes the component and the associated ressources.
  51316. */
  51317. dispose(): void;
  51318. }
  51319. }
  51320. declare module "babylonjs/Culling/Octrees/index" {
  51321. export * from "babylonjs/Culling/Octrees/octree";
  51322. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51323. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51324. }
  51325. declare module "babylonjs/Culling/index" {
  51326. export * from "babylonjs/Culling/boundingBox";
  51327. export * from "babylonjs/Culling/boundingInfo";
  51328. export * from "babylonjs/Culling/boundingSphere";
  51329. export * from "babylonjs/Culling/Octrees/index";
  51330. export * from "babylonjs/Culling/ray";
  51331. }
  51332. declare module "babylonjs/Gizmos/gizmo" {
  51333. import { Nullable } from "babylonjs/types";
  51334. import { IDisposable } from "babylonjs/scene";
  51335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51336. import { Mesh } from "babylonjs/Meshes/mesh";
  51337. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51338. /**
  51339. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51340. */
  51341. export class Gizmo implements IDisposable {
  51342. /** The utility layer the gizmo will be added to */
  51343. gizmoLayer: UtilityLayerRenderer;
  51344. /**
  51345. * The root mesh of the gizmo
  51346. */
  51347. _rootMesh: Mesh;
  51348. private _attachedMesh;
  51349. /**
  51350. * Ratio for the scale of the gizmo (Default: 1)
  51351. */
  51352. scaleRatio: number;
  51353. /**
  51354. * If a custom mesh has been set (Default: false)
  51355. */
  51356. protected _customMeshSet: boolean;
  51357. /**
  51358. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51359. * * When set, interactions will be enabled
  51360. */
  51361. get attachedMesh(): Nullable<AbstractMesh>;
  51362. set attachedMesh(value: Nullable<AbstractMesh>);
  51363. /**
  51364. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51365. * @param mesh The mesh to replace the default mesh of the gizmo
  51366. */
  51367. setCustomMesh(mesh: Mesh): void;
  51368. /**
  51369. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51370. */
  51371. updateGizmoRotationToMatchAttachedMesh: boolean;
  51372. /**
  51373. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51374. */
  51375. updateGizmoPositionToMatchAttachedMesh: boolean;
  51376. /**
  51377. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51378. */
  51379. updateScale: boolean;
  51380. protected _interactionsEnabled: boolean;
  51381. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51382. private _beforeRenderObserver;
  51383. private _tempVector;
  51384. /**
  51385. * Creates a gizmo
  51386. * @param gizmoLayer The utility layer the gizmo will be added to
  51387. */
  51388. constructor(
  51389. /** The utility layer the gizmo will be added to */
  51390. gizmoLayer?: UtilityLayerRenderer);
  51391. /**
  51392. * Updates the gizmo to match the attached mesh's position/rotation
  51393. */
  51394. protected _update(): void;
  51395. /**
  51396. * Disposes of the gizmo
  51397. */
  51398. dispose(): void;
  51399. }
  51400. }
  51401. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51402. import { Observable } from "babylonjs/Misc/observable";
  51403. import { Nullable } from "babylonjs/types";
  51404. import { Vector3 } from "babylonjs/Maths/math.vector";
  51405. import { Color3 } from "babylonjs/Maths/math.color";
  51406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51408. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51409. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51411. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51412. import { Scene } from "babylonjs/scene";
  51413. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51414. /**
  51415. * Single plane drag gizmo
  51416. */
  51417. export class PlaneDragGizmo extends Gizmo {
  51418. /**
  51419. * Drag behavior responsible for the gizmos dragging interactions
  51420. */
  51421. dragBehavior: PointerDragBehavior;
  51422. private _pointerObserver;
  51423. /**
  51424. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51425. */
  51426. snapDistance: number;
  51427. /**
  51428. * Event that fires each time the gizmo snaps to a new location.
  51429. * * snapDistance is the the change in distance
  51430. */
  51431. onSnapObservable: Observable<{
  51432. snapDistance: number;
  51433. }>;
  51434. private _plane;
  51435. private _coloredMaterial;
  51436. private _hoverMaterial;
  51437. private _isEnabled;
  51438. private _parent;
  51439. /** @hidden */
  51440. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51441. /** @hidden */
  51442. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51443. /**
  51444. * Creates a PlaneDragGizmo
  51445. * @param gizmoLayer The utility layer the gizmo will be added to
  51446. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51447. * @param color The color of the gizmo
  51448. */
  51449. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51450. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51451. /**
  51452. * If the gizmo is enabled
  51453. */
  51454. set isEnabled(value: boolean);
  51455. get isEnabled(): boolean;
  51456. /**
  51457. * Disposes of the gizmo
  51458. */
  51459. dispose(): void;
  51460. }
  51461. }
  51462. declare module "babylonjs/Gizmos/positionGizmo" {
  51463. import { Observable } from "babylonjs/Misc/observable";
  51464. import { Nullable } from "babylonjs/types";
  51465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51466. import { Mesh } from "babylonjs/Meshes/mesh";
  51467. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51468. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51469. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51470. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51471. /**
  51472. * Gizmo that enables dragging a mesh along 3 axis
  51473. */
  51474. export class PositionGizmo extends Gizmo {
  51475. /**
  51476. * Internal gizmo used for interactions on the x axis
  51477. */
  51478. xGizmo: AxisDragGizmo;
  51479. /**
  51480. * Internal gizmo used for interactions on the y axis
  51481. */
  51482. yGizmo: AxisDragGizmo;
  51483. /**
  51484. * Internal gizmo used for interactions on the z axis
  51485. */
  51486. zGizmo: AxisDragGizmo;
  51487. /**
  51488. * Internal gizmo used for interactions on the yz plane
  51489. */
  51490. xPlaneGizmo: PlaneDragGizmo;
  51491. /**
  51492. * Internal gizmo used for interactions on the xz plane
  51493. */
  51494. yPlaneGizmo: PlaneDragGizmo;
  51495. /**
  51496. * Internal gizmo used for interactions on the xy plane
  51497. */
  51498. zPlaneGizmo: PlaneDragGizmo;
  51499. /**
  51500. * private variables
  51501. */
  51502. private _meshAttached;
  51503. private _updateGizmoRotationToMatchAttachedMesh;
  51504. private _snapDistance;
  51505. private _scaleRatio;
  51506. /** Fires an event when any of it's sub gizmos are dragged */
  51507. onDragStartObservable: Observable<unknown>;
  51508. /** Fires an event when any of it's sub gizmos are released from dragging */
  51509. onDragEndObservable: Observable<unknown>;
  51510. /**
  51511. * If set to true, planar drag is enabled
  51512. */
  51513. private _planarGizmoEnabled;
  51514. get attachedMesh(): Nullable<AbstractMesh>;
  51515. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51516. /**
  51517. * Creates a PositionGizmo
  51518. * @param gizmoLayer The utility layer the gizmo will be added to
  51519. */
  51520. constructor(gizmoLayer?: UtilityLayerRenderer);
  51521. /**
  51522. * If the planar drag gizmo is enabled
  51523. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51524. */
  51525. set planarGizmoEnabled(value: boolean);
  51526. get planarGizmoEnabled(): boolean;
  51527. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51528. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51529. /**
  51530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51531. */
  51532. set snapDistance(value: number);
  51533. get snapDistance(): number;
  51534. /**
  51535. * Ratio for the scale of the gizmo (Default: 1)
  51536. */
  51537. set scaleRatio(value: number);
  51538. get scaleRatio(): number;
  51539. /**
  51540. * Disposes of the gizmo
  51541. */
  51542. dispose(): void;
  51543. /**
  51544. * CustomMeshes are not supported by this gizmo
  51545. * @param mesh The mesh to replace the default mesh of the gizmo
  51546. */
  51547. setCustomMesh(mesh: Mesh): void;
  51548. }
  51549. }
  51550. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51551. import { Observable } from "babylonjs/Misc/observable";
  51552. import { Nullable } from "babylonjs/types";
  51553. import { Vector3 } from "babylonjs/Maths/math.vector";
  51554. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51556. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51557. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51558. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51559. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51560. import { Scene } from "babylonjs/scene";
  51561. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51562. import { Color3 } from "babylonjs/Maths/math.color";
  51563. /**
  51564. * Single axis drag gizmo
  51565. */
  51566. export class AxisDragGizmo extends Gizmo {
  51567. /**
  51568. * Drag behavior responsible for the gizmos dragging interactions
  51569. */
  51570. dragBehavior: PointerDragBehavior;
  51571. private _pointerObserver;
  51572. /**
  51573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51574. */
  51575. snapDistance: number;
  51576. /**
  51577. * Event that fires each time the gizmo snaps to a new location.
  51578. * * snapDistance is the the change in distance
  51579. */
  51580. onSnapObservable: Observable<{
  51581. snapDistance: number;
  51582. }>;
  51583. private _isEnabled;
  51584. private _parent;
  51585. private _arrow;
  51586. private _coloredMaterial;
  51587. private _hoverMaterial;
  51588. /** @hidden */
  51589. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51590. /** @hidden */
  51591. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51592. /**
  51593. * Creates an AxisDragGizmo
  51594. * @param gizmoLayer The utility layer the gizmo will be added to
  51595. * @param dragAxis The axis which the gizmo will be able to drag on
  51596. * @param color The color of the gizmo
  51597. */
  51598. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51600. /**
  51601. * If the gizmo is enabled
  51602. */
  51603. set isEnabled(value: boolean);
  51604. get isEnabled(): boolean;
  51605. /**
  51606. * Disposes of the gizmo
  51607. */
  51608. dispose(): void;
  51609. }
  51610. }
  51611. declare module "babylonjs/Debug/axesViewer" {
  51612. import { Vector3 } from "babylonjs/Maths/math.vector";
  51613. import { Nullable } from "babylonjs/types";
  51614. import { Scene } from "babylonjs/scene";
  51615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51616. /**
  51617. * The Axes viewer will show 3 axes in a specific point in space
  51618. */
  51619. export class AxesViewer {
  51620. private _xAxis;
  51621. private _yAxis;
  51622. private _zAxis;
  51623. private _scaleLinesFactor;
  51624. private _instanced;
  51625. /**
  51626. * Gets the hosting scene
  51627. */
  51628. scene: Scene;
  51629. /**
  51630. * Gets or sets a number used to scale line length
  51631. */
  51632. scaleLines: number;
  51633. /** Gets the node hierarchy used to render x-axis */
  51634. get xAxis(): TransformNode;
  51635. /** Gets the node hierarchy used to render y-axis */
  51636. get yAxis(): TransformNode;
  51637. /** Gets the node hierarchy used to render z-axis */
  51638. get zAxis(): TransformNode;
  51639. /**
  51640. * Creates a new AxesViewer
  51641. * @param scene defines the hosting scene
  51642. * @param scaleLines defines a number used to scale line length (1 by default)
  51643. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51644. * @param xAxis defines the node hierarchy used to render the x-axis
  51645. * @param yAxis defines the node hierarchy used to render the y-axis
  51646. * @param zAxis defines the node hierarchy used to render the z-axis
  51647. */
  51648. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51649. /**
  51650. * Force the viewer to update
  51651. * @param position defines the position of the viewer
  51652. * @param xaxis defines the x axis of the viewer
  51653. * @param yaxis defines the y axis of the viewer
  51654. * @param zaxis defines the z axis of the viewer
  51655. */
  51656. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51657. /**
  51658. * Creates an instance of this axes viewer.
  51659. * @returns a new axes viewer with instanced meshes
  51660. */
  51661. createInstance(): AxesViewer;
  51662. /** Releases resources */
  51663. dispose(): void;
  51664. private static _SetRenderingGroupId;
  51665. }
  51666. }
  51667. declare module "babylonjs/Debug/boneAxesViewer" {
  51668. import { Nullable } from "babylonjs/types";
  51669. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51670. import { Vector3 } from "babylonjs/Maths/math.vector";
  51671. import { Mesh } from "babylonjs/Meshes/mesh";
  51672. import { Bone } from "babylonjs/Bones/bone";
  51673. import { Scene } from "babylonjs/scene";
  51674. /**
  51675. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51676. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51677. */
  51678. export class BoneAxesViewer extends AxesViewer {
  51679. /**
  51680. * Gets or sets the target mesh where to display the axes viewer
  51681. */
  51682. mesh: Nullable<Mesh>;
  51683. /**
  51684. * Gets or sets the target bone where to display the axes viewer
  51685. */
  51686. bone: Nullable<Bone>;
  51687. /** Gets current position */
  51688. pos: Vector3;
  51689. /** Gets direction of X axis */
  51690. xaxis: Vector3;
  51691. /** Gets direction of Y axis */
  51692. yaxis: Vector3;
  51693. /** Gets direction of Z axis */
  51694. zaxis: Vector3;
  51695. /**
  51696. * Creates a new BoneAxesViewer
  51697. * @param scene defines the hosting scene
  51698. * @param bone defines the target bone
  51699. * @param mesh defines the target mesh
  51700. * @param scaleLines defines a scaling factor for line length (1 by default)
  51701. */
  51702. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51703. /**
  51704. * Force the viewer to update
  51705. */
  51706. update(): void;
  51707. /** Releases resources */
  51708. dispose(): void;
  51709. }
  51710. }
  51711. declare module "babylonjs/Debug/debugLayer" {
  51712. import { Scene } from "babylonjs/scene";
  51713. /**
  51714. * Interface used to define scene explorer extensibility option
  51715. */
  51716. export interface IExplorerExtensibilityOption {
  51717. /**
  51718. * Define the option label
  51719. */
  51720. label: string;
  51721. /**
  51722. * Defines the action to execute on click
  51723. */
  51724. action: (entity: any) => void;
  51725. }
  51726. /**
  51727. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51728. */
  51729. export interface IExplorerExtensibilityGroup {
  51730. /**
  51731. * Defines a predicate to test if a given type mut be extended
  51732. */
  51733. predicate: (entity: any) => boolean;
  51734. /**
  51735. * Gets the list of options added to a type
  51736. */
  51737. entries: IExplorerExtensibilityOption[];
  51738. }
  51739. /**
  51740. * Interface used to define the options to use to create the Inspector
  51741. */
  51742. export interface IInspectorOptions {
  51743. /**
  51744. * Display in overlay mode (default: false)
  51745. */
  51746. overlay?: boolean;
  51747. /**
  51748. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51749. */
  51750. globalRoot?: HTMLElement;
  51751. /**
  51752. * Display the Scene explorer
  51753. */
  51754. showExplorer?: boolean;
  51755. /**
  51756. * Display the property inspector
  51757. */
  51758. showInspector?: boolean;
  51759. /**
  51760. * Display in embed mode (both panes on the right)
  51761. */
  51762. embedMode?: boolean;
  51763. /**
  51764. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51765. */
  51766. handleResize?: boolean;
  51767. /**
  51768. * Allow the panes to popup (default: true)
  51769. */
  51770. enablePopup?: boolean;
  51771. /**
  51772. * Allow the panes to be closed by users (default: true)
  51773. */
  51774. enableClose?: boolean;
  51775. /**
  51776. * Optional list of extensibility entries
  51777. */
  51778. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51779. /**
  51780. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51781. */
  51782. inspectorURL?: string;
  51783. /**
  51784. * Optional initial tab (default to DebugLayerTab.Properties)
  51785. */
  51786. initialTab?: DebugLayerTab;
  51787. }
  51788. module "babylonjs/scene" {
  51789. interface Scene {
  51790. /**
  51791. * @hidden
  51792. * Backing field
  51793. */
  51794. _debugLayer: DebugLayer;
  51795. /**
  51796. * Gets the debug layer (aka Inspector) associated with the scene
  51797. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51798. */
  51799. debugLayer: DebugLayer;
  51800. }
  51801. }
  51802. /**
  51803. * Enum of inspector action tab
  51804. */
  51805. export enum DebugLayerTab {
  51806. /**
  51807. * Properties tag (default)
  51808. */
  51809. Properties = 0,
  51810. /**
  51811. * Debug tab
  51812. */
  51813. Debug = 1,
  51814. /**
  51815. * Statistics tab
  51816. */
  51817. Statistics = 2,
  51818. /**
  51819. * Tools tab
  51820. */
  51821. Tools = 3,
  51822. /**
  51823. * Settings tab
  51824. */
  51825. Settings = 4
  51826. }
  51827. /**
  51828. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51829. * what is happening in your scene
  51830. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51831. */
  51832. export class DebugLayer {
  51833. /**
  51834. * Define the url to get the inspector script from.
  51835. * By default it uses the babylonjs CDN.
  51836. * @ignoreNaming
  51837. */
  51838. static InspectorURL: string;
  51839. private _scene;
  51840. private BJSINSPECTOR;
  51841. private _onPropertyChangedObservable?;
  51842. /**
  51843. * Observable triggered when a property is changed through the inspector.
  51844. */
  51845. get onPropertyChangedObservable(): any;
  51846. /**
  51847. * Instantiates a new debug layer.
  51848. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51849. * what is happening in your scene
  51850. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51851. * @param scene Defines the scene to inspect
  51852. */
  51853. constructor(scene: Scene);
  51854. /** Creates the inspector window. */
  51855. private _createInspector;
  51856. /**
  51857. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51858. * @param entity defines the entity to select
  51859. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51860. */
  51861. select(entity: any, lineContainerTitles?: string | string[]): void;
  51862. /** Get the inspector from bundle or global */
  51863. private _getGlobalInspector;
  51864. /**
  51865. * Get if the inspector is visible or not.
  51866. * @returns true if visible otherwise, false
  51867. */
  51868. isVisible(): boolean;
  51869. /**
  51870. * Hide the inspector and close its window.
  51871. */
  51872. hide(): void;
  51873. /**
  51874. * Update the scene in the inspector
  51875. */
  51876. setAsActiveScene(): void;
  51877. /**
  51878. * Launch the debugLayer.
  51879. * @param config Define the configuration of the inspector
  51880. * @return a promise fulfilled when the debug layer is visible
  51881. */
  51882. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51883. }
  51884. }
  51885. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51886. import { Nullable } from "babylonjs/types";
  51887. import { Scene } from "babylonjs/scene";
  51888. import { Vector4 } from "babylonjs/Maths/math.vector";
  51889. import { Color4 } from "babylonjs/Maths/math.color";
  51890. import { Mesh } from "babylonjs/Meshes/mesh";
  51891. /**
  51892. * Class containing static functions to help procedurally build meshes
  51893. */
  51894. export class BoxBuilder {
  51895. /**
  51896. * Creates a box mesh
  51897. * * The parameter `size` sets the size (float) of each box side (default 1)
  51898. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51899. * * 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)
  51900. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51904. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51905. * @param name defines the name of the mesh
  51906. * @param options defines the options used to create the mesh
  51907. * @param scene defines the hosting scene
  51908. * @returns the box mesh
  51909. */
  51910. static CreateBox(name: string, options: {
  51911. size?: number;
  51912. width?: number;
  51913. height?: number;
  51914. depth?: number;
  51915. faceUV?: Vector4[];
  51916. faceColors?: Color4[];
  51917. sideOrientation?: number;
  51918. frontUVs?: Vector4;
  51919. backUVs?: Vector4;
  51920. wrap?: boolean;
  51921. topBaseAt?: number;
  51922. bottomBaseAt?: number;
  51923. updatable?: boolean;
  51924. }, scene?: Nullable<Scene>): Mesh;
  51925. }
  51926. }
  51927. declare module "babylonjs/Debug/physicsViewer" {
  51928. import { Nullable } from "babylonjs/types";
  51929. import { Scene } from "babylonjs/scene";
  51930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51931. import { Mesh } from "babylonjs/Meshes/mesh";
  51932. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51933. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51934. /**
  51935. * Used to show the physics impostor around the specific mesh
  51936. */
  51937. export class PhysicsViewer {
  51938. /** @hidden */
  51939. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51940. /** @hidden */
  51941. protected _meshes: Array<Nullable<AbstractMesh>>;
  51942. /** @hidden */
  51943. protected _scene: Nullable<Scene>;
  51944. /** @hidden */
  51945. protected _numMeshes: number;
  51946. /** @hidden */
  51947. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51948. private _renderFunction;
  51949. private _utilityLayer;
  51950. private _debugBoxMesh;
  51951. private _debugSphereMesh;
  51952. private _debugCylinderMesh;
  51953. private _debugMaterial;
  51954. private _debugMeshMeshes;
  51955. /**
  51956. * Creates a new PhysicsViewer
  51957. * @param scene defines the hosting scene
  51958. */
  51959. constructor(scene: Scene);
  51960. /** @hidden */
  51961. protected _updateDebugMeshes(): void;
  51962. /**
  51963. * Renders a specified physic impostor
  51964. * @param impostor defines the impostor to render
  51965. * @param targetMesh defines the mesh represented by the impostor
  51966. * @returns the new debug mesh used to render the impostor
  51967. */
  51968. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51969. /**
  51970. * Hides a specified physic impostor
  51971. * @param impostor defines the impostor to hide
  51972. */
  51973. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51974. private _getDebugMaterial;
  51975. private _getDebugBoxMesh;
  51976. private _getDebugSphereMesh;
  51977. private _getDebugCylinderMesh;
  51978. private _getDebugMeshMesh;
  51979. private _getDebugMesh;
  51980. /** Releases all resources */
  51981. dispose(): void;
  51982. }
  51983. }
  51984. declare module "babylonjs/Debug/rayHelper" {
  51985. import { Nullable } from "babylonjs/types";
  51986. import { Ray } from "babylonjs/Culling/ray";
  51987. import { Vector3 } from "babylonjs/Maths/math.vector";
  51988. import { Color3 } from "babylonjs/Maths/math.color";
  51989. import { Scene } from "babylonjs/scene";
  51990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51991. import "babylonjs/Meshes/Builders/linesBuilder";
  51992. /**
  51993. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51994. * in order to better appreciate the issue one might have.
  51995. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51996. */
  51997. export class RayHelper {
  51998. /**
  51999. * Defines the ray we are currently tryin to visualize.
  52000. */
  52001. ray: Nullable<Ray>;
  52002. private _renderPoints;
  52003. private _renderLine;
  52004. private _renderFunction;
  52005. private _scene;
  52006. private _updateToMeshFunction;
  52007. private _attachedToMesh;
  52008. private _meshSpaceDirection;
  52009. private _meshSpaceOrigin;
  52010. /**
  52011. * Helper function to create a colored helper in a scene in one line.
  52012. * @param ray Defines the ray we are currently tryin to visualize
  52013. * @param scene Defines the scene the ray is used in
  52014. * @param color Defines the color we want to see the ray in
  52015. * @returns The newly created ray helper.
  52016. */
  52017. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52018. /**
  52019. * Instantiate a new ray helper.
  52020. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52021. * in order to better appreciate the issue one might have.
  52022. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52023. * @param ray Defines the ray we are currently tryin to visualize
  52024. */
  52025. constructor(ray: Ray);
  52026. /**
  52027. * Shows the ray we are willing to debug.
  52028. * @param scene Defines the scene the ray needs to be rendered in
  52029. * @param color Defines the color the ray needs to be rendered in
  52030. */
  52031. show(scene: Scene, color?: Color3): void;
  52032. /**
  52033. * Hides the ray we are debugging.
  52034. */
  52035. hide(): void;
  52036. private _render;
  52037. /**
  52038. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52039. * @param mesh Defines the mesh we want the helper attached to
  52040. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52041. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52042. * @param length Defines the length of the ray
  52043. */
  52044. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52045. /**
  52046. * Detach the ray helper from the mesh it has previously been attached to.
  52047. */
  52048. detachFromMesh(): void;
  52049. private _updateToMesh;
  52050. /**
  52051. * Dispose the helper and release its associated resources.
  52052. */
  52053. dispose(): void;
  52054. }
  52055. }
  52056. declare module "babylonjs/Debug/skeletonViewer" {
  52057. import { Color3 } from "babylonjs/Maths/math.color";
  52058. import { Scene } from "babylonjs/scene";
  52059. import { Nullable } from "babylonjs/types";
  52060. import { Skeleton } from "babylonjs/Bones/skeleton";
  52061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52062. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52063. /**
  52064. * Class used to render a debug view of a given skeleton
  52065. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52066. */
  52067. export class SkeletonViewer {
  52068. /** defines the skeleton to render */
  52069. skeleton: Skeleton;
  52070. /** defines the mesh attached to the skeleton */
  52071. mesh: AbstractMesh;
  52072. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52073. autoUpdateBonesMatrices: boolean;
  52074. /** defines the rendering group id to use with the viewer */
  52075. renderingGroupId: number;
  52076. /** Gets or sets the color used to render the skeleton */
  52077. color: Color3;
  52078. private _scene;
  52079. private _debugLines;
  52080. private _debugMesh;
  52081. private _isEnabled;
  52082. private _renderFunction;
  52083. private _utilityLayer;
  52084. /**
  52085. * Returns the mesh used to render the bones
  52086. */
  52087. get debugMesh(): Nullable<LinesMesh>;
  52088. /**
  52089. * Creates a new SkeletonViewer
  52090. * @param skeleton defines the skeleton to render
  52091. * @param mesh defines the mesh attached to the skeleton
  52092. * @param scene defines the hosting scene
  52093. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52094. * @param renderingGroupId defines the rendering group id to use with the viewer
  52095. */
  52096. constructor(
  52097. /** defines the skeleton to render */
  52098. skeleton: Skeleton,
  52099. /** defines the mesh attached to the skeleton */
  52100. mesh: AbstractMesh, scene: Scene,
  52101. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52102. autoUpdateBonesMatrices?: boolean,
  52103. /** defines the rendering group id to use with the viewer */
  52104. renderingGroupId?: number);
  52105. /** Gets or sets a boolean indicating if the viewer is enabled */
  52106. set isEnabled(value: boolean);
  52107. get isEnabled(): boolean;
  52108. private _getBonePosition;
  52109. private _getLinesForBonesWithLength;
  52110. private _getLinesForBonesNoLength;
  52111. /** Update the viewer to sync with current skeleton state */
  52112. update(): void;
  52113. /** Release associated resources */
  52114. dispose(): void;
  52115. }
  52116. }
  52117. declare module "babylonjs/Debug/index" {
  52118. export * from "babylonjs/Debug/axesViewer";
  52119. export * from "babylonjs/Debug/boneAxesViewer";
  52120. export * from "babylonjs/Debug/debugLayer";
  52121. export * from "babylonjs/Debug/physicsViewer";
  52122. export * from "babylonjs/Debug/rayHelper";
  52123. export * from "babylonjs/Debug/skeletonViewer";
  52124. }
  52125. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52126. /**
  52127. * Enum for Device Types
  52128. */
  52129. export enum DeviceType {
  52130. /** Generic */
  52131. Generic = 0,
  52132. /** Keyboard */
  52133. Keyboard = 1,
  52134. /** Mouse */
  52135. Mouse = 2,
  52136. /** Touch Pointers */
  52137. Touch = 3,
  52138. /** PS4 Dual Shock */
  52139. DualShock = 4,
  52140. /** Xbox */
  52141. Xbox = 5,
  52142. /** Switch Controller */
  52143. Switch = 6
  52144. }
  52145. /**
  52146. * Enum for All Pointers (Touch/Mouse)
  52147. */
  52148. export enum PointerInput {
  52149. /** Horizontal Axis */
  52150. Horizontal = 0,
  52151. /** Vertical Axis */
  52152. Vertical = 1,
  52153. /** Left Click or Touch */
  52154. LeftClick = 2,
  52155. /** Middle Click */
  52156. MiddleClick = 3,
  52157. /** Right Click */
  52158. RightClick = 4,
  52159. /** Browser Back */
  52160. BrowserBack = 5,
  52161. /** Browser Forward */
  52162. BrowserForward = 6
  52163. }
  52164. /**
  52165. * Enum for Dual Shock Gamepad
  52166. */
  52167. export enum DualShockInput {
  52168. /** Cross */
  52169. Cross = 0,
  52170. /** Circle */
  52171. Circle = 1,
  52172. /** Square */
  52173. Square = 2,
  52174. /** Triangle */
  52175. Triangle = 3,
  52176. /** L1 */
  52177. L1 = 4,
  52178. /** R1 */
  52179. R1 = 5,
  52180. /** L2 */
  52181. L2 = 6,
  52182. /** R2 */
  52183. R2 = 7,
  52184. /** Share */
  52185. Share = 8,
  52186. /** Options */
  52187. Options = 9,
  52188. /** L3 */
  52189. L3 = 10,
  52190. /** R3 */
  52191. R3 = 11,
  52192. /** DPadUp */
  52193. DPadUp = 12,
  52194. /** DPadDown */
  52195. DPadDown = 13,
  52196. /** DPadLeft */
  52197. DPadLeft = 14,
  52198. /** DRight */
  52199. DPadRight = 15,
  52200. /** Home */
  52201. Home = 16,
  52202. /** TouchPad */
  52203. TouchPad = 17,
  52204. /** LStickXAxis */
  52205. LStickXAxis = 18,
  52206. /** LStickYAxis */
  52207. LStickYAxis = 19,
  52208. /** RStickXAxis */
  52209. RStickXAxis = 20,
  52210. /** RStickYAxis */
  52211. RStickYAxis = 21
  52212. }
  52213. /**
  52214. * Enum for Xbox Gamepad
  52215. */
  52216. export enum XboxInput {
  52217. /** A */
  52218. A = 0,
  52219. /** B */
  52220. B = 1,
  52221. /** X */
  52222. X = 2,
  52223. /** Y */
  52224. Y = 3,
  52225. /** LB */
  52226. LB = 4,
  52227. /** RB */
  52228. RB = 5,
  52229. /** LT */
  52230. LT = 6,
  52231. /** RT */
  52232. RT = 7,
  52233. /** Back */
  52234. Back = 8,
  52235. /** Start */
  52236. Start = 9,
  52237. /** LS */
  52238. LS = 10,
  52239. /** RS */
  52240. RS = 11,
  52241. /** DPadUp */
  52242. DPadUp = 12,
  52243. /** DPadDown */
  52244. DPadDown = 13,
  52245. /** DPadLeft */
  52246. DPadLeft = 14,
  52247. /** DRight */
  52248. DPadRight = 15,
  52249. /** Home */
  52250. Home = 16,
  52251. /** LStickXAxis */
  52252. LStickXAxis = 17,
  52253. /** LStickYAxis */
  52254. LStickYAxis = 18,
  52255. /** RStickXAxis */
  52256. RStickXAxis = 19,
  52257. /** RStickYAxis */
  52258. RStickYAxis = 20
  52259. }
  52260. /**
  52261. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52262. */
  52263. export enum SwitchInput {
  52264. /** B */
  52265. B = 0,
  52266. /** A */
  52267. A = 1,
  52268. /** Y */
  52269. Y = 2,
  52270. /** X */
  52271. X = 3,
  52272. /** L */
  52273. L = 4,
  52274. /** R */
  52275. R = 5,
  52276. /** ZL */
  52277. ZL = 6,
  52278. /** ZR */
  52279. ZR = 7,
  52280. /** Minus */
  52281. Minus = 8,
  52282. /** Plus */
  52283. Plus = 9,
  52284. /** LS */
  52285. LS = 10,
  52286. /** RS */
  52287. RS = 11,
  52288. /** DPadUp */
  52289. DPadUp = 12,
  52290. /** DPadDown */
  52291. DPadDown = 13,
  52292. /** DPadLeft */
  52293. DPadLeft = 14,
  52294. /** DRight */
  52295. DPadRight = 15,
  52296. /** Home */
  52297. Home = 16,
  52298. /** Capture */
  52299. Capture = 17,
  52300. /** LStickXAxis */
  52301. LStickXAxis = 18,
  52302. /** LStickYAxis */
  52303. LStickYAxis = 19,
  52304. /** RStickXAxis */
  52305. RStickXAxis = 20,
  52306. /** RStickYAxis */
  52307. RStickYAxis = 21
  52308. }
  52309. }
  52310. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52311. import { Engine } from "babylonjs/Engines/engine";
  52312. import { IDisposable } from "babylonjs/scene";
  52313. import { Nullable } from "babylonjs/types";
  52314. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52315. /**
  52316. * This class will take all inputs from Keyboard, Pointer, and
  52317. * any Gamepads and provide a polling system that all devices
  52318. * will use. This class assumes that there will only be one
  52319. * pointer device and one keyboard.
  52320. */
  52321. export class DeviceInputSystem implements IDisposable {
  52322. /**
  52323. * Callback to be triggered when a device is connected
  52324. */
  52325. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52326. /**
  52327. * Callback to be triggered when a device is disconnected
  52328. */
  52329. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52330. /**
  52331. * Callback to be triggered when event driven input is updated
  52332. */
  52333. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52334. private _inputs;
  52335. private _gamepads;
  52336. private _keyboardActive;
  52337. private _pointerActive;
  52338. private _elementToAttachTo;
  52339. private _keyboardDownEvent;
  52340. private _keyboardUpEvent;
  52341. private _pointerMoveEvent;
  52342. private _pointerDownEvent;
  52343. private _pointerUpEvent;
  52344. private _gamepadConnectedEvent;
  52345. private _gamepadDisconnectedEvent;
  52346. private static _MAX_KEYCODES;
  52347. private static _MAX_POINTER_INPUTS;
  52348. private constructor();
  52349. /**
  52350. * Creates a new DeviceInputSystem instance
  52351. * @param engine Engine to pull input element from
  52352. * @returns The new instance
  52353. */
  52354. static Create(engine: Engine): DeviceInputSystem;
  52355. /**
  52356. * Checks for current device input value, given an id and input index
  52357. * @param deviceName Id of connected device
  52358. * @param inputIndex Index of device input
  52359. * @returns Current value of input
  52360. */
  52361. /**
  52362. * Checks for current device input value, given an id and input index
  52363. * @param deviceType Enum specifiying device type
  52364. * @param deviceSlot "Slot" or index that device is referenced in
  52365. * @param inputIndex Id of input to be checked
  52366. * @returns Current value of input
  52367. */
  52368. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52369. /**
  52370. * Dispose of all the eventlisteners
  52371. */
  52372. dispose(): void;
  52373. /**
  52374. * Add device and inputs to device array
  52375. * @param deviceType Enum specifiying device type
  52376. * @param deviceSlot "Slot" or index that device is referenced in
  52377. * @param numberOfInputs Number of input entries to create for given device
  52378. */
  52379. private _registerDevice;
  52380. /**
  52381. * Given a specific device name, remove that device from the device map
  52382. * @param deviceType Enum specifiying device type
  52383. * @param deviceSlot "Slot" or index that device is referenced in
  52384. */
  52385. private _unregisterDevice;
  52386. /**
  52387. * Handle all actions that come from keyboard interaction
  52388. */
  52389. private _handleKeyActions;
  52390. /**
  52391. * Handle all actions that come from pointer interaction
  52392. */
  52393. private _handlePointerActions;
  52394. /**
  52395. * Handle all actions that come from gamepad interaction
  52396. */
  52397. private _handleGamepadActions;
  52398. /**
  52399. * Update all non-event based devices with each frame
  52400. * @param deviceType Enum specifiying device type
  52401. * @param deviceSlot "Slot" or index that device is referenced in
  52402. * @param inputIndex Id of input to be checked
  52403. */
  52404. private _updateDevice;
  52405. /**
  52406. * Gets DeviceType from the device name
  52407. * @param deviceName Name of Device from DeviceInputSystem
  52408. * @returns DeviceType enum value
  52409. */
  52410. private _getGamepadDeviceType;
  52411. }
  52412. }
  52413. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52414. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52415. /**
  52416. * Type to handle enforcement of inputs
  52417. */
  52418. 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;
  52419. }
  52420. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52421. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52422. import { Engine } from "babylonjs/Engines/engine";
  52423. import { IDisposable } from "babylonjs/scene";
  52424. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52425. import { Nullable } from "babylonjs/types";
  52426. import { Observable } from "babylonjs/Misc/observable";
  52427. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52428. /**
  52429. * Class that handles all input for a specific device
  52430. */
  52431. export class DeviceSource<T extends DeviceType> {
  52432. /** Type of device */
  52433. readonly deviceType: DeviceType;
  52434. /** "Slot" or index that device is referenced in */
  52435. readonly deviceSlot: number;
  52436. /**
  52437. * Observable to handle device input changes per device
  52438. */
  52439. readonly onInputChangedObservable: Observable<{
  52440. inputIndex: DeviceInput<T>;
  52441. previousState: Nullable<number>;
  52442. currentState: Nullable<number>;
  52443. }>;
  52444. private readonly _deviceInputSystem;
  52445. /**
  52446. * Default Constructor
  52447. * @param deviceInputSystem Reference to DeviceInputSystem
  52448. * @param deviceType Type of device
  52449. * @param deviceSlot "Slot" or index that device is referenced in
  52450. */
  52451. constructor(deviceInputSystem: DeviceInputSystem,
  52452. /** Type of device */
  52453. deviceType: DeviceType,
  52454. /** "Slot" or index that device is referenced in */
  52455. deviceSlot?: number);
  52456. /**
  52457. * Get input for specific input
  52458. * @param inputIndex index of specific input on device
  52459. * @returns Input value from DeviceInputSystem
  52460. */
  52461. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52462. }
  52463. /**
  52464. * Class to keep track of devices
  52465. */
  52466. export class DeviceSourceManager implements IDisposable {
  52467. /**
  52468. * Observable to be triggered when before a device is connected
  52469. */
  52470. readonly onBeforeDeviceConnectedObservable: Observable<{
  52471. deviceType: DeviceType;
  52472. deviceSlot: number;
  52473. }>;
  52474. /**
  52475. * Observable to be triggered when before a device is disconnected
  52476. */
  52477. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52478. deviceType: DeviceType;
  52479. deviceSlot: number;
  52480. }>;
  52481. /**
  52482. * Observable to be triggered when after a device is connected
  52483. */
  52484. readonly onAfterDeviceConnectedObservable: Observable<{
  52485. deviceType: DeviceType;
  52486. deviceSlot: number;
  52487. }>;
  52488. /**
  52489. * Observable to be triggered when after a device is disconnected
  52490. */
  52491. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52492. deviceType: DeviceType;
  52493. deviceSlot: number;
  52494. }>;
  52495. private readonly _devices;
  52496. private readonly _firstDevice;
  52497. private readonly _deviceInputSystem;
  52498. /**
  52499. * Default Constructor
  52500. * @param engine engine to pull input element from
  52501. */
  52502. constructor(engine: Engine);
  52503. /**
  52504. * Gets a DeviceSource, given a type and slot
  52505. * @param deviceType Enum specifying device type
  52506. * @param deviceSlot "Slot" or index that device is referenced in
  52507. * @returns DeviceSource object
  52508. */
  52509. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52510. /**
  52511. * Gets an array of DeviceSource objects for a given device type
  52512. * @param deviceType Enum specifying device type
  52513. * @returns Array of DeviceSource objects
  52514. */
  52515. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52516. /**
  52517. * Dispose of DeviceInputSystem and other parts
  52518. */
  52519. dispose(): void;
  52520. /**
  52521. * Function to add device name to device list
  52522. * @param deviceType Enum specifying device type
  52523. * @param deviceSlot "Slot" or index that device is referenced in
  52524. */
  52525. private _addDevice;
  52526. /**
  52527. * Function to remove device name to device list
  52528. * @param deviceType Enum specifying device type
  52529. * @param deviceSlot "Slot" or index that device is referenced in
  52530. */
  52531. private _removeDevice;
  52532. /**
  52533. * Updates array storing first connected device of each type
  52534. * @param type Type of Device
  52535. */
  52536. private _updateFirstDevices;
  52537. }
  52538. }
  52539. declare module "babylonjs/DeviceInput/index" {
  52540. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52541. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52542. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52543. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52544. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52545. }
  52546. declare module "babylonjs/Engines/nullEngine" {
  52547. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52548. import { Engine } from "babylonjs/Engines/engine";
  52549. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52550. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52552. import { Effect } from "babylonjs/Materials/effect";
  52553. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52554. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52555. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52556. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52557. /**
  52558. * Options to create the null engine
  52559. */
  52560. export class NullEngineOptions {
  52561. /**
  52562. * Render width (Default: 512)
  52563. */
  52564. renderWidth: number;
  52565. /**
  52566. * Render height (Default: 256)
  52567. */
  52568. renderHeight: number;
  52569. /**
  52570. * Texture size (Default: 512)
  52571. */
  52572. textureSize: number;
  52573. /**
  52574. * If delta time between frames should be constant
  52575. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52576. */
  52577. deterministicLockstep: boolean;
  52578. /**
  52579. * Maximum about of steps between frames (Default: 4)
  52580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52581. */
  52582. lockstepMaxSteps: number;
  52583. }
  52584. /**
  52585. * The null engine class provides support for headless version of babylon.js.
  52586. * This can be used in server side scenario or for testing purposes
  52587. */
  52588. export class NullEngine extends Engine {
  52589. private _options;
  52590. /**
  52591. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52592. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52593. * @returns true if engine is in deterministic lock step mode
  52594. */
  52595. isDeterministicLockStep(): boolean;
  52596. /**
  52597. * Gets the max steps when engine is running in deterministic lock step
  52598. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52599. * @returns the max steps
  52600. */
  52601. getLockstepMaxSteps(): number;
  52602. /**
  52603. * Gets the current hardware scaling level.
  52604. * By default the hardware scaling level is computed from the window device ratio.
  52605. * 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.
  52606. * @returns a number indicating the current hardware scaling level
  52607. */
  52608. getHardwareScalingLevel(): number;
  52609. constructor(options?: NullEngineOptions);
  52610. /**
  52611. * Creates a vertex buffer
  52612. * @param vertices the data for the vertex buffer
  52613. * @returns the new WebGL static buffer
  52614. */
  52615. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52616. /**
  52617. * Creates a new index buffer
  52618. * @param indices defines the content of the index buffer
  52619. * @param updatable defines if the index buffer must be updatable
  52620. * @returns a new webGL buffer
  52621. */
  52622. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52623. /**
  52624. * Clear the current render buffer or the current render target (if any is set up)
  52625. * @param color defines the color to use
  52626. * @param backBuffer defines if the back buffer must be cleared
  52627. * @param depth defines if the depth buffer must be cleared
  52628. * @param stencil defines if the stencil buffer must be cleared
  52629. */
  52630. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52631. /**
  52632. * Gets the current render width
  52633. * @param useScreen defines if screen size must be used (or the current render target if any)
  52634. * @returns a number defining the current render width
  52635. */
  52636. getRenderWidth(useScreen?: boolean): number;
  52637. /**
  52638. * Gets the current render height
  52639. * @param useScreen defines if screen size must be used (or the current render target if any)
  52640. * @returns a number defining the current render height
  52641. */
  52642. getRenderHeight(useScreen?: boolean): number;
  52643. /**
  52644. * Set the WebGL's viewport
  52645. * @param viewport defines the viewport element to be used
  52646. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52647. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52648. */
  52649. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52650. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52651. /**
  52652. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52653. * @param pipelineContext defines the pipeline context to use
  52654. * @param uniformsNames defines the list of uniform names
  52655. * @returns an array of webGL uniform locations
  52656. */
  52657. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52658. /**
  52659. * Gets the lsit of active attributes for a given webGL program
  52660. * @param pipelineContext defines the pipeline context to use
  52661. * @param attributesNames defines the list of attribute names to get
  52662. * @returns an array of indices indicating the offset of each attribute
  52663. */
  52664. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52665. /**
  52666. * Binds an effect to the webGL context
  52667. * @param effect defines the effect to bind
  52668. */
  52669. bindSamplers(effect: Effect): void;
  52670. /**
  52671. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52672. * @param effect defines the effect to activate
  52673. */
  52674. enableEffect(effect: Effect): void;
  52675. /**
  52676. * Set various states to the webGL context
  52677. * @param culling defines backface culling state
  52678. * @param zOffset defines the value to apply to zOffset (0 by default)
  52679. * @param force defines if states must be applied even if cache is up to date
  52680. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52681. */
  52682. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52683. /**
  52684. * Set the value of an uniform to an array of int32
  52685. * @param uniform defines the webGL uniform location where to store the value
  52686. * @param array defines the array of int32 to store
  52687. */
  52688. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52689. /**
  52690. * Set the value of an uniform to an array of int32 (stored as vec2)
  52691. * @param uniform defines the webGL uniform location where to store the value
  52692. * @param array defines the array of int32 to store
  52693. */
  52694. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52695. /**
  52696. * Set the value of an uniform to an array of int32 (stored as vec3)
  52697. * @param uniform defines the webGL uniform location where to store the value
  52698. * @param array defines the array of int32 to store
  52699. */
  52700. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52701. /**
  52702. * Set the value of an uniform to an array of int32 (stored as vec4)
  52703. * @param uniform defines the webGL uniform location where to store the value
  52704. * @param array defines the array of int32 to store
  52705. */
  52706. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52707. /**
  52708. * Set the value of an uniform to an array of float32
  52709. * @param uniform defines the webGL uniform location where to store the value
  52710. * @param array defines the array of float32 to store
  52711. */
  52712. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52713. /**
  52714. * Set the value of an uniform to an array of float32 (stored as vec2)
  52715. * @param uniform defines the webGL uniform location where to store the value
  52716. * @param array defines the array of float32 to store
  52717. */
  52718. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52719. /**
  52720. * Set the value of an uniform to an array of float32 (stored as vec3)
  52721. * @param uniform defines the webGL uniform location where to store the value
  52722. * @param array defines the array of float32 to store
  52723. */
  52724. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52725. /**
  52726. * Set the value of an uniform to an array of float32 (stored as vec4)
  52727. * @param uniform defines the webGL uniform location where to store the value
  52728. * @param array defines the array of float32 to store
  52729. */
  52730. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52731. /**
  52732. * Set the value of an uniform to an array of number
  52733. * @param uniform defines the webGL uniform location where to store the value
  52734. * @param array defines the array of number to store
  52735. */
  52736. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52737. /**
  52738. * Set the value of an uniform to an array of number (stored as vec2)
  52739. * @param uniform defines the webGL uniform location where to store the value
  52740. * @param array defines the array of number to store
  52741. */
  52742. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52743. /**
  52744. * Set the value of an uniform to an array of number (stored as vec3)
  52745. * @param uniform defines the webGL uniform location where to store the value
  52746. * @param array defines the array of number to store
  52747. */
  52748. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52749. /**
  52750. * Set the value of an uniform to an array of number (stored as vec4)
  52751. * @param uniform defines the webGL uniform location where to store the value
  52752. * @param array defines the array of number to store
  52753. */
  52754. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52755. /**
  52756. * Set the value of an uniform to an array of float32 (stored as matrices)
  52757. * @param uniform defines the webGL uniform location where to store the value
  52758. * @param matrices defines the array of float32 to store
  52759. */
  52760. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52761. /**
  52762. * Set the value of an uniform to a matrix (3x3)
  52763. * @param uniform defines the webGL uniform location where to store the value
  52764. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52765. */
  52766. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52767. /**
  52768. * Set the value of an uniform to a matrix (2x2)
  52769. * @param uniform defines the webGL uniform location where to store the value
  52770. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52771. */
  52772. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52773. /**
  52774. * Set the value of an uniform to a number (float)
  52775. * @param uniform defines the webGL uniform location where to store the value
  52776. * @param value defines the float number to store
  52777. */
  52778. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52779. /**
  52780. * Set the value of an uniform to a vec2
  52781. * @param uniform defines the webGL uniform location where to store the value
  52782. * @param x defines the 1st component of the value
  52783. * @param y defines the 2nd component of the value
  52784. */
  52785. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52786. /**
  52787. * Set the value of an uniform to a vec3
  52788. * @param uniform defines the webGL uniform location where to store the value
  52789. * @param x defines the 1st component of the value
  52790. * @param y defines the 2nd component of the value
  52791. * @param z defines the 3rd component of the value
  52792. */
  52793. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52794. /**
  52795. * Set the value of an uniform to a boolean
  52796. * @param uniform defines the webGL uniform location where to store the value
  52797. * @param bool defines the boolean to store
  52798. */
  52799. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52800. /**
  52801. * Set the value of an uniform to a vec4
  52802. * @param uniform defines the webGL uniform location where to store the value
  52803. * @param x defines the 1st component of the value
  52804. * @param y defines the 2nd component of the value
  52805. * @param z defines the 3rd component of the value
  52806. * @param w defines the 4th component of the value
  52807. */
  52808. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52809. /**
  52810. * Sets the current alpha mode
  52811. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52812. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52813. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52814. */
  52815. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52816. /**
  52817. * Bind webGl buffers directly to the webGL context
  52818. * @param vertexBuffers defines the vertex buffer to bind
  52819. * @param indexBuffer defines the index buffer to bind
  52820. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52821. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52822. * @param effect defines the effect associated with the vertex buffer
  52823. */
  52824. bindBuffers(vertexBuffers: {
  52825. [key: string]: VertexBuffer;
  52826. }, indexBuffer: DataBuffer, effect: Effect): void;
  52827. /**
  52828. * Force the entire cache to be cleared
  52829. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52830. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52831. */
  52832. wipeCaches(bruteForce?: boolean): void;
  52833. /**
  52834. * Send a draw order
  52835. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52836. * @param indexStart defines the starting index
  52837. * @param indexCount defines the number of index to draw
  52838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52839. */
  52840. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52841. /**
  52842. * Draw a list of indexed primitives
  52843. * @param fillMode defines the primitive to use
  52844. * @param indexStart defines the starting index
  52845. * @param indexCount defines the number of index to draw
  52846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52847. */
  52848. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52849. /**
  52850. * Draw a list of unindexed primitives
  52851. * @param fillMode defines the primitive to use
  52852. * @param verticesStart defines the index of first vertex to draw
  52853. * @param verticesCount defines the count of vertices to draw
  52854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52855. */
  52856. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52857. /** @hidden */
  52858. _createTexture(): WebGLTexture;
  52859. /** @hidden */
  52860. _releaseTexture(texture: InternalTexture): void;
  52861. /**
  52862. * Usually called from Texture.ts.
  52863. * Passed information to create a WebGLTexture
  52864. * @param urlArg defines a value which contains one of the following:
  52865. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52866. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52867. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52868. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52869. * @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)
  52870. * @param scene needed for loading to the correct scene
  52871. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52872. * @param onLoad optional callback to be called upon successful completion
  52873. * @param onError optional callback to be called upon failure
  52874. * @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
  52875. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52876. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52877. * @param forcedExtension defines the extension to use to pick the right loader
  52878. * @param mimeType defines an optional mime type
  52879. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52880. */
  52881. 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;
  52882. /**
  52883. * Creates a new render target texture
  52884. * @param size defines the size of the texture
  52885. * @param options defines the options used to create the texture
  52886. * @returns a new render target texture stored in an InternalTexture
  52887. */
  52888. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52889. /**
  52890. * Update the sampling mode of a given texture
  52891. * @param samplingMode defines the required sampling mode
  52892. * @param texture defines the texture to update
  52893. */
  52894. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52895. /**
  52896. * Binds the frame buffer to the specified texture.
  52897. * @param texture The texture to render to or null for the default canvas
  52898. * @param faceIndex The face of the texture to render to in case of cube texture
  52899. * @param requiredWidth The width of the target to render to
  52900. * @param requiredHeight The height of the target to render to
  52901. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52902. * @param lodLevel defines le lod level to bind to the frame buffer
  52903. */
  52904. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52905. /**
  52906. * Unbind the current render target texture from the webGL context
  52907. * @param texture defines the render target texture to unbind
  52908. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52909. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52910. */
  52911. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52912. /**
  52913. * Creates a dynamic vertex buffer
  52914. * @param vertices the data for the dynamic vertex buffer
  52915. * @returns the new WebGL dynamic buffer
  52916. */
  52917. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52918. /**
  52919. * Update the content of a dynamic texture
  52920. * @param texture defines the texture to update
  52921. * @param canvas defines the canvas containing the source
  52922. * @param invertY defines if data must be stored with Y axis inverted
  52923. * @param premulAlpha defines if alpha is stored as premultiplied
  52924. * @param format defines the format of the data
  52925. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52926. */
  52927. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52928. /**
  52929. * Gets a boolean indicating if all created effects are ready
  52930. * @returns true if all effects are ready
  52931. */
  52932. areAllEffectsReady(): boolean;
  52933. /**
  52934. * @hidden
  52935. * Get the current error code of the webGL context
  52936. * @returns the error code
  52937. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52938. */
  52939. getError(): number;
  52940. /** @hidden */
  52941. _getUnpackAlignement(): number;
  52942. /** @hidden */
  52943. _unpackFlipY(value: boolean): void;
  52944. /**
  52945. * Update a dynamic index buffer
  52946. * @param indexBuffer defines the target index buffer
  52947. * @param indices defines the data to update
  52948. * @param offset defines the offset in the target index buffer where update should start
  52949. */
  52950. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52951. /**
  52952. * Updates a dynamic vertex buffer.
  52953. * @param vertexBuffer the vertex buffer to update
  52954. * @param vertices the data used to update the vertex buffer
  52955. * @param byteOffset the byte offset of the data (optional)
  52956. * @param byteLength the byte length of the data (optional)
  52957. */
  52958. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52959. /** @hidden */
  52960. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52961. /** @hidden */
  52962. _bindTexture(channel: number, texture: InternalTexture): void;
  52963. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52964. /**
  52965. * 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
  52966. */
  52967. releaseEffects(): void;
  52968. displayLoadingUI(): void;
  52969. hideLoadingUI(): void;
  52970. /** @hidden */
  52971. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52972. /** @hidden */
  52973. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52974. /** @hidden */
  52975. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52976. /** @hidden */
  52977. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52978. }
  52979. }
  52980. declare module "babylonjs/Instrumentation/timeToken" {
  52981. import { Nullable } from "babylonjs/types";
  52982. /**
  52983. * @hidden
  52984. **/
  52985. export class _TimeToken {
  52986. _startTimeQuery: Nullable<WebGLQuery>;
  52987. _endTimeQuery: Nullable<WebGLQuery>;
  52988. _timeElapsedQuery: Nullable<WebGLQuery>;
  52989. _timeElapsedQueryEnded: boolean;
  52990. }
  52991. }
  52992. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52993. import { Nullable, int } from "babylonjs/types";
  52994. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52995. /** @hidden */
  52996. export class _OcclusionDataStorage {
  52997. /** @hidden */
  52998. occlusionInternalRetryCounter: number;
  52999. /** @hidden */
  53000. isOcclusionQueryInProgress: boolean;
  53001. /** @hidden */
  53002. isOccluded: boolean;
  53003. /** @hidden */
  53004. occlusionRetryCount: number;
  53005. /** @hidden */
  53006. occlusionType: number;
  53007. /** @hidden */
  53008. occlusionQueryAlgorithmType: number;
  53009. }
  53010. module "babylonjs/Engines/engine" {
  53011. interface Engine {
  53012. /**
  53013. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53014. * @return the new query
  53015. */
  53016. createQuery(): WebGLQuery;
  53017. /**
  53018. * Delete and release a webGL query
  53019. * @param query defines the query to delete
  53020. * @return the current engine
  53021. */
  53022. deleteQuery(query: WebGLQuery): Engine;
  53023. /**
  53024. * Check if a given query has resolved and got its value
  53025. * @param query defines the query to check
  53026. * @returns true if the query got its value
  53027. */
  53028. isQueryResultAvailable(query: WebGLQuery): boolean;
  53029. /**
  53030. * Gets the value of a given query
  53031. * @param query defines the query to check
  53032. * @returns the value of the query
  53033. */
  53034. getQueryResult(query: WebGLQuery): number;
  53035. /**
  53036. * Initiates an occlusion query
  53037. * @param algorithmType defines the algorithm to use
  53038. * @param query defines the query to use
  53039. * @returns the current engine
  53040. * @see https://doc.babylonjs.com/features/occlusionquery
  53041. */
  53042. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53043. /**
  53044. * Ends an occlusion query
  53045. * @see https://doc.babylonjs.com/features/occlusionquery
  53046. * @param algorithmType defines the algorithm to use
  53047. * @returns the current engine
  53048. */
  53049. endOcclusionQuery(algorithmType: number): Engine;
  53050. /**
  53051. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53052. * Please note that only one query can be issued at a time
  53053. * @returns a time token used to track the time span
  53054. */
  53055. startTimeQuery(): Nullable<_TimeToken>;
  53056. /**
  53057. * Ends a time query
  53058. * @param token defines the token used to measure the time span
  53059. * @returns the time spent (in ns)
  53060. */
  53061. endTimeQuery(token: _TimeToken): int;
  53062. /** @hidden */
  53063. _currentNonTimestampToken: Nullable<_TimeToken>;
  53064. /** @hidden */
  53065. _createTimeQuery(): WebGLQuery;
  53066. /** @hidden */
  53067. _deleteTimeQuery(query: WebGLQuery): void;
  53068. /** @hidden */
  53069. _getGlAlgorithmType(algorithmType: number): number;
  53070. /** @hidden */
  53071. _getTimeQueryResult(query: WebGLQuery): any;
  53072. /** @hidden */
  53073. _getTimeQueryAvailability(query: WebGLQuery): any;
  53074. }
  53075. }
  53076. module "babylonjs/Meshes/abstractMesh" {
  53077. interface AbstractMesh {
  53078. /**
  53079. * Backing filed
  53080. * @hidden
  53081. */
  53082. __occlusionDataStorage: _OcclusionDataStorage;
  53083. /**
  53084. * Access property
  53085. * @hidden
  53086. */
  53087. _occlusionDataStorage: _OcclusionDataStorage;
  53088. /**
  53089. * 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.
  53090. * The default value is -1 which means don't break the query and wait till the result
  53091. * @see https://doc.babylonjs.com/features/occlusionquery
  53092. */
  53093. occlusionRetryCount: number;
  53094. /**
  53095. * 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:
  53096. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53097. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53098. * * 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.
  53099. * @see https://doc.babylonjs.com/features/occlusionquery
  53100. */
  53101. occlusionType: number;
  53102. /**
  53103. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53104. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53105. * * 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.
  53106. * @see https://doc.babylonjs.com/features/occlusionquery
  53107. */
  53108. occlusionQueryAlgorithmType: number;
  53109. /**
  53110. * 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
  53111. * @see https://doc.babylonjs.com/features/occlusionquery
  53112. */
  53113. isOccluded: boolean;
  53114. /**
  53115. * Flag to check the progress status of the query
  53116. * @see https://doc.babylonjs.com/features/occlusionquery
  53117. */
  53118. isOcclusionQueryInProgress: boolean;
  53119. }
  53120. }
  53121. }
  53122. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53123. import { Nullable } from "babylonjs/types";
  53124. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53125. /** @hidden */
  53126. export var _forceTransformFeedbackToBundle: boolean;
  53127. module "babylonjs/Engines/engine" {
  53128. interface Engine {
  53129. /**
  53130. * Creates a webGL transform feedback object
  53131. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53132. * @returns the webGL transform feedback object
  53133. */
  53134. createTransformFeedback(): WebGLTransformFeedback;
  53135. /**
  53136. * Delete a webGL transform feedback object
  53137. * @param value defines the webGL transform feedback object to delete
  53138. */
  53139. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53140. /**
  53141. * Bind a webGL transform feedback object to the webgl context
  53142. * @param value defines the webGL transform feedback object to bind
  53143. */
  53144. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53145. /**
  53146. * Begins a transform feedback operation
  53147. * @param usePoints defines if points or triangles must be used
  53148. */
  53149. beginTransformFeedback(usePoints: boolean): void;
  53150. /**
  53151. * Ends a transform feedback operation
  53152. */
  53153. endTransformFeedback(): void;
  53154. /**
  53155. * Specify the varyings to use with transform feedback
  53156. * @param program defines the associated webGL program
  53157. * @param value defines the list of strings representing the varying names
  53158. */
  53159. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53160. /**
  53161. * Bind a webGL buffer for a transform feedback operation
  53162. * @param value defines the webGL buffer to bind
  53163. */
  53164. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53165. }
  53166. }
  53167. }
  53168. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53169. import { Scene } from "babylonjs/scene";
  53170. import { Engine } from "babylonjs/Engines/engine";
  53171. import { Texture } from "babylonjs/Materials/Textures/texture";
  53172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53173. import "babylonjs/Engines/Extensions/engine.multiRender";
  53174. /**
  53175. * Creation options of the multi render target texture.
  53176. */
  53177. export interface IMultiRenderTargetOptions {
  53178. /**
  53179. * Define if the texture needs to create mip maps after render.
  53180. */
  53181. generateMipMaps?: boolean;
  53182. /**
  53183. * Define the types of all the draw buffers we want to create
  53184. */
  53185. types?: number[];
  53186. /**
  53187. * Define the sampling modes of all the draw buffers we want to create
  53188. */
  53189. samplingModes?: number[];
  53190. /**
  53191. * Define if a depth buffer is required
  53192. */
  53193. generateDepthBuffer?: boolean;
  53194. /**
  53195. * Define if a stencil buffer is required
  53196. */
  53197. generateStencilBuffer?: boolean;
  53198. /**
  53199. * Define if a depth texture is required instead of a depth buffer
  53200. */
  53201. generateDepthTexture?: boolean;
  53202. /**
  53203. * Define the number of desired draw buffers
  53204. */
  53205. textureCount?: number;
  53206. /**
  53207. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53208. */
  53209. doNotChangeAspectRatio?: boolean;
  53210. /**
  53211. * Define the default type of the buffers we are creating
  53212. */
  53213. defaultType?: number;
  53214. }
  53215. /**
  53216. * A multi render target, like a render target provides the ability to render to a texture.
  53217. * Unlike the render target, it can render to several draw buffers in one draw.
  53218. * This is specially interesting in deferred rendering or for any effects requiring more than
  53219. * just one color from a single pass.
  53220. */
  53221. export class MultiRenderTarget extends RenderTargetTexture {
  53222. private _internalTextures;
  53223. private _textures;
  53224. private _multiRenderTargetOptions;
  53225. private _count;
  53226. /**
  53227. * Get if draw buffers are currently supported by the used hardware and browser.
  53228. */
  53229. get isSupported(): boolean;
  53230. /**
  53231. * Get the list of textures generated by the multi render target.
  53232. */
  53233. get textures(): Texture[];
  53234. /**
  53235. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53236. */
  53237. get count(): number;
  53238. /**
  53239. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53240. */
  53241. get depthTexture(): Texture;
  53242. /**
  53243. * Set the wrapping mode on U of all the textures we are rendering to.
  53244. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53245. */
  53246. set wrapU(wrap: number);
  53247. /**
  53248. * Set the wrapping mode on V of all the textures we are rendering to.
  53249. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53250. */
  53251. set wrapV(wrap: number);
  53252. /**
  53253. * Instantiate a new multi render target texture.
  53254. * A multi render target, like a render target provides the ability to render to a texture.
  53255. * Unlike the render target, it can render to several draw buffers in one draw.
  53256. * This is specially interesting in deferred rendering or for any effects requiring more than
  53257. * just one color from a single pass.
  53258. * @param name Define the name of the texture
  53259. * @param size Define the size of the buffers to render to
  53260. * @param count Define the number of target we are rendering into
  53261. * @param scene Define the scene the texture belongs to
  53262. * @param options Define the options used to create the multi render target
  53263. */
  53264. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53265. /** @hidden */
  53266. _rebuild(): void;
  53267. private _createInternalTextures;
  53268. private _createTextures;
  53269. /**
  53270. * Define the number of samples used if MSAA is enabled.
  53271. */
  53272. get samples(): number;
  53273. set samples(value: number);
  53274. /**
  53275. * Resize all the textures in the multi render target.
  53276. * Be carrefull as it will recreate all the data in the new texture.
  53277. * @param size Define the new size
  53278. */
  53279. resize(size: any): void;
  53280. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53281. /**
  53282. * Dispose the render targets and their associated resources
  53283. */
  53284. dispose(): void;
  53285. /**
  53286. * Release all the underlying texture used as draw buffers.
  53287. */
  53288. releaseInternalTextures(): void;
  53289. }
  53290. }
  53291. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53293. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53294. import { Nullable } from "babylonjs/types";
  53295. module "babylonjs/Engines/thinEngine" {
  53296. interface ThinEngine {
  53297. /**
  53298. * Unbind a list of render target textures from the webGL context
  53299. * This is used only when drawBuffer extension or webGL2 are active
  53300. * @param textures defines the render target textures to unbind
  53301. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53302. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53303. */
  53304. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53305. /**
  53306. * Create a multi render target texture
  53307. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53308. * @param size defines the size of the texture
  53309. * @param options defines the creation options
  53310. * @returns the cube texture as an InternalTexture
  53311. */
  53312. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53313. /**
  53314. * Update the sample count for a given multiple render target texture
  53315. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53316. * @param textures defines the textures to update
  53317. * @param samples defines the sample count to set
  53318. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53319. */
  53320. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53321. /**
  53322. * Select a subsets of attachments to draw to.
  53323. * @param attachments gl attachments
  53324. */
  53325. bindAttachments(attachments: number[]): void;
  53326. }
  53327. }
  53328. }
  53329. declare module "babylonjs/Engines/Extensions/engine.views" {
  53330. import { Camera } from "babylonjs/Cameras/camera";
  53331. import { Nullable } from "babylonjs/types";
  53332. /**
  53333. * Class used to define an additional view for the engine
  53334. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53335. */
  53336. export class EngineView {
  53337. /** Defines the canvas where to render the view */
  53338. target: HTMLCanvasElement;
  53339. /** Defines an optional camera used to render the view (will use active camera else) */
  53340. camera?: Camera;
  53341. }
  53342. module "babylonjs/Engines/engine" {
  53343. interface Engine {
  53344. /**
  53345. * Gets or sets the HTML element to use for attaching events
  53346. */
  53347. inputElement: Nullable<HTMLElement>;
  53348. /**
  53349. * Gets the current engine view
  53350. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53351. */
  53352. activeView: Nullable<EngineView>;
  53353. /** Gets or sets the list of views */
  53354. views: EngineView[];
  53355. /**
  53356. * Register a new child canvas
  53357. * @param canvas defines the canvas to register
  53358. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53359. * @returns the associated view
  53360. */
  53361. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53362. /**
  53363. * Remove a registered child canvas
  53364. * @param canvas defines the canvas to remove
  53365. * @returns the current engine
  53366. */
  53367. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53368. }
  53369. }
  53370. }
  53371. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53372. import { Nullable } from "babylonjs/types";
  53373. module "babylonjs/Engines/engine" {
  53374. interface Engine {
  53375. /** @hidden */
  53376. _excludedCompressedTextures: string[];
  53377. /** @hidden */
  53378. _textureFormatInUse: string;
  53379. /**
  53380. * Gets the list of texture formats supported
  53381. */
  53382. readonly texturesSupported: Array<string>;
  53383. /**
  53384. * Gets the texture format in use
  53385. */
  53386. readonly textureFormatInUse: Nullable<string>;
  53387. /**
  53388. * Set the compressed texture extensions or file names to skip.
  53389. *
  53390. * @param skippedFiles defines the list of those texture files you want to skip
  53391. * Example: [".dds", ".env", "myfile.png"]
  53392. */
  53393. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53394. /**
  53395. * Set the compressed texture format to use, based on the formats you have, and the formats
  53396. * supported by the hardware / browser.
  53397. *
  53398. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53399. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53400. * to API arguments needed to compressed textures. This puts the burden on the container
  53401. * generator to house the arcane code for determining these for current & future formats.
  53402. *
  53403. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53404. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53405. *
  53406. * Note: The result of this call is not taken into account when a texture is base64.
  53407. *
  53408. * @param formatsAvailable defines the list of those format families you have created
  53409. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53410. *
  53411. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53412. * @returns The extension selected.
  53413. */
  53414. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53415. }
  53416. }
  53417. }
  53418. declare module "babylonjs/Engines/Extensions/index" {
  53419. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53420. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53421. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53422. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53423. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53424. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53425. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53426. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53427. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53428. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53429. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53430. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53431. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53432. export * from "babylonjs/Engines/Extensions/engine.views";
  53433. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53434. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53435. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53436. }
  53437. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53438. import { Nullable } from "babylonjs/types";
  53439. /**
  53440. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53441. */
  53442. export interface CubeMapInfo {
  53443. /**
  53444. * The pixel array for the front face.
  53445. * This is stored in format, left to right, up to down format.
  53446. */
  53447. front: Nullable<ArrayBufferView>;
  53448. /**
  53449. * The pixel array for the back face.
  53450. * This is stored in format, left to right, up to down format.
  53451. */
  53452. back: Nullable<ArrayBufferView>;
  53453. /**
  53454. * The pixel array for the left face.
  53455. * This is stored in format, left to right, up to down format.
  53456. */
  53457. left: Nullable<ArrayBufferView>;
  53458. /**
  53459. * The pixel array for the right face.
  53460. * This is stored in format, left to right, up to down format.
  53461. */
  53462. right: Nullable<ArrayBufferView>;
  53463. /**
  53464. * The pixel array for the up face.
  53465. * This is stored in format, left to right, up to down format.
  53466. */
  53467. up: Nullable<ArrayBufferView>;
  53468. /**
  53469. * The pixel array for the down face.
  53470. * This is stored in format, left to right, up to down format.
  53471. */
  53472. down: Nullable<ArrayBufferView>;
  53473. /**
  53474. * The size of the cubemap stored.
  53475. *
  53476. * Each faces will be size * size pixels.
  53477. */
  53478. size: number;
  53479. /**
  53480. * The format of the texture.
  53481. *
  53482. * RGBA, RGB.
  53483. */
  53484. format: number;
  53485. /**
  53486. * The type of the texture data.
  53487. *
  53488. * UNSIGNED_INT, FLOAT.
  53489. */
  53490. type: number;
  53491. /**
  53492. * Specifies whether the texture is in gamma space.
  53493. */
  53494. gammaSpace: boolean;
  53495. }
  53496. /**
  53497. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53498. */
  53499. export class PanoramaToCubeMapTools {
  53500. private static FACE_LEFT;
  53501. private static FACE_RIGHT;
  53502. private static FACE_FRONT;
  53503. private static FACE_BACK;
  53504. private static FACE_DOWN;
  53505. private static FACE_UP;
  53506. /**
  53507. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53508. *
  53509. * @param float32Array The source data.
  53510. * @param inputWidth The width of the input panorama.
  53511. * @param inputHeight The height of the input panorama.
  53512. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53513. * @return The cubemap data
  53514. */
  53515. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53516. private static CreateCubemapTexture;
  53517. private static CalcProjectionSpherical;
  53518. }
  53519. }
  53520. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53521. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53523. import { Nullable } from "babylonjs/types";
  53524. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53525. /**
  53526. * Helper class dealing with the extraction of spherical polynomial dataArray
  53527. * from a cube map.
  53528. */
  53529. export class CubeMapToSphericalPolynomialTools {
  53530. private static FileFaces;
  53531. /**
  53532. * Converts a texture to the according Spherical Polynomial data.
  53533. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53534. *
  53535. * @param texture The texture to extract the information from.
  53536. * @return The Spherical Polynomial data.
  53537. */
  53538. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53539. /**
  53540. * Converts a cubemap to the according Spherical Polynomial data.
  53541. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53542. *
  53543. * @param cubeInfo The Cube map to extract the information from.
  53544. * @return The Spherical Polynomial data.
  53545. */
  53546. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53547. }
  53548. }
  53549. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53550. import { Nullable } from "babylonjs/types";
  53551. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53552. module "babylonjs/Materials/Textures/baseTexture" {
  53553. interface BaseTexture {
  53554. /**
  53555. * Get the polynomial representation of the texture data.
  53556. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53557. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53558. */
  53559. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53560. }
  53561. }
  53562. }
  53563. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53565. /** @hidden */
  53566. export var rgbdEncodePixelShader: {
  53567. name: string;
  53568. shader: string;
  53569. };
  53570. }
  53571. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53572. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53573. /** @hidden */
  53574. export var rgbdDecodePixelShader: {
  53575. name: string;
  53576. shader: string;
  53577. };
  53578. }
  53579. declare module "babylonjs/Misc/environmentTextureTools" {
  53580. import { Nullable } from "babylonjs/types";
  53581. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53584. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53585. import "babylonjs/Engines/Extensions/engine.readTexture";
  53586. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53587. import "babylonjs/Shaders/rgbdEncode.fragment";
  53588. import "babylonjs/Shaders/rgbdDecode.fragment";
  53589. /**
  53590. * Raw texture data and descriptor sufficient for WebGL texture upload
  53591. */
  53592. export interface EnvironmentTextureInfo {
  53593. /**
  53594. * Version of the environment map
  53595. */
  53596. version: number;
  53597. /**
  53598. * Width of image
  53599. */
  53600. width: number;
  53601. /**
  53602. * Irradiance information stored in the file.
  53603. */
  53604. irradiance: any;
  53605. /**
  53606. * Specular information stored in the file.
  53607. */
  53608. specular: any;
  53609. }
  53610. /**
  53611. * Defines One Image in the file. It requires only the position in the file
  53612. * as well as the length.
  53613. */
  53614. interface BufferImageData {
  53615. /**
  53616. * Length of the image data.
  53617. */
  53618. length: number;
  53619. /**
  53620. * Position of the data from the null terminator delimiting the end of the JSON.
  53621. */
  53622. position: number;
  53623. }
  53624. /**
  53625. * Defines the specular data enclosed in the file.
  53626. * This corresponds to the version 1 of the data.
  53627. */
  53628. export interface EnvironmentTextureSpecularInfoV1 {
  53629. /**
  53630. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53631. */
  53632. specularDataPosition?: number;
  53633. /**
  53634. * This contains all the images data needed to reconstruct the cubemap.
  53635. */
  53636. mipmaps: Array<BufferImageData>;
  53637. /**
  53638. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53639. */
  53640. lodGenerationScale: number;
  53641. }
  53642. /**
  53643. * Sets of helpers addressing the serialization and deserialization of environment texture
  53644. * stored in a BabylonJS env file.
  53645. * Those files are usually stored as .env files.
  53646. */
  53647. export class EnvironmentTextureTools {
  53648. /**
  53649. * Magic number identifying the env file.
  53650. */
  53651. private static _MagicBytes;
  53652. /**
  53653. * Gets the environment info from an env file.
  53654. * @param data The array buffer containing the .env bytes.
  53655. * @returns the environment file info (the json header) if successfully parsed.
  53656. */
  53657. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53658. /**
  53659. * Creates an environment texture from a loaded cube texture.
  53660. * @param texture defines the cube texture to convert in env file
  53661. * @return a promise containing the environment data if succesfull.
  53662. */
  53663. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53664. /**
  53665. * Creates a JSON representation of the spherical data.
  53666. * @param texture defines the texture containing the polynomials
  53667. * @return the JSON representation of the spherical info
  53668. */
  53669. private static _CreateEnvTextureIrradiance;
  53670. /**
  53671. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53672. * @param data the image data
  53673. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53674. * @return the views described by info providing access to the underlying buffer
  53675. */
  53676. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53677. /**
  53678. * Uploads the texture info contained in the env file to the GPU.
  53679. * @param texture defines the internal texture to upload to
  53680. * @param data defines the data to load
  53681. * @param info defines the texture info retrieved through the GetEnvInfo method
  53682. * @returns a promise
  53683. */
  53684. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53685. private static _OnImageReadyAsync;
  53686. /**
  53687. * Uploads the levels of image data to the GPU.
  53688. * @param texture defines the internal texture to upload to
  53689. * @param imageData defines the array buffer views of image data [mipmap][face]
  53690. * @returns a promise
  53691. */
  53692. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53693. /**
  53694. * Uploads spherical polynomials information to the texture.
  53695. * @param texture defines the texture we are trying to upload the information to
  53696. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53697. */
  53698. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53699. /** @hidden */
  53700. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53701. }
  53702. }
  53703. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53704. /**
  53705. * Class used to inline functions in shader code
  53706. */
  53707. export class ShaderCodeInliner {
  53708. private static readonly _RegexpFindFunctionNameAndType;
  53709. private _sourceCode;
  53710. private _functionDescr;
  53711. private _numMaxIterations;
  53712. /** Gets or sets the token used to mark the functions to inline */
  53713. inlineToken: string;
  53714. /** Gets or sets the debug mode */
  53715. debug: boolean;
  53716. /** Gets the code after the inlining process */
  53717. get code(): string;
  53718. /**
  53719. * Initializes the inliner
  53720. * @param sourceCode shader code source to inline
  53721. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53722. */
  53723. constructor(sourceCode: string, numMaxIterations?: number);
  53724. /**
  53725. * Start the processing of the shader code
  53726. */
  53727. processCode(): void;
  53728. private _collectFunctions;
  53729. private _processInlining;
  53730. private _extractBetweenMarkers;
  53731. private _skipWhitespaces;
  53732. private _removeComments;
  53733. private _replaceFunctionCallsByCode;
  53734. private _findBackward;
  53735. private _escapeRegExp;
  53736. private _replaceNames;
  53737. }
  53738. }
  53739. declare module "babylonjs/Engines/nativeEngine" {
  53740. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53741. import { Engine } from "babylonjs/Engines/engine";
  53742. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53745. import { Effect } from "babylonjs/Materials/effect";
  53746. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53747. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53748. import { IColor4Like } from "babylonjs/Maths/math.like";
  53749. import { Scene } from "babylonjs/scene";
  53750. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53751. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53752. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53753. /**
  53754. * Container for accessors for natively-stored mesh data buffers.
  53755. */
  53756. class NativeDataBuffer extends DataBuffer {
  53757. /**
  53758. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53759. */
  53760. nativeIndexBuffer?: any;
  53761. /**
  53762. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53763. */
  53764. nativeVertexBuffer?: any;
  53765. }
  53766. /** @hidden */
  53767. class NativeTexture extends InternalTexture {
  53768. getInternalTexture(): InternalTexture;
  53769. getViewCount(): number;
  53770. }
  53771. /** @hidden */
  53772. export class NativeEngine extends Engine {
  53773. private readonly _native;
  53774. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53775. private readonly INVALID_HANDLE;
  53776. getHardwareScalingLevel(): number;
  53777. constructor();
  53778. dispose(): void;
  53779. /**
  53780. * Can be used to override the current requestAnimationFrame requester.
  53781. * @hidden
  53782. */
  53783. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53784. /**
  53785. * Override default engine behavior.
  53786. * @param color
  53787. * @param backBuffer
  53788. * @param depth
  53789. * @param stencil
  53790. */
  53791. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53792. /**
  53793. * Gets host document
  53794. * @returns the host document object
  53795. */
  53796. getHostDocument(): Nullable<Document>;
  53797. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53798. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53799. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53800. recordVertexArrayObject(vertexBuffers: {
  53801. [key: string]: VertexBuffer;
  53802. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53803. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53804. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53805. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53806. /**
  53807. * Draw a list of indexed primitives
  53808. * @param fillMode defines the primitive to use
  53809. * @param indexStart defines the starting index
  53810. * @param indexCount defines the number of index to draw
  53811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53812. */
  53813. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53814. /**
  53815. * Draw a list of unindexed primitives
  53816. * @param fillMode defines the primitive to use
  53817. * @param verticesStart defines the index of first vertex to draw
  53818. * @param verticesCount defines the count of vertices to draw
  53819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53820. */
  53821. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53822. createPipelineContext(): IPipelineContext;
  53823. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53824. /** @hidden */
  53825. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53826. /** @hidden */
  53827. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53828. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53829. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53830. protected _setProgram(program: WebGLProgram): void;
  53831. _releaseEffect(effect: Effect): void;
  53832. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53833. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53834. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53835. bindSamplers(effect: Effect): void;
  53836. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53837. getRenderWidth(useScreen?: boolean): number;
  53838. getRenderHeight(useScreen?: boolean): number;
  53839. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53840. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53841. /**
  53842. * Set the z offset to apply to current rendering
  53843. * @param value defines the offset to apply
  53844. */
  53845. setZOffset(value: number): void;
  53846. /**
  53847. * Gets the current value of the zOffset
  53848. * @returns the current zOffset state
  53849. */
  53850. getZOffset(): number;
  53851. /**
  53852. * Enable or disable depth buffering
  53853. * @param enable defines the state to set
  53854. */
  53855. setDepthBuffer(enable: boolean): void;
  53856. /**
  53857. * Gets a boolean indicating if depth writing is enabled
  53858. * @returns the current depth writing state
  53859. */
  53860. getDepthWrite(): boolean;
  53861. /**
  53862. * Enable or disable depth writing
  53863. * @param enable defines the state to set
  53864. */
  53865. setDepthWrite(enable: boolean): void;
  53866. /**
  53867. * Enable or disable color writing
  53868. * @param enable defines the state to set
  53869. */
  53870. setColorWrite(enable: boolean): void;
  53871. /**
  53872. * Gets a boolean indicating if color writing is enabled
  53873. * @returns the current color writing state
  53874. */
  53875. getColorWrite(): boolean;
  53876. /**
  53877. * Sets alpha constants used by some alpha blending modes
  53878. * @param r defines the red component
  53879. * @param g defines the green component
  53880. * @param b defines the blue component
  53881. * @param a defines the alpha component
  53882. */
  53883. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53884. /**
  53885. * Sets the current alpha mode
  53886. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53887. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53888. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53889. */
  53890. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53891. /**
  53892. * Gets the current alpha mode
  53893. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53894. * @returns the current alpha mode
  53895. */
  53896. getAlphaMode(): number;
  53897. setInt(uniform: WebGLUniformLocation, int: number): void;
  53898. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53899. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53900. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53901. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53902. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53903. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53904. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53905. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53906. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53907. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53908. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53909. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53910. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53911. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53912. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53913. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53914. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53915. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53916. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53917. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53918. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53919. wipeCaches(bruteForce?: boolean): void;
  53920. _createTexture(): WebGLTexture;
  53921. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53922. /**
  53923. * Usually called from Texture.ts.
  53924. * Passed information to create a WebGLTexture
  53925. * @param url defines a value which contains one of the following:
  53926. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53927. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53928. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53929. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53930. * @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)
  53931. * @param scene needed for loading to the correct scene
  53932. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53933. * @param onLoad optional callback to be called upon successful completion
  53934. * @param onError optional callback to be called upon failure
  53935. * @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
  53936. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53937. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53938. * @param forcedExtension defines the extension to use to pick the right loader
  53939. * @param mimeType defines an optional mime type
  53940. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53941. */
  53942. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  53943. /**
  53944. * Creates a cube texture
  53945. * @param rootUrl defines the url where the files to load is located
  53946. * @param scene defines the current scene
  53947. * @param files defines the list of files to load (1 per face)
  53948. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53949. * @param onLoad defines an optional callback raised when the texture is loaded
  53950. * @param onError defines an optional callback raised if there is an issue to load the texture
  53951. * @param format defines the format of the data
  53952. * @param forcedExtension defines the extension to use to pick the right loader
  53953. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53954. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53955. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53956. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53957. * @returns the cube texture as an InternalTexture
  53958. */
  53959. 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;
  53960. private _getSamplingFilter;
  53961. private static _GetNativeTextureFormat;
  53962. createRenderTargetTexture(size: number | {
  53963. width: number;
  53964. height: number;
  53965. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53966. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53967. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53968. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53969. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53970. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53971. /**
  53972. * Updates a dynamic vertex buffer.
  53973. * @param vertexBuffer the vertex buffer to update
  53974. * @param data the data used to update the vertex buffer
  53975. * @param byteOffset the byte offset of the data (optional)
  53976. * @param byteLength the byte length of the data (optional)
  53977. */
  53978. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53979. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53980. private _updateAnisotropicLevel;
  53981. private _getAddressMode;
  53982. /** @hidden */
  53983. _bindTexture(channel: number, texture: InternalTexture): void;
  53984. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53985. releaseEffects(): void;
  53986. /** @hidden */
  53987. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53988. /** @hidden */
  53989. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53990. /** @hidden */
  53991. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53992. /** @hidden */
  53993. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53994. }
  53995. }
  53996. declare module "babylonjs/Engines/index" {
  53997. export * from "babylonjs/Engines/constants";
  53998. export * from "babylonjs/Engines/engineCapabilities";
  53999. export * from "babylonjs/Engines/instancingAttributeInfo";
  54000. export * from "babylonjs/Engines/thinEngine";
  54001. export * from "babylonjs/Engines/engine";
  54002. export * from "babylonjs/Engines/engineStore";
  54003. export * from "babylonjs/Engines/nullEngine";
  54004. export * from "babylonjs/Engines/Extensions/index";
  54005. export * from "babylonjs/Engines/IPipelineContext";
  54006. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54007. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54008. export * from "babylonjs/Engines/nativeEngine";
  54009. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54010. }
  54011. declare module "babylonjs/Events/clipboardEvents" {
  54012. /**
  54013. * Gather the list of clipboard event types as constants.
  54014. */
  54015. export class ClipboardEventTypes {
  54016. /**
  54017. * The clipboard event is fired when a copy command is active (pressed).
  54018. */
  54019. static readonly COPY: number;
  54020. /**
  54021. * The clipboard event is fired when a cut command is active (pressed).
  54022. */
  54023. static readonly CUT: number;
  54024. /**
  54025. * The clipboard event is fired when a paste command is active (pressed).
  54026. */
  54027. static readonly PASTE: number;
  54028. }
  54029. /**
  54030. * This class is used to store clipboard related info for the onClipboardObservable event.
  54031. */
  54032. export class ClipboardInfo {
  54033. /**
  54034. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54035. */
  54036. type: number;
  54037. /**
  54038. * Defines the related dom event
  54039. */
  54040. event: ClipboardEvent;
  54041. /**
  54042. *Creates an instance of ClipboardInfo.
  54043. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54044. * @param event Defines the related dom event
  54045. */
  54046. constructor(
  54047. /**
  54048. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54049. */
  54050. type: number,
  54051. /**
  54052. * Defines the related dom event
  54053. */
  54054. event: ClipboardEvent);
  54055. /**
  54056. * Get the clipboard event's type from the keycode.
  54057. * @param keyCode Defines the keyCode for the current keyboard event.
  54058. * @return {number}
  54059. */
  54060. static GetTypeFromCharacter(keyCode: number): number;
  54061. }
  54062. }
  54063. declare module "babylonjs/Events/index" {
  54064. export * from "babylonjs/Events/keyboardEvents";
  54065. export * from "babylonjs/Events/pointerEvents";
  54066. export * from "babylonjs/Events/clipboardEvents";
  54067. }
  54068. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54069. import { Scene } from "babylonjs/scene";
  54070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54071. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54072. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54073. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54074. /**
  54075. * Google Daydream controller
  54076. */
  54077. export class DaydreamController extends WebVRController {
  54078. /**
  54079. * Base Url for the controller model.
  54080. */
  54081. static MODEL_BASE_URL: string;
  54082. /**
  54083. * File name for the controller model.
  54084. */
  54085. static MODEL_FILENAME: string;
  54086. /**
  54087. * Gamepad Id prefix used to identify Daydream Controller.
  54088. */
  54089. static readonly GAMEPAD_ID_PREFIX: string;
  54090. /**
  54091. * Creates a new DaydreamController from a gamepad
  54092. * @param vrGamepad the gamepad that the controller should be created from
  54093. */
  54094. constructor(vrGamepad: any);
  54095. /**
  54096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54097. * @param scene scene in which to add meshes
  54098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54099. */
  54100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54101. /**
  54102. * Called once for each button that changed state since the last frame
  54103. * @param buttonIdx Which button index changed
  54104. * @param state New state of the button
  54105. * @param changes Which properties on the state changed since last frame
  54106. */
  54107. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54108. }
  54109. }
  54110. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54111. import { Scene } from "babylonjs/scene";
  54112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54113. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54114. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54115. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54116. /**
  54117. * Gear VR Controller
  54118. */
  54119. export class GearVRController extends WebVRController {
  54120. /**
  54121. * Base Url for the controller model.
  54122. */
  54123. static MODEL_BASE_URL: string;
  54124. /**
  54125. * File name for the controller model.
  54126. */
  54127. static MODEL_FILENAME: string;
  54128. /**
  54129. * Gamepad Id prefix used to identify this controller.
  54130. */
  54131. static readonly GAMEPAD_ID_PREFIX: string;
  54132. private readonly _buttonIndexToObservableNameMap;
  54133. /**
  54134. * Creates a new GearVRController from a gamepad
  54135. * @param vrGamepad the gamepad that the controller should be created from
  54136. */
  54137. constructor(vrGamepad: any);
  54138. /**
  54139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54140. * @param scene scene in which to add meshes
  54141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54142. */
  54143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54144. /**
  54145. * Called once for each button that changed state since the last frame
  54146. * @param buttonIdx Which button index changed
  54147. * @param state New state of the button
  54148. * @param changes Which properties on the state changed since last frame
  54149. */
  54150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54151. }
  54152. }
  54153. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54154. import { Scene } from "babylonjs/scene";
  54155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54156. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54157. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54158. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54159. /**
  54160. * Generic Controller
  54161. */
  54162. export class GenericController extends WebVRController {
  54163. /**
  54164. * Base Url for the controller model.
  54165. */
  54166. static readonly MODEL_BASE_URL: string;
  54167. /**
  54168. * File name for the controller model.
  54169. */
  54170. static readonly MODEL_FILENAME: string;
  54171. /**
  54172. * Creates a new GenericController from a gamepad
  54173. * @param vrGamepad the gamepad that the controller should be created from
  54174. */
  54175. constructor(vrGamepad: any);
  54176. /**
  54177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54178. * @param scene scene in which to add meshes
  54179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54180. */
  54181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54182. /**
  54183. * Called once for each button that changed state since the last frame
  54184. * @param buttonIdx Which button index changed
  54185. * @param state New state of the button
  54186. * @param changes Which properties on the state changed since last frame
  54187. */
  54188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54189. }
  54190. }
  54191. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54192. import { Observable } from "babylonjs/Misc/observable";
  54193. import { Scene } from "babylonjs/scene";
  54194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54195. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54196. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54197. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54198. /**
  54199. * Oculus Touch Controller
  54200. */
  54201. export class OculusTouchController extends WebVRController {
  54202. /**
  54203. * Base Url for the controller model.
  54204. */
  54205. static MODEL_BASE_URL: string;
  54206. /**
  54207. * File name for the left controller model.
  54208. */
  54209. static MODEL_LEFT_FILENAME: string;
  54210. /**
  54211. * File name for the right controller model.
  54212. */
  54213. static MODEL_RIGHT_FILENAME: string;
  54214. /**
  54215. * Base Url for the Quest controller model.
  54216. */
  54217. static QUEST_MODEL_BASE_URL: string;
  54218. /**
  54219. * @hidden
  54220. * If the controllers are running on a device that needs the updated Quest controller models
  54221. */
  54222. static _IsQuest: boolean;
  54223. /**
  54224. * Fired when the secondary trigger on this controller is modified
  54225. */
  54226. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54227. /**
  54228. * Fired when the thumb rest on this controller is modified
  54229. */
  54230. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54231. /**
  54232. * Creates a new OculusTouchController from a gamepad
  54233. * @param vrGamepad the gamepad that the controller should be created from
  54234. */
  54235. constructor(vrGamepad: any);
  54236. /**
  54237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54238. * @param scene scene in which to add meshes
  54239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54240. */
  54241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54242. /**
  54243. * Fired when the A button on this controller is modified
  54244. */
  54245. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54246. /**
  54247. * Fired when the B button on this controller is modified
  54248. */
  54249. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54250. /**
  54251. * Fired when the X button on this controller is modified
  54252. */
  54253. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54254. /**
  54255. * Fired when the Y button on this controller is modified
  54256. */
  54257. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54258. /**
  54259. * Called once for each button that changed state since the last frame
  54260. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54261. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54262. * 2) secondary trigger (same)
  54263. * 3) A (right) X (left), touch, pressed = value
  54264. * 4) B / Y
  54265. * 5) thumb rest
  54266. * @param buttonIdx Which button index changed
  54267. * @param state New state of the button
  54268. * @param changes Which properties on the state changed since last frame
  54269. */
  54270. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54271. }
  54272. }
  54273. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54274. import { Scene } from "babylonjs/scene";
  54275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54276. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54277. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54278. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54279. import { Observable } from "babylonjs/Misc/observable";
  54280. /**
  54281. * Vive Controller
  54282. */
  54283. export class ViveController extends WebVRController {
  54284. /**
  54285. * Base Url for the controller model.
  54286. */
  54287. static MODEL_BASE_URL: string;
  54288. /**
  54289. * File name for the controller model.
  54290. */
  54291. static MODEL_FILENAME: string;
  54292. /**
  54293. * Creates a new ViveController from a gamepad
  54294. * @param vrGamepad the gamepad that the controller should be created from
  54295. */
  54296. constructor(vrGamepad: any);
  54297. /**
  54298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54299. * @param scene scene in which to add meshes
  54300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54301. */
  54302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54303. /**
  54304. * Fired when the left button on this controller is modified
  54305. */
  54306. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54307. /**
  54308. * Fired when the right button on this controller is modified
  54309. */
  54310. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54311. /**
  54312. * Fired when the menu button on this controller is modified
  54313. */
  54314. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54315. /**
  54316. * Called once for each button that changed state since the last frame
  54317. * Vive mapping:
  54318. * 0: touchpad
  54319. * 1: trigger
  54320. * 2: left AND right buttons
  54321. * 3: menu button
  54322. * @param buttonIdx Which button index changed
  54323. * @param state New state of the button
  54324. * @param changes Which properties on the state changed since last frame
  54325. */
  54326. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54327. }
  54328. }
  54329. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54330. import { Observable } from "babylonjs/Misc/observable";
  54331. import { Scene } from "babylonjs/scene";
  54332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54333. import { Ray } from "babylonjs/Culling/ray";
  54334. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54335. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54336. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54337. /**
  54338. * Defines the WindowsMotionController object that the state of the windows motion controller
  54339. */
  54340. export class WindowsMotionController extends WebVRController {
  54341. /**
  54342. * The base url used to load the left and right controller models
  54343. */
  54344. static MODEL_BASE_URL: string;
  54345. /**
  54346. * The name of the left controller model file
  54347. */
  54348. static MODEL_LEFT_FILENAME: string;
  54349. /**
  54350. * The name of the right controller model file
  54351. */
  54352. static MODEL_RIGHT_FILENAME: string;
  54353. /**
  54354. * The controller name prefix for this controller type
  54355. */
  54356. static readonly GAMEPAD_ID_PREFIX: string;
  54357. /**
  54358. * The controller id pattern for this controller type
  54359. */
  54360. private static readonly GAMEPAD_ID_PATTERN;
  54361. private _loadedMeshInfo;
  54362. protected readonly _mapping: {
  54363. buttons: string[];
  54364. buttonMeshNames: {
  54365. trigger: string;
  54366. menu: string;
  54367. grip: string;
  54368. thumbstick: string;
  54369. trackpad: string;
  54370. };
  54371. buttonObservableNames: {
  54372. trigger: string;
  54373. menu: string;
  54374. grip: string;
  54375. thumbstick: string;
  54376. trackpad: string;
  54377. };
  54378. axisMeshNames: string[];
  54379. pointingPoseMeshName: string;
  54380. };
  54381. /**
  54382. * Fired when the trackpad on this controller is clicked
  54383. */
  54384. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54385. /**
  54386. * Fired when the trackpad on this controller is modified
  54387. */
  54388. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54389. /**
  54390. * The current x and y values of this controller's trackpad
  54391. */
  54392. trackpad: StickValues;
  54393. /**
  54394. * Creates a new WindowsMotionController from a gamepad
  54395. * @param vrGamepad the gamepad that the controller should be created from
  54396. */
  54397. constructor(vrGamepad: any);
  54398. /**
  54399. * Fired when the trigger on this controller is modified
  54400. */
  54401. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54402. /**
  54403. * Fired when the menu button on this controller is modified
  54404. */
  54405. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54406. /**
  54407. * Fired when the grip button on this controller is modified
  54408. */
  54409. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54410. /**
  54411. * Fired when the thumbstick button on this controller is modified
  54412. */
  54413. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54414. /**
  54415. * Fired when the touchpad button on this controller is modified
  54416. */
  54417. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54418. /**
  54419. * Fired when the touchpad values on this controller are modified
  54420. */
  54421. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54422. protected _updateTrackpad(): void;
  54423. /**
  54424. * Called once per frame by the engine.
  54425. */
  54426. update(): void;
  54427. /**
  54428. * Called once for each button that changed state since the last frame
  54429. * @param buttonIdx Which button index changed
  54430. * @param state New state of the button
  54431. * @param changes Which properties on the state changed since last frame
  54432. */
  54433. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54434. /**
  54435. * Moves the buttons on the controller mesh based on their current state
  54436. * @param buttonName the name of the button to move
  54437. * @param buttonValue the value of the button which determines the buttons new position
  54438. */
  54439. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54440. /**
  54441. * Moves the axis on the controller mesh based on its current state
  54442. * @param axis the index of the axis
  54443. * @param axisValue the value of the axis which determines the meshes new position
  54444. * @hidden
  54445. */
  54446. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54447. /**
  54448. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54449. * @param scene scene in which to add meshes
  54450. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54451. */
  54452. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54453. /**
  54454. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54455. * can be transformed by button presses and axes values, based on this._mapping.
  54456. *
  54457. * @param scene scene in which the meshes exist
  54458. * @param meshes list of meshes that make up the controller model to process
  54459. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54460. */
  54461. private processModel;
  54462. private createMeshInfo;
  54463. /**
  54464. * Gets the ray of the controller in the direction the controller is pointing
  54465. * @param length the length the resulting ray should be
  54466. * @returns a ray in the direction the controller is pointing
  54467. */
  54468. getForwardRay(length?: number): Ray;
  54469. /**
  54470. * Disposes of the controller
  54471. */
  54472. dispose(): void;
  54473. }
  54474. /**
  54475. * This class represents a new windows motion controller in XR.
  54476. */
  54477. export class XRWindowsMotionController extends WindowsMotionController {
  54478. /**
  54479. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54480. */
  54481. protected readonly _mapping: {
  54482. buttons: string[];
  54483. buttonMeshNames: {
  54484. trigger: string;
  54485. menu: string;
  54486. grip: string;
  54487. thumbstick: string;
  54488. trackpad: string;
  54489. };
  54490. buttonObservableNames: {
  54491. trigger: string;
  54492. menu: string;
  54493. grip: string;
  54494. thumbstick: string;
  54495. trackpad: string;
  54496. };
  54497. axisMeshNames: string[];
  54498. pointingPoseMeshName: string;
  54499. };
  54500. /**
  54501. * Construct a new XR-Based windows motion controller
  54502. *
  54503. * @param gamepadInfo the gamepad object from the browser
  54504. */
  54505. constructor(gamepadInfo: any);
  54506. /**
  54507. * holds the thumbstick values (X,Y)
  54508. */
  54509. thumbstickValues: StickValues;
  54510. /**
  54511. * Fired when the thumbstick on this controller is clicked
  54512. */
  54513. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54514. /**
  54515. * Fired when the thumbstick on this controller is modified
  54516. */
  54517. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54518. /**
  54519. * Fired when the touchpad button on this controller is modified
  54520. */
  54521. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54522. /**
  54523. * Fired when the touchpad values on this controller are modified
  54524. */
  54525. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54526. /**
  54527. * Fired when the thumbstick button on this controller is modified
  54528. * here to prevent breaking changes
  54529. */
  54530. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54531. /**
  54532. * updating the thumbstick(!) and not the trackpad.
  54533. * This is named this way due to the difference between WebVR and XR and to avoid
  54534. * changing the parent class.
  54535. */
  54536. protected _updateTrackpad(): void;
  54537. /**
  54538. * Disposes the class with joy
  54539. */
  54540. dispose(): void;
  54541. }
  54542. }
  54543. declare module "babylonjs/Gamepads/Controllers/index" {
  54544. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54545. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54546. export * from "babylonjs/Gamepads/Controllers/genericController";
  54547. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54548. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54549. export * from "babylonjs/Gamepads/Controllers/viveController";
  54550. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54551. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54552. }
  54553. declare module "babylonjs/Gamepads/index" {
  54554. export * from "babylonjs/Gamepads/Controllers/index";
  54555. export * from "babylonjs/Gamepads/gamepad";
  54556. export * from "babylonjs/Gamepads/gamepadManager";
  54557. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54558. export * from "babylonjs/Gamepads/xboxGamepad";
  54559. export * from "babylonjs/Gamepads/dualShockGamepad";
  54560. }
  54561. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54562. import { Scene } from "babylonjs/scene";
  54563. import { Vector4 } from "babylonjs/Maths/math.vector";
  54564. import { Color4 } from "babylonjs/Maths/math.color";
  54565. import { Mesh } from "babylonjs/Meshes/mesh";
  54566. import { Nullable } from "babylonjs/types";
  54567. /**
  54568. * Class containing static functions to help procedurally build meshes
  54569. */
  54570. export class PolyhedronBuilder {
  54571. /**
  54572. * Creates a polyhedron mesh
  54573. * * 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
  54574. * * The parameter `size` (positive float, default 1) sets the polygon size
  54575. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54576. * * 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`
  54577. * * 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
  54578. * * 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)`)
  54579. * * 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
  54580. * * 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
  54581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54584. * @param name defines the name of the mesh
  54585. * @param options defines the options used to create the mesh
  54586. * @param scene defines the hosting scene
  54587. * @returns the polyhedron mesh
  54588. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54589. */
  54590. static CreatePolyhedron(name: string, options: {
  54591. type?: number;
  54592. size?: number;
  54593. sizeX?: number;
  54594. sizeY?: number;
  54595. sizeZ?: number;
  54596. custom?: any;
  54597. faceUV?: Vector4[];
  54598. faceColors?: Color4[];
  54599. flat?: boolean;
  54600. updatable?: boolean;
  54601. sideOrientation?: number;
  54602. frontUVs?: Vector4;
  54603. backUVs?: Vector4;
  54604. }, scene?: Nullable<Scene>): Mesh;
  54605. }
  54606. }
  54607. declare module "babylonjs/Gizmos/scaleGizmo" {
  54608. import { Observable } from "babylonjs/Misc/observable";
  54609. import { Nullable } from "babylonjs/types";
  54610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54611. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54612. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54613. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54614. /**
  54615. * Gizmo that enables scaling a mesh along 3 axis
  54616. */
  54617. export class ScaleGizmo extends Gizmo {
  54618. /**
  54619. * Internal gizmo used for interactions on the x axis
  54620. */
  54621. xGizmo: AxisScaleGizmo;
  54622. /**
  54623. * Internal gizmo used for interactions on the y axis
  54624. */
  54625. yGizmo: AxisScaleGizmo;
  54626. /**
  54627. * Internal gizmo used for interactions on the z axis
  54628. */
  54629. zGizmo: AxisScaleGizmo;
  54630. /**
  54631. * Internal gizmo used to scale all axis equally
  54632. */
  54633. uniformScaleGizmo: AxisScaleGizmo;
  54634. private _meshAttached;
  54635. private _updateGizmoRotationToMatchAttachedMesh;
  54636. private _snapDistance;
  54637. private _scaleRatio;
  54638. private _uniformScalingMesh;
  54639. private _octahedron;
  54640. private _sensitivity;
  54641. /** Fires an event when any of it's sub gizmos are dragged */
  54642. onDragStartObservable: Observable<unknown>;
  54643. /** Fires an event when any of it's sub gizmos are released from dragging */
  54644. onDragEndObservable: Observable<unknown>;
  54645. get attachedMesh(): Nullable<AbstractMesh>;
  54646. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54647. /**
  54648. * Creates a ScaleGizmo
  54649. * @param gizmoLayer The utility layer the gizmo will be added to
  54650. */
  54651. constructor(gizmoLayer?: UtilityLayerRenderer);
  54652. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54653. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54654. /**
  54655. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54656. */
  54657. set snapDistance(value: number);
  54658. get snapDistance(): number;
  54659. /**
  54660. * Ratio for the scale of the gizmo (Default: 1)
  54661. */
  54662. set scaleRatio(value: number);
  54663. get scaleRatio(): number;
  54664. /**
  54665. * Sensitivity factor for dragging (Default: 1)
  54666. */
  54667. set sensitivity(value: number);
  54668. get sensitivity(): number;
  54669. /**
  54670. * Disposes of the gizmo
  54671. */
  54672. dispose(): void;
  54673. }
  54674. }
  54675. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54676. import { Observable } from "babylonjs/Misc/observable";
  54677. import { Nullable } from "babylonjs/types";
  54678. import { Vector3 } from "babylonjs/Maths/math.vector";
  54679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54680. import { Mesh } from "babylonjs/Meshes/mesh";
  54681. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54682. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54683. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54684. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54685. import { Color3 } from "babylonjs/Maths/math.color";
  54686. /**
  54687. * Single axis scale gizmo
  54688. */
  54689. export class AxisScaleGizmo extends Gizmo {
  54690. /**
  54691. * Drag behavior responsible for the gizmos dragging interactions
  54692. */
  54693. dragBehavior: PointerDragBehavior;
  54694. private _pointerObserver;
  54695. /**
  54696. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54697. */
  54698. snapDistance: number;
  54699. /**
  54700. * Event that fires each time the gizmo snaps to a new location.
  54701. * * snapDistance is the the change in distance
  54702. */
  54703. onSnapObservable: Observable<{
  54704. snapDistance: number;
  54705. }>;
  54706. /**
  54707. * If the scaling operation should be done on all axis (default: false)
  54708. */
  54709. uniformScaling: boolean;
  54710. /**
  54711. * Custom sensitivity value for the drag strength
  54712. */
  54713. sensitivity: number;
  54714. private _isEnabled;
  54715. private _parent;
  54716. private _arrow;
  54717. private _coloredMaterial;
  54718. private _hoverMaterial;
  54719. /**
  54720. * Creates an AxisScaleGizmo
  54721. * @param gizmoLayer The utility layer the gizmo will be added to
  54722. * @param dragAxis The axis which the gizmo will be able to scale on
  54723. * @param color The color of the gizmo
  54724. */
  54725. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54726. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54727. /**
  54728. * If the gizmo is enabled
  54729. */
  54730. set isEnabled(value: boolean);
  54731. get isEnabled(): boolean;
  54732. /**
  54733. * Disposes of the gizmo
  54734. */
  54735. dispose(): void;
  54736. /**
  54737. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54738. * @param mesh The mesh to replace the default mesh of the gizmo
  54739. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54740. */
  54741. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54742. }
  54743. }
  54744. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54745. import { Observable } from "babylonjs/Misc/observable";
  54746. import { Nullable } from "babylonjs/types";
  54747. import { Vector3 } from "babylonjs/Maths/math.vector";
  54748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54749. import { Mesh } from "babylonjs/Meshes/mesh";
  54750. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54751. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54752. import { Color3 } from "babylonjs/Maths/math.color";
  54753. import "babylonjs/Meshes/Builders/boxBuilder";
  54754. /**
  54755. * Bounding box gizmo
  54756. */
  54757. export class BoundingBoxGizmo extends Gizmo {
  54758. private _lineBoundingBox;
  54759. private _rotateSpheresParent;
  54760. private _scaleBoxesParent;
  54761. private _boundingDimensions;
  54762. private _renderObserver;
  54763. private _pointerObserver;
  54764. private _scaleDragSpeed;
  54765. private _tmpQuaternion;
  54766. private _tmpVector;
  54767. private _tmpRotationMatrix;
  54768. /**
  54769. * 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)
  54770. */
  54771. ignoreChildren: boolean;
  54772. /**
  54773. * 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)
  54774. */
  54775. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54776. /**
  54777. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54778. */
  54779. rotationSphereSize: number;
  54780. /**
  54781. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54782. */
  54783. scaleBoxSize: number;
  54784. /**
  54785. * 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)
  54786. */
  54787. fixedDragMeshScreenSize: boolean;
  54788. /**
  54789. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54790. */
  54791. fixedDragMeshScreenSizeDistanceFactor: number;
  54792. /**
  54793. * Fired when a rotation sphere or scale box is dragged
  54794. */
  54795. onDragStartObservable: Observable<{}>;
  54796. /**
  54797. * Fired when a scale box is dragged
  54798. */
  54799. onScaleBoxDragObservable: Observable<{}>;
  54800. /**
  54801. * Fired when a scale box drag is ended
  54802. */
  54803. onScaleBoxDragEndObservable: Observable<{}>;
  54804. /**
  54805. * Fired when a rotation sphere is dragged
  54806. */
  54807. onRotationSphereDragObservable: Observable<{}>;
  54808. /**
  54809. * Fired when a rotation sphere drag is ended
  54810. */
  54811. onRotationSphereDragEndObservable: Observable<{}>;
  54812. /**
  54813. * Relative bounding box pivot used when scaling the attached mesh. 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)
  54814. */
  54815. scalePivot: Nullable<Vector3>;
  54816. /**
  54817. * Mesh used as a pivot to rotate the attached mesh
  54818. */
  54819. private _anchorMesh;
  54820. private _existingMeshScale;
  54821. private _dragMesh;
  54822. private pointerDragBehavior;
  54823. private coloredMaterial;
  54824. private hoverColoredMaterial;
  54825. /**
  54826. * Sets the color of the bounding box gizmo
  54827. * @param color the color to set
  54828. */
  54829. setColor(color: Color3): void;
  54830. /**
  54831. * Creates an BoundingBoxGizmo
  54832. * @param gizmoLayer The utility layer the gizmo will be added to
  54833. * @param color The color of the gizmo
  54834. */
  54835. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54836. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54837. private _selectNode;
  54838. /**
  54839. * Updates the bounding box information for the Gizmo
  54840. */
  54841. updateBoundingBox(): void;
  54842. private _updateRotationSpheres;
  54843. private _updateScaleBoxes;
  54844. /**
  54845. * Enables rotation on the specified axis and disables rotation on the others
  54846. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54847. */
  54848. setEnabledRotationAxis(axis: string): void;
  54849. /**
  54850. * Enables/disables scaling
  54851. * @param enable if scaling should be enabled
  54852. * @param homogeneousScaling defines if scaling should only be homogeneous
  54853. */
  54854. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54855. private _updateDummy;
  54856. /**
  54857. * Enables a pointer drag behavior on the bounding box of the gizmo
  54858. */
  54859. enableDragBehavior(): void;
  54860. /**
  54861. * Disposes of the gizmo
  54862. */
  54863. dispose(): void;
  54864. /**
  54865. * 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)
  54866. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54867. * @returns the bounding box mesh with the passed in mesh as a child
  54868. */
  54869. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54870. /**
  54871. * CustomMeshes are not supported by this gizmo
  54872. * @param mesh The mesh to replace the default mesh of the gizmo
  54873. */
  54874. setCustomMesh(mesh: Mesh): void;
  54875. }
  54876. }
  54877. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54878. import { Observable } from "babylonjs/Misc/observable";
  54879. import { Nullable } from "babylonjs/types";
  54880. import { Vector3 } from "babylonjs/Maths/math.vector";
  54881. import { Color3 } from "babylonjs/Maths/math.color";
  54882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54883. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54884. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54885. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54886. import "babylonjs/Meshes/Builders/linesBuilder";
  54887. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54888. /**
  54889. * Single plane rotation gizmo
  54890. */
  54891. export class PlaneRotationGizmo extends Gizmo {
  54892. /**
  54893. * Drag behavior responsible for the gizmos dragging interactions
  54894. */
  54895. dragBehavior: PointerDragBehavior;
  54896. private _pointerObserver;
  54897. /**
  54898. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54899. */
  54900. snapDistance: number;
  54901. /**
  54902. * Event that fires each time the gizmo snaps to a new location.
  54903. * * snapDistance is the the change in distance
  54904. */
  54905. onSnapObservable: Observable<{
  54906. snapDistance: number;
  54907. }>;
  54908. private _isEnabled;
  54909. private _parent;
  54910. /**
  54911. * Creates a PlaneRotationGizmo
  54912. * @param gizmoLayer The utility layer the gizmo will be added to
  54913. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54914. * @param color The color of the gizmo
  54915. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54916. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54917. */
  54918. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54919. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54920. /**
  54921. * If the gizmo is enabled
  54922. */
  54923. set isEnabled(value: boolean);
  54924. get isEnabled(): boolean;
  54925. /**
  54926. * Disposes of the gizmo
  54927. */
  54928. dispose(): void;
  54929. }
  54930. }
  54931. declare module "babylonjs/Gizmos/rotationGizmo" {
  54932. import { Observable } from "babylonjs/Misc/observable";
  54933. import { Nullable } from "babylonjs/types";
  54934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54935. import { Mesh } from "babylonjs/Meshes/mesh";
  54936. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54937. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54938. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54939. /**
  54940. * Gizmo that enables rotating a mesh along 3 axis
  54941. */
  54942. export class RotationGizmo extends Gizmo {
  54943. /**
  54944. * Internal gizmo used for interactions on the x axis
  54945. */
  54946. xGizmo: PlaneRotationGizmo;
  54947. /**
  54948. * Internal gizmo used for interactions on the y axis
  54949. */
  54950. yGizmo: PlaneRotationGizmo;
  54951. /**
  54952. * Internal gizmo used for interactions on the z axis
  54953. */
  54954. zGizmo: PlaneRotationGizmo;
  54955. /** Fires an event when any of it's sub gizmos are dragged */
  54956. onDragStartObservable: Observable<unknown>;
  54957. /** Fires an event when any of it's sub gizmos are released from dragging */
  54958. onDragEndObservable: Observable<unknown>;
  54959. private _meshAttached;
  54960. get attachedMesh(): Nullable<AbstractMesh>;
  54961. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54962. /**
  54963. * Creates a RotationGizmo
  54964. * @param gizmoLayer The utility layer the gizmo will be added to
  54965. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54966. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54967. */
  54968. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54969. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54970. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54971. /**
  54972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54973. */
  54974. set snapDistance(value: number);
  54975. get snapDistance(): number;
  54976. /**
  54977. * Ratio for the scale of the gizmo (Default: 1)
  54978. */
  54979. set scaleRatio(value: number);
  54980. get scaleRatio(): number;
  54981. /**
  54982. * Disposes of the gizmo
  54983. */
  54984. dispose(): void;
  54985. /**
  54986. * CustomMeshes are not supported by this gizmo
  54987. * @param mesh The mesh to replace the default mesh of the gizmo
  54988. */
  54989. setCustomMesh(mesh: Mesh): void;
  54990. }
  54991. }
  54992. declare module "babylonjs/Gizmos/gizmoManager" {
  54993. import { Observable } from "babylonjs/Misc/observable";
  54994. import { Nullable } from "babylonjs/types";
  54995. import { Scene, IDisposable } from "babylonjs/scene";
  54996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54997. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54998. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54999. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55000. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55001. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55002. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55003. /**
  55004. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55005. */
  55006. export class GizmoManager implements IDisposable {
  55007. private scene;
  55008. /**
  55009. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55010. */
  55011. gizmos: {
  55012. positionGizmo: Nullable<PositionGizmo>;
  55013. rotationGizmo: Nullable<RotationGizmo>;
  55014. scaleGizmo: Nullable<ScaleGizmo>;
  55015. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55016. };
  55017. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55018. clearGizmoOnEmptyPointerEvent: boolean;
  55019. /** Fires an event when the manager is attached to a mesh */
  55020. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55021. private _gizmosEnabled;
  55022. private _pointerObserver;
  55023. private _attachedMesh;
  55024. private _boundingBoxColor;
  55025. private _defaultUtilityLayer;
  55026. private _defaultKeepDepthUtilityLayer;
  55027. /**
  55028. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55029. */
  55030. boundingBoxDragBehavior: SixDofDragBehavior;
  55031. /**
  55032. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55033. */
  55034. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55035. /**
  55036. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55037. */
  55038. usePointerToAttachGizmos: boolean;
  55039. /**
  55040. * Utility layer that the bounding box gizmo belongs to
  55041. */
  55042. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55043. /**
  55044. * Utility layer that all gizmos besides bounding box belong to
  55045. */
  55046. get utilityLayer(): UtilityLayerRenderer;
  55047. /**
  55048. * Instatiates a gizmo manager
  55049. * @param scene the scene to overlay the gizmos on top of
  55050. */
  55051. constructor(scene: Scene);
  55052. /**
  55053. * Attaches a set of gizmos to the specified mesh
  55054. * @param mesh The mesh the gizmo's should be attached to
  55055. */
  55056. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55057. /**
  55058. * If the position gizmo is enabled
  55059. */
  55060. set positionGizmoEnabled(value: boolean);
  55061. get positionGizmoEnabled(): boolean;
  55062. /**
  55063. * If the rotation gizmo is enabled
  55064. */
  55065. set rotationGizmoEnabled(value: boolean);
  55066. get rotationGizmoEnabled(): boolean;
  55067. /**
  55068. * If the scale gizmo is enabled
  55069. */
  55070. set scaleGizmoEnabled(value: boolean);
  55071. get scaleGizmoEnabled(): boolean;
  55072. /**
  55073. * If the boundingBox gizmo is enabled
  55074. */
  55075. set boundingBoxGizmoEnabled(value: boolean);
  55076. get boundingBoxGizmoEnabled(): boolean;
  55077. /**
  55078. * Disposes of the gizmo manager
  55079. */
  55080. dispose(): void;
  55081. }
  55082. }
  55083. declare module "babylonjs/Lights/directionalLight" {
  55084. import { Camera } from "babylonjs/Cameras/camera";
  55085. import { Scene } from "babylonjs/scene";
  55086. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55088. import { Light } from "babylonjs/Lights/light";
  55089. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55090. import { Effect } from "babylonjs/Materials/effect";
  55091. /**
  55092. * A directional light is defined by a direction (what a surprise!).
  55093. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55094. * 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.
  55095. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55096. */
  55097. export class DirectionalLight extends ShadowLight {
  55098. private _shadowFrustumSize;
  55099. /**
  55100. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55101. */
  55102. get shadowFrustumSize(): number;
  55103. /**
  55104. * Specifies a fix frustum size for the shadow generation.
  55105. */
  55106. set shadowFrustumSize(value: number);
  55107. private _shadowOrthoScale;
  55108. /**
  55109. * Gets the shadow projection scale against the optimal computed one.
  55110. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55111. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55112. */
  55113. get shadowOrthoScale(): number;
  55114. /**
  55115. * Sets the shadow projection scale against the optimal computed one.
  55116. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55117. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55118. */
  55119. set shadowOrthoScale(value: number);
  55120. /**
  55121. * Automatically compute the projection matrix to best fit (including all the casters)
  55122. * on each frame.
  55123. */
  55124. autoUpdateExtends: boolean;
  55125. /**
  55126. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55127. * on each frame. autoUpdateExtends must be set to true for this to work
  55128. */
  55129. autoCalcShadowZBounds: boolean;
  55130. private _orthoLeft;
  55131. private _orthoRight;
  55132. private _orthoTop;
  55133. private _orthoBottom;
  55134. /**
  55135. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55136. * The directional light is emitted from everywhere in the given direction.
  55137. * It can cast shadows.
  55138. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55139. * @param name The friendly name of the light
  55140. * @param direction The direction of the light
  55141. * @param scene The scene the light belongs to
  55142. */
  55143. constructor(name: string, direction: Vector3, scene: Scene);
  55144. /**
  55145. * Returns the string "DirectionalLight".
  55146. * @return The class name
  55147. */
  55148. getClassName(): string;
  55149. /**
  55150. * Returns the integer 1.
  55151. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55152. */
  55153. getTypeID(): number;
  55154. /**
  55155. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55156. * Returns the DirectionalLight Shadow projection matrix.
  55157. */
  55158. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55159. /**
  55160. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55161. * Returns the DirectionalLight Shadow projection matrix.
  55162. */
  55163. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55164. /**
  55165. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55166. * Returns the DirectionalLight Shadow projection matrix.
  55167. */
  55168. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55169. protected _buildUniformLayout(): void;
  55170. /**
  55171. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55172. * @param effect The effect to update
  55173. * @param lightIndex The index of the light in the effect to update
  55174. * @returns The directional light
  55175. */
  55176. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55177. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55178. /**
  55179. * Gets the minZ used for shadow according to both the scene and the light.
  55180. *
  55181. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55182. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55183. * @param activeCamera The camera we are returning the min for
  55184. * @returns the depth min z
  55185. */
  55186. getDepthMinZ(activeCamera: Camera): number;
  55187. /**
  55188. * Gets the maxZ used for shadow according to both the scene and the light.
  55189. *
  55190. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55191. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55192. * @param activeCamera The camera we are returning the max for
  55193. * @returns the depth max z
  55194. */
  55195. getDepthMaxZ(activeCamera: Camera): number;
  55196. /**
  55197. * Prepares the list of defines specific to the light type.
  55198. * @param defines the list of defines
  55199. * @param lightIndex defines the index of the light for the effect
  55200. */
  55201. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55202. }
  55203. }
  55204. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55205. import { Mesh } from "babylonjs/Meshes/mesh";
  55206. /**
  55207. * Class containing static functions to help procedurally build meshes
  55208. */
  55209. export class HemisphereBuilder {
  55210. /**
  55211. * Creates a hemisphere mesh
  55212. * @param name defines the name of the mesh
  55213. * @param options defines the options used to create the mesh
  55214. * @param scene defines the hosting scene
  55215. * @returns the hemisphere mesh
  55216. */
  55217. static CreateHemisphere(name: string, options: {
  55218. segments?: number;
  55219. diameter?: number;
  55220. sideOrientation?: number;
  55221. }, scene: any): Mesh;
  55222. }
  55223. }
  55224. declare module "babylonjs/Lights/spotLight" {
  55225. import { Nullable } from "babylonjs/types";
  55226. import { Scene } from "babylonjs/scene";
  55227. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55229. import { Effect } from "babylonjs/Materials/effect";
  55230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55231. import { Light } from "babylonjs/Lights/light";
  55232. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55233. /**
  55234. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55235. * These values define a cone of light starting from the position, emitting toward the direction.
  55236. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55237. * and the exponent defines the speed of the decay of the light with distance (reach).
  55238. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55239. */
  55240. export class SpotLight extends ShadowLight {
  55241. private _angle;
  55242. private _innerAngle;
  55243. private _cosHalfAngle;
  55244. private _lightAngleScale;
  55245. private _lightAngleOffset;
  55246. /**
  55247. * Gets the cone angle of the spot light in Radians.
  55248. */
  55249. get angle(): number;
  55250. /**
  55251. * Sets the cone angle of the spot light in Radians.
  55252. */
  55253. set angle(value: number);
  55254. /**
  55255. * Only used in gltf falloff mode, this defines the angle where
  55256. * the directional falloff will start before cutting at angle which could be seen
  55257. * as outer angle.
  55258. */
  55259. get innerAngle(): number;
  55260. /**
  55261. * Only used in gltf falloff mode, this defines the angle where
  55262. * the directional falloff will start before cutting at angle which could be seen
  55263. * as outer angle.
  55264. */
  55265. set innerAngle(value: number);
  55266. private _shadowAngleScale;
  55267. /**
  55268. * Allows scaling the angle of the light for shadow generation only.
  55269. */
  55270. get shadowAngleScale(): number;
  55271. /**
  55272. * Allows scaling the angle of the light for shadow generation only.
  55273. */
  55274. set shadowAngleScale(value: number);
  55275. /**
  55276. * The light decay speed with the distance from the emission spot.
  55277. */
  55278. exponent: number;
  55279. private _projectionTextureMatrix;
  55280. /**
  55281. * Allows reading the projecton texture
  55282. */
  55283. get projectionTextureMatrix(): Matrix;
  55284. protected _projectionTextureLightNear: number;
  55285. /**
  55286. * Gets the near clip of the Spotlight for texture projection.
  55287. */
  55288. get projectionTextureLightNear(): number;
  55289. /**
  55290. * Sets the near clip of the Spotlight for texture projection.
  55291. */
  55292. set projectionTextureLightNear(value: number);
  55293. protected _projectionTextureLightFar: number;
  55294. /**
  55295. * Gets the far clip of the Spotlight for texture projection.
  55296. */
  55297. get projectionTextureLightFar(): number;
  55298. /**
  55299. * Sets the far clip of the Spotlight for texture projection.
  55300. */
  55301. set projectionTextureLightFar(value: number);
  55302. protected _projectionTextureUpDirection: Vector3;
  55303. /**
  55304. * Gets the Up vector of the Spotlight for texture projection.
  55305. */
  55306. get projectionTextureUpDirection(): Vector3;
  55307. /**
  55308. * Sets the Up vector of the Spotlight for texture projection.
  55309. */
  55310. set projectionTextureUpDirection(value: Vector3);
  55311. private _projectionTexture;
  55312. /**
  55313. * Gets the projection texture of the light.
  55314. */
  55315. get projectionTexture(): Nullable<BaseTexture>;
  55316. /**
  55317. * Sets the projection texture of the light.
  55318. */
  55319. set projectionTexture(value: Nullable<BaseTexture>);
  55320. private _projectionTextureViewLightDirty;
  55321. private _projectionTextureProjectionLightDirty;
  55322. private _projectionTextureDirty;
  55323. private _projectionTextureViewTargetVector;
  55324. private _projectionTextureViewLightMatrix;
  55325. private _projectionTextureProjectionLightMatrix;
  55326. private _projectionTextureScalingMatrix;
  55327. /**
  55328. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55329. * It can cast shadows.
  55330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55331. * @param name The light friendly name
  55332. * @param position The position of the spot light in the scene
  55333. * @param direction The direction of the light in the scene
  55334. * @param angle The cone angle of the light in Radians
  55335. * @param exponent The light decay speed with the distance from the emission spot
  55336. * @param scene The scene the lights belongs to
  55337. */
  55338. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55339. /**
  55340. * Returns the string "SpotLight".
  55341. * @returns the class name
  55342. */
  55343. getClassName(): string;
  55344. /**
  55345. * Returns the integer 2.
  55346. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55347. */
  55348. getTypeID(): number;
  55349. /**
  55350. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55351. */
  55352. protected _setDirection(value: Vector3): void;
  55353. /**
  55354. * Overrides the position setter to recompute the projection texture view light Matrix.
  55355. */
  55356. protected _setPosition(value: Vector3): void;
  55357. /**
  55358. * 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.
  55359. * Returns the SpotLight.
  55360. */
  55361. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55362. protected _computeProjectionTextureViewLightMatrix(): void;
  55363. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55364. /**
  55365. * Main function for light texture projection matrix computing.
  55366. */
  55367. protected _computeProjectionTextureMatrix(): void;
  55368. protected _buildUniformLayout(): void;
  55369. private _computeAngleValues;
  55370. /**
  55371. * Sets the passed Effect "effect" with the Light textures.
  55372. * @param effect The effect to update
  55373. * @param lightIndex The index of the light in the effect to update
  55374. * @returns The light
  55375. */
  55376. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55377. /**
  55378. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55379. * @param effect The effect to update
  55380. * @param lightIndex The index of the light in the effect to update
  55381. * @returns The spot light
  55382. */
  55383. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55384. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55385. /**
  55386. * Disposes the light and the associated resources.
  55387. */
  55388. dispose(): void;
  55389. /**
  55390. * Prepares the list of defines specific to the light type.
  55391. * @param defines the list of defines
  55392. * @param lightIndex defines the index of the light for the effect
  55393. */
  55394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55395. }
  55396. }
  55397. declare module "babylonjs/Gizmos/lightGizmo" {
  55398. import { Nullable } from "babylonjs/types";
  55399. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55400. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55401. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55402. import { Light } from "babylonjs/Lights/light";
  55403. /**
  55404. * Gizmo that enables viewing a light
  55405. */
  55406. export class LightGizmo extends Gizmo {
  55407. private _lightMesh;
  55408. private _material;
  55409. private _cachedPosition;
  55410. private _cachedForward;
  55411. private _attachedMeshParent;
  55412. /**
  55413. * Creates a LightGizmo
  55414. * @param gizmoLayer The utility layer the gizmo will be added to
  55415. */
  55416. constructor(gizmoLayer?: UtilityLayerRenderer);
  55417. private _light;
  55418. /**
  55419. * The light that the gizmo is attached to
  55420. */
  55421. set light(light: Nullable<Light>);
  55422. get light(): Nullable<Light>;
  55423. /**
  55424. * Gets the material used to render the light gizmo
  55425. */
  55426. get material(): StandardMaterial;
  55427. /**
  55428. * @hidden
  55429. * Updates the gizmo to match the attached mesh's position/rotation
  55430. */
  55431. protected _update(): void;
  55432. private static _Scale;
  55433. /**
  55434. * Creates the lines for a light mesh
  55435. */
  55436. private static _CreateLightLines;
  55437. /**
  55438. * Disposes of the light gizmo
  55439. */
  55440. dispose(): void;
  55441. private static _CreateHemisphericLightMesh;
  55442. private static _CreatePointLightMesh;
  55443. private static _CreateSpotLightMesh;
  55444. private static _CreateDirectionalLightMesh;
  55445. }
  55446. }
  55447. declare module "babylonjs/Gizmos/index" {
  55448. export * from "babylonjs/Gizmos/axisDragGizmo";
  55449. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55450. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55451. export * from "babylonjs/Gizmos/gizmo";
  55452. export * from "babylonjs/Gizmos/gizmoManager";
  55453. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55454. export * from "babylonjs/Gizmos/positionGizmo";
  55455. export * from "babylonjs/Gizmos/rotationGizmo";
  55456. export * from "babylonjs/Gizmos/scaleGizmo";
  55457. export * from "babylonjs/Gizmos/lightGizmo";
  55458. export * from "babylonjs/Gizmos/planeDragGizmo";
  55459. }
  55460. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55461. /** @hidden */
  55462. export var backgroundFragmentDeclaration: {
  55463. name: string;
  55464. shader: string;
  55465. };
  55466. }
  55467. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55468. /** @hidden */
  55469. export var backgroundUboDeclaration: {
  55470. name: string;
  55471. shader: string;
  55472. };
  55473. }
  55474. declare module "babylonjs/Shaders/background.fragment" {
  55475. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55476. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55477. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55478. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55479. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55480. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55482. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55483. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55484. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55485. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55486. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55487. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55488. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55489. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55490. /** @hidden */
  55491. export var backgroundPixelShader: {
  55492. name: string;
  55493. shader: string;
  55494. };
  55495. }
  55496. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55497. /** @hidden */
  55498. export var backgroundVertexDeclaration: {
  55499. name: string;
  55500. shader: string;
  55501. };
  55502. }
  55503. declare module "babylonjs/Shaders/background.vertex" {
  55504. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55505. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55506. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55507. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55508. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55510. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55516. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55517. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55518. /** @hidden */
  55519. export var backgroundVertexShader: {
  55520. name: string;
  55521. shader: string;
  55522. };
  55523. }
  55524. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55525. import { Nullable, int, float } from "babylonjs/types";
  55526. import { Scene } from "babylonjs/scene";
  55527. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55530. import { Mesh } from "babylonjs/Meshes/mesh";
  55531. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55532. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55533. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55535. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55536. import { Color3 } from "babylonjs/Maths/math.color";
  55537. import "babylonjs/Shaders/background.fragment";
  55538. import "babylonjs/Shaders/background.vertex";
  55539. /**
  55540. * Background material used to create an efficient environement around your scene.
  55541. */
  55542. export class BackgroundMaterial extends PushMaterial {
  55543. /**
  55544. * Standard reflectance value at parallel view angle.
  55545. */
  55546. static StandardReflectance0: number;
  55547. /**
  55548. * Standard reflectance value at grazing angle.
  55549. */
  55550. static StandardReflectance90: number;
  55551. protected _primaryColor: Color3;
  55552. /**
  55553. * Key light Color (multiply against the environement texture)
  55554. */
  55555. primaryColor: Color3;
  55556. protected __perceptualColor: Nullable<Color3>;
  55557. /**
  55558. * Experimental Internal Use Only.
  55559. *
  55560. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55561. * This acts as a helper to set the primary color to a more "human friendly" value.
  55562. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55563. * output color as close as possible from the chosen value.
  55564. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55565. * part of lighting setup.)
  55566. */
  55567. get _perceptualColor(): Nullable<Color3>;
  55568. set _perceptualColor(value: Nullable<Color3>);
  55569. protected _primaryColorShadowLevel: float;
  55570. /**
  55571. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55572. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55573. */
  55574. get primaryColorShadowLevel(): float;
  55575. set primaryColorShadowLevel(value: float);
  55576. protected _primaryColorHighlightLevel: float;
  55577. /**
  55578. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55579. * The primary color is used at the level chosen to define what the white area would look.
  55580. */
  55581. get primaryColorHighlightLevel(): float;
  55582. set primaryColorHighlightLevel(value: float);
  55583. protected _reflectionTexture: Nullable<BaseTexture>;
  55584. /**
  55585. * Reflection Texture used in the material.
  55586. * Should be author in a specific way for the best result (refer to the documentation).
  55587. */
  55588. reflectionTexture: Nullable<BaseTexture>;
  55589. protected _reflectionBlur: float;
  55590. /**
  55591. * Reflection Texture level of blur.
  55592. *
  55593. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55594. * texture twice.
  55595. */
  55596. reflectionBlur: float;
  55597. protected _diffuseTexture: Nullable<BaseTexture>;
  55598. /**
  55599. * Diffuse Texture used in the material.
  55600. * Should be author in a specific way for the best result (refer to the documentation).
  55601. */
  55602. diffuseTexture: Nullable<BaseTexture>;
  55603. protected _shadowLights: Nullable<IShadowLight[]>;
  55604. /**
  55605. * Specify the list of lights casting shadow on the material.
  55606. * All scene shadow lights will be included if null.
  55607. */
  55608. shadowLights: Nullable<IShadowLight[]>;
  55609. protected _shadowLevel: float;
  55610. /**
  55611. * Helps adjusting the shadow to a softer level if required.
  55612. * 0 means black shadows and 1 means no shadows.
  55613. */
  55614. shadowLevel: float;
  55615. protected _sceneCenter: Vector3;
  55616. /**
  55617. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55618. * It is usually zero but might be interesting to modify according to your setup.
  55619. */
  55620. sceneCenter: Vector3;
  55621. protected _opacityFresnel: boolean;
  55622. /**
  55623. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55624. * This helps ensuring a nice transition when the camera goes under the ground.
  55625. */
  55626. opacityFresnel: boolean;
  55627. protected _reflectionFresnel: boolean;
  55628. /**
  55629. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55630. * This helps adding a mirror texture on the ground.
  55631. */
  55632. reflectionFresnel: boolean;
  55633. protected _reflectionFalloffDistance: number;
  55634. /**
  55635. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55636. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55637. */
  55638. reflectionFalloffDistance: number;
  55639. protected _reflectionAmount: number;
  55640. /**
  55641. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55642. */
  55643. reflectionAmount: number;
  55644. protected _reflectionReflectance0: number;
  55645. /**
  55646. * This specifies the weight of the reflection at grazing angle.
  55647. */
  55648. reflectionReflectance0: number;
  55649. protected _reflectionReflectance90: number;
  55650. /**
  55651. * This specifies the weight of the reflection at a perpendicular point of view.
  55652. */
  55653. reflectionReflectance90: number;
  55654. /**
  55655. * Sets the reflection reflectance fresnel values according to the default standard
  55656. * empirically know to work well :-)
  55657. */
  55658. set reflectionStandardFresnelWeight(value: number);
  55659. protected _useRGBColor: boolean;
  55660. /**
  55661. * Helps to directly use the maps channels instead of their level.
  55662. */
  55663. useRGBColor: boolean;
  55664. protected _enableNoise: boolean;
  55665. /**
  55666. * This helps reducing the banding effect that could occur on the background.
  55667. */
  55668. enableNoise: boolean;
  55669. /**
  55670. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55671. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55672. * Recommended to be keep at 1.0 except for special cases.
  55673. */
  55674. get fovMultiplier(): number;
  55675. set fovMultiplier(value: number);
  55676. private _fovMultiplier;
  55677. /**
  55678. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55679. */
  55680. useEquirectangularFOV: boolean;
  55681. private _maxSimultaneousLights;
  55682. /**
  55683. * Number of Simultaneous lights allowed on the material.
  55684. */
  55685. maxSimultaneousLights: int;
  55686. private _shadowOnly;
  55687. /**
  55688. * Make the material only render shadows
  55689. */
  55690. shadowOnly: boolean;
  55691. /**
  55692. * Default configuration related to image processing available in the Background Material.
  55693. */
  55694. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55695. /**
  55696. * Keep track of the image processing observer to allow dispose and replace.
  55697. */
  55698. private _imageProcessingObserver;
  55699. /**
  55700. * Attaches a new image processing configuration to the PBR Material.
  55701. * @param configuration (if null the scene configuration will be use)
  55702. */
  55703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55704. /**
  55705. * Gets the image processing configuration used either in this material.
  55706. */
  55707. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55708. /**
  55709. * Sets the Default image processing configuration used either in the this material.
  55710. *
  55711. * If sets to null, the scene one is in use.
  55712. */
  55713. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55714. /**
  55715. * Gets wether the color curves effect is enabled.
  55716. */
  55717. get cameraColorCurvesEnabled(): boolean;
  55718. /**
  55719. * Sets wether the color curves effect is enabled.
  55720. */
  55721. set cameraColorCurvesEnabled(value: boolean);
  55722. /**
  55723. * Gets wether the color grading effect is enabled.
  55724. */
  55725. get cameraColorGradingEnabled(): boolean;
  55726. /**
  55727. * Gets wether the color grading effect is enabled.
  55728. */
  55729. set cameraColorGradingEnabled(value: boolean);
  55730. /**
  55731. * Gets wether tonemapping is enabled or not.
  55732. */
  55733. get cameraToneMappingEnabled(): boolean;
  55734. /**
  55735. * Sets wether tonemapping is enabled or not
  55736. */
  55737. set cameraToneMappingEnabled(value: boolean);
  55738. /**
  55739. * The camera exposure used on this material.
  55740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55741. * This corresponds to a photographic exposure.
  55742. */
  55743. get cameraExposure(): float;
  55744. /**
  55745. * The camera exposure used on this material.
  55746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55747. * This corresponds to a photographic exposure.
  55748. */
  55749. set cameraExposure(value: float);
  55750. /**
  55751. * Gets The camera contrast used on this material.
  55752. */
  55753. get cameraContrast(): float;
  55754. /**
  55755. * Sets The camera contrast used on this material.
  55756. */
  55757. set cameraContrast(value: float);
  55758. /**
  55759. * Gets the Color Grading 2D Lookup Texture.
  55760. */
  55761. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55762. /**
  55763. * Sets the Color Grading 2D Lookup Texture.
  55764. */
  55765. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55766. /**
  55767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55769. * 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;
  55770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55771. */
  55772. get cameraColorCurves(): Nullable<ColorCurves>;
  55773. /**
  55774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55776. * 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;
  55777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55778. */
  55779. set cameraColorCurves(value: Nullable<ColorCurves>);
  55780. /**
  55781. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55782. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55783. */
  55784. switchToBGR: boolean;
  55785. private _renderTargets;
  55786. private _reflectionControls;
  55787. private _white;
  55788. private _primaryShadowColor;
  55789. private _primaryHighlightColor;
  55790. /**
  55791. * Instantiates a Background Material in the given scene
  55792. * @param name The friendly name of the material
  55793. * @param scene The scene to add the material to
  55794. */
  55795. constructor(name: string, scene: Scene);
  55796. /**
  55797. * Gets a boolean indicating that current material needs to register RTT
  55798. */
  55799. get hasRenderTargetTextures(): boolean;
  55800. /**
  55801. * The entire material has been created in order to prevent overdraw.
  55802. * @returns false
  55803. */
  55804. needAlphaTesting(): boolean;
  55805. /**
  55806. * The entire material has been created in order to prevent overdraw.
  55807. * @returns true if blending is enable
  55808. */
  55809. needAlphaBlending(): boolean;
  55810. /**
  55811. * Checks wether the material is ready to be rendered for a given mesh.
  55812. * @param mesh The mesh to render
  55813. * @param subMesh The submesh to check against
  55814. * @param useInstances Specify wether or not the material is used with instances
  55815. * @returns true if all the dependencies are ready (Textures, Effects...)
  55816. */
  55817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55818. /**
  55819. * Compute the primary color according to the chosen perceptual color.
  55820. */
  55821. private _computePrimaryColorFromPerceptualColor;
  55822. /**
  55823. * Compute the highlights and shadow colors according to their chosen levels.
  55824. */
  55825. private _computePrimaryColors;
  55826. /**
  55827. * Build the uniform buffer used in the material.
  55828. */
  55829. buildUniformLayout(): void;
  55830. /**
  55831. * Unbind the material.
  55832. */
  55833. unbind(): void;
  55834. /**
  55835. * Bind only the world matrix to the material.
  55836. * @param world The world matrix to bind.
  55837. */
  55838. bindOnlyWorldMatrix(world: Matrix): void;
  55839. /**
  55840. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55841. * @param world The world matrix to bind.
  55842. * @param subMesh The submesh to bind for.
  55843. */
  55844. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55845. /**
  55846. * Checks to see if a texture is used in the material.
  55847. * @param texture - Base texture to use.
  55848. * @returns - Boolean specifying if a texture is used in the material.
  55849. */
  55850. hasTexture(texture: BaseTexture): boolean;
  55851. /**
  55852. * Dispose the material.
  55853. * @param forceDisposeEffect Force disposal of the associated effect.
  55854. * @param forceDisposeTextures Force disposal of the associated textures.
  55855. */
  55856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55857. /**
  55858. * Clones the material.
  55859. * @param name The cloned name.
  55860. * @returns The cloned material.
  55861. */
  55862. clone(name: string): BackgroundMaterial;
  55863. /**
  55864. * Serializes the current material to its JSON representation.
  55865. * @returns The JSON representation.
  55866. */
  55867. serialize(): any;
  55868. /**
  55869. * Gets the class name of the material
  55870. * @returns "BackgroundMaterial"
  55871. */
  55872. getClassName(): string;
  55873. /**
  55874. * Parse a JSON input to create back a background material.
  55875. * @param source The JSON data to parse
  55876. * @param scene The scene to create the parsed material in
  55877. * @param rootUrl The root url of the assets the material depends upon
  55878. * @returns the instantiated BackgroundMaterial.
  55879. */
  55880. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55881. }
  55882. }
  55883. declare module "babylonjs/Helpers/environmentHelper" {
  55884. import { Observable } from "babylonjs/Misc/observable";
  55885. import { Nullable } from "babylonjs/types";
  55886. import { Scene } from "babylonjs/scene";
  55887. import { Vector3 } from "babylonjs/Maths/math.vector";
  55888. import { Color3 } from "babylonjs/Maths/math.color";
  55889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55890. import { Mesh } from "babylonjs/Meshes/mesh";
  55891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55892. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55893. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55894. import "babylonjs/Meshes/Builders/planeBuilder";
  55895. import "babylonjs/Meshes/Builders/boxBuilder";
  55896. /**
  55897. * Represents the different options available during the creation of
  55898. * a Environment helper.
  55899. *
  55900. * This can control the default ground, skybox and image processing setup of your scene.
  55901. */
  55902. export interface IEnvironmentHelperOptions {
  55903. /**
  55904. * Specifies whether or not to create a ground.
  55905. * True by default.
  55906. */
  55907. createGround: boolean;
  55908. /**
  55909. * Specifies the ground size.
  55910. * 15 by default.
  55911. */
  55912. groundSize: number;
  55913. /**
  55914. * The texture used on the ground for the main color.
  55915. * Comes from the BabylonJS CDN by default.
  55916. *
  55917. * Remarks: Can be either a texture or a url.
  55918. */
  55919. groundTexture: string | BaseTexture;
  55920. /**
  55921. * The color mixed in the ground texture by default.
  55922. * BabylonJS clearColor by default.
  55923. */
  55924. groundColor: Color3;
  55925. /**
  55926. * Specifies the ground opacity.
  55927. * 1 by default.
  55928. */
  55929. groundOpacity: number;
  55930. /**
  55931. * Enables the ground to receive shadows.
  55932. * True by default.
  55933. */
  55934. enableGroundShadow: boolean;
  55935. /**
  55936. * Helps preventing the shadow to be fully black on the ground.
  55937. * 0.5 by default.
  55938. */
  55939. groundShadowLevel: number;
  55940. /**
  55941. * Creates a mirror texture attach to the ground.
  55942. * false by default.
  55943. */
  55944. enableGroundMirror: boolean;
  55945. /**
  55946. * Specifies the ground mirror size ratio.
  55947. * 0.3 by default as the default kernel is 64.
  55948. */
  55949. groundMirrorSizeRatio: number;
  55950. /**
  55951. * Specifies the ground mirror blur kernel size.
  55952. * 64 by default.
  55953. */
  55954. groundMirrorBlurKernel: number;
  55955. /**
  55956. * Specifies the ground mirror visibility amount.
  55957. * 1 by default
  55958. */
  55959. groundMirrorAmount: number;
  55960. /**
  55961. * Specifies the ground mirror reflectance weight.
  55962. * This uses the standard weight of the background material to setup the fresnel effect
  55963. * of the mirror.
  55964. * 1 by default.
  55965. */
  55966. groundMirrorFresnelWeight: number;
  55967. /**
  55968. * Specifies the ground mirror Falloff distance.
  55969. * This can helps reducing the size of the reflection.
  55970. * 0 by Default.
  55971. */
  55972. groundMirrorFallOffDistance: number;
  55973. /**
  55974. * Specifies the ground mirror texture type.
  55975. * Unsigned Int by Default.
  55976. */
  55977. groundMirrorTextureType: number;
  55978. /**
  55979. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55980. * the shown objects.
  55981. */
  55982. groundYBias: number;
  55983. /**
  55984. * Specifies whether or not to create a skybox.
  55985. * True by default.
  55986. */
  55987. createSkybox: boolean;
  55988. /**
  55989. * Specifies the skybox size.
  55990. * 20 by default.
  55991. */
  55992. skyboxSize: number;
  55993. /**
  55994. * The texture used on the skybox for the main color.
  55995. * Comes from the BabylonJS CDN by default.
  55996. *
  55997. * Remarks: Can be either a texture or a url.
  55998. */
  55999. skyboxTexture: string | BaseTexture;
  56000. /**
  56001. * The color mixed in the skybox texture by default.
  56002. * BabylonJS clearColor by default.
  56003. */
  56004. skyboxColor: Color3;
  56005. /**
  56006. * The background rotation around the Y axis of the scene.
  56007. * This helps aligning the key lights of your scene with the background.
  56008. * 0 by default.
  56009. */
  56010. backgroundYRotation: number;
  56011. /**
  56012. * Compute automatically the size of the elements to best fit with the scene.
  56013. */
  56014. sizeAuto: boolean;
  56015. /**
  56016. * Default position of the rootMesh if autoSize is not true.
  56017. */
  56018. rootPosition: Vector3;
  56019. /**
  56020. * Sets up the image processing in the scene.
  56021. * true by default.
  56022. */
  56023. setupImageProcessing: boolean;
  56024. /**
  56025. * The texture used as your environment texture in the scene.
  56026. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56027. *
  56028. * Remarks: Can be either a texture or a url.
  56029. */
  56030. environmentTexture: string | BaseTexture;
  56031. /**
  56032. * The value of the exposure to apply to the scene.
  56033. * 0.6 by default if setupImageProcessing is true.
  56034. */
  56035. cameraExposure: number;
  56036. /**
  56037. * The value of the contrast to apply to the scene.
  56038. * 1.6 by default if setupImageProcessing is true.
  56039. */
  56040. cameraContrast: number;
  56041. /**
  56042. * Specifies whether or not tonemapping should be enabled in the scene.
  56043. * true by default if setupImageProcessing is true.
  56044. */
  56045. toneMappingEnabled: boolean;
  56046. }
  56047. /**
  56048. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56049. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56050. * It also helps with the default setup of your imageProcessing configuration.
  56051. */
  56052. export class EnvironmentHelper {
  56053. /**
  56054. * Default ground texture URL.
  56055. */
  56056. private static _groundTextureCDNUrl;
  56057. /**
  56058. * Default skybox texture URL.
  56059. */
  56060. private static _skyboxTextureCDNUrl;
  56061. /**
  56062. * Default environment texture URL.
  56063. */
  56064. private static _environmentTextureCDNUrl;
  56065. /**
  56066. * Creates the default options for the helper.
  56067. */
  56068. private static _getDefaultOptions;
  56069. private _rootMesh;
  56070. /**
  56071. * Gets the root mesh created by the helper.
  56072. */
  56073. get rootMesh(): Mesh;
  56074. private _skybox;
  56075. /**
  56076. * Gets the skybox created by the helper.
  56077. */
  56078. get skybox(): Nullable<Mesh>;
  56079. private _skyboxTexture;
  56080. /**
  56081. * Gets the skybox texture created by the helper.
  56082. */
  56083. get skyboxTexture(): Nullable<BaseTexture>;
  56084. private _skyboxMaterial;
  56085. /**
  56086. * Gets the skybox material created by the helper.
  56087. */
  56088. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56089. private _ground;
  56090. /**
  56091. * Gets the ground mesh created by the helper.
  56092. */
  56093. get ground(): Nullable<Mesh>;
  56094. private _groundTexture;
  56095. /**
  56096. * Gets the ground texture created by the helper.
  56097. */
  56098. get groundTexture(): Nullable<BaseTexture>;
  56099. private _groundMirror;
  56100. /**
  56101. * Gets the ground mirror created by the helper.
  56102. */
  56103. get groundMirror(): Nullable<MirrorTexture>;
  56104. /**
  56105. * Gets the ground mirror render list to helps pushing the meshes
  56106. * you wish in the ground reflection.
  56107. */
  56108. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56109. private _groundMaterial;
  56110. /**
  56111. * Gets the ground material created by the helper.
  56112. */
  56113. get groundMaterial(): Nullable<BackgroundMaterial>;
  56114. /**
  56115. * Stores the creation options.
  56116. */
  56117. private readonly _scene;
  56118. private _options;
  56119. /**
  56120. * This observable will be notified with any error during the creation of the environment,
  56121. * mainly texture creation errors.
  56122. */
  56123. onErrorObservable: Observable<{
  56124. message?: string;
  56125. exception?: any;
  56126. }>;
  56127. /**
  56128. * constructor
  56129. * @param options Defines the options we want to customize the helper
  56130. * @param scene The scene to add the material to
  56131. */
  56132. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56133. /**
  56134. * Updates the background according to the new options
  56135. * @param options
  56136. */
  56137. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56138. /**
  56139. * Sets the primary color of all the available elements.
  56140. * @param color the main color to affect to the ground and the background
  56141. */
  56142. setMainColor(color: Color3): void;
  56143. /**
  56144. * Setup the image processing according to the specified options.
  56145. */
  56146. private _setupImageProcessing;
  56147. /**
  56148. * Setup the environment texture according to the specified options.
  56149. */
  56150. private _setupEnvironmentTexture;
  56151. /**
  56152. * Setup the background according to the specified options.
  56153. */
  56154. private _setupBackground;
  56155. /**
  56156. * Get the scene sizes according to the setup.
  56157. */
  56158. private _getSceneSize;
  56159. /**
  56160. * Setup the ground according to the specified options.
  56161. */
  56162. private _setupGround;
  56163. /**
  56164. * Setup the ground material according to the specified options.
  56165. */
  56166. private _setupGroundMaterial;
  56167. /**
  56168. * Setup the ground diffuse texture according to the specified options.
  56169. */
  56170. private _setupGroundDiffuseTexture;
  56171. /**
  56172. * Setup the ground mirror texture according to the specified options.
  56173. */
  56174. private _setupGroundMirrorTexture;
  56175. /**
  56176. * Setup the ground to receive the mirror texture.
  56177. */
  56178. private _setupMirrorInGroundMaterial;
  56179. /**
  56180. * Setup the skybox according to the specified options.
  56181. */
  56182. private _setupSkybox;
  56183. /**
  56184. * Setup the skybox material according to the specified options.
  56185. */
  56186. private _setupSkyboxMaterial;
  56187. /**
  56188. * Setup the skybox reflection texture according to the specified options.
  56189. */
  56190. private _setupSkyboxReflectionTexture;
  56191. private _errorHandler;
  56192. /**
  56193. * Dispose all the elements created by the Helper.
  56194. */
  56195. dispose(): void;
  56196. }
  56197. }
  56198. declare module "babylonjs/Helpers/photoDome" {
  56199. import { Observable } from "babylonjs/Misc/observable";
  56200. import { Nullable } from "babylonjs/types";
  56201. import { Scene } from "babylonjs/scene";
  56202. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56203. import { Mesh } from "babylonjs/Meshes/mesh";
  56204. import { Texture } from "babylonjs/Materials/Textures/texture";
  56205. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56206. import "babylonjs/Meshes/Builders/sphereBuilder";
  56207. /**
  56208. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56209. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56210. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56211. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56212. */
  56213. export class PhotoDome extends TransformNode {
  56214. /**
  56215. * Define the image as a Monoscopic panoramic 360 image.
  56216. */
  56217. static readonly MODE_MONOSCOPIC: number;
  56218. /**
  56219. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56220. */
  56221. static readonly MODE_TOPBOTTOM: number;
  56222. /**
  56223. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56224. */
  56225. static readonly MODE_SIDEBYSIDE: number;
  56226. private _useDirectMapping;
  56227. /**
  56228. * The texture being displayed on the sphere
  56229. */
  56230. protected _photoTexture: Texture;
  56231. /**
  56232. * Gets or sets the texture being displayed on the sphere
  56233. */
  56234. get photoTexture(): Texture;
  56235. set photoTexture(value: Texture);
  56236. /**
  56237. * Observable raised when an error occured while loading the 360 image
  56238. */
  56239. onLoadErrorObservable: Observable<string>;
  56240. /**
  56241. * The skybox material
  56242. */
  56243. protected _material: BackgroundMaterial;
  56244. /**
  56245. * The surface used for the skybox
  56246. */
  56247. protected _mesh: Mesh;
  56248. /**
  56249. * Gets the mesh used for the skybox.
  56250. */
  56251. get mesh(): Mesh;
  56252. /**
  56253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56254. * Also see the options.resolution property.
  56255. */
  56256. get fovMultiplier(): number;
  56257. set fovMultiplier(value: number);
  56258. private _imageMode;
  56259. /**
  56260. * Gets or set the current video mode for the video. It can be:
  56261. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56262. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56263. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56264. */
  56265. get imageMode(): number;
  56266. set imageMode(value: number);
  56267. /**
  56268. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56269. * @param name Element's name, child elements will append suffixes for their own names.
  56270. * @param urlsOfPhoto defines the url of the photo to display
  56271. * @param options defines an object containing optional or exposed sub element properties
  56272. * @param onError defines a callback called when an error occured while loading the texture
  56273. */
  56274. constructor(name: string, urlOfPhoto: string, options: {
  56275. resolution?: number;
  56276. size?: number;
  56277. useDirectMapping?: boolean;
  56278. faceForward?: boolean;
  56279. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56280. private _onBeforeCameraRenderObserver;
  56281. private _changeImageMode;
  56282. /**
  56283. * Releases resources associated with this node.
  56284. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56285. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56286. */
  56287. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56288. }
  56289. }
  56290. declare module "babylonjs/Misc/rgbdTextureTools" {
  56291. import "babylonjs/Shaders/rgbdDecode.fragment";
  56292. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56293. import { Texture } from "babylonjs/Materials/Textures/texture";
  56294. /**
  56295. * Class used to host RGBD texture specific utilities
  56296. */
  56297. export class RGBDTextureTools {
  56298. /**
  56299. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56300. * @param texture the texture to expand.
  56301. */
  56302. static ExpandRGBDTexture(texture: Texture): void;
  56303. }
  56304. }
  56305. declare module "babylonjs/Misc/brdfTextureTools" {
  56306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56307. import { Scene } from "babylonjs/scene";
  56308. /**
  56309. * Class used to host texture specific utilities
  56310. */
  56311. export class BRDFTextureTools {
  56312. /**
  56313. * Prevents texture cache collision
  56314. */
  56315. private static _instanceNumber;
  56316. /**
  56317. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56318. * @param scene defines the hosting scene
  56319. * @returns the environment BRDF texture
  56320. */
  56321. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56322. private static _environmentBRDFBase64Texture;
  56323. }
  56324. }
  56325. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56326. import { Nullable } from "babylonjs/types";
  56327. import { Color3 } from "babylonjs/Maths/math.color";
  56328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56329. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56330. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56331. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56332. import { Engine } from "babylonjs/Engines/engine";
  56333. import { Scene } from "babylonjs/scene";
  56334. /**
  56335. * @hidden
  56336. */
  56337. export interface IMaterialClearCoatDefines {
  56338. CLEARCOAT: boolean;
  56339. CLEARCOAT_DEFAULTIOR: boolean;
  56340. CLEARCOAT_TEXTURE: boolean;
  56341. CLEARCOAT_TEXTUREDIRECTUV: number;
  56342. CLEARCOAT_BUMP: boolean;
  56343. CLEARCOAT_BUMPDIRECTUV: number;
  56344. CLEARCOAT_TINT: boolean;
  56345. CLEARCOAT_TINT_TEXTURE: boolean;
  56346. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56347. /** @hidden */
  56348. _areTexturesDirty: boolean;
  56349. }
  56350. /**
  56351. * Define the code related to the clear coat parameters of the pbr material.
  56352. */
  56353. export class PBRClearCoatConfiguration {
  56354. /**
  56355. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56356. * The default fits with a polyurethane material.
  56357. */
  56358. private static readonly _DefaultIndexOfRefraction;
  56359. private _isEnabled;
  56360. /**
  56361. * Defines if the clear coat is enabled in the material.
  56362. */
  56363. isEnabled: boolean;
  56364. /**
  56365. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56366. */
  56367. intensity: number;
  56368. /**
  56369. * Defines the clear coat layer roughness.
  56370. */
  56371. roughness: number;
  56372. private _indexOfRefraction;
  56373. /**
  56374. * Defines the index of refraction of the clear coat.
  56375. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56376. * The default fits with a polyurethane material.
  56377. * Changing the default value is more performance intensive.
  56378. */
  56379. indexOfRefraction: number;
  56380. private _texture;
  56381. /**
  56382. * Stores the clear coat values in a texture.
  56383. */
  56384. texture: Nullable<BaseTexture>;
  56385. private _bumpTexture;
  56386. /**
  56387. * Define the clear coat specific bump texture.
  56388. */
  56389. bumpTexture: Nullable<BaseTexture>;
  56390. private _isTintEnabled;
  56391. /**
  56392. * Defines if the clear coat tint is enabled in the material.
  56393. */
  56394. isTintEnabled: boolean;
  56395. /**
  56396. * Defines the clear coat tint of the material.
  56397. * This is only use if tint is enabled
  56398. */
  56399. tintColor: Color3;
  56400. /**
  56401. * Defines the distance at which the tint color should be found in the
  56402. * clear coat media.
  56403. * This is only use if tint is enabled
  56404. */
  56405. tintColorAtDistance: number;
  56406. /**
  56407. * Defines the clear coat layer thickness.
  56408. * This is only use if tint is enabled
  56409. */
  56410. tintThickness: number;
  56411. private _tintTexture;
  56412. /**
  56413. * Stores the clear tint values in a texture.
  56414. * rgb is tint
  56415. * a is a thickness factor
  56416. */
  56417. tintTexture: Nullable<BaseTexture>;
  56418. /** @hidden */
  56419. private _internalMarkAllSubMeshesAsTexturesDirty;
  56420. /** @hidden */
  56421. _markAllSubMeshesAsTexturesDirty(): void;
  56422. /**
  56423. * Instantiate a new istance of clear coat configuration.
  56424. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56425. */
  56426. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56427. /**
  56428. * Gets wehter the submesh is ready to be used or not.
  56429. * @param defines the list of "defines" to update.
  56430. * @param scene defines the scene the material belongs to.
  56431. * @param engine defines the engine the material belongs to.
  56432. * @param disableBumpMap defines wether the material disables bump or not.
  56433. * @returns - boolean indicating that the submesh is ready or not.
  56434. */
  56435. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56436. /**
  56437. * Checks to see if a texture is used in the material.
  56438. * @param defines the list of "defines" to update.
  56439. * @param scene defines the scene to the material belongs to.
  56440. */
  56441. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56442. /**
  56443. * Binds the material data.
  56444. * @param uniformBuffer defines the Uniform buffer to fill in.
  56445. * @param scene defines the scene the material belongs to.
  56446. * @param engine defines the engine the material belongs to.
  56447. * @param disableBumpMap defines wether the material disables bump or not.
  56448. * @param isFrozen defines wether the material is frozen or not.
  56449. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56450. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56451. */
  56452. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56453. /**
  56454. * Checks to see if a texture is used in the material.
  56455. * @param texture - Base texture to use.
  56456. * @returns - Boolean specifying if a texture is used in the material.
  56457. */
  56458. hasTexture(texture: BaseTexture): boolean;
  56459. /**
  56460. * Returns an array of the actively used textures.
  56461. * @param activeTextures Array of BaseTextures
  56462. */
  56463. getActiveTextures(activeTextures: BaseTexture[]): void;
  56464. /**
  56465. * Returns the animatable textures.
  56466. * @param animatables Array of animatable textures.
  56467. */
  56468. getAnimatables(animatables: IAnimatable[]): void;
  56469. /**
  56470. * Disposes the resources of the material.
  56471. * @param forceDisposeTextures - Forces the disposal of all textures.
  56472. */
  56473. dispose(forceDisposeTextures?: boolean): void;
  56474. /**
  56475. * Get the current class name of the texture useful for serialization or dynamic coding.
  56476. * @returns "PBRClearCoatConfiguration"
  56477. */
  56478. getClassName(): string;
  56479. /**
  56480. * Add fallbacks to the effect fallbacks list.
  56481. * @param defines defines the Base texture to use.
  56482. * @param fallbacks defines the current fallback list.
  56483. * @param currentRank defines the current fallback rank.
  56484. * @returns the new fallback rank.
  56485. */
  56486. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56487. /**
  56488. * Add the required uniforms to the current list.
  56489. * @param uniforms defines the current uniform list.
  56490. */
  56491. static AddUniforms(uniforms: string[]): void;
  56492. /**
  56493. * Add the required samplers to the current list.
  56494. * @param samplers defines the current sampler list.
  56495. */
  56496. static AddSamplers(samplers: string[]): void;
  56497. /**
  56498. * Add the required uniforms to the current buffer.
  56499. * @param uniformBuffer defines the current uniform buffer.
  56500. */
  56501. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56502. /**
  56503. * Makes a duplicate of the current configuration into another one.
  56504. * @param clearCoatConfiguration define the config where to copy the info
  56505. */
  56506. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56507. /**
  56508. * Serializes this clear coat configuration.
  56509. * @returns - An object with the serialized config.
  56510. */
  56511. serialize(): any;
  56512. /**
  56513. * Parses a anisotropy Configuration from a serialized object.
  56514. * @param source - Serialized object.
  56515. * @param scene Defines the scene we are parsing for
  56516. * @param rootUrl Defines the rootUrl to load from
  56517. */
  56518. parse(source: any, scene: Scene, rootUrl: string): void;
  56519. }
  56520. }
  56521. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56522. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56524. import { Vector2 } from "babylonjs/Maths/math.vector";
  56525. import { Scene } from "babylonjs/scene";
  56526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56527. import { Nullable } from "babylonjs/types";
  56528. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56529. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56530. /**
  56531. * @hidden
  56532. */
  56533. export interface IMaterialAnisotropicDefines {
  56534. ANISOTROPIC: boolean;
  56535. ANISOTROPIC_TEXTURE: boolean;
  56536. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56537. MAINUV1: boolean;
  56538. _areTexturesDirty: boolean;
  56539. _needUVs: boolean;
  56540. }
  56541. /**
  56542. * Define the code related to the anisotropic parameters of the pbr material.
  56543. */
  56544. export class PBRAnisotropicConfiguration {
  56545. private _isEnabled;
  56546. /**
  56547. * Defines if the anisotropy is enabled in the material.
  56548. */
  56549. isEnabled: boolean;
  56550. /**
  56551. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56552. */
  56553. intensity: number;
  56554. /**
  56555. * Defines if the effect is along the tangents, bitangents or in between.
  56556. * By default, the effect is "strectching" the highlights along the tangents.
  56557. */
  56558. direction: Vector2;
  56559. private _texture;
  56560. /**
  56561. * Stores the anisotropy values in a texture.
  56562. * rg is direction (like normal from -1 to 1)
  56563. * b is a intensity
  56564. */
  56565. texture: Nullable<BaseTexture>;
  56566. /** @hidden */
  56567. private _internalMarkAllSubMeshesAsTexturesDirty;
  56568. /** @hidden */
  56569. _markAllSubMeshesAsTexturesDirty(): void;
  56570. /**
  56571. * Instantiate a new istance of anisotropy configuration.
  56572. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56573. */
  56574. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56575. /**
  56576. * Specifies that the submesh is ready to be used.
  56577. * @param defines the list of "defines" to update.
  56578. * @param scene defines the scene the material belongs to.
  56579. * @returns - boolean indicating that the submesh is ready or not.
  56580. */
  56581. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56582. /**
  56583. * Checks to see if a texture is used in the material.
  56584. * @param defines the list of "defines" to update.
  56585. * @param mesh the mesh we are preparing the defines for.
  56586. * @param scene defines the scene the material belongs to.
  56587. */
  56588. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56589. /**
  56590. * Binds the material data.
  56591. * @param uniformBuffer defines the Uniform buffer to fill in.
  56592. * @param scene defines the scene the material belongs to.
  56593. * @param isFrozen defines wether the material is frozen or not.
  56594. */
  56595. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56596. /**
  56597. * Checks to see if a texture is used in the material.
  56598. * @param texture - Base texture to use.
  56599. * @returns - Boolean specifying if a texture is used in the material.
  56600. */
  56601. hasTexture(texture: BaseTexture): boolean;
  56602. /**
  56603. * Returns an array of the actively used textures.
  56604. * @param activeTextures Array of BaseTextures
  56605. */
  56606. getActiveTextures(activeTextures: BaseTexture[]): void;
  56607. /**
  56608. * Returns the animatable textures.
  56609. * @param animatables Array of animatable textures.
  56610. */
  56611. getAnimatables(animatables: IAnimatable[]): void;
  56612. /**
  56613. * Disposes the resources of the material.
  56614. * @param forceDisposeTextures - Forces the disposal of all textures.
  56615. */
  56616. dispose(forceDisposeTextures?: boolean): void;
  56617. /**
  56618. * Get the current class name of the texture useful for serialization or dynamic coding.
  56619. * @returns "PBRAnisotropicConfiguration"
  56620. */
  56621. getClassName(): string;
  56622. /**
  56623. * Add fallbacks to the effect fallbacks list.
  56624. * @param defines defines the Base texture to use.
  56625. * @param fallbacks defines the current fallback list.
  56626. * @param currentRank defines the current fallback rank.
  56627. * @returns the new fallback rank.
  56628. */
  56629. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56630. /**
  56631. * Add the required uniforms to the current list.
  56632. * @param uniforms defines the current uniform list.
  56633. */
  56634. static AddUniforms(uniforms: string[]): void;
  56635. /**
  56636. * Add the required uniforms to the current buffer.
  56637. * @param uniformBuffer defines the current uniform buffer.
  56638. */
  56639. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56640. /**
  56641. * Add the required samplers to the current list.
  56642. * @param samplers defines the current sampler list.
  56643. */
  56644. static AddSamplers(samplers: string[]): void;
  56645. /**
  56646. * Makes a duplicate of the current configuration into another one.
  56647. * @param anisotropicConfiguration define the config where to copy the info
  56648. */
  56649. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56650. /**
  56651. * Serializes this anisotropy configuration.
  56652. * @returns - An object with the serialized config.
  56653. */
  56654. serialize(): any;
  56655. /**
  56656. * Parses a anisotropy Configuration from a serialized object.
  56657. * @param source - Serialized object.
  56658. * @param scene Defines the scene we are parsing for
  56659. * @param rootUrl Defines the rootUrl to load from
  56660. */
  56661. parse(source: any, scene: Scene, rootUrl: string): void;
  56662. }
  56663. }
  56664. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56665. import { Scene } from "babylonjs/scene";
  56666. /**
  56667. * @hidden
  56668. */
  56669. export interface IMaterialBRDFDefines {
  56670. BRDF_V_HEIGHT_CORRELATED: boolean;
  56671. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56672. SPHERICAL_HARMONICS: boolean;
  56673. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56674. /** @hidden */
  56675. _areMiscDirty: boolean;
  56676. }
  56677. /**
  56678. * Define the code related to the BRDF parameters of the pbr material.
  56679. */
  56680. export class PBRBRDFConfiguration {
  56681. /**
  56682. * Default value used for the energy conservation.
  56683. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56684. */
  56685. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56686. /**
  56687. * Default value used for the Smith Visibility Height Correlated mode.
  56688. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56689. */
  56690. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56691. /**
  56692. * Default value used for the IBL diffuse part.
  56693. * This can help switching back to the polynomials mode globally which is a tiny bit
  56694. * less GPU intensive at the drawback of a lower quality.
  56695. */
  56696. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56697. /**
  56698. * Default value used for activating energy conservation for the specular workflow.
  56699. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56700. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56701. */
  56702. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56703. private _useEnergyConservation;
  56704. /**
  56705. * Defines if the material uses energy conservation.
  56706. */
  56707. useEnergyConservation: boolean;
  56708. private _useSmithVisibilityHeightCorrelated;
  56709. /**
  56710. * LEGACY Mode set to false
  56711. * Defines if the material uses height smith correlated visibility term.
  56712. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56713. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56714. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56715. * Not relying on height correlated will also disable energy conservation.
  56716. */
  56717. useSmithVisibilityHeightCorrelated: boolean;
  56718. private _useSphericalHarmonics;
  56719. /**
  56720. * LEGACY Mode set to false
  56721. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56722. * diffuse part of the IBL.
  56723. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56724. * to the ground truth.
  56725. */
  56726. useSphericalHarmonics: boolean;
  56727. private _useSpecularGlossinessInputEnergyConservation;
  56728. /**
  56729. * Defines if the material uses energy conservation, when the specular workflow is active.
  56730. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56731. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56732. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56733. */
  56734. useSpecularGlossinessInputEnergyConservation: boolean;
  56735. /** @hidden */
  56736. private _internalMarkAllSubMeshesAsMiscDirty;
  56737. /** @hidden */
  56738. _markAllSubMeshesAsMiscDirty(): void;
  56739. /**
  56740. * Instantiate a new istance of clear coat configuration.
  56741. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56742. */
  56743. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56744. /**
  56745. * Checks to see if a texture is used in the material.
  56746. * @param defines the list of "defines" to update.
  56747. */
  56748. prepareDefines(defines: IMaterialBRDFDefines): void;
  56749. /**
  56750. * Get the current class name of the texture useful for serialization or dynamic coding.
  56751. * @returns "PBRClearCoatConfiguration"
  56752. */
  56753. getClassName(): string;
  56754. /**
  56755. * Makes a duplicate of the current configuration into another one.
  56756. * @param brdfConfiguration define the config where to copy the info
  56757. */
  56758. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56759. /**
  56760. * Serializes this BRDF configuration.
  56761. * @returns - An object with the serialized config.
  56762. */
  56763. serialize(): any;
  56764. /**
  56765. * Parses a anisotropy Configuration from a serialized object.
  56766. * @param source - Serialized object.
  56767. * @param scene Defines the scene we are parsing for
  56768. * @param rootUrl Defines the rootUrl to load from
  56769. */
  56770. parse(source: any, scene: Scene, rootUrl: string): void;
  56771. }
  56772. }
  56773. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56774. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56775. import { Color3 } from "babylonjs/Maths/math.color";
  56776. import { Scene } from "babylonjs/scene";
  56777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56778. import { Nullable } from "babylonjs/types";
  56779. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56780. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56781. /**
  56782. * @hidden
  56783. */
  56784. export interface IMaterialSheenDefines {
  56785. SHEEN: boolean;
  56786. SHEEN_TEXTURE: boolean;
  56787. SHEEN_TEXTUREDIRECTUV: number;
  56788. SHEEN_LINKWITHALBEDO: boolean;
  56789. SHEEN_ROUGHNESS: boolean;
  56790. SHEEN_ALBEDOSCALING: boolean;
  56791. /** @hidden */
  56792. _areTexturesDirty: boolean;
  56793. }
  56794. /**
  56795. * Define the code related to the Sheen parameters of the pbr material.
  56796. */
  56797. export class PBRSheenConfiguration {
  56798. private _isEnabled;
  56799. /**
  56800. * Defines if the material uses sheen.
  56801. */
  56802. isEnabled: boolean;
  56803. private _linkSheenWithAlbedo;
  56804. /**
  56805. * Defines if the sheen is linked to the sheen color.
  56806. */
  56807. linkSheenWithAlbedo: boolean;
  56808. /**
  56809. * Defines the sheen intensity.
  56810. */
  56811. intensity: number;
  56812. /**
  56813. * Defines the sheen color.
  56814. */
  56815. color: Color3;
  56816. private _texture;
  56817. /**
  56818. * Stores the sheen tint values in a texture.
  56819. * rgb is tint
  56820. * a is a intensity or roughness if roughness has been defined
  56821. */
  56822. texture: Nullable<BaseTexture>;
  56823. private _roughness;
  56824. /**
  56825. * Defines the sheen roughness.
  56826. * It is not taken into account if linkSheenWithAlbedo is true.
  56827. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56828. */
  56829. roughness: Nullable<number>;
  56830. private _albedoScaling;
  56831. /**
  56832. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56833. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56834. * making it easier to setup and tweak the effect
  56835. */
  56836. albedoScaling: boolean;
  56837. /** @hidden */
  56838. private _internalMarkAllSubMeshesAsTexturesDirty;
  56839. /** @hidden */
  56840. _markAllSubMeshesAsTexturesDirty(): void;
  56841. /**
  56842. * Instantiate a new istance of clear coat configuration.
  56843. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56844. */
  56845. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56846. /**
  56847. * Specifies that the submesh is ready to be used.
  56848. * @param defines the list of "defines" to update.
  56849. * @param scene defines the scene the material belongs to.
  56850. * @returns - boolean indicating that the submesh is ready or not.
  56851. */
  56852. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56853. /**
  56854. * Checks to see if a texture is used in the material.
  56855. * @param defines the list of "defines" to update.
  56856. * @param scene defines the scene the material belongs to.
  56857. */
  56858. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56859. /**
  56860. * Binds the material data.
  56861. * @param uniformBuffer defines the Uniform buffer to fill in.
  56862. * @param scene defines the scene the material belongs to.
  56863. * @param isFrozen defines wether the material is frozen or not.
  56864. */
  56865. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56866. /**
  56867. * Checks to see if a texture is used in the material.
  56868. * @param texture - Base texture to use.
  56869. * @returns - Boolean specifying if a texture is used in the material.
  56870. */
  56871. hasTexture(texture: BaseTexture): boolean;
  56872. /**
  56873. * Returns an array of the actively used textures.
  56874. * @param activeTextures Array of BaseTextures
  56875. */
  56876. getActiveTextures(activeTextures: BaseTexture[]): void;
  56877. /**
  56878. * Returns the animatable textures.
  56879. * @param animatables Array of animatable textures.
  56880. */
  56881. getAnimatables(animatables: IAnimatable[]): void;
  56882. /**
  56883. * Disposes the resources of the material.
  56884. * @param forceDisposeTextures - Forces the disposal of all textures.
  56885. */
  56886. dispose(forceDisposeTextures?: boolean): void;
  56887. /**
  56888. * Get the current class name of the texture useful for serialization or dynamic coding.
  56889. * @returns "PBRSheenConfiguration"
  56890. */
  56891. getClassName(): string;
  56892. /**
  56893. * Add fallbacks to the effect fallbacks list.
  56894. * @param defines defines the Base texture to use.
  56895. * @param fallbacks defines the current fallback list.
  56896. * @param currentRank defines the current fallback rank.
  56897. * @returns the new fallback rank.
  56898. */
  56899. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56900. /**
  56901. * Add the required uniforms to the current list.
  56902. * @param uniforms defines the current uniform list.
  56903. */
  56904. static AddUniforms(uniforms: string[]): void;
  56905. /**
  56906. * Add the required uniforms to the current buffer.
  56907. * @param uniformBuffer defines the current uniform buffer.
  56908. */
  56909. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56910. /**
  56911. * Add the required samplers to the current list.
  56912. * @param samplers defines the current sampler list.
  56913. */
  56914. static AddSamplers(samplers: string[]): void;
  56915. /**
  56916. * Makes a duplicate of the current configuration into another one.
  56917. * @param sheenConfiguration define the config where to copy the info
  56918. */
  56919. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56920. /**
  56921. * Serializes this BRDF configuration.
  56922. * @returns - An object with the serialized config.
  56923. */
  56924. serialize(): any;
  56925. /**
  56926. * Parses a anisotropy Configuration from a serialized object.
  56927. * @param source - Serialized object.
  56928. * @param scene Defines the scene we are parsing for
  56929. * @param rootUrl Defines the rootUrl to load from
  56930. */
  56931. parse(source: any, scene: Scene, rootUrl: string): void;
  56932. }
  56933. }
  56934. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56935. import { Nullable } from "babylonjs/types";
  56936. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56937. import { Color3 } from "babylonjs/Maths/math.color";
  56938. import { SmartArray } from "babylonjs/Misc/smartArray";
  56939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56940. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56941. import { Effect } from "babylonjs/Materials/effect";
  56942. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56943. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56944. import { Engine } from "babylonjs/Engines/engine";
  56945. import { Scene } from "babylonjs/scene";
  56946. /**
  56947. * @hidden
  56948. */
  56949. export interface IMaterialSubSurfaceDefines {
  56950. SUBSURFACE: boolean;
  56951. SS_REFRACTION: boolean;
  56952. SS_TRANSLUCENCY: boolean;
  56953. SS_SCATTERING: boolean;
  56954. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56955. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56956. SS_REFRACTIONMAP_3D: boolean;
  56957. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56958. SS_LODINREFRACTIONALPHA: boolean;
  56959. SS_GAMMAREFRACTION: boolean;
  56960. SS_RGBDREFRACTION: boolean;
  56961. SS_LINEARSPECULARREFRACTION: boolean;
  56962. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56963. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56964. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56965. /** @hidden */
  56966. _areTexturesDirty: boolean;
  56967. }
  56968. /**
  56969. * Define the code related to the sub surface parameters of the pbr material.
  56970. */
  56971. export class PBRSubSurfaceConfiguration {
  56972. private _isRefractionEnabled;
  56973. /**
  56974. * Defines if the refraction is enabled in the material.
  56975. */
  56976. isRefractionEnabled: boolean;
  56977. private _isTranslucencyEnabled;
  56978. /**
  56979. * Defines if the translucency is enabled in the material.
  56980. */
  56981. isTranslucencyEnabled: boolean;
  56982. private _isScatteringEnabled;
  56983. /**
  56984. * Defines if the sub surface scattering is enabled in the material.
  56985. */
  56986. isScatteringEnabled: boolean;
  56987. private _scatteringDiffusionProfileIndex;
  56988. /**
  56989. * Diffusion profile for subsurface scattering.
  56990. * Useful for better scattering in the skins or foliages.
  56991. */
  56992. get scatteringDiffusionProfile(): Nullable<Color3>;
  56993. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56994. /**
  56995. * Defines the refraction intensity of the material.
  56996. * The refraction when enabled replaces the Diffuse part of the material.
  56997. * The intensity helps transitionning between diffuse and refraction.
  56998. */
  56999. refractionIntensity: number;
  57000. /**
  57001. * Defines the translucency intensity of the material.
  57002. * When translucency has been enabled, this defines how much of the "translucency"
  57003. * is addded to the diffuse part of the material.
  57004. */
  57005. translucencyIntensity: number;
  57006. /**
  57007. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57008. */
  57009. useAlbedoToTintRefraction: boolean;
  57010. private _thicknessTexture;
  57011. /**
  57012. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57013. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57014. * 0 would mean minimumThickness
  57015. * 1 would mean maximumThickness
  57016. * The other channels might be use as a mask to vary the different effects intensity.
  57017. */
  57018. thicknessTexture: Nullable<BaseTexture>;
  57019. private _refractionTexture;
  57020. /**
  57021. * Defines the texture to use for refraction.
  57022. */
  57023. refractionTexture: Nullable<BaseTexture>;
  57024. private _indexOfRefraction;
  57025. /**
  57026. * Index of refraction of the material base layer.
  57027. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57028. *
  57029. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57030. *
  57031. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57032. */
  57033. indexOfRefraction: number;
  57034. private _volumeIndexOfRefraction;
  57035. /**
  57036. * Index of refraction of the material's volume.
  57037. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57038. *
  57039. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57040. * the volume will use the same IOR as the surface.
  57041. */
  57042. get volumeIndexOfRefraction(): number;
  57043. set volumeIndexOfRefraction(value: number);
  57044. private _invertRefractionY;
  57045. /**
  57046. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57047. */
  57048. invertRefractionY: boolean;
  57049. private _linkRefractionWithTransparency;
  57050. /**
  57051. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57052. * Materials half opaque for instance using refraction could benefit from this control.
  57053. */
  57054. linkRefractionWithTransparency: boolean;
  57055. /**
  57056. * Defines the minimum thickness stored in the thickness map.
  57057. * If no thickness map is defined, this value will be used to simulate thickness.
  57058. */
  57059. minimumThickness: number;
  57060. /**
  57061. * Defines the maximum thickness stored in the thickness map.
  57062. */
  57063. maximumThickness: number;
  57064. /**
  57065. * Defines the volume tint of the material.
  57066. * This is used for both translucency and scattering.
  57067. */
  57068. tintColor: Color3;
  57069. /**
  57070. * Defines the distance at which the tint color should be found in the media.
  57071. * This is used for refraction only.
  57072. */
  57073. tintColorAtDistance: number;
  57074. /**
  57075. * Defines how far each channel transmit through the media.
  57076. * It is defined as a color to simplify it selection.
  57077. */
  57078. diffusionDistance: Color3;
  57079. private _useMaskFromThicknessTexture;
  57080. /**
  57081. * Stores the intensity of the different subsurface effects in the thickness texture.
  57082. * * the green channel is the translucency intensity.
  57083. * * the blue channel is the scattering intensity.
  57084. * * the alpha channel is the refraction intensity.
  57085. */
  57086. useMaskFromThicknessTexture: boolean;
  57087. private _scene;
  57088. /** @hidden */
  57089. private _internalMarkAllSubMeshesAsTexturesDirty;
  57090. private _internalMarkScenePrePassDirty;
  57091. /** @hidden */
  57092. _markAllSubMeshesAsTexturesDirty(): void;
  57093. /** @hidden */
  57094. _markScenePrePassDirty(): void;
  57095. /**
  57096. * Instantiate a new istance of sub surface configuration.
  57097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57098. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57099. * @param scene The scene
  57100. */
  57101. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57102. /**
  57103. * Gets wehter the submesh is ready to be used or not.
  57104. * @param defines the list of "defines" to update.
  57105. * @param scene defines the scene the material belongs to.
  57106. * @returns - boolean indicating that the submesh is ready or not.
  57107. */
  57108. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57109. /**
  57110. * Checks to see if a texture is used in the material.
  57111. * @param defines the list of "defines" to update.
  57112. * @param scene defines the scene to the material belongs to.
  57113. */
  57114. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57115. /**
  57116. * Binds the material data.
  57117. * @param uniformBuffer defines the Uniform buffer to fill in.
  57118. * @param scene defines the scene the material belongs to.
  57119. * @param engine defines the engine the material belongs to.
  57120. * @param isFrozen defines whether the material is frozen or not.
  57121. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57122. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57123. */
  57124. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57125. /**
  57126. * Unbinds the material from the mesh.
  57127. * @param activeEffect defines the effect that should be unbound from.
  57128. * @returns true if unbound, otherwise false
  57129. */
  57130. unbind(activeEffect: Effect): boolean;
  57131. /**
  57132. * Returns the texture used for refraction or null if none is used.
  57133. * @param scene defines the scene the material belongs to.
  57134. * @returns - Refraction texture if present. If no refraction texture and refraction
  57135. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57136. */
  57137. private _getRefractionTexture;
  57138. /**
  57139. * Returns true if alpha blending should be disabled.
  57140. */
  57141. get disableAlphaBlending(): boolean;
  57142. /**
  57143. * Fills the list of render target textures.
  57144. * @param renderTargets the list of render targets to update
  57145. */
  57146. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57147. /**
  57148. * Checks to see if a texture is used in the material.
  57149. * @param texture - Base texture to use.
  57150. * @returns - Boolean specifying if a texture is used in the material.
  57151. */
  57152. hasTexture(texture: BaseTexture): boolean;
  57153. /**
  57154. * Gets a boolean indicating that current material needs to register RTT
  57155. * @returns true if this uses a render target otherwise false.
  57156. */
  57157. hasRenderTargetTextures(): boolean;
  57158. /**
  57159. * Returns an array of the actively used textures.
  57160. * @param activeTextures Array of BaseTextures
  57161. */
  57162. getActiveTextures(activeTextures: BaseTexture[]): void;
  57163. /**
  57164. * Returns the animatable textures.
  57165. * @param animatables Array of animatable textures.
  57166. */
  57167. getAnimatables(animatables: IAnimatable[]): void;
  57168. /**
  57169. * Disposes the resources of the material.
  57170. * @param forceDisposeTextures - Forces the disposal of all textures.
  57171. */
  57172. dispose(forceDisposeTextures?: boolean): void;
  57173. /**
  57174. * Get the current class name of the texture useful for serialization or dynamic coding.
  57175. * @returns "PBRSubSurfaceConfiguration"
  57176. */
  57177. getClassName(): string;
  57178. /**
  57179. * Add fallbacks to the effect fallbacks list.
  57180. * @param defines defines the Base texture to use.
  57181. * @param fallbacks defines the current fallback list.
  57182. * @param currentRank defines the current fallback rank.
  57183. * @returns the new fallback rank.
  57184. */
  57185. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57186. /**
  57187. * Add the required uniforms to the current list.
  57188. * @param uniforms defines the current uniform list.
  57189. */
  57190. static AddUniforms(uniforms: string[]): void;
  57191. /**
  57192. * Add the required samplers to the current list.
  57193. * @param samplers defines the current sampler list.
  57194. */
  57195. static AddSamplers(samplers: string[]): void;
  57196. /**
  57197. * Add the required uniforms to the current buffer.
  57198. * @param uniformBuffer defines the current uniform buffer.
  57199. */
  57200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57201. /**
  57202. * Makes a duplicate of the current configuration into another one.
  57203. * @param configuration define the config where to copy the info
  57204. */
  57205. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57206. /**
  57207. * Serializes this Sub Surface configuration.
  57208. * @returns - An object with the serialized config.
  57209. */
  57210. serialize(): any;
  57211. /**
  57212. * Parses a anisotropy Configuration from a serialized object.
  57213. * @param source - Serialized object.
  57214. * @param scene Defines the scene we are parsing for
  57215. * @param rootUrl Defines the rootUrl to load from
  57216. */
  57217. parse(source: any, scene: Scene, rootUrl: string): void;
  57218. }
  57219. }
  57220. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  57221. /** @hidden */
  57222. export var prePassDeclaration: {
  57223. name: string;
  57224. shader: string;
  57225. };
  57226. }
  57227. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57228. /** @hidden */
  57229. export var pbrFragmentDeclaration: {
  57230. name: string;
  57231. shader: string;
  57232. };
  57233. }
  57234. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57235. /** @hidden */
  57236. export var pbrUboDeclaration: {
  57237. name: string;
  57238. shader: string;
  57239. };
  57240. }
  57241. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57242. /** @hidden */
  57243. export var pbrFragmentExtraDeclaration: {
  57244. name: string;
  57245. shader: string;
  57246. };
  57247. }
  57248. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57249. /** @hidden */
  57250. export var pbrFragmentSamplersDeclaration: {
  57251. name: string;
  57252. shader: string;
  57253. };
  57254. }
  57255. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57256. /** @hidden */
  57257. export var subSurfaceScatteringFunctions: {
  57258. name: string;
  57259. shader: string;
  57260. };
  57261. }
  57262. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57263. /** @hidden */
  57264. export var importanceSampling: {
  57265. name: string;
  57266. shader: string;
  57267. };
  57268. }
  57269. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57270. /** @hidden */
  57271. export var pbrHelperFunctions: {
  57272. name: string;
  57273. shader: string;
  57274. };
  57275. }
  57276. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57277. /** @hidden */
  57278. export var harmonicsFunctions: {
  57279. name: string;
  57280. shader: string;
  57281. };
  57282. }
  57283. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57284. /** @hidden */
  57285. export var pbrDirectLightingSetupFunctions: {
  57286. name: string;
  57287. shader: string;
  57288. };
  57289. }
  57290. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57291. /** @hidden */
  57292. export var pbrDirectLightingFalloffFunctions: {
  57293. name: string;
  57294. shader: string;
  57295. };
  57296. }
  57297. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57298. /** @hidden */
  57299. export var pbrBRDFFunctions: {
  57300. name: string;
  57301. shader: string;
  57302. };
  57303. }
  57304. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57305. /** @hidden */
  57306. export var hdrFilteringFunctions: {
  57307. name: string;
  57308. shader: string;
  57309. };
  57310. }
  57311. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57312. /** @hidden */
  57313. export var pbrDirectLightingFunctions: {
  57314. name: string;
  57315. shader: string;
  57316. };
  57317. }
  57318. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57319. /** @hidden */
  57320. export var pbrIBLFunctions: {
  57321. name: string;
  57322. shader: string;
  57323. };
  57324. }
  57325. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57326. /** @hidden */
  57327. export var pbrBlockAlbedoOpacity: {
  57328. name: string;
  57329. shader: string;
  57330. };
  57331. }
  57332. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57333. /** @hidden */
  57334. export var pbrBlockReflectivity: {
  57335. name: string;
  57336. shader: string;
  57337. };
  57338. }
  57339. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57340. /** @hidden */
  57341. export var pbrBlockAmbientOcclusion: {
  57342. name: string;
  57343. shader: string;
  57344. };
  57345. }
  57346. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57347. /** @hidden */
  57348. export var pbrBlockAlphaFresnel: {
  57349. name: string;
  57350. shader: string;
  57351. };
  57352. }
  57353. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57354. /** @hidden */
  57355. export var pbrBlockAnisotropic: {
  57356. name: string;
  57357. shader: string;
  57358. };
  57359. }
  57360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57361. /** @hidden */
  57362. export var pbrBlockReflection: {
  57363. name: string;
  57364. shader: string;
  57365. };
  57366. }
  57367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57368. /** @hidden */
  57369. export var pbrBlockSheen: {
  57370. name: string;
  57371. shader: string;
  57372. };
  57373. }
  57374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57375. /** @hidden */
  57376. export var pbrBlockClearcoat: {
  57377. name: string;
  57378. shader: string;
  57379. };
  57380. }
  57381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57382. /** @hidden */
  57383. export var pbrBlockSubSurface: {
  57384. name: string;
  57385. shader: string;
  57386. };
  57387. }
  57388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57389. /** @hidden */
  57390. export var pbrBlockNormalGeometric: {
  57391. name: string;
  57392. shader: string;
  57393. };
  57394. }
  57395. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57396. /** @hidden */
  57397. export var pbrBlockNormalFinal: {
  57398. name: string;
  57399. shader: string;
  57400. };
  57401. }
  57402. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57403. /** @hidden */
  57404. export var pbrBlockGeometryInfo: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57410. /** @hidden */
  57411. export var pbrBlockReflectance0: {
  57412. name: string;
  57413. shader: string;
  57414. };
  57415. }
  57416. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57417. /** @hidden */
  57418. export var pbrBlockReflectance: {
  57419. name: string;
  57420. shader: string;
  57421. };
  57422. }
  57423. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57424. /** @hidden */
  57425. export var pbrBlockDirectLighting: {
  57426. name: string;
  57427. shader: string;
  57428. };
  57429. }
  57430. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57431. /** @hidden */
  57432. export var pbrBlockFinalLitComponents: {
  57433. name: string;
  57434. shader: string;
  57435. };
  57436. }
  57437. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57438. /** @hidden */
  57439. export var pbrBlockFinalUnlitComponents: {
  57440. name: string;
  57441. shader: string;
  57442. };
  57443. }
  57444. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57445. /** @hidden */
  57446. export var pbrBlockFinalColorComposition: {
  57447. name: string;
  57448. shader: string;
  57449. };
  57450. }
  57451. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57452. /** @hidden */
  57453. export var pbrBlockImageProcessing: {
  57454. name: string;
  57455. shader: string;
  57456. };
  57457. }
  57458. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57459. /** @hidden */
  57460. export var pbrDebug: {
  57461. name: string;
  57462. shader: string;
  57463. };
  57464. }
  57465. declare module "babylonjs/Shaders/pbr.fragment" {
  57466. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57467. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57468. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57469. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57470. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57471. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57472. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57473. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57474. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57475. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57476. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57478. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57479. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57480. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57481. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57482. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57483. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57484. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57485. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57486. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57487. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57488. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57489. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57490. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57491. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57492. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57493. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57494. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57495. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57496. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57497. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57498. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57499. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57500. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57501. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57502. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57503. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57504. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57505. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57506. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57507. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57508. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57509. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57510. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57511. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57512. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57513. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57514. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57515. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57516. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57517. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57518. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57519. /** @hidden */
  57520. export var pbrPixelShader: {
  57521. name: string;
  57522. shader: string;
  57523. };
  57524. }
  57525. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57526. /** @hidden */
  57527. export var pbrVertexDeclaration: {
  57528. name: string;
  57529. shader: string;
  57530. };
  57531. }
  57532. declare module "babylonjs/Shaders/pbr.vertex" {
  57533. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57534. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57535. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57536. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57537. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57538. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57539. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57540. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57542. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57543. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57546. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57548. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57549. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57550. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57552. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57553. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57554. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57555. /** @hidden */
  57556. export var pbrVertexShader: {
  57557. name: string;
  57558. shader: string;
  57559. };
  57560. }
  57561. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57562. import { Nullable } from "babylonjs/types";
  57563. import { Scene } from "babylonjs/scene";
  57564. import { Matrix } from "babylonjs/Maths/math.vector";
  57565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57567. import { Mesh } from "babylonjs/Meshes/mesh";
  57568. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57569. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57570. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57571. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57572. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57573. import { Color3 } from "babylonjs/Maths/math.color";
  57574. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57575. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57576. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57577. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57580. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57581. import "babylonjs/Shaders/pbr.fragment";
  57582. import "babylonjs/Shaders/pbr.vertex";
  57583. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57584. /**
  57585. * Manages the defines for the PBR Material.
  57586. * @hidden
  57587. */
  57588. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57589. PBR: boolean;
  57590. NUM_SAMPLES: string;
  57591. REALTIME_FILTERING: boolean;
  57592. MAINUV1: boolean;
  57593. MAINUV2: boolean;
  57594. UV1: boolean;
  57595. UV2: boolean;
  57596. ALBEDO: boolean;
  57597. GAMMAALBEDO: boolean;
  57598. ALBEDODIRECTUV: number;
  57599. VERTEXCOLOR: boolean;
  57600. DETAIL: boolean;
  57601. DETAILDIRECTUV: number;
  57602. DETAIL_NORMALBLENDMETHOD: number;
  57603. AMBIENT: boolean;
  57604. AMBIENTDIRECTUV: number;
  57605. AMBIENTINGRAYSCALE: boolean;
  57606. OPACITY: boolean;
  57607. VERTEXALPHA: boolean;
  57608. OPACITYDIRECTUV: number;
  57609. OPACITYRGB: boolean;
  57610. ALPHATEST: boolean;
  57611. DEPTHPREPASS: boolean;
  57612. ALPHABLEND: boolean;
  57613. ALPHAFROMALBEDO: boolean;
  57614. ALPHATESTVALUE: string;
  57615. SPECULAROVERALPHA: boolean;
  57616. RADIANCEOVERALPHA: boolean;
  57617. ALPHAFRESNEL: boolean;
  57618. LINEARALPHAFRESNEL: boolean;
  57619. PREMULTIPLYALPHA: boolean;
  57620. EMISSIVE: boolean;
  57621. EMISSIVEDIRECTUV: number;
  57622. REFLECTIVITY: boolean;
  57623. REFLECTIVITYDIRECTUV: number;
  57624. SPECULARTERM: boolean;
  57625. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57626. MICROSURFACEAUTOMATIC: boolean;
  57627. LODBASEDMICROSFURACE: boolean;
  57628. MICROSURFACEMAP: boolean;
  57629. MICROSURFACEMAPDIRECTUV: number;
  57630. METALLICWORKFLOW: boolean;
  57631. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57632. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57633. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57634. AOSTOREINMETALMAPRED: boolean;
  57635. METALLIC_REFLECTANCE: boolean;
  57636. METALLIC_REFLECTANCEDIRECTUV: number;
  57637. ENVIRONMENTBRDF: boolean;
  57638. ENVIRONMENTBRDF_RGBD: boolean;
  57639. NORMAL: boolean;
  57640. TANGENT: boolean;
  57641. BUMP: boolean;
  57642. BUMPDIRECTUV: number;
  57643. OBJECTSPACE_NORMALMAP: boolean;
  57644. PARALLAX: boolean;
  57645. PARALLAXOCCLUSION: boolean;
  57646. NORMALXYSCALE: boolean;
  57647. LIGHTMAP: boolean;
  57648. LIGHTMAPDIRECTUV: number;
  57649. USELIGHTMAPASSHADOWMAP: boolean;
  57650. GAMMALIGHTMAP: boolean;
  57651. RGBDLIGHTMAP: boolean;
  57652. REFLECTION: boolean;
  57653. REFLECTIONMAP_3D: boolean;
  57654. REFLECTIONMAP_SPHERICAL: boolean;
  57655. REFLECTIONMAP_PLANAR: boolean;
  57656. REFLECTIONMAP_CUBIC: boolean;
  57657. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57658. REFLECTIONMAP_PROJECTION: boolean;
  57659. REFLECTIONMAP_SKYBOX: boolean;
  57660. REFLECTIONMAP_EXPLICIT: boolean;
  57661. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57662. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57663. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57664. INVERTCUBICMAP: boolean;
  57665. USESPHERICALFROMREFLECTIONMAP: boolean;
  57666. USEIRRADIANCEMAP: boolean;
  57667. SPHERICAL_HARMONICS: boolean;
  57668. USESPHERICALINVERTEX: boolean;
  57669. REFLECTIONMAP_OPPOSITEZ: boolean;
  57670. LODINREFLECTIONALPHA: boolean;
  57671. GAMMAREFLECTION: boolean;
  57672. RGBDREFLECTION: boolean;
  57673. LINEARSPECULARREFLECTION: boolean;
  57674. RADIANCEOCCLUSION: boolean;
  57675. HORIZONOCCLUSION: boolean;
  57676. INSTANCES: boolean;
  57677. THIN_INSTANCES: boolean;
  57678. PREPASS: boolean;
  57679. SCENE_MRT_COUNT: number;
  57680. NUM_BONE_INFLUENCERS: number;
  57681. BonesPerMesh: number;
  57682. BONETEXTURE: boolean;
  57683. NONUNIFORMSCALING: boolean;
  57684. MORPHTARGETS: boolean;
  57685. MORPHTARGETS_NORMAL: boolean;
  57686. MORPHTARGETS_TANGENT: boolean;
  57687. MORPHTARGETS_UV: boolean;
  57688. NUM_MORPH_INFLUENCERS: number;
  57689. IMAGEPROCESSING: boolean;
  57690. VIGNETTE: boolean;
  57691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57692. VIGNETTEBLENDMODEOPAQUE: boolean;
  57693. TONEMAPPING: boolean;
  57694. TONEMAPPING_ACES: boolean;
  57695. CONTRAST: boolean;
  57696. COLORCURVES: boolean;
  57697. COLORGRADING: boolean;
  57698. COLORGRADING3D: boolean;
  57699. SAMPLER3DGREENDEPTH: boolean;
  57700. SAMPLER3DBGRMAP: boolean;
  57701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57702. EXPOSURE: boolean;
  57703. MULTIVIEW: boolean;
  57704. USEPHYSICALLIGHTFALLOFF: boolean;
  57705. USEGLTFLIGHTFALLOFF: boolean;
  57706. TWOSIDEDLIGHTING: boolean;
  57707. SHADOWFLOAT: boolean;
  57708. CLIPPLANE: boolean;
  57709. CLIPPLANE2: boolean;
  57710. CLIPPLANE3: boolean;
  57711. CLIPPLANE4: boolean;
  57712. CLIPPLANE5: boolean;
  57713. CLIPPLANE6: boolean;
  57714. POINTSIZE: boolean;
  57715. FOG: boolean;
  57716. LOGARITHMICDEPTH: boolean;
  57717. FORCENORMALFORWARD: boolean;
  57718. SPECULARAA: boolean;
  57719. CLEARCOAT: boolean;
  57720. CLEARCOAT_DEFAULTIOR: boolean;
  57721. CLEARCOAT_TEXTURE: boolean;
  57722. CLEARCOAT_TEXTUREDIRECTUV: number;
  57723. CLEARCOAT_BUMP: boolean;
  57724. CLEARCOAT_BUMPDIRECTUV: number;
  57725. CLEARCOAT_TINT: boolean;
  57726. CLEARCOAT_TINT_TEXTURE: boolean;
  57727. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57728. ANISOTROPIC: boolean;
  57729. ANISOTROPIC_TEXTURE: boolean;
  57730. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57731. BRDF_V_HEIGHT_CORRELATED: boolean;
  57732. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57733. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57734. SHEEN: boolean;
  57735. SHEEN_TEXTURE: boolean;
  57736. SHEEN_TEXTUREDIRECTUV: number;
  57737. SHEEN_LINKWITHALBEDO: boolean;
  57738. SHEEN_ROUGHNESS: boolean;
  57739. SHEEN_ALBEDOSCALING: boolean;
  57740. SUBSURFACE: boolean;
  57741. SS_REFRACTION: boolean;
  57742. SS_TRANSLUCENCY: boolean;
  57743. SS_SCATTERING: boolean;
  57744. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57745. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57746. SS_REFRACTIONMAP_3D: boolean;
  57747. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57748. SS_LODINREFRACTIONALPHA: boolean;
  57749. SS_GAMMAREFRACTION: boolean;
  57750. SS_RGBDREFRACTION: boolean;
  57751. SS_LINEARSPECULARREFRACTION: boolean;
  57752. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57753. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57754. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57755. UNLIT: boolean;
  57756. DEBUGMODE: number;
  57757. /**
  57758. * Initializes the PBR Material defines.
  57759. */
  57760. constructor();
  57761. /**
  57762. * Resets the PBR Material defines.
  57763. */
  57764. reset(): void;
  57765. }
  57766. /**
  57767. * The Physically based material base class of BJS.
  57768. *
  57769. * This offers the main features of a standard PBR material.
  57770. * For more information, please refer to the documentation :
  57771. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57772. */
  57773. export abstract class PBRBaseMaterial extends PushMaterial {
  57774. /**
  57775. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57776. */
  57777. static readonly PBRMATERIAL_OPAQUE: number;
  57778. /**
  57779. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57780. */
  57781. static readonly PBRMATERIAL_ALPHATEST: number;
  57782. /**
  57783. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57784. */
  57785. static readonly PBRMATERIAL_ALPHABLEND: number;
  57786. /**
  57787. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57788. * They are also discarded below the alpha cutoff threshold to improve performances.
  57789. */
  57790. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57791. /**
  57792. * Defines the default value of how much AO map is occluding the analytical lights
  57793. * (point spot...).
  57794. */
  57795. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57796. /**
  57797. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57798. */
  57799. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57800. /**
  57801. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57802. * to enhance interoperability with other engines.
  57803. */
  57804. static readonly LIGHTFALLOFF_GLTF: number;
  57805. /**
  57806. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57807. * to enhance interoperability with other materials.
  57808. */
  57809. static readonly LIGHTFALLOFF_STANDARD: number;
  57810. /**
  57811. * Intensity of the direct lights e.g. the four lights available in your scene.
  57812. * This impacts both the direct diffuse and specular highlights.
  57813. */
  57814. protected _directIntensity: number;
  57815. /**
  57816. * Intensity of the emissive part of the material.
  57817. * This helps controlling the emissive effect without modifying the emissive color.
  57818. */
  57819. protected _emissiveIntensity: number;
  57820. /**
  57821. * Intensity of the environment e.g. how much the environment will light the object
  57822. * either through harmonics for rough material or through the refelction for shiny ones.
  57823. */
  57824. protected _environmentIntensity: number;
  57825. /**
  57826. * This is a special control allowing the reduction of the specular highlights coming from the
  57827. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57828. */
  57829. protected _specularIntensity: number;
  57830. /**
  57831. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57832. */
  57833. private _lightingInfos;
  57834. /**
  57835. * Debug Control allowing disabling the bump map on this material.
  57836. */
  57837. protected _disableBumpMap: boolean;
  57838. /**
  57839. * AKA Diffuse Texture in standard nomenclature.
  57840. */
  57841. protected _albedoTexture: Nullable<BaseTexture>;
  57842. /**
  57843. * AKA Occlusion Texture in other nomenclature.
  57844. */
  57845. protected _ambientTexture: Nullable<BaseTexture>;
  57846. /**
  57847. * AKA Occlusion Texture Intensity in other nomenclature.
  57848. */
  57849. protected _ambientTextureStrength: number;
  57850. /**
  57851. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57852. * 1 means it completely occludes it
  57853. * 0 mean it has no impact
  57854. */
  57855. protected _ambientTextureImpactOnAnalyticalLights: number;
  57856. /**
  57857. * Stores the alpha values in a texture.
  57858. */
  57859. protected _opacityTexture: Nullable<BaseTexture>;
  57860. /**
  57861. * Stores the reflection values in a texture.
  57862. */
  57863. protected _reflectionTexture: Nullable<BaseTexture>;
  57864. /**
  57865. * Stores the emissive values in a texture.
  57866. */
  57867. protected _emissiveTexture: Nullable<BaseTexture>;
  57868. /**
  57869. * AKA Specular texture in other nomenclature.
  57870. */
  57871. protected _reflectivityTexture: Nullable<BaseTexture>;
  57872. /**
  57873. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57874. */
  57875. protected _metallicTexture: Nullable<BaseTexture>;
  57876. /**
  57877. * Specifies the metallic scalar of the metallic/roughness workflow.
  57878. * Can also be used to scale the metalness values of the metallic texture.
  57879. */
  57880. protected _metallic: Nullable<number>;
  57881. /**
  57882. * Specifies the roughness scalar of the metallic/roughness workflow.
  57883. * Can also be used to scale the roughness values of the metallic texture.
  57884. */
  57885. protected _roughness: Nullable<number>;
  57886. /**
  57887. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57888. * By default the indexOfrefraction is used to compute F0;
  57889. *
  57890. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57891. *
  57892. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57893. * F90 = metallicReflectanceColor;
  57894. */
  57895. protected _metallicF0Factor: number;
  57896. /**
  57897. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57898. * By default the F90 is always 1;
  57899. *
  57900. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57901. *
  57902. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57903. * F90 = metallicReflectanceColor;
  57904. */
  57905. protected _metallicReflectanceColor: Color3;
  57906. /**
  57907. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57908. * This is multiply against the scalar values defined in the material.
  57909. */
  57910. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57911. /**
  57912. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57913. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57914. */
  57915. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57916. /**
  57917. * Stores surface normal data used to displace a mesh in a texture.
  57918. */
  57919. protected _bumpTexture: Nullable<BaseTexture>;
  57920. /**
  57921. * Stores the pre-calculated light information of a mesh in a texture.
  57922. */
  57923. protected _lightmapTexture: Nullable<BaseTexture>;
  57924. /**
  57925. * The color of a material in ambient lighting.
  57926. */
  57927. protected _ambientColor: Color3;
  57928. /**
  57929. * AKA Diffuse Color in other nomenclature.
  57930. */
  57931. protected _albedoColor: Color3;
  57932. /**
  57933. * AKA Specular Color in other nomenclature.
  57934. */
  57935. protected _reflectivityColor: Color3;
  57936. /**
  57937. * The color applied when light is reflected from a material.
  57938. */
  57939. protected _reflectionColor: Color3;
  57940. /**
  57941. * The color applied when light is emitted from a material.
  57942. */
  57943. protected _emissiveColor: Color3;
  57944. /**
  57945. * AKA Glossiness in other nomenclature.
  57946. */
  57947. protected _microSurface: number;
  57948. /**
  57949. * Specifies that the material will use the light map as a show map.
  57950. */
  57951. protected _useLightmapAsShadowmap: boolean;
  57952. /**
  57953. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57954. * makes the reflect vector face the model (under horizon).
  57955. */
  57956. protected _useHorizonOcclusion: boolean;
  57957. /**
  57958. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57959. * too much the area relying on ambient texture to define their ambient occlusion.
  57960. */
  57961. protected _useRadianceOcclusion: boolean;
  57962. /**
  57963. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57964. */
  57965. protected _useAlphaFromAlbedoTexture: boolean;
  57966. /**
  57967. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57968. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57969. */
  57970. protected _useSpecularOverAlpha: boolean;
  57971. /**
  57972. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57973. */
  57974. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57975. /**
  57976. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57977. */
  57978. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57979. /**
  57980. * Specifies if the metallic texture contains the roughness information in its green channel.
  57981. */
  57982. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57983. /**
  57984. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57985. */
  57986. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57987. /**
  57988. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57989. */
  57990. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57991. /**
  57992. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57993. */
  57994. protected _useAmbientInGrayScale: boolean;
  57995. /**
  57996. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57997. * The material will try to infer what glossiness each pixel should be.
  57998. */
  57999. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58000. /**
  58001. * Defines the falloff type used in this material.
  58002. * It by default is Physical.
  58003. */
  58004. protected _lightFalloff: number;
  58005. /**
  58006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58008. */
  58009. protected _useRadianceOverAlpha: boolean;
  58010. /**
  58011. * Allows using an object space normal map (instead of tangent space).
  58012. */
  58013. protected _useObjectSpaceNormalMap: boolean;
  58014. /**
  58015. * Allows using the bump map in parallax mode.
  58016. */
  58017. protected _useParallax: boolean;
  58018. /**
  58019. * Allows using the bump map in parallax occlusion mode.
  58020. */
  58021. protected _useParallaxOcclusion: boolean;
  58022. /**
  58023. * Controls the scale bias of the parallax mode.
  58024. */
  58025. protected _parallaxScaleBias: number;
  58026. /**
  58027. * If sets to true, disables all the lights affecting the material.
  58028. */
  58029. protected _disableLighting: boolean;
  58030. /**
  58031. * Number of Simultaneous lights allowed on the material.
  58032. */
  58033. protected _maxSimultaneousLights: number;
  58034. /**
  58035. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58036. */
  58037. protected _invertNormalMapX: boolean;
  58038. /**
  58039. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58040. */
  58041. protected _invertNormalMapY: boolean;
  58042. /**
  58043. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58044. */
  58045. protected _twoSidedLighting: boolean;
  58046. /**
  58047. * Defines the alpha limits in alpha test mode.
  58048. */
  58049. protected _alphaCutOff: number;
  58050. /**
  58051. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58052. */
  58053. protected _forceAlphaTest: boolean;
  58054. /**
  58055. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58056. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58057. */
  58058. protected _useAlphaFresnel: boolean;
  58059. /**
  58060. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58061. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58062. */
  58063. protected _useLinearAlphaFresnel: boolean;
  58064. /**
  58065. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58066. * from cos thetav and roughness:
  58067. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58068. */
  58069. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58070. /**
  58071. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58072. */
  58073. protected _forceIrradianceInFragment: boolean;
  58074. private _realTimeFiltering;
  58075. /**
  58076. * Enables realtime filtering on the texture.
  58077. */
  58078. get realTimeFiltering(): boolean;
  58079. set realTimeFiltering(b: boolean);
  58080. private _realTimeFilteringQuality;
  58081. /**
  58082. * Quality switch for realtime filtering
  58083. */
  58084. get realTimeFilteringQuality(): number;
  58085. set realTimeFilteringQuality(n: number);
  58086. /**
  58087. * Should this material render to several textures at once
  58088. */
  58089. get shouldRenderToMRT(): boolean;
  58090. /**
  58091. * Force normal to face away from face.
  58092. */
  58093. protected _forceNormalForward: boolean;
  58094. /**
  58095. * Enables specular anti aliasing in the PBR shader.
  58096. * It will both interacts on the Geometry for analytical and IBL lighting.
  58097. * It also prefilter the roughness map based on the bump values.
  58098. */
  58099. protected _enableSpecularAntiAliasing: boolean;
  58100. /**
  58101. * Default configuration related to image processing available in the PBR Material.
  58102. */
  58103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58104. /**
  58105. * Keep track of the image processing observer to allow dispose and replace.
  58106. */
  58107. private _imageProcessingObserver;
  58108. /**
  58109. * Attaches a new image processing configuration to the PBR Material.
  58110. * @param configuration
  58111. */
  58112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58113. /**
  58114. * Stores the available render targets.
  58115. */
  58116. private _renderTargets;
  58117. /**
  58118. * Sets the global ambient color for the material used in lighting calculations.
  58119. */
  58120. private _globalAmbientColor;
  58121. /**
  58122. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58123. */
  58124. private _useLogarithmicDepth;
  58125. /**
  58126. * If set to true, no lighting calculations will be applied.
  58127. */
  58128. private _unlit;
  58129. private _debugMode;
  58130. /**
  58131. * @hidden
  58132. * This is reserved for the inspector.
  58133. * Defines the material debug mode.
  58134. * It helps seeing only some components of the material while troubleshooting.
  58135. */
  58136. debugMode: number;
  58137. /**
  58138. * @hidden
  58139. * This is reserved for the inspector.
  58140. * Specify from where on screen the debug mode should start.
  58141. * The value goes from -1 (full screen) to 1 (not visible)
  58142. * It helps with side by side comparison against the final render
  58143. * This defaults to -1
  58144. */
  58145. private debugLimit;
  58146. /**
  58147. * @hidden
  58148. * This is reserved for the inspector.
  58149. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58150. * You can use the factor to better multiply the final value.
  58151. */
  58152. private debugFactor;
  58153. /**
  58154. * Defines the clear coat layer parameters for the material.
  58155. */
  58156. readonly clearCoat: PBRClearCoatConfiguration;
  58157. /**
  58158. * Defines the anisotropic parameters for the material.
  58159. */
  58160. readonly anisotropy: PBRAnisotropicConfiguration;
  58161. /**
  58162. * Defines the BRDF parameters for the material.
  58163. */
  58164. readonly brdf: PBRBRDFConfiguration;
  58165. /**
  58166. * Defines the Sheen parameters for the material.
  58167. */
  58168. readonly sheen: PBRSheenConfiguration;
  58169. /**
  58170. * Defines the SubSurface parameters for the material.
  58171. */
  58172. readonly subSurface: PBRSubSurfaceConfiguration;
  58173. /**
  58174. * Defines the detail map parameters for the material.
  58175. */
  58176. readonly detailMap: DetailMapConfiguration;
  58177. protected _rebuildInParallel: boolean;
  58178. /**
  58179. * Instantiates a new PBRMaterial instance.
  58180. *
  58181. * @param name The material name
  58182. * @param scene The scene the material will be use in.
  58183. */
  58184. constructor(name: string, scene: Scene);
  58185. /**
  58186. * Gets a boolean indicating that current material needs to register RTT
  58187. */
  58188. get hasRenderTargetTextures(): boolean;
  58189. /**
  58190. * Gets the name of the material class.
  58191. */
  58192. getClassName(): string;
  58193. /**
  58194. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58195. */
  58196. get useLogarithmicDepth(): boolean;
  58197. /**
  58198. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58199. */
  58200. set useLogarithmicDepth(value: boolean);
  58201. /**
  58202. * Returns true if alpha blending should be disabled.
  58203. */
  58204. protected get _disableAlphaBlending(): boolean;
  58205. /**
  58206. * Specifies whether or not this material should be rendered in alpha blend mode.
  58207. */
  58208. needAlphaBlending(): boolean;
  58209. /**
  58210. * Specifies whether or not this material should be rendered in alpha test mode.
  58211. */
  58212. needAlphaTesting(): boolean;
  58213. /**
  58214. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58215. */
  58216. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58217. /**
  58218. * Gets the texture used for the alpha test.
  58219. */
  58220. getAlphaTestTexture(): Nullable<BaseTexture>;
  58221. /**
  58222. * Specifies that the submesh is ready to be used.
  58223. * @param mesh - BJS mesh.
  58224. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58225. * @param useInstances - Specifies that instances should be used.
  58226. * @returns - boolean indicating that the submesh is ready or not.
  58227. */
  58228. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58229. /**
  58230. * Specifies if the material uses metallic roughness workflow.
  58231. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58232. */
  58233. isMetallicWorkflow(): boolean;
  58234. private _prepareEffect;
  58235. private _prepareDefines;
  58236. /**
  58237. * Force shader compilation
  58238. */
  58239. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58240. /**
  58241. * Initializes the uniform buffer layout for the shader.
  58242. */
  58243. buildUniformLayout(): void;
  58244. /**
  58245. * Unbinds the material from the mesh
  58246. */
  58247. unbind(): void;
  58248. /**
  58249. * Binds the submesh data.
  58250. * @param world - The world matrix.
  58251. * @param mesh - The BJS mesh.
  58252. * @param subMesh - A submesh of the BJS mesh.
  58253. */
  58254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58255. /**
  58256. * Returns the animatable textures.
  58257. * @returns - Array of animatable textures.
  58258. */
  58259. getAnimatables(): IAnimatable[];
  58260. /**
  58261. * Returns the texture used for reflections.
  58262. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58263. */
  58264. private _getReflectionTexture;
  58265. /**
  58266. * Returns an array of the actively used textures.
  58267. * @returns - Array of BaseTextures
  58268. */
  58269. getActiveTextures(): BaseTexture[];
  58270. /**
  58271. * Checks to see if a texture is used in the material.
  58272. * @param texture - Base texture to use.
  58273. * @returns - Boolean specifying if a texture is used in the material.
  58274. */
  58275. hasTexture(texture: BaseTexture): boolean;
  58276. /**
  58277. * Disposes the resources of the material.
  58278. * @param forceDisposeEffect - Forces the disposal of effects.
  58279. * @param forceDisposeTextures - Forces the disposal of all textures.
  58280. */
  58281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58282. }
  58283. }
  58284. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58285. import { Nullable } from "babylonjs/types";
  58286. import { Scene } from "babylonjs/scene";
  58287. import { Color3 } from "babylonjs/Maths/math.color";
  58288. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58289. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58291. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58292. /**
  58293. * The Physically based material of BJS.
  58294. *
  58295. * This offers the main features of a standard PBR material.
  58296. * For more information, please refer to the documentation :
  58297. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58298. */
  58299. export class PBRMaterial extends PBRBaseMaterial {
  58300. /**
  58301. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58302. */
  58303. static readonly PBRMATERIAL_OPAQUE: number;
  58304. /**
  58305. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58306. */
  58307. static readonly PBRMATERIAL_ALPHATEST: number;
  58308. /**
  58309. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58310. */
  58311. static readonly PBRMATERIAL_ALPHABLEND: number;
  58312. /**
  58313. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58314. * They are also discarded below the alpha cutoff threshold to improve performances.
  58315. */
  58316. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58317. /**
  58318. * Defines the default value of how much AO map is occluding the analytical lights
  58319. * (point spot...).
  58320. */
  58321. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58322. /**
  58323. * Intensity of the direct lights e.g. the four lights available in your scene.
  58324. * This impacts both the direct diffuse and specular highlights.
  58325. */
  58326. directIntensity: number;
  58327. /**
  58328. * Intensity of the emissive part of the material.
  58329. * This helps controlling the emissive effect without modifying the emissive color.
  58330. */
  58331. emissiveIntensity: number;
  58332. /**
  58333. * Intensity of the environment e.g. how much the environment will light the object
  58334. * either through harmonics for rough material or through the refelction for shiny ones.
  58335. */
  58336. environmentIntensity: number;
  58337. /**
  58338. * This is a special control allowing the reduction of the specular highlights coming from the
  58339. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58340. */
  58341. specularIntensity: number;
  58342. /**
  58343. * Debug Control allowing disabling the bump map on this material.
  58344. */
  58345. disableBumpMap: boolean;
  58346. /**
  58347. * AKA Diffuse Texture in standard nomenclature.
  58348. */
  58349. albedoTexture: BaseTexture;
  58350. /**
  58351. * AKA Occlusion Texture in other nomenclature.
  58352. */
  58353. ambientTexture: BaseTexture;
  58354. /**
  58355. * AKA Occlusion Texture Intensity in other nomenclature.
  58356. */
  58357. ambientTextureStrength: number;
  58358. /**
  58359. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58360. * 1 means it completely occludes it
  58361. * 0 mean it has no impact
  58362. */
  58363. ambientTextureImpactOnAnalyticalLights: number;
  58364. /**
  58365. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58366. */
  58367. opacityTexture: BaseTexture;
  58368. /**
  58369. * Stores the reflection values in a texture.
  58370. */
  58371. reflectionTexture: Nullable<BaseTexture>;
  58372. /**
  58373. * Stores the emissive values in a texture.
  58374. */
  58375. emissiveTexture: BaseTexture;
  58376. /**
  58377. * AKA Specular texture in other nomenclature.
  58378. */
  58379. reflectivityTexture: BaseTexture;
  58380. /**
  58381. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58382. */
  58383. metallicTexture: BaseTexture;
  58384. /**
  58385. * Specifies the metallic scalar of the metallic/roughness workflow.
  58386. * Can also be used to scale the metalness values of the metallic texture.
  58387. */
  58388. metallic: Nullable<number>;
  58389. /**
  58390. * Specifies the roughness scalar of the metallic/roughness workflow.
  58391. * Can also be used to scale the roughness values of the metallic texture.
  58392. */
  58393. roughness: Nullable<number>;
  58394. /**
  58395. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58396. * By default the indexOfrefraction is used to compute F0;
  58397. *
  58398. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58399. *
  58400. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58401. * F90 = metallicReflectanceColor;
  58402. */
  58403. metallicF0Factor: number;
  58404. /**
  58405. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58406. * By default the F90 is always 1;
  58407. *
  58408. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58409. *
  58410. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58411. * F90 = metallicReflectanceColor;
  58412. */
  58413. metallicReflectanceColor: Color3;
  58414. /**
  58415. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58416. * This is multiply against the scalar values defined in the material.
  58417. */
  58418. metallicReflectanceTexture: Nullable<BaseTexture>;
  58419. /**
  58420. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58421. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58422. */
  58423. microSurfaceTexture: BaseTexture;
  58424. /**
  58425. * Stores surface normal data used to displace a mesh in a texture.
  58426. */
  58427. bumpTexture: BaseTexture;
  58428. /**
  58429. * Stores the pre-calculated light information of a mesh in a texture.
  58430. */
  58431. lightmapTexture: BaseTexture;
  58432. /**
  58433. * Stores the refracted light information in a texture.
  58434. */
  58435. get refractionTexture(): Nullable<BaseTexture>;
  58436. set refractionTexture(value: Nullable<BaseTexture>);
  58437. /**
  58438. * The color of a material in ambient lighting.
  58439. */
  58440. ambientColor: Color3;
  58441. /**
  58442. * AKA Diffuse Color in other nomenclature.
  58443. */
  58444. albedoColor: Color3;
  58445. /**
  58446. * AKA Specular Color in other nomenclature.
  58447. */
  58448. reflectivityColor: Color3;
  58449. /**
  58450. * The color reflected from the material.
  58451. */
  58452. reflectionColor: Color3;
  58453. /**
  58454. * The color emitted from the material.
  58455. */
  58456. emissiveColor: Color3;
  58457. /**
  58458. * AKA Glossiness in other nomenclature.
  58459. */
  58460. microSurface: number;
  58461. /**
  58462. * Index of refraction of the material base layer.
  58463. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58464. *
  58465. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58466. *
  58467. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58468. */
  58469. get indexOfRefraction(): number;
  58470. set indexOfRefraction(value: number);
  58471. /**
  58472. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58473. */
  58474. get invertRefractionY(): boolean;
  58475. set invertRefractionY(value: boolean);
  58476. /**
  58477. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58478. * Materials half opaque for instance using refraction could benefit from this control.
  58479. */
  58480. get linkRefractionWithTransparency(): boolean;
  58481. set linkRefractionWithTransparency(value: boolean);
  58482. /**
  58483. * If true, the light map contains occlusion information instead of lighting info.
  58484. */
  58485. useLightmapAsShadowmap: boolean;
  58486. /**
  58487. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58488. */
  58489. useAlphaFromAlbedoTexture: boolean;
  58490. /**
  58491. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58492. */
  58493. forceAlphaTest: boolean;
  58494. /**
  58495. * Defines the alpha limits in alpha test mode.
  58496. */
  58497. alphaCutOff: number;
  58498. /**
  58499. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58500. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58501. */
  58502. useSpecularOverAlpha: boolean;
  58503. /**
  58504. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58505. */
  58506. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58507. /**
  58508. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58509. */
  58510. useRoughnessFromMetallicTextureAlpha: boolean;
  58511. /**
  58512. * Specifies if the metallic texture contains the roughness information in its green channel.
  58513. */
  58514. useRoughnessFromMetallicTextureGreen: boolean;
  58515. /**
  58516. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58517. */
  58518. useMetallnessFromMetallicTextureBlue: boolean;
  58519. /**
  58520. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58521. */
  58522. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58523. /**
  58524. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58525. */
  58526. useAmbientInGrayScale: boolean;
  58527. /**
  58528. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58529. * The material will try to infer what glossiness each pixel should be.
  58530. */
  58531. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58532. /**
  58533. * BJS is using an harcoded light falloff based on a manually sets up range.
  58534. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58535. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58536. */
  58537. get usePhysicalLightFalloff(): boolean;
  58538. /**
  58539. * BJS is using an harcoded light falloff based on a manually sets up range.
  58540. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58541. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58542. */
  58543. set usePhysicalLightFalloff(value: boolean);
  58544. /**
  58545. * In order to support the falloff compatibility with gltf, a special mode has been added
  58546. * to reproduce the gltf light falloff.
  58547. */
  58548. get useGLTFLightFalloff(): boolean;
  58549. /**
  58550. * In order to support the falloff compatibility with gltf, a special mode has been added
  58551. * to reproduce the gltf light falloff.
  58552. */
  58553. set useGLTFLightFalloff(value: boolean);
  58554. /**
  58555. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58556. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58557. */
  58558. useRadianceOverAlpha: boolean;
  58559. /**
  58560. * Allows using an object space normal map (instead of tangent space).
  58561. */
  58562. useObjectSpaceNormalMap: boolean;
  58563. /**
  58564. * Allows using the bump map in parallax mode.
  58565. */
  58566. useParallax: boolean;
  58567. /**
  58568. * Allows using the bump map in parallax occlusion mode.
  58569. */
  58570. useParallaxOcclusion: boolean;
  58571. /**
  58572. * Controls the scale bias of the parallax mode.
  58573. */
  58574. parallaxScaleBias: number;
  58575. /**
  58576. * If sets to true, disables all the lights affecting the material.
  58577. */
  58578. disableLighting: boolean;
  58579. /**
  58580. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58581. */
  58582. forceIrradianceInFragment: boolean;
  58583. /**
  58584. * Number of Simultaneous lights allowed on the material.
  58585. */
  58586. maxSimultaneousLights: number;
  58587. /**
  58588. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58589. */
  58590. invertNormalMapX: boolean;
  58591. /**
  58592. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58593. */
  58594. invertNormalMapY: boolean;
  58595. /**
  58596. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58597. */
  58598. twoSidedLighting: boolean;
  58599. /**
  58600. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58601. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58602. */
  58603. useAlphaFresnel: boolean;
  58604. /**
  58605. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58606. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58607. */
  58608. useLinearAlphaFresnel: boolean;
  58609. /**
  58610. * Let user defines the brdf lookup texture used for IBL.
  58611. * A default 8bit version is embedded but you could point at :
  58612. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58613. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58614. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58615. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58616. */
  58617. environmentBRDFTexture: Nullable<BaseTexture>;
  58618. /**
  58619. * Force normal to face away from face.
  58620. */
  58621. forceNormalForward: boolean;
  58622. /**
  58623. * Enables specular anti aliasing in the PBR shader.
  58624. * It will both interacts on the Geometry for analytical and IBL lighting.
  58625. * It also prefilter the roughness map based on the bump values.
  58626. */
  58627. enableSpecularAntiAliasing: boolean;
  58628. /**
  58629. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58630. * makes the reflect vector face the model (under horizon).
  58631. */
  58632. useHorizonOcclusion: boolean;
  58633. /**
  58634. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58635. * too much the area relying on ambient texture to define their ambient occlusion.
  58636. */
  58637. useRadianceOcclusion: boolean;
  58638. /**
  58639. * If set to true, no lighting calculations will be applied.
  58640. */
  58641. unlit: boolean;
  58642. /**
  58643. * Gets the image processing configuration used either in this material.
  58644. */
  58645. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58646. /**
  58647. * Sets the Default image processing configuration used either in the this material.
  58648. *
  58649. * If sets to null, the scene one is in use.
  58650. */
  58651. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58652. /**
  58653. * Gets wether the color curves effect is enabled.
  58654. */
  58655. get cameraColorCurvesEnabled(): boolean;
  58656. /**
  58657. * Sets wether the color curves effect is enabled.
  58658. */
  58659. set cameraColorCurvesEnabled(value: boolean);
  58660. /**
  58661. * Gets wether the color grading effect is enabled.
  58662. */
  58663. get cameraColorGradingEnabled(): boolean;
  58664. /**
  58665. * Gets wether the color grading effect is enabled.
  58666. */
  58667. set cameraColorGradingEnabled(value: boolean);
  58668. /**
  58669. * Gets wether tonemapping is enabled or not.
  58670. */
  58671. get cameraToneMappingEnabled(): boolean;
  58672. /**
  58673. * Sets wether tonemapping is enabled or not
  58674. */
  58675. set cameraToneMappingEnabled(value: boolean);
  58676. /**
  58677. * The camera exposure used on this material.
  58678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58679. * This corresponds to a photographic exposure.
  58680. */
  58681. get cameraExposure(): number;
  58682. /**
  58683. * The camera exposure used on this material.
  58684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58685. * This corresponds to a photographic exposure.
  58686. */
  58687. set cameraExposure(value: number);
  58688. /**
  58689. * Gets The camera contrast used on this material.
  58690. */
  58691. get cameraContrast(): number;
  58692. /**
  58693. * Sets The camera contrast used on this material.
  58694. */
  58695. set cameraContrast(value: number);
  58696. /**
  58697. * Gets the Color Grading 2D Lookup Texture.
  58698. */
  58699. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58700. /**
  58701. * Sets the Color Grading 2D Lookup Texture.
  58702. */
  58703. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58704. /**
  58705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58707. * 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;
  58708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58709. */
  58710. get cameraColorCurves(): Nullable<ColorCurves>;
  58711. /**
  58712. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58713. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58714. * 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;
  58715. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58716. */
  58717. set cameraColorCurves(value: Nullable<ColorCurves>);
  58718. /**
  58719. * Instantiates a new PBRMaterial instance.
  58720. *
  58721. * @param name The material name
  58722. * @param scene The scene the material will be use in.
  58723. */
  58724. constructor(name: string, scene: Scene);
  58725. /**
  58726. * Returns the name of this material class.
  58727. */
  58728. getClassName(): string;
  58729. /**
  58730. * Makes a duplicate of the current material.
  58731. * @param name - name to use for the new material.
  58732. */
  58733. clone(name: string): PBRMaterial;
  58734. /**
  58735. * Serializes this PBR Material.
  58736. * @returns - An object with the serialized material.
  58737. */
  58738. serialize(): any;
  58739. /**
  58740. * Parses a PBR Material from a serialized object.
  58741. * @param source - Serialized object.
  58742. * @param scene - BJS scene instance.
  58743. * @param rootUrl - url for the scene object
  58744. * @returns - PBRMaterial
  58745. */
  58746. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58747. }
  58748. }
  58749. declare module "babylonjs/Misc/dds" {
  58750. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58752. import { Nullable } from "babylonjs/types";
  58753. import { Scene } from "babylonjs/scene";
  58754. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58755. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58756. /**
  58757. * Direct draw surface info
  58758. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58759. */
  58760. export interface DDSInfo {
  58761. /**
  58762. * Width of the texture
  58763. */
  58764. width: number;
  58765. /**
  58766. * Width of the texture
  58767. */
  58768. height: number;
  58769. /**
  58770. * Number of Mipmaps for the texture
  58771. * @see https://en.wikipedia.org/wiki/Mipmap
  58772. */
  58773. mipmapCount: number;
  58774. /**
  58775. * If the textures format is a known fourCC format
  58776. * @see https://www.fourcc.org/
  58777. */
  58778. isFourCC: boolean;
  58779. /**
  58780. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58781. */
  58782. isRGB: boolean;
  58783. /**
  58784. * If the texture is a lumincance format
  58785. */
  58786. isLuminance: boolean;
  58787. /**
  58788. * If this is a cube texture
  58789. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58790. */
  58791. isCube: boolean;
  58792. /**
  58793. * If the texture is a compressed format eg. FOURCC_DXT1
  58794. */
  58795. isCompressed: boolean;
  58796. /**
  58797. * The dxgiFormat of the texture
  58798. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58799. */
  58800. dxgiFormat: number;
  58801. /**
  58802. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58803. */
  58804. textureType: number;
  58805. /**
  58806. * Sphericle polynomial created for the dds texture
  58807. */
  58808. sphericalPolynomial?: SphericalPolynomial;
  58809. }
  58810. /**
  58811. * Class used to provide DDS decompression tools
  58812. */
  58813. export class DDSTools {
  58814. /**
  58815. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58816. */
  58817. static StoreLODInAlphaChannel: boolean;
  58818. /**
  58819. * Gets DDS information from an array buffer
  58820. * @param data defines the array buffer view to read data from
  58821. * @returns the DDS information
  58822. */
  58823. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58824. private static _FloatView;
  58825. private static _Int32View;
  58826. private static _ToHalfFloat;
  58827. private static _FromHalfFloat;
  58828. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58829. private static _GetHalfFloatRGBAArrayBuffer;
  58830. private static _GetFloatRGBAArrayBuffer;
  58831. private static _GetFloatAsUIntRGBAArrayBuffer;
  58832. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58833. private static _GetRGBAArrayBuffer;
  58834. private static _ExtractLongWordOrder;
  58835. private static _GetRGBArrayBuffer;
  58836. private static _GetLuminanceArrayBuffer;
  58837. /**
  58838. * Uploads DDS Levels to a Babylon Texture
  58839. * @hidden
  58840. */
  58841. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58842. }
  58843. module "babylonjs/Engines/thinEngine" {
  58844. interface ThinEngine {
  58845. /**
  58846. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58847. * @param rootUrl defines the url where the file to load is located
  58848. * @param scene defines the current scene
  58849. * @param lodScale defines scale to apply to the mip map selection
  58850. * @param lodOffset defines offset to apply to the mip map selection
  58851. * @param onLoad defines an optional callback raised when the texture is loaded
  58852. * @param onError defines an optional callback raised if there is an issue to load the texture
  58853. * @param format defines the format of the data
  58854. * @param forcedExtension defines the extension to use to pick the right loader
  58855. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58856. * @returns the cube texture as an InternalTexture
  58857. */
  58858. 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;
  58859. }
  58860. }
  58861. }
  58862. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58863. import { Nullable } from "babylonjs/types";
  58864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58865. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58866. /**
  58867. * Implementation of the DDS Texture Loader.
  58868. * @hidden
  58869. */
  58870. export class _DDSTextureLoader implements IInternalTextureLoader {
  58871. /**
  58872. * Defines wether the loader supports cascade loading the different faces.
  58873. */
  58874. readonly supportCascades: boolean;
  58875. /**
  58876. * This returns if the loader support the current file information.
  58877. * @param extension defines the file extension of the file being loaded
  58878. * @returns true if the loader can load the specified file
  58879. */
  58880. canLoad(extension: string): boolean;
  58881. /**
  58882. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58883. * @param data contains the texture data
  58884. * @param texture defines the BabylonJS internal texture
  58885. * @param createPolynomials will be true if polynomials have been requested
  58886. * @param onLoad defines the callback to trigger once the texture is ready
  58887. * @param onError defines the callback to trigger in case of error
  58888. */
  58889. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58890. /**
  58891. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58892. * @param data contains the texture data
  58893. * @param texture defines the BabylonJS internal texture
  58894. * @param callback defines the method to call once ready to upload
  58895. */
  58896. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58897. }
  58898. }
  58899. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58900. import { Nullable } from "babylonjs/types";
  58901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58902. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58903. /**
  58904. * Implementation of the ENV Texture Loader.
  58905. * @hidden
  58906. */
  58907. export class _ENVTextureLoader implements IInternalTextureLoader {
  58908. /**
  58909. * Defines wether the loader supports cascade loading the different faces.
  58910. */
  58911. readonly supportCascades: boolean;
  58912. /**
  58913. * This returns if the loader support the current file information.
  58914. * @param extension defines the file extension of the file being loaded
  58915. * @returns true if the loader can load the specified file
  58916. */
  58917. canLoad(extension: string): boolean;
  58918. /**
  58919. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58920. * @param data contains the texture data
  58921. * @param texture defines the BabylonJS internal texture
  58922. * @param createPolynomials will be true if polynomials have been requested
  58923. * @param onLoad defines the callback to trigger once the texture is ready
  58924. * @param onError defines the callback to trigger in case of error
  58925. */
  58926. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58927. /**
  58928. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58929. * @param data contains the texture data
  58930. * @param texture defines the BabylonJS internal texture
  58931. * @param callback defines the method to call once ready to upload
  58932. */
  58933. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58934. }
  58935. }
  58936. declare module "babylonjs/Misc/khronosTextureContainer" {
  58937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58938. /**
  58939. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58940. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58941. */
  58942. export class KhronosTextureContainer {
  58943. /** contents of the KTX container file */
  58944. data: ArrayBufferView;
  58945. private static HEADER_LEN;
  58946. private static COMPRESSED_2D;
  58947. private static COMPRESSED_3D;
  58948. private static TEX_2D;
  58949. private static TEX_3D;
  58950. /**
  58951. * Gets the openGL type
  58952. */
  58953. glType: number;
  58954. /**
  58955. * Gets the openGL type size
  58956. */
  58957. glTypeSize: number;
  58958. /**
  58959. * Gets the openGL format
  58960. */
  58961. glFormat: number;
  58962. /**
  58963. * Gets the openGL internal format
  58964. */
  58965. glInternalFormat: number;
  58966. /**
  58967. * Gets the base internal format
  58968. */
  58969. glBaseInternalFormat: number;
  58970. /**
  58971. * Gets image width in pixel
  58972. */
  58973. pixelWidth: number;
  58974. /**
  58975. * Gets image height in pixel
  58976. */
  58977. pixelHeight: number;
  58978. /**
  58979. * Gets image depth in pixels
  58980. */
  58981. pixelDepth: number;
  58982. /**
  58983. * Gets the number of array elements
  58984. */
  58985. numberOfArrayElements: number;
  58986. /**
  58987. * Gets the number of faces
  58988. */
  58989. numberOfFaces: number;
  58990. /**
  58991. * Gets the number of mipmap levels
  58992. */
  58993. numberOfMipmapLevels: number;
  58994. /**
  58995. * Gets the bytes of key value data
  58996. */
  58997. bytesOfKeyValueData: number;
  58998. /**
  58999. * Gets the load type
  59000. */
  59001. loadType: number;
  59002. /**
  59003. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59004. */
  59005. isInvalid: boolean;
  59006. /**
  59007. * Creates a new KhronosTextureContainer
  59008. * @param data contents of the KTX container file
  59009. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59010. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59011. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59012. */
  59013. constructor(
  59014. /** contents of the KTX container file */
  59015. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59016. /**
  59017. * Uploads KTX content to a Babylon Texture.
  59018. * It is assumed that the texture has already been created & is currently bound
  59019. * @hidden
  59020. */
  59021. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59022. private _upload2DCompressedLevels;
  59023. /**
  59024. * Checks if the given data starts with a KTX file identifier.
  59025. * @param data the data to check
  59026. * @returns true if the data is a KTX file or false otherwise
  59027. */
  59028. static IsValid(data: ArrayBufferView): boolean;
  59029. }
  59030. }
  59031. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59033. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59034. /**
  59035. * Class for loading KTX2 files
  59036. * !!! Experimental Extension Subject to Changes !!!
  59037. * @hidden
  59038. */
  59039. export class KhronosTextureContainer2 {
  59040. private static _ModulePromise;
  59041. private static _TranscodeFormat;
  59042. constructor(engine: ThinEngine);
  59043. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59044. private _determineTranscodeFormat;
  59045. /**
  59046. * Checks if the given data starts with a KTX2 file identifier.
  59047. * @param data the data to check
  59048. * @returns true if the data is a KTX2 file or false otherwise
  59049. */
  59050. static IsValid(data: ArrayBufferView): boolean;
  59051. }
  59052. }
  59053. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59054. import { Nullable } from "babylonjs/types";
  59055. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59056. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59057. /**
  59058. * Implementation of the KTX Texture Loader.
  59059. * @hidden
  59060. */
  59061. export class _KTXTextureLoader implements IInternalTextureLoader {
  59062. /**
  59063. * Defines wether the loader supports cascade loading the different faces.
  59064. */
  59065. readonly supportCascades: boolean;
  59066. /**
  59067. * This returns if the loader support the current file information.
  59068. * @param extension defines the file extension of the file being loaded
  59069. * @param mimeType defines the optional mime type of the file being loaded
  59070. * @returns true if the loader can load the specified file
  59071. */
  59072. canLoad(extension: string, mimeType?: string): boolean;
  59073. /**
  59074. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59075. * @param data contains the texture data
  59076. * @param texture defines the BabylonJS internal texture
  59077. * @param createPolynomials will be true if polynomials have been requested
  59078. * @param onLoad defines the callback to trigger once the texture is ready
  59079. * @param onError defines the callback to trigger in case of error
  59080. */
  59081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59082. /**
  59083. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59084. * @param data contains the texture data
  59085. * @param texture defines the BabylonJS internal texture
  59086. * @param callback defines the method to call once ready to upload
  59087. */
  59088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59089. }
  59090. }
  59091. declare module "babylonjs/Helpers/sceneHelpers" {
  59092. import { Nullable } from "babylonjs/types";
  59093. import { Mesh } from "babylonjs/Meshes/mesh";
  59094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59095. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59096. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59097. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59098. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59099. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59100. import "babylonjs/Meshes/Builders/boxBuilder";
  59101. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59102. /** @hidden */
  59103. export var _forceSceneHelpersToBundle: boolean;
  59104. module "babylonjs/scene" {
  59105. interface Scene {
  59106. /**
  59107. * Creates a default light for the scene.
  59108. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59109. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59110. */
  59111. createDefaultLight(replace?: boolean): void;
  59112. /**
  59113. * Creates a default camera for the scene.
  59114. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59115. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59116. * @param replace has default false, when true replaces the active camera in the scene
  59117. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59118. */
  59119. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59120. /**
  59121. * Creates a default camera and a default light.
  59122. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59123. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59124. * @param replace has the default false, when true replaces the active camera/light in the scene
  59125. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59126. */
  59127. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59128. /**
  59129. * Creates a new sky box
  59130. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59131. * @param environmentTexture defines the texture to use as environment texture
  59132. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59133. * @param scale defines the overall scale of the skybox
  59134. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59135. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59136. * @returns a new mesh holding the sky box
  59137. */
  59138. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59139. /**
  59140. * Creates a new environment
  59141. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59142. * @param options defines the options you can use to configure the environment
  59143. * @returns the new EnvironmentHelper
  59144. */
  59145. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59146. /**
  59147. * Creates a new VREXperienceHelper
  59148. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59149. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59150. * @returns a new VREXperienceHelper
  59151. */
  59152. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59153. /**
  59154. * Creates a new WebXRDefaultExperience
  59155. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59156. * @param options experience options
  59157. * @returns a promise for a new WebXRDefaultExperience
  59158. */
  59159. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59160. }
  59161. }
  59162. }
  59163. declare module "babylonjs/Helpers/videoDome" {
  59164. import { Scene } from "babylonjs/scene";
  59165. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59166. import { Mesh } from "babylonjs/Meshes/mesh";
  59167. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59168. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59169. import "babylonjs/Meshes/Builders/sphereBuilder";
  59170. /**
  59171. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59172. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59173. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59174. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59175. */
  59176. export class VideoDome extends TransformNode {
  59177. /**
  59178. * Define the video source as a Monoscopic panoramic 360 video.
  59179. */
  59180. static readonly MODE_MONOSCOPIC: number;
  59181. /**
  59182. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59183. */
  59184. static readonly MODE_TOPBOTTOM: number;
  59185. /**
  59186. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59187. */
  59188. static readonly MODE_SIDEBYSIDE: number;
  59189. private _halfDome;
  59190. private _useDirectMapping;
  59191. /**
  59192. * The video texture being displayed on the sphere
  59193. */
  59194. protected _videoTexture: VideoTexture;
  59195. /**
  59196. * Gets the video texture being displayed on the sphere
  59197. */
  59198. get videoTexture(): VideoTexture;
  59199. /**
  59200. * The skybox material
  59201. */
  59202. protected _material: BackgroundMaterial;
  59203. /**
  59204. * The surface used for the skybox
  59205. */
  59206. protected _mesh: Mesh;
  59207. /**
  59208. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59209. */
  59210. private _halfDomeMask;
  59211. /**
  59212. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59213. * Also see the options.resolution property.
  59214. */
  59215. get fovMultiplier(): number;
  59216. set fovMultiplier(value: number);
  59217. private _videoMode;
  59218. /**
  59219. * Gets or set the current video mode for the video. It can be:
  59220. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59221. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59222. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59223. */
  59224. get videoMode(): number;
  59225. set videoMode(value: number);
  59226. /**
  59227. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59228. *
  59229. */
  59230. get halfDome(): boolean;
  59231. /**
  59232. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59233. */
  59234. set halfDome(enabled: boolean);
  59235. /**
  59236. * Oberserver used in Stereoscopic VR Mode.
  59237. */
  59238. private _onBeforeCameraRenderObserver;
  59239. /**
  59240. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59241. * @param name Element's name, child elements will append suffixes for their own names.
  59242. * @param urlsOrVideo defines the url(s) or the video element to use
  59243. * @param options An object containing optional or exposed sub element properties
  59244. */
  59245. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59246. resolution?: number;
  59247. clickToPlay?: boolean;
  59248. autoPlay?: boolean;
  59249. loop?: boolean;
  59250. size?: number;
  59251. poster?: string;
  59252. faceForward?: boolean;
  59253. useDirectMapping?: boolean;
  59254. halfDomeMode?: boolean;
  59255. }, scene: Scene);
  59256. private _changeVideoMode;
  59257. /**
  59258. * Releases resources associated with this node.
  59259. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59260. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59261. */
  59262. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59263. }
  59264. }
  59265. declare module "babylonjs/Helpers/index" {
  59266. export * from "babylonjs/Helpers/environmentHelper";
  59267. export * from "babylonjs/Helpers/photoDome";
  59268. export * from "babylonjs/Helpers/sceneHelpers";
  59269. export * from "babylonjs/Helpers/videoDome";
  59270. }
  59271. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59272. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59273. import { IDisposable } from "babylonjs/scene";
  59274. import { Engine } from "babylonjs/Engines/engine";
  59275. /**
  59276. * This class can be used to get instrumentation data from a Babylon engine
  59277. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59278. */
  59279. export class EngineInstrumentation implements IDisposable {
  59280. /**
  59281. * Define the instrumented engine.
  59282. */
  59283. engine: Engine;
  59284. private _captureGPUFrameTime;
  59285. private _gpuFrameTimeToken;
  59286. private _gpuFrameTime;
  59287. private _captureShaderCompilationTime;
  59288. private _shaderCompilationTime;
  59289. private _onBeginFrameObserver;
  59290. private _onEndFrameObserver;
  59291. private _onBeforeShaderCompilationObserver;
  59292. private _onAfterShaderCompilationObserver;
  59293. /**
  59294. * Gets the perf counter used for GPU frame time
  59295. */
  59296. get gpuFrameTimeCounter(): PerfCounter;
  59297. /**
  59298. * Gets the GPU frame time capture status
  59299. */
  59300. get captureGPUFrameTime(): boolean;
  59301. /**
  59302. * Enable or disable the GPU frame time capture
  59303. */
  59304. set captureGPUFrameTime(value: boolean);
  59305. /**
  59306. * Gets the perf counter used for shader compilation time
  59307. */
  59308. get shaderCompilationTimeCounter(): PerfCounter;
  59309. /**
  59310. * Gets the shader compilation time capture status
  59311. */
  59312. get captureShaderCompilationTime(): boolean;
  59313. /**
  59314. * Enable or disable the shader compilation time capture
  59315. */
  59316. set captureShaderCompilationTime(value: boolean);
  59317. /**
  59318. * Instantiates a new engine instrumentation.
  59319. * This class can be used to get instrumentation data from a Babylon engine
  59320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59321. * @param engine Defines the engine to instrument
  59322. */
  59323. constructor(
  59324. /**
  59325. * Define the instrumented engine.
  59326. */
  59327. engine: Engine);
  59328. /**
  59329. * Dispose and release associated resources.
  59330. */
  59331. dispose(): void;
  59332. }
  59333. }
  59334. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59335. import { Scene, IDisposable } from "babylonjs/scene";
  59336. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59337. /**
  59338. * This class can be used to get instrumentation data from a Babylon engine
  59339. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59340. */
  59341. export class SceneInstrumentation implements IDisposable {
  59342. /**
  59343. * Defines the scene to instrument
  59344. */
  59345. scene: Scene;
  59346. private _captureActiveMeshesEvaluationTime;
  59347. private _activeMeshesEvaluationTime;
  59348. private _captureRenderTargetsRenderTime;
  59349. private _renderTargetsRenderTime;
  59350. private _captureFrameTime;
  59351. private _frameTime;
  59352. private _captureRenderTime;
  59353. private _renderTime;
  59354. private _captureInterFrameTime;
  59355. private _interFrameTime;
  59356. private _captureParticlesRenderTime;
  59357. private _particlesRenderTime;
  59358. private _captureSpritesRenderTime;
  59359. private _spritesRenderTime;
  59360. private _capturePhysicsTime;
  59361. private _physicsTime;
  59362. private _captureAnimationsTime;
  59363. private _animationsTime;
  59364. private _captureCameraRenderTime;
  59365. private _cameraRenderTime;
  59366. private _onBeforeActiveMeshesEvaluationObserver;
  59367. private _onAfterActiveMeshesEvaluationObserver;
  59368. private _onBeforeRenderTargetsRenderObserver;
  59369. private _onAfterRenderTargetsRenderObserver;
  59370. private _onAfterRenderObserver;
  59371. private _onBeforeDrawPhaseObserver;
  59372. private _onAfterDrawPhaseObserver;
  59373. private _onBeforeAnimationsObserver;
  59374. private _onBeforeParticlesRenderingObserver;
  59375. private _onAfterParticlesRenderingObserver;
  59376. private _onBeforeSpritesRenderingObserver;
  59377. private _onAfterSpritesRenderingObserver;
  59378. private _onBeforePhysicsObserver;
  59379. private _onAfterPhysicsObserver;
  59380. private _onAfterAnimationsObserver;
  59381. private _onBeforeCameraRenderObserver;
  59382. private _onAfterCameraRenderObserver;
  59383. /**
  59384. * Gets the perf counter used for active meshes evaluation time
  59385. */
  59386. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59387. /**
  59388. * Gets the active meshes evaluation time capture status
  59389. */
  59390. get captureActiveMeshesEvaluationTime(): boolean;
  59391. /**
  59392. * Enable or disable the active meshes evaluation time capture
  59393. */
  59394. set captureActiveMeshesEvaluationTime(value: boolean);
  59395. /**
  59396. * Gets the perf counter used for render targets render time
  59397. */
  59398. get renderTargetsRenderTimeCounter(): PerfCounter;
  59399. /**
  59400. * Gets the render targets render time capture status
  59401. */
  59402. get captureRenderTargetsRenderTime(): boolean;
  59403. /**
  59404. * Enable or disable the render targets render time capture
  59405. */
  59406. set captureRenderTargetsRenderTime(value: boolean);
  59407. /**
  59408. * Gets the perf counter used for particles render time
  59409. */
  59410. get particlesRenderTimeCounter(): PerfCounter;
  59411. /**
  59412. * Gets the particles render time capture status
  59413. */
  59414. get captureParticlesRenderTime(): boolean;
  59415. /**
  59416. * Enable or disable the particles render time capture
  59417. */
  59418. set captureParticlesRenderTime(value: boolean);
  59419. /**
  59420. * Gets the perf counter used for sprites render time
  59421. */
  59422. get spritesRenderTimeCounter(): PerfCounter;
  59423. /**
  59424. * Gets the sprites render time capture status
  59425. */
  59426. get captureSpritesRenderTime(): boolean;
  59427. /**
  59428. * Enable or disable the sprites render time capture
  59429. */
  59430. set captureSpritesRenderTime(value: boolean);
  59431. /**
  59432. * Gets the perf counter used for physics time
  59433. */
  59434. get physicsTimeCounter(): PerfCounter;
  59435. /**
  59436. * Gets the physics time capture status
  59437. */
  59438. get capturePhysicsTime(): boolean;
  59439. /**
  59440. * Enable or disable the physics time capture
  59441. */
  59442. set capturePhysicsTime(value: boolean);
  59443. /**
  59444. * Gets the perf counter used for animations time
  59445. */
  59446. get animationsTimeCounter(): PerfCounter;
  59447. /**
  59448. * Gets the animations time capture status
  59449. */
  59450. get captureAnimationsTime(): boolean;
  59451. /**
  59452. * Enable or disable the animations time capture
  59453. */
  59454. set captureAnimationsTime(value: boolean);
  59455. /**
  59456. * Gets the perf counter used for frame time capture
  59457. */
  59458. get frameTimeCounter(): PerfCounter;
  59459. /**
  59460. * Gets the frame time capture status
  59461. */
  59462. get captureFrameTime(): boolean;
  59463. /**
  59464. * Enable or disable the frame time capture
  59465. */
  59466. set captureFrameTime(value: boolean);
  59467. /**
  59468. * Gets the perf counter used for inter-frames time capture
  59469. */
  59470. get interFrameTimeCounter(): PerfCounter;
  59471. /**
  59472. * Gets the inter-frames time capture status
  59473. */
  59474. get captureInterFrameTime(): boolean;
  59475. /**
  59476. * Enable or disable the inter-frames time capture
  59477. */
  59478. set captureInterFrameTime(value: boolean);
  59479. /**
  59480. * Gets the perf counter used for render time capture
  59481. */
  59482. get renderTimeCounter(): PerfCounter;
  59483. /**
  59484. * Gets the render time capture status
  59485. */
  59486. get captureRenderTime(): boolean;
  59487. /**
  59488. * Enable or disable the render time capture
  59489. */
  59490. set captureRenderTime(value: boolean);
  59491. /**
  59492. * Gets the perf counter used for camera render time capture
  59493. */
  59494. get cameraRenderTimeCounter(): PerfCounter;
  59495. /**
  59496. * Gets the camera render time capture status
  59497. */
  59498. get captureCameraRenderTime(): boolean;
  59499. /**
  59500. * Enable or disable the camera render time capture
  59501. */
  59502. set captureCameraRenderTime(value: boolean);
  59503. /**
  59504. * Gets the perf counter used for draw calls
  59505. */
  59506. get drawCallsCounter(): PerfCounter;
  59507. /**
  59508. * Instantiates a new scene instrumentation.
  59509. * This class can be used to get instrumentation data from a Babylon engine
  59510. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59511. * @param scene Defines the scene to instrument
  59512. */
  59513. constructor(
  59514. /**
  59515. * Defines the scene to instrument
  59516. */
  59517. scene: Scene);
  59518. /**
  59519. * Dispose and release associated resources.
  59520. */
  59521. dispose(): void;
  59522. }
  59523. }
  59524. declare module "babylonjs/Instrumentation/index" {
  59525. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59526. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59527. export * from "babylonjs/Instrumentation/timeToken";
  59528. }
  59529. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59530. /** @hidden */
  59531. export var glowMapGenerationPixelShader: {
  59532. name: string;
  59533. shader: string;
  59534. };
  59535. }
  59536. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59537. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59540. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59542. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59543. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59544. /** @hidden */
  59545. export var glowMapGenerationVertexShader: {
  59546. name: string;
  59547. shader: string;
  59548. };
  59549. }
  59550. declare module "babylonjs/Layers/effectLayer" {
  59551. import { Observable } from "babylonjs/Misc/observable";
  59552. import { Nullable } from "babylonjs/types";
  59553. import { Camera } from "babylonjs/Cameras/camera";
  59554. import { Scene } from "babylonjs/scene";
  59555. import { ISize } from "babylonjs/Maths/math.size";
  59556. import { Color4 } from "babylonjs/Maths/math.color";
  59557. import { Engine } from "babylonjs/Engines/engine";
  59558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59560. import { Mesh } from "babylonjs/Meshes/mesh";
  59561. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59564. import { Effect } from "babylonjs/Materials/effect";
  59565. import { Material } from "babylonjs/Materials/material";
  59566. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59567. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59568. /**
  59569. * Effect layer options. This helps customizing the behaviour
  59570. * of the effect layer.
  59571. */
  59572. export interface IEffectLayerOptions {
  59573. /**
  59574. * Multiplication factor apply to the canvas size to compute the render target size
  59575. * used to generated the objects (the smaller the faster).
  59576. */
  59577. mainTextureRatio: number;
  59578. /**
  59579. * Enforces a fixed size texture to ensure effect stability across devices.
  59580. */
  59581. mainTextureFixedSize?: number;
  59582. /**
  59583. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59584. */
  59585. alphaBlendingMode: number;
  59586. /**
  59587. * The camera attached to the layer.
  59588. */
  59589. camera: Nullable<Camera>;
  59590. /**
  59591. * The rendering group to draw the layer in.
  59592. */
  59593. renderingGroupId: number;
  59594. }
  59595. /**
  59596. * The effect layer Helps adding post process effect blended with the main pass.
  59597. *
  59598. * This can be for instance use to generate glow or higlight effects on the scene.
  59599. *
  59600. * The effect layer class can not be used directly and is intented to inherited from to be
  59601. * customized per effects.
  59602. */
  59603. export abstract class EffectLayer {
  59604. private _vertexBuffers;
  59605. private _indexBuffer;
  59606. private _cachedDefines;
  59607. private _effectLayerMapGenerationEffect;
  59608. private _effectLayerOptions;
  59609. private _mergeEffect;
  59610. protected _scene: Scene;
  59611. protected _engine: Engine;
  59612. protected _maxSize: number;
  59613. protected _mainTextureDesiredSize: ISize;
  59614. protected _mainTexture: RenderTargetTexture;
  59615. protected _shouldRender: boolean;
  59616. protected _postProcesses: PostProcess[];
  59617. protected _textures: BaseTexture[];
  59618. protected _emissiveTextureAndColor: {
  59619. texture: Nullable<BaseTexture>;
  59620. color: Color4;
  59621. };
  59622. /**
  59623. * The name of the layer
  59624. */
  59625. name: string;
  59626. /**
  59627. * The clear color of the texture used to generate the glow map.
  59628. */
  59629. neutralColor: Color4;
  59630. /**
  59631. * Specifies whether the highlight layer is enabled or not.
  59632. */
  59633. isEnabled: boolean;
  59634. /**
  59635. * Gets the camera attached to the layer.
  59636. */
  59637. get camera(): Nullable<Camera>;
  59638. /**
  59639. * Gets the rendering group id the layer should render in.
  59640. */
  59641. get renderingGroupId(): number;
  59642. set renderingGroupId(renderingGroupId: number);
  59643. /**
  59644. * An event triggered when the effect layer has been disposed.
  59645. */
  59646. onDisposeObservable: Observable<EffectLayer>;
  59647. /**
  59648. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59649. */
  59650. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59651. /**
  59652. * An event triggered when the generated texture is being merged in the scene.
  59653. */
  59654. onBeforeComposeObservable: Observable<EffectLayer>;
  59655. /**
  59656. * An event triggered when the mesh is rendered into the effect render target.
  59657. */
  59658. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59659. /**
  59660. * An event triggered after the mesh has been rendered into the effect render target.
  59661. */
  59662. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59663. /**
  59664. * An event triggered when the generated texture has been merged in the scene.
  59665. */
  59666. onAfterComposeObservable: Observable<EffectLayer>;
  59667. /**
  59668. * An event triggered when the efffect layer changes its size.
  59669. */
  59670. onSizeChangedObservable: Observable<EffectLayer>;
  59671. /** @hidden */
  59672. static _SceneComponentInitialization: (scene: Scene) => void;
  59673. /**
  59674. * Instantiates a new effect Layer and references it in the scene.
  59675. * @param name The name of the layer
  59676. * @param scene The scene to use the layer in
  59677. */
  59678. constructor(
  59679. /** The Friendly of the effect in the scene */
  59680. name: string, scene: Scene);
  59681. /**
  59682. * Get the effect name of the layer.
  59683. * @return The effect name
  59684. */
  59685. abstract getEffectName(): string;
  59686. /**
  59687. * Checks for the readiness of the element composing the layer.
  59688. * @param subMesh the mesh to check for
  59689. * @param useInstances specify whether or not to use instances to render the mesh
  59690. * @return true if ready otherwise, false
  59691. */
  59692. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59693. /**
  59694. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59695. * @returns true if the effect requires stencil during the main canvas render pass.
  59696. */
  59697. abstract needStencil(): boolean;
  59698. /**
  59699. * Create the merge effect. This is the shader use to blit the information back
  59700. * to the main canvas at the end of the scene rendering.
  59701. * @returns The effect containing the shader used to merge the effect on the main canvas
  59702. */
  59703. protected abstract _createMergeEffect(): Effect;
  59704. /**
  59705. * Creates the render target textures and post processes used in the effect layer.
  59706. */
  59707. protected abstract _createTextureAndPostProcesses(): void;
  59708. /**
  59709. * Implementation specific of rendering the generating effect on the main canvas.
  59710. * @param effect The effect used to render through
  59711. */
  59712. protected abstract _internalRender(effect: Effect): void;
  59713. /**
  59714. * Sets the required values for both the emissive texture and and the main color.
  59715. */
  59716. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59717. /**
  59718. * Free any resources and references associated to a mesh.
  59719. * Internal use
  59720. * @param mesh The mesh to free.
  59721. */
  59722. abstract _disposeMesh(mesh: Mesh): void;
  59723. /**
  59724. * Serializes this layer (Glow or Highlight for example)
  59725. * @returns a serialized layer object
  59726. */
  59727. abstract serialize?(): any;
  59728. /**
  59729. * Initializes the effect layer with the required options.
  59730. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59731. */
  59732. protected _init(options: Partial<IEffectLayerOptions>): void;
  59733. /**
  59734. * Generates the index buffer of the full screen quad blending to the main canvas.
  59735. */
  59736. private _generateIndexBuffer;
  59737. /**
  59738. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59739. */
  59740. private _generateVertexBuffer;
  59741. /**
  59742. * Sets the main texture desired size which is the closest power of two
  59743. * of the engine canvas size.
  59744. */
  59745. private _setMainTextureSize;
  59746. /**
  59747. * Creates the main texture for the effect layer.
  59748. */
  59749. protected _createMainTexture(): void;
  59750. /**
  59751. * Adds specific effects defines.
  59752. * @param defines The defines to add specifics to.
  59753. */
  59754. protected _addCustomEffectDefines(defines: string[]): void;
  59755. /**
  59756. * Checks for the readiness of the element composing the layer.
  59757. * @param subMesh the mesh to check for
  59758. * @param useInstances specify whether or not to use instances to render the mesh
  59759. * @param emissiveTexture the associated emissive texture used to generate the glow
  59760. * @return true if ready otherwise, false
  59761. */
  59762. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59763. /**
  59764. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59765. */
  59766. render(): void;
  59767. /**
  59768. * Determine if a given mesh will be used in the current effect.
  59769. * @param mesh mesh to test
  59770. * @returns true if the mesh will be used
  59771. */
  59772. hasMesh(mesh: AbstractMesh): boolean;
  59773. /**
  59774. * Returns true if the layer contains information to display, otherwise false.
  59775. * @returns true if the glow layer should be rendered
  59776. */
  59777. shouldRender(): boolean;
  59778. /**
  59779. * Returns true if the mesh should render, otherwise false.
  59780. * @param mesh The mesh to render
  59781. * @returns true if it should render otherwise false
  59782. */
  59783. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59784. /**
  59785. * Returns true if the mesh can be rendered, otherwise false.
  59786. * @param mesh The mesh to render
  59787. * @param material The material used on the mesh
  59788. * @returns true if it can be rendered otherwise false
  59789. */
  59790. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59791. /**
  59792. * Returns true if the mesh should render, otherwise false.
  59793. * @param mesh The mesh to render
  59794. * @returns true if it should render otherwise false
  59795. */
  59796. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59797. /**
  59798. * Renders the submesh passed in parameter to the generation map.
  59799. */
  59800. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59801. /**
  59802. * Defines whether the current material of the mesh should be use to render the effect.
  59803. * @param mesh defines the current mesh to render
  59804. */
  59805. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59806. /**
  59807. * Rebuild the required buffers.
  59808. * @hidden Internal use only.
  59809. */
  59810. _rebuild(): void;
  59811. /**
  59812. * Dispose only the render target textures and post process.
  59813. */
  59814. private _disposeTextureAndPostProcesses;
  59815. /**
  59816. * Dispose the highlight layer and free resources.
  59817. */
  59818. dispose(): void;
  59819. /**
  59820. * Gets the class name of the effect layer
  59821. * @returns the string with the class name of the effect layer
  59822. */
  59823. getClassName(): string;
  59824. /**
  59825. * Creates an effect layer from parsed effect layer data
  59826. * @param parsedEffectLayer defines effect layer data
  59827. * @param scene defines the current scene
  59828. * @param rootUrl defines the root URL containing the effect layer information
  59829. * @returns a parsed effect Layer
  59830. */
  59831. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59832. }
  59833. }
  59834. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59835. import { Scene } from "babylonjs/scene";
  59836. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59837. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59838. import { AbstractScene } from "babylonjs/abstractScene";
  59839. module "babylonjs/abstractScene" {
  59840. interface AbstractScene {
  59841. /**
  59842. * The list of effect layers (highlights/glow) added to the scene
  59843. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59844. * @see https://doc.babylonjs.com/how_to/glow_layer
  59845. */
  59846. effectLayers: Array<EffectLayer>;
  59847. /**
  59848. * Removes the given effect layer from this scene.
  59849. * @param toRemove defines the effect layer to remove
  59850. * @returns the index of the removed effect layer
  59851. */
  59852. removeEffectLayer(toRemove: EffectLayer): number;
  59853. /**
  59854. * Adds the given effect layer to this scene
  59855. * @param newEffectLayer defines the effect layer to add
  59856. */
  59857. addEffectLayer(newEffectLayer: EffectLayer): void;
  59858. }
  59859. }
  59860. /**
  59861. * Defines the layer scene component responsible to manage any effect layers
  59862. * in a given scene.
  59863. */
  59864. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59865. /**
  59866. * The component name helpfull to identify the component in the list of scene components.
  59867. */
  59868. readonly name: string;
  59869. /**
  59870. * The scene the component belongs to.
  59871. */
  59872. scene: Scene;
  59873. private _engine;
  59874. private _renderEffects;
  59875. private _needStencil;
  59876. private _previousStencilState;
  59877. /**
  59878. * Creates a new instance of the component for the given scene
  59879. * @param scene Defines the scene to register the component in
  59880. */
  59881. constructor(scene: Scene);
  59882. /**
  59883. * Registers the component in a given scene
  59884. */
  59885. register(): void;
  59886. /**
  59887. * Rebuilds the elements related to this component in case of
  59888. * context lost for instance.
  59889. */
  59890. rebuild(): void;
  59891. /**
  59892. * Serializes the component data to the specified json object
  59893. * @param serializationObject The object to serialize to
  59894. */
  59895. serialize(serializationObject: any): void;
  59896. /**
  59897. * Adds all the elements from the container to the scene
  59898. * @param container the container holding the elements
  59899. */
  59900. addFromContainer(container: AbstractScene): void;
  59901. /**
  59902. * Removes all the elements in the container from the scene
  59903. * @param container contains the elements to remove
  59904. * @param dispose if the removed element should be disposed (default: false)
  59905. */
  59906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59907. /**
  59908. * Disposes the component and the associated ressources.
  59909. */
  59910. dispose(): void;
  59911. private _isReadyForMesh;
  59912. private _renderMainTexture;
  59913. private _setStencil;
  59914. private _setStencilBack;
  59915. private _draw;
  59916. private _drawCamera;
  59917. private _drawRenderingGroup;
  59918. }
  59919. }
  59920. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59921. /** @hidden */
  59922. export var glowMapMergePixelShader: {
  59923. name: string;
  59924. shader: string;
  59925. };
  59926. }
  59927. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59928. /** @hidden */
  59929. export var glowMapMergeVertexShader: {
  59930. name: string;
  59931. shader: string;
  59932. };
  59933. }
  59934. declare module "babylonjs/Layers/glowLayer" {
  59935. import { Nullable } from "babylonjs/types";
  59936. import { Camera } from "babylonjs/Cameras/camera";
  59937. import { Scene } from "babylonjs/scene";
  59938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59940. import { Mesh } from "babylonjs/Meshes/mesh";
  59941. import { Texture } from "babylonjs/Materials/Textures/texture";
  59942. import { Effect } from "babylonjs/Materials/effect";
  59943. import { Material } from "babylonjs/Materials/material";
  59944. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59945. import { Color4 } from "babylonjs/Maths/math.color";
  59946. import "babylonjs/Shaders/glowMapMerge.fragment";
  59947. import "babylonjs/Shaders/glowMapMerge.vertex";
  59948. import "babylonjs/Layers/effectLayerSceneComponent";
  59949. module "babylonjs/abstractScene" {
  59950. interface AbstractScene {
  59951. /**
  59952. * Return a the first highlight layer of the scene with a given name.
  59953. * @param name The name of the highlight layer to look for.
  59954. * @return The highlight layer if found otherwise null.
  59955. */
  59956. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59957. }
  59958. }
  59959. /**
  59960. * Glow layer options. This helps customizing the behaviour
  59961. * of the glow layer.
  59962. */
  59963. export interface IGlowLayerOptions {
  59964. /**
  59965. * Multiplication factor apply to the canvas size to compute the render target size
  59966. * used to generated the glowing objects (the smaller the faster).
  59967. */
  59968. mainTextureRatio: number;
  59969. /**
  59970. * Enforces a fixed size texture to ensure resize independant blur.
  59971. */
  59972. mainTextureFixedSize?: number;
  59973. /**
  59974. * How big is the kernel of the blur texture.
  59975. */
  59976. blurKernelSize: number;
  59977. /**
  59978. * The camera attached to the layer.
  59979. */
  59980. camera: Nullable<Camera>;
  59981. /**
  59982. * Enable MSAA by chosing the number of samples.
  59983. */
  59984. mainTextureSamples?: number;
  59985. /**
  59986. * The rendering group to draw the layer in.
  59987. */
  59988. renderingGroupId: number;
  59989. }
  59990. /**
  59991. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59992. *
  59993. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59994. *
  59995. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59996. */
  59997. export class GlowLayer extends EffectLayer {
  59998. /**
  59999. * Effect Name of the layer.
  60000. */
  60001. static readonly EffectName: string;
  60002. /**
  60003. * The default blur kernel size used for the glow.
  60004. */
  60005. static DefaultBlurKernelSize: number;
  60006. /**
  60007. * The default texture size ratio used for the glow.
  60008. */
  60009. static DefaultTextureRatio: number;
  60010. /**
  60011. * Sets the kernel size of the blur.
  60012. */
  60013. set blurKernelSize(value: number);
  60014. /**
  60015. * Gets the kernel size of the blur.
  60016. */
  60017. get blurKernelSize(): number;
  60018. /**
  60019. * Sets the glow intensity.
  60020. */
  60021. set intensity(value: number);
  60022. /**
  60023. * Gets the glow intensity.
  60024. */
  60025. get intensity(): number;
  60026. private _options;
  60027. private _intensity;
  60028. private _horizontalBlurPostprocess1;
  60029. private _verticalBlurPostprocess1;
  60030. private _horizontalBlurPostprocess2;
  60031. private _verticalBlurPostprocess2;
  60032. private _blurTexture1;
  60033. private _blurTexture2;
  60034. private _postProcesses1;
  60035. private _postProcesses2;
  60036. private _includedOnlyMeshes;
  60037. private _excludedMeshes;
  60038. private _meshesUsingTheirOwnMaterials;
  60039. /**
  60040. * Callback used to let the user override the color selection on a per mesh basis
  60041. */
  60042. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60043. /**
  60044. * Callback used to let the user override the texture selection on a per mesh basis
  60045. */
  60046. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60047. /**
  60048. * Instantiates a new glow Layer and references it to the scene.
  60049. * @param name The name of the layer
  60050. * @param scene The scene to use the layer in
  60051. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60052. */
  60053. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60054. /**
  60055. * Get the effect name of the layer.
  60056. * @return The effect name
  60057. */
  60058. getEffectName(): string;
  60059. /**
  60060. * Create the merge effect. This is the shader use to blit the information back
  60061. * to the main canvas at the end of the scene rendering.
  60062. */
  60063. protected _createMergeEffect(): Effect;
  60064. /**
  60065. * Creates the render target textures and post processes used in the glow layer.
  60066. */
  60067. protected _createTextureAndPostProcesses(): void;
  60068. /**
  60069. * Checks for the readiness of the element composing the layer.
  60070. * @param subMesh the mesh to check for
  60071. * @param useInstances specify wether or not to use instances to render the mesh
  60072. * @param emissiveTexture the associated emissive texture used to generate the glow
  60073. * @return true if ready otherwise, false
  60074. */
  60075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60076. /**
  60077. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60078. */
  60079. needStencil(): boolean;
  60080. /**
  60081. * Returns true if the mesh can be rendered, otherwise false.
  60082. * @param mesh The mesh to render
  60083. * @param material The material used on the mesh
  60084. * @returns true if it can be rendered otherwise false
  60085. */
  60086. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60087. /**
  60088. * Implementation specific of rendering the generating effect on the main canvas.
  60089. * @param effect The effect used to render through
  60090. */
  60091. protected _internalRender(effect: Effect): void;
  60092. /**
  60093. * Sets the required values for both the emissive texture and and the main color.
  60094. */
  60095. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60096. /**
  60097. * Returns true if the mesh should render, otherwise false.
  60098. * @param mesh The mesh to render
  60099. * @returns true if it should render otherwise false
  60100. */
  60101. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60102. /**
  60103. * Adds specific effects defines.
  60104. * @param defines The defines to add specifics to.
  60105. */
  60106. protected _addCustomEffectDefines(defines: string[]): void;
  60107. /**
  60108. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60109. * @param mesh The mesh to exclude from the glow layer
  60110. */
  60111. addExcludedMesh(mesh: Mesh): void;
  60112. /**
  60113. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60114. * @param mesh The mesh to remove
  60115. */
  60116. removeExcludedMesh(mesh: Mesh): void;
  60117. /**
  60118. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60119. * @param mesh The mesh to include in the glow layer
  60120. */
  60121. addIncludedOnlyMesh(mesh: Mesh): void;
  60122. /**
  60123. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60124. * @param mesh The mesh to remove
  60125. */
  60126. removeIncludedOnlyMesh(mesh: Mesh): void;
  60127. /**
  60128. * Determine if a given mesh will be used in the glow layer
  60129. * @param mesh The mesh to test
  60130. * @returns true if the mesh will be highlighted by the current glow layer
  60131. */
  60132. hasMesh(mesh: AbstractMesh): boolean;
  60133. /**
  60134. * Defines whether the current material of the mesh should be use to render the effect.
  60135. * @param mesh defines the current mesh to render
  60136. */
  60137. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60138. /**
  60139. * Add a mesh to be rendered through its own material and not with emissive only.
  60140. * @param mesh The mesh for which we need to use its material
  60141. */
  60142. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60143. /**
  60144. * Remove a mesh from being rendered through its own material and not with emissive only.
  60145. * @param mesh The mesh for which we need to not use its material
  60146. */
  60147. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60148. /**
  60149. * Free any resources and references associated to a mesh.
  60150. * Internal use
  60151. * @param mesh The mesh to free.
  60152. * @hidden
  60153. */
  60154. _disposeMesh(mesh: Mesh): void;
  60155. /**
  60156. * Gets the class name of the effect layer
  60157. * @returns the string with the class name of the effect layer
  60158. */
  60159. getClassName(): string;
  60160. /**
  60161. * Serializes this glow layer
  60162. * @returns a serialized glow layer object
  60163. */
  60164. serialize(): any;
  60165. /**
  60166. * Creates a Glow Layer from parsed glow layer data
  60167. * @param parsedGlowLayer defines glow layer data
  60168. * @param scene defines the current scene
  60169. * @param rootUrl defines the root URL containing the glow layer information
  60170. * @returns a parsed Glow Layer
  60171. */
  60172. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60173. }
  60174. }
  60175. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60176. /** @hidden */
  60177. export var glowBlurPostProcessPixelShader: {
  60178. name: string;
  60179. shader: string;
  60180. };
  60181. }
  60182. declare module "babylonjs/Layers/highlightLayer" {
  60183. import { Observable } from "babylonjs/Misc/observable";
  60184. import { Nullable } from "babylonjs/types";
  60185. import { Camera } from "babylonjs/Cameras/camera";
  60186. import { Scene } from "babylonjs/scene";
  60187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60189. import { Mesh } from "babylonjs/Meshes/mesh";
  60190. import { Effect } from "babylonjs/Materials/effect";
  60191. import { Material } from "babylonjs/Materials/material";
  60192. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60193. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60194. import "babylonjs/Shaders/glowMapMerge.fragment";
  60195. import "babylonjs/Shaders/glowMapMerge.vertex";
  60196. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60197. module "babylonjs/abstractScene" {
  60198. interface AbstractScene {
  60199. /**
  60200. * Return a the first highlight layer of the scene with a given name.
  60201. * @param name The name of the highlight layer to look for.
  60202. * @return The highlight layer if found otherwise null.
  60203. */
  60204. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60205. }
  60206. }
  60207. /**
  60208. * Highlight layer options. This helps customizing the behaviour
  60209. * of the highlight layer.
  60210. */
  60211. export interface IHighlightLayerOptions {
  60212. /**
  60213. * Multiplication factor apply to the canvas size to compute the render target size
  60214. * used to generated the glowing objects (the smaller the faster).
  60215. */
  60216. mainTextureRatio: number;
  60217. /**
  60218. * Enforces a fixed size texture to ensure resize independant blur.
  60219. */
  60220. mainTextureFixedSize?: number;
  60221. /**
  60222. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60223. * of the picture to blur (the smaller the faster).
  60224. */
  60225. blurTextureSizeRatio: number;
  60226. /**
  60227. * How big in texel of the blur texture is the vertical blur.
  60228. */
  60229. blurVerticalSize: number;
  60230. /**
  60231. * How big in texel of the blur texture is the horizontal blur.
  60232. */
  60233. blurHorizontalSize: number;
  60234. /**
  60235. * Alpha blending mode used to apply the blur. Default is combine.
  60236. */
  60237. alphaBlendingMode: number;
  60238. /**
  60239. * The camera attached to the layer.
  60240. */
  60241. camera: Nullable<Camera>;
  60242. /**
  60243. * Should we display highlight as a solid stroke?
  60244. */
  60245. isStroke?: boolean;
  60246. /**
  60247. * The rendering group to draw the layer in.
  60248. */
  60249. renderingGroupId: number;
  60250. }
  60251. /**
  60252. * The highlight layer Helps adding a glow effect around a mesh.
  60253. *
  60254. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60255. * glowy meshes to your scene.
  60256. *
  60257. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60258. */
  60259. export class HighlightLayer extends EffectLayer {
  60260. name: string;
  60261. /**
  60262. * Effect Name of the highlight layer.
  60263. */
  60264. static readonly EffectName: string;
  60265. /**
  60266. * The neutral color used during the preparation of the glow effect.
  60267. * This is black by default as the blend operation is a blend operation.
  60268. */
  60269. static NeutralColor: Color4;
  60270. /**
  60271. * Stencil value used for glowing meshes.
  60272. */
  60273. static GlowingMeshStencilReference: number;
  60274. /**
  60275. * Stencil value used for the other meshes in the scene.
  60276. */
  60277. static NormalMeshStencilReference: number;
  60278. /**
  60279. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60280. */
  60281. innerGlow: boolean;
  60282. /**
  60283. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60284. */
  60285. outerGlow: boolean;
  60286. /**
  60287. * Specifies the horizontal size of the blur.
  60288. */
  60289. set blurHorizontalSize(value: number);
  60290. /**
  60291. * Specifies the vertical size of the blur.
  60292. */
  60293. set blurVerticalSize(value: number);
  60294. /**
  60295. * Gets the horizontal size of the blur.
  60296. */
  60297. get blurHorizontalSize(): number;
  60298. /**
  60299. * Gets the vertical size of the blur.
  60300. */
  60301. get blurVerticalSize(): number;
  60302. /**
  60303. * An event triggered when the highlight layer is being blurred.
  60304. */
  60305. onBeforeBlurObservable: Observable<HighlightLayer>;
  60306. /**
  60307. * An event triggered when the highlight layer has been blurred.
  60308. */
  60309. onAfterBlurObservable: Observable<HighlightLayer>;
  60310. private _instanceGlowingMeshStencilReference;
  60311. private _options;
  60312. private _downSamplePostprocess;
  60313. private _horizontalBlurPostprocess;
  60314. private _verticalBlurPostprocess;
  60315. private _blurTexture;
  60316. private _meshes;
  60317. private _excludedMeshes;
  60318. /**
  60319. * Instantiates a new highlight Layer and references it to the scene..
  60320. * @param name The name of the layer
  60321. * @param scene The scene to use the layer in
  60322. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60323. */
  60324. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60325. /**
  60326. * Get the effect name of the layer.
  60327. * @return The effect name
  60328. */
  60329. getEffectName(): string;
  60330. /**
  60331. * Create the merge effect. This is the shader use to blit the information back
  60332. * to the main canvas at the end of the scene rendering.
  60333. */
  60334. protected _createMergeEffect(): Effect;
  60335. /**
  60336. * Creates the render target textures and post processes used in the highlight layer.
  60337. */
  60338. protected _createTextureAndPostProcesses(): void;
  60339. /**
  60340. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60341. */
  60342. needStencil(): boolean;
  60343. /**
  60344. * Checks for the readiness of the element composing the layer.
  60345. * @param subMesh the mesh to check for
  60346. * @param useInstances specify wether or not to use instances to render the mesh
  60347. * @param emissiveTexture the associated emissive texture used to generate the glow
  60348. * @return true if ready otherwise, false
  60349. */
  60350. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60351. /**
  60352. * Implementation specific of rendering the generating effect on the main canvas.
  60353. * @param effect The effect used to render through
  60354. */
  60355. protected _internalRender(effect: Effect): void;
  60356. /**
  60357. * Returns true if the layer contains information to display, otherwise false.
  60358. */
  60359. shouldRender(): boolean;
  60360. /**
  60361. * Returns true if the mesh should render, otherwise false.
  60362. * @param mesh The mesh to render
  60363. * @returns true if it should render otherwise false
  60364. */
  60365. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60366. /**
  60367. * Returns true if the mesh can be rendered, otherwise false.
  60368. * @param mesh The mesh to render
  60369. * @param material The material used on the mesh
  60370. * @returns true if it can be rendered otherwise false
  60371. */
  60372. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60373. /**
  60374. * Adds specific effects defines.
  60375. * @param defines The defines to add specifics to.
  60376. */
  60377. protected _addCustomEffectDefines(defines: string[]): void;
  60378. /**
  60379. * Sets the required values for both the emissive texture and and the main color.
  60380. */
  60381. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60382. /**
  60383. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60384. * @param mesh The mesh to exclude from the highlight layer
  60385. */
  60386. addExcludedMesh(mesh: Mesh): void;
  60387. /**
  60388. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60389. * @param mesh The mesh to highlight
  60390. */
  60391. removeExcludedMesh(mesh: Mesh): void;
  60392. /**
  60393. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60394. * @param mesh mesh to test
  60395. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60396. */
  60397. hasMesh(mesh: AbstractMesh): boolean;
  60398. /**
  60399. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60400. * @param mesh The mesh to highlight
  60401. * @param color The color of the highlight
  60402. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60403. */
  60404. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60405. /**
  60406. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60407. * @param mesh The mesh to highlight
  60408. */
  60409. removeMesh(mesh: Mesh): void;
  60410. /**
  60411. * Remove all the meshes currently referenced in the highlight layer
  60412. */
  60413. removeAllMeshes(): void;
  60414. /**
  60415. * Force the stencil to the normal expected value for none glowing parts
  60416. */
  60417. private _defaultStencilReference;
  60418. /**
  60419. * Free any resources and references associated to a mesh.
  60420. * Internal use
  60421. * @param mesh The mesh to free.
  60422. * @hidden
  60423. */
  60424. _disposeMesh(mesh: Mesh): void;
  60425. /**
  60426. * Dispose the highlight layer and free resources.
  60427. */
  60428. dispose(): void;
  60429. /**
  60430. * Gets the class name of the effect layer
  60431. * @returns the string with the class name of the effect layer
  60432. */
  60433. getClassName(): string;
  60434. /**
  60435. * Serializes this Highlight layer
  60436. * @returns a serialized Highlight layer object
  60437. */
  60438. serialize(): any;
  60439. /**
  60440. * Creates a Highlight layer from parsed Highlight layer data
  60441. * @param parsedHightlightLayer defines the Highlight layer data
  60442. * @param scene defines the current scene
  60443. * @param rootUrl defines the root URL containing the Highlight layer information
  60444. * @returns a parsed Highlight layer
  60445. */
  60446. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60447. }
  60448. }
  60449. declare module "babylonjs/Layers/layerSceneComponent" {
  60450. import { Scene } from "babylonjs/scene";
  60451. import { ISceneComponent } from "babylonjs/sceneComponent";
  60452. import { Layer } from "babylonjs/Layers/layer";
  60453. import { AbstractScene } from "babylonjs/abstractScene";
  60454. module "babylonjs/abstractScene" {
  60455. interface AbstractScene {
  60456. /**
  60457. * The list of layers (background and foreground) of the scene
  60458. */
  60459. layers: Array<Layer>;
  60460. }
  60461. }
  60462. /**
  60463. * Defines the layer scene component responsible to manage any layers
  60464. * in a given scene.
  60465. */
  60466. export class LayerSceneComponent implements ISceneComponent {
  60467. /**
  60468. * The component name helpfull to identify the component in the list of scene components.
  60469. */
  60470. readonly name: string;
  60471. /**
  60472. * The scene the component belongs to.
  60473. */
  60474. scene: Scene;
  60475. private _engine;
  60476. /**
  60477. * Creates a new instance of the component for the given scene
  60478. * @param scene Defines the scene to register the component in
  60479. */
  60480. constructor(scene: Scene);
  60481. /**
  60482. * Registers the component in a given scene
  60483. */
  60484. register(): void;
  60485. /**
  60486. * Rebuilds the elements related to this component in case of
  60487. * context lost for instance.
  60488. */
  60489. rebuild(): void;
  60490. /**
  60491. * Disposes the component and the associated ressources.
  60492. */
  60493. dispose(): void;
  60494. private _draw;
  60495. private _drawCameraPredicate;
  60496. private _drawCameraBackground;
  60497. private _drawCameraForeground;
  60498. private _drawRenderTargetPredicate;
  60499. private _drawRenderTargetBackground;
  60500. private _drawRenderTargetForeground;
  60501. /**
  60502. * Adds all the elements from the container to the scene
  60503. * @param container the container holding the elements
  60504. */
  60505. addFromContainer(container: AbstractScene): void;
  60506. /**
  60507. * Removes all the elements in the container from the scene
  60508. * @param container contains the elements to remove
  60509. * @param dispose if the removed element should be disposed (default: false)
  60510. */
  60511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60512. }
  60513. }
  60514. declare module "babylonjs/Shaders/layer.fragment" {
  60515. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60516. /** @hidden */
  60517. export var layerPixelShader: {
  60518. name: string;
  60519. shader: string;
  60520. };
  60521. }
  60522. declare module "babylonjs/Shaders/layer.vertex" {
  60523. /** @hidden */
  60524. export var layerVertexShader: {
  60525. name: string;
  60526. shader: string;
  60527. };
  60528. }
  60529. declare module "babylonjs/Layers/layer" {
  60530. import { Observable } from "babylonjs/Misc/observable";
  60531. import { Nullable } from "babylonjs/types";
  60532. import { Scene } from "babylonjs/scene";
  60533. import { Vector2 } from "babylonjs/Maths/math.vector";
  60534. import { Color4 } from "babylonjs/Maths/math.color";
  60535. import { Texture } from "babylonjs/Materials/Textures/texture";
  60536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60537. import "babylonjs/Shaders/layer.fragment";
  60538. import "babylonjs/Shaders/layer.vertex";
  60539. /**
  60540. * This represents a full screen 2d layer.
  60541. * This can be useful to display a picture in the background of your scene for instance.
  60542. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60543. */
  60544. export class Layer {
  60545. /**
  60546. * Define the name of the layer.
  60547. */
  60548. name: string;
  60549. /**
  60550. * Define the texture the layer should display.
  60551. */
  60552. texture: Nullable<Texture>;
  60553. /**
  60554. * Is the layer in background or foreground.
  60555. */
  60556. isBackground: boolean;
  60557. /**
  60558. * Define the color of the layer (instead of texture).
  60559. */
  60560. color: Color4;
  60561. /**
  60562. * Define the scale of the layer in order to zoom in out of the texture.
  60563. */
  60564. scale: Vector2;
  60565. /**
  60566. * Define an offset for the layer in order to shift the texture.
  60567. */
  60568. offset: Vector2;
  60569. /**
  60570. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60571. */
  60572. alphaBlendingMode: number;
  60573. /**
  60574. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60575. * Alpha test will not mix with the background color in case of transparency.
  60576. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60577. */
  60578. alphaTest: boolean;
  60579. /**
  60580. * Define a mask to restrict the layer to only some of the scene cameras.
  60581. */
  60582. layerMask: number;
  60583. /**
  60584. * Define the list of render target the layer is visible into.
  60585. */
  60586. renderTargetTextures: RenderTargetTexture[];
  60587. /**
  60588. * Define if the layer is only used in renderTarget or if it also
  60589. * renders in the main frame buffer of the canvas.
  60590. */
  60591. renderOnlyInRenderTargetTextures: boolean;
  60592. private _scene;
  60593. private _vertexBuffers;
  60594. private _indexBuffer;
  60595. private _effect;
  60596. private _previousDefines;
  60597. /**
  60598. * An event triggered when the layer is disposed.
  60599. */
  60600. onDisposeObservable: Observable<Layer>;
  60601. private _onDisposeObserver;
  60602. /**
  60603. * Back compatibility with callback before the onDisposeObservable existed.
  60604. * The set callback will be triggered when the layer has been disposed.
  60605. */
  60606. set onDispose(callback: () => void);
  60607. /**
  60608. * An event triggered before rendering the scene
  60609. */
  60610. onBeforeRenderObservable: Observable<Layer>;
  60611. private _onBeforeRenderObserver;
  60612. /**
  60613. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60614. * The set callback will be triggered just before rendering the layer.
  60615. */
  60616. set onBeforeRender(callback: () => void);
  60617. /**
  60618. * An event triggered after rendering the scene
  60619. */
  60620. onAfterRenderObservable: Observable<Layer>;
  60621. private _onAfterRenderObserver;
  60622. /**
  60623. * Back compatibility with callback before the onAfterRenderObservable existed.
  60624. * The set callback will be triggered just after rendering the layer.
  60625. */
  60626. set onAfterRender(callback: () => void);
  60627. /**
  60628. * Instantiates a new layer.
  60629. * This represents a full screen 2d layer.
  60630. * This can be useful to display a picture in the background of your scene for instance.
  60631. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60632. * @param name Define the name of the layer in the scene
  60633. * @param imgUrl Define the url of the texture to display in the layer
  60634. * @param scene Define the scene the layer belongs to
  60635. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60636. * @param color Defines a color for the layer
  60637. */
  60638. constructor(
  60639. /**
  60640. * Define the name of the layer.
  60641. */
  60642. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60643. private _createIndexBuffer;
  60644. /** @hidden */
  60645. _rebuild(): void;
  60646. /**
  60647. * Renders the layer in the scene.
  60648. */
  60649. render(): void;
  60650. /**
  60651. * Disposes and releases the associated ressources.
  60652. */
  60653. dispose(): void;
  60654. }
  60655. }
  60656. declare module "babylonjs/Layers/index" {
  60657. export * from "babylonjs/Layers/effectLayer";
  60658. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60659. export * from "babylonjs/Layers/glowLayer";
  60660. export * from "babylonjs/Layers/highlightLayer";
  60661. export * from "babylonjs/Layers/layer";
  60662. export * from "babylonjs/Layers/layerSceneComponent";
  60663. }
  60664. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60665. /** @hidden */
  60666. export var lensFlarePixelShader: {
  60667. name: string;
  60668. shader: string;
  60669. };
  60670. }
  60671. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60672. /** @hidden */
  60673. export var lensFlareVertexShader: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60679. import { Scene } from "babylonjs/scene";
  60680. import { Vector3 } from "babylonjs/Maths/math.vector";
  60681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60682. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60683. import "babylonjs/Shaders/lensFlare.fragment";
  60684. import "babylonjs/Shaders/lensFlare.vertex";
  60685. import { Viewport } from "babylonjs/Maths/math.viewport";
  60686. /**
  60687. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60688. * It is usually composed of several `lensFlare`.
  60689. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60690. */
  60691. export class LensFlareSystem {
  60692. /**
  60693. * Define the name of the lens flare system
  60694. */
  60695. name: string;
  60696. /**
  60697. * List of lens flares used in this system.
  60698. */
  60699. lensFlares: LensFlare[];
  60700. /**
  60701. * Define a limit from the border the lens flare can be visible.
  60702. */
  60703. borderLimit: number;
  60704. /**
  60705. * Define a viewport border we do not want to see the lens flare in.
  60706. */
  60707. viewportBorder: number;
  60708. /**
  60709. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60710. */
  60711. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60712. /**
  60713. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60714. */
  60715. layerMask: number;
  60716. /**
  60717. * Define the id of the lens flare system in the scene.
  60718. * (equal to name by default)
  60719. */
  60720. id: string;
  60721. private _scene;
  60722. private _emitter;
  60723. private _vertexBuffers;
  60724. private _indexBuffer;
  60725. private _effect;
  60726. private _positionX;
  60727. private _positionY;
  60728. private _isEnabled;
  60729. /** @hidden */
  60730. static _SceneComponentInitialization: (scene: Scene) => void;
  60731. /**
  60732. * Instantiates a lens flare system.
  60733. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60734. * It is usually composed of several `lensFlare`.
  60735. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60736. * @param name Define the name of the lens flare system in the scene
  60737. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60738. * @param scene Define the scene the lens flare system belongs to
  60739. */
  60740. constructor(
  60741. /**
  60742. * Define the name of the lens flare system
  60743. */
  60744. name: string, emitter: any, scene: Scene);
  60745. /**
  60746. * Define if the lens flare system is enabled.
  60747. */
  60748. get isEnabled(): boolean;
  60749. set isEnabled(value: boolean);
  60750. /**
  60751. * Get the scene the effects belongs to.
  60752. * @returns the scene holding the lens flare system
  60753. */
  60754. getScene(): Scene;
  60755. /**
  60756. * Get the emitter of the lens flare system.
  60757. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60758. * @returns the emitter of the lens flare system
  60759. */
  60760. getEmitter(): any;
  60761. /**
  60762. * Set the emitter of the lens flare system.
  60763. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60764. * @param newEmitter Define the new emitter of the system
  60765. */
  60766. setEmitter(newEmitter: any): void;
  60767. /**
  60768. * Get the lens flare system emitter position.
  60769. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60770. * @returns the position
  60771. */
  60772. getEmitterPosition(): Vector3;
  60773. /**
  60774. * @hidden
  60775. */
  60776. computeEffectivePosition(globalViewport: Viewport): boolean;
  60777. /** @hidden */
  60778. _isVisible(): boolean;
  60779. /**
  60780. * @hidden
  60781. */
  60782. render(): boolean;
  60783. /**
  60784. * Dispose and release the lens flare with its associated resources.
  60785. */
  60786. dispose(): void;
  60787. /**
  60788. * Parse a lens flare system from a JSON repressentation
  60789. * @param parsedLensFlareSystem Define the JSON to parse
  60790. * @param scene Define the scene the parsed system should be instantiated in
  60791. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60792. * @returns the parsed system
  60793. */
  60794. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60795. /**
  60796. * Serialize the current Lens Flare System into a JSON representation.
  60797. * @returns the serialized JSON
  60798. */
  60799. serialize(): any;
  60800. }
  60801. }
  60802. declare module "babylonjs/LensFlares/lensFlare" {
  60803. import { Nullable } from "babylonjs/types";
  60804. import { Color3 } from "babylonjs/Maths/math.color";
  60805. import { Texture } from "babylonjs/Materials/Textures/texture";
  60806. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60807. /**
  60808. * This represents one of the lens effect in a `lensFlareSystem`.
  60809. * It controls one of the indiviual texture used in the effect.
  60810. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60811. */
  60812. export class LensFlare {
  60813. /**
  60814. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60815. */
  60816. size: number;
  60817. /**
  60818. * 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.
  60819. */
  60820. position: number;
  60821. /**
  60822. * Define the lens color.
  60823. */
  60824. color: Color3;
  60825. /**
  60826. * Define the lens texture.
  60827. */
  60828. texture: Nullable<Texture>;
  60829. /**
  60830. * Define the alpha mode to render this particular lens.
  60831. */
  60832. alphaMode: number;
  60833. private _system;
  60834. /**
  60835. * Creates a new Lens Flare.
  60836. * This represents one of the lens effect in a `lensFlareSystem`.
  60837. * It controls one of the indiviual texture used in the effect.
  60838. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60839. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60840. * @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.
  60841. * @param color Define the lens color
  60842. * @param imgUrl Define the lens texture url
  60843. * @param system Define the `lensFlareSystem` this flare is part of
  60844. * @returns The newly created Lens Flare
  60845. */
  60846. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60847. /**
  60848. * Instantiates a new Lens Flare.
  60849. * This represents one of the lens effect in a `lensFlareSystem`.
  60850. * It controls one of the indiviual texture used in the effect.
  60851. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60852. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60853. * @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.
  60854. * @param color Define the lens color
  60855. * @param imgUrl Define the lens texture url
  60856. * @param system Define the `lensFlareSystem` this flare is part of
  60857. */
  60858. constructor(
  60859. /**
  60860. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60861. */
  60862. size: number,
  60863. /**
  60864. * 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.
  60865. */
  60866. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60867. /**
  60868. * Dispose and release the lens flare with its associated resources.
  60869. */
  60870. dispose(): void;
  60871. }
  60872. }
  60873. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60874. import { Nullable } from "babylonjs/types";
  60875. import { Scene } from "babylonjs/scene";
  60876. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60877. import { AbstractScene } from "babylonjs/abstractScene";
  60878. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60879. module "babylonjs/abstractScene" {
  60880. interface AbstractScene {
  60881. /**
  60882. * The list of lens flare system added to the scene
  60883. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60884. */
  60885. lensFlareSystems: Array<LensFlareSystem>;
  60886. /**
  60887. * Removes the given lens flare system from this scene.
  60888. * @param toRemove The lens flare system to remove
  60889. * @returns The index of the removed lens flare system
  60890. */
  60891. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60892. /**
  60893. * Adds the given lens flare system to this scene
  60894. * @param newLensFlareSystem The lens flare system to add
  60895. */
  60896. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60897. /**
  60898. * Gets a lens flare system using its name
  60899. * @param name defines the name to look for
  60900. * @returns the lens flare system or null if not found
  60901. */
  60902. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60903. /**
  60904. * Gets a lens flare system using its id
  60905. * @param id defines the id to look for
  60906. * @returns the lens flare system or null if not found
  60907. */
  60908. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60909. }
  60910. }
  60911. /**
  60912. * Defines the lens flare scene component responsible to manage any lens flares
  60913. * in a given scene.
  60914. */
  60915. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60916. /**
  60917. * The component name helpfull to identify the component in the list of scene components.
  60918. */
  60919. readonly name: string;
  60920. /**
  60921. * The scene the component belongs to.
  60922. */
  60923. scene: Scene;
  60924. /**
  60925. * Creates a new instance of the component for the given scene
  60926. * @param scene Defines the scene to register the component in
  60927. */
  60928. constructor(scene: Scene);
  60929. /**
  60930. * Registers the component in a given scene
  60931. */
  60932. register(): void;
  60933. /**
  60934. * Rebuilds the elements related to this component in case of
  60935. * context lost for instance.
  60936. */
  60937. rebuild(): void;
  60938. /**
  60939. * Adds all the elements from the container to the scene
  60940. * @param container the container holding the elements
  60941. */
  60942. addFromContainer(container: AbstractScene): void;
  60943. /**
  60944. * Removes all the elements in the container from the scene
  60945. * @param container contains the elements to remove
  60946. * @param dispose if the removed element should be disposed (default: false)
  60947. */
  60948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60949. /**
  60950. * Serializes the component data to the specified json object
  60951. * @param serializationObject The object to serialize to
  60952. */
  60953. serialize(serializationObject: any): void;
  60954. /**
  60955. * Disposes the component and the associated ressources.
  60956. */
  60957. dispose(): void;
  60958. private _draw;
  60959. }
  60960. }
  60961. declare module "babylonjs/LensFlares/index" {
  60962. export * from "babylonjs/LensFlares/lensFlare";
  60963. export * from "babylonjs/LensFlares/lensFlareSystem";
  60964. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60965. }
  60966. declare module "babylonjs/Shaders/depth.fragment" {
  60967. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60968. /** @hidden */
  60969. export var depthPixelShader: {
  60970. name: string;
  60971. shader: string;
  60972. };
  60973. }
  60974. declare module "babylonjs/Shaders/depth.vertex" {
  60975. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60976. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60977. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60978. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60980. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60981. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60982. /** @hidden */
  60983. export var depthVertexShader: {
  60984. name: string;
  60985. shader: string;
  60986. };
  60987. }
  60988. declare module "babylonjs/Rendering/depthRenderer" {
  60989. import { Nullable } from "babylonjs/types";
  60990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60991. import { Scene } from "babylonjs/scene";
  60992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60993. import { Camera } from "babylonjs/Cameras/camera";
  60994. import "babylonjs/Shaders/depth.fragment";
  60995. import "babylonjs/Shaders/depth.vertex";
  60996. /**
  60997. * This represents a depth renderer in Babylon.
  60998. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60999. */
  61000. export class DepthRenderer {
  61001. private _scene;
  61002. private _depthMap;
  61003. private _effect;
  61004. private readonly _storeNonLinearDepth;
  61005. private readonly _clearColor;
  61006. /** Get if the depth renderer is using packed depth or not */
  61007. readonly isPacked: boolean;
  61008. private _cachedDefines;
  61009. private _camera;
  61010. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61011. enabled: boolean;
  61012. /**
  61013. * Specifiess that the depth renderer will only be used within
  61014. * the camera it is created for.
  61015. * This can help forcing its rendering during the camera processing.
  61016. */
  61017. useOnlyInActiveCamera: boolean;
  61018. /** @hidden */
  61019. static _SceneComponentInitialization: (scene: Scene) => void;
  61020. /**
  61021. * Instantiates a depth renderer
  61022. * @param scene The scene the renderer belongs to
  61023. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61024. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61025. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61026. */
  61027. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61028. /**
  61029. * Creates the depth rendering effect and checks if the effect is ready.
  61030. * @param subMesh The submesh to be used to render the depth map of
  61031. * @param useInstances If multiple world instances should be used
  61032. * @returns if the depth renderer is ready to render the depth map
  61033. */
  61034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61035. /**
  61036. * Gets the texture which the depth map will be written to.
  61037. * @returns The depth map texture
  61038. */
  61039. getDepthMap(): RenderTargetTexture;
  61040. /**
  61041. * Disposes of the depth renderer.
  61042. */
  61043. dispose(): void;
  61044. }
  61045. }
  61046. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61047. /** @hidden */
  61048. export var minmaxReduxPixelShader: {
  61049. name: string;
  61050. shader: string;
  61051. };
  61052. }
  61053. declare module "babylonjs/Misc/minMaxReducer" {
  61054. import { Nullable } from "babylonjs/types";
  61055. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61056. import { Camera } from "babylonjs/Cameras/camera";
  61057. import { Observer } from "babylonjs/Misc/observable";
  61058. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61059. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61060. import { Observable } from "babylonjs/Misc/observable";
  61061. import "babylonjs/Shaders/minmaxRedux.fragment";
  61062. /**
  61063. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61064. * and maximum values from all values of the texture.
  61065. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61066. * The source values are read from the red channel of the texture.
  61067. */
  61068. export class MinMaxReducer {
  61069. /**
  61070. * Observable triggered when the computation has been performed
  61071. */
  61072. onAfterReductionPerformed: Observable<{
  61073. min: number;
  61074. max: number;
  61075. }>;
  61076. protected _camera: Camera;
  61077. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61078. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61079. protected _postProcessManager: PostProcessManager;
  61080. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61081. protected _forceFullscreenViewport: boolean;
  61082. /**
  61083. * Creates a min/max reducer
  61084. * @param camera The camera to use for the post processes
  61085. */
  61086. constructor(camera: Camera);
  61087. /**
  61088. * Gets the texture used to read the values from.
  61089. */
  61090. get sourceTexture(): Nullable<RenderTargetTexture>;
  61091. /**
  61092. * Sets the source texture to read the values from.
  61093. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61094. * because in such textures '1' value must not be taken into account to compute the maximum
  61095. * as this value is used to clear the texture.
  61096. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61097. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61098. * @param depthRedux Indicates if the texture is a depth texture or not
  61099. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61100. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61101. */
  61102. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61103. /**
  61104. * Defines the refresh rate of the computation.
  61105. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61106. */
  61107. get refreshRate(): number;
  61108. set refreshRate(value: number);
  61109. protected _activated: boolean;
  61110. /**
  61111. * Gets the activation status of the reducer
  61112. */
  61113. get activated(): boolean;
  61114. /**
  61115. * Activates the reduction computation.
  61116. * When activated, the observers registered in onAfterReductionPerformed are
  61117. * called after the compuation is performed
  61118. */
  61119. activate(): void;
  61120. /**
  61121. * Deactivates the reduction computation.
  61122. */
  61123. deactivate(): void;
  61124. /**
  61125. * Disposes the min/max reducer
  61126. * @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.
  61127. */
  61128. dispose(disposeAll?: boolean): void;
  61129. }
  61130. }
  61131. declare module "babylonjs/Misc/depthReducer" {
  61132. import { Nullable } from "babylonjs/types";
  61133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61134. import { Camera } from "babylonjs/Cameras/camera";
  61135. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61136. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61137. /**
  61138. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61139. */
  61140. export class DepthReducer extends MinMaxReducer {
  61141. private _depthRenderer;
  61142. private _depthRendererId;
  61143. /**
  61144. * Gets the depth renderer used for the computation.
  61145. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61146. */
  61147. get depthRenderer(): Nullable<DepthRenderer>;
  61148. /**
  61149. * Creates a depth reducer
  61150. * @param camera The camera used to render the depth texture
  61151. */
  61152. constructor(camera: Camera);
  61153. /**
  61154. * Sets the depth renderer to use to generate the depth map
  61155. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61156. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61157. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61158. */
  61159. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61160. /** @hidden */
  61161. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61162. /**
  61163. * Activates the reduction computation.
  61164. * When activated, the observers registered in onAfterReductionPerformed are
  61165. * called after the compuation is performed
  61166. */
  61167. activate(): void;
  61168. /**
  61169. * Deactivates the reduction computation.
  61170. */
  61171. deactivate(): void;
  61172. /**
  61173. * Disposes the depth reducer
  61174. * @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.
  61175. */
  61176. dispose(disposeAll?: boolean): void;
  61177. }
  61178. }
  61179. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61180. import { Nullable } from "babylonjs/types";
  61181. import { Scene } from "babylonjs/scene";
  61182. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61183. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61185. import { Effect } from "babylonjs/Materials/effect";
  61186. import "babylonjs/Shaders/shadowMap.fragment";
  61187. import "babylonjs/Shaders/shadowMap.vertex";
  61188. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61189. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61190. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61191. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61192. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61193. /**
  61194. * A CSM implementation allowing casting shadows on large scenes.
  61195. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61196. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61197. */
  61198. export class CascadedShadowGenerator extends ShadowGenerator {
  61199. private static readonly frustumCornersNDCSpace;
  61200. /**
  61201. * Name of the CSM class
  61202. */
  61203. static CLASSNAME: string;
  61204. /**
  61205. * Defines the default number of cascades used by the CSM.
  61206. */
  61207. static readonly DEFAULT_CASCADES_COUNT: number;
  61208. /**
  61209. * Defines the minimum number of cascades used by the CSM.
  61210. */
  61211. static readonly MIN_CASCADES_COUNT: number;
  61212. /**
  61213. * Defines the maximum number of cascades used by the CSM.
  61214. */
  61215. static readonly MAX_CASCADES_COUNT: number;
  61216. protected _validateFilter(filter: number): number;
  61217. /**
  61218. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61219. */
  61220. penumbraDarkness: number;
  61221. private _numCascades;
  61222. /**
  61223. * Gets or set the number of cascades used by the CSM.
  61224. */
  61225. get numCascades(): number;
  61226. set numCascades(value: number);
  61227. /**
  61228. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61229. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61230. */
  61231. stabilizeCascades: boolean;
  61232. private _freezeShadowCastersBoundingInfo;
  61233. private _freezeShadowCastersBoundingInfoObservable;
  61234. /**
  61235. * Enables or disables the shadow casters bounding info computation.
  61236. * If your shadow casters don't move, you can disable this feature.
  61237. * If it is enabled, the bounding box computation is done every frame.
  61238. */
  61239. get freezeShadowCastersBoundingInfo(): boolean;
  61240. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61241. private _scbiMin;
  61242. private _scbiMax;
  61243. protected _computeShadowCastersBoundingInfo(): void;
  61244. protected _shadowCastersBoundingInfo: BoundingInfo;
  61245. /**
  61246. * Gets or sets the shadow casters bounding info.
  61247. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61248. * so that the system won't overwrite the bounds you provide
  61249. */
  61250. get shadowCastersBoundingInfo(): BoundingInfo;
  61251. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61252. protected _breaksAreDirty: boolean;
  61253. protected _minDistance: number;
  61254. protected _maxDistance: number;
  61255. /**
  61256. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61257. *
  61258. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61259. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61260. * @param min minimal distance for the breaks (default to 0.)
  61261. * @param max maximal distance for the breaks (default to 1.)
  61262. */
  61263. setMinMaxDistance(min: number, max: number): void;
  61264. /** Gets the minimal distance used in the cascade break computation */
  61265. get minDistance(): number;
  61266. /** Gets the maximal distance used in the cascade break computation */
  61267. get maxDistance(): number;
  61268. /**
  61269. * Gets the class name of that object
  61270. * @returns "CascadedShadowGenerator"
  61271. */
  61272. getClassName(): string;
  61273. private _cascadeMinExtents;
  61274. private _cascadeMaxExtents;
  61275. /**
  61276. * Gets a cascade minimum extents
  61277. * @param cascadeIndex index of the cascade
  61278. * @returns the minimum cascade extents
  61279. */
  61280. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61281. /**
  61282. * Gets a cascade maximum extents
  61283. * @param cascadeIndex index of the cascade
  61284. * @returns the maximum cascade extents
  61285. */
  61286. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61287. private _cascades;
  61288. private _currentLayer;
  61289. private _viewSpaceFrustumsZ;
  61290. private _viewMatrices;
  61291. private _projectionMatrices;
  61292. private _transformMatrices;
  61293. private _transformMatricesAsArray;
  61294. private _frustumLengths;
  61295. private _lightSizeUVCorrection;
  61296. private _depthCorrection;
  61297. private _frustumCornersWorldSpace;
  61298. private _frustumCenter;
  61299. private _shadowCameraPos;
  61300. private _shadowMaxZ;
  61301. /**
  61302. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61303. * It defaults to camera.maxZ
  61304. */
  61305. get shadowMaxZ(): number;
  61306. /**
  61307. * Sets the shadow max z distance.
  61308. */
  61309. set shadowMaxZ(value: number);
  61310. protected _debug: boolean;
  61311. /**
  61312. * Gets or sets the debug flag.
  61313. * When enabled, the cascades are materialized by different colors on the screen.
  61314. */
  61315. get debug(): boolean;
  61316. set debug(dbg: boolean);
  61317. private _depthClamp;
  61318. /**
  61319. * Gets or sets the depth clamping value.
  61320. *
  61321. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61322. * to account for the shadow casters far away.
  61323. *
  61324. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61325. */
  61326. get depthClamp(): boolean;
  61327. set depthClamp(value: boolean);
  61328. private _cascadeBlendPercentage;
  61329. /**
  61330. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61331. * It defaults to 0.1 (10% blending).
  61332. */
  61333. get cascadeBlendPercentage(): number;
  61334. set cascadeBlendPercentage(value: number);
  61335. private _lambda;
  61336. /**
  61337. * Gets or set the lambda parameter.
  61338. * This parameter is used to split the camera frustum and create the cascades.
  61339. * 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.
  61340. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61341. */
  61342. get lambda(): number;
  61343. set lambda(value: number);
  61344. /**
  61345. * Gets the view matrix corresponding to a given cascade
  61346. * @param cascadeNum cascade to retrieve the view matrix from
  61347. * @returns the cascade view matrix
  61348. */
  61349. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61350. /**
  61351. * Gets the projection matrix corresponding to a given cascade
  61352. * @param cascadeNum cascade to retrieve the projection matrix from
  61353. * @returns the cascade projection matrix
  61354. */
  61355. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61356. /**
  61357. * Gets the transformation matrix corresponding to a given cascade
  61358. * @param cascadeNum cascade to retrieve the transformation matrix from
  61359. * @returns the cascade transformation matrix
  61360. */
  61361. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61362. private _depthRenderer;
  61363. /**
  61364. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61365. *
  61366. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61367. *
  61368. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61369. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61370. * @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
  61371. */
  61372. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61373. private _depthReducer;
  61374. private _autoCalcDepthBounds;
  61375. /**
  61376. * Gets or sets the autoCalcDepthBounds property.
  61377. *
  61378. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61379. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61380. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61381. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61382. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61383. */
  61384. get autoCalcDepthBounds(): boolean;
  61385. set autoCalcDepthBounds(value: boolean);
  61386. /**
  61387. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61388. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61389. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61390. * for setting the refresh rate on the renderer yourself!
  61391. */
  61392. get autoCalcDepthBoundsRefreshRate(): number;
  61393. set autoCalcDepthBoundsRefreshRate(value: number);
  61394. /**
  61395. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61396. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61397. * you change the camera near/far planes!
  61398. */
  61399. splitFrustum(): void;
  61400. private _splitFrustum;
  61401. private _computeMatrices;
  61402. private _computeFrustumInWorldSpace;
  61403. private _computeCascadeFrustum;
  61404. /**
  61405. * Support test.
  61406. */
  61407. static get IsSupported(): boolean;
  61408. /** @hidden */
  61409. static _SceneComponentInitialization: (scene: Scene) => void;
  61410. /**
  61411. * Creates a Cascaded Shadow Generator object.
  61412. * A ShadowGenerator is the required tool to use the shadows.
  61413. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61414. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61415. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61416. * @param light The directional light object generating the shadows.
  61417. * @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.
  61418. */
  61419. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61420. protected _initializeGenerator(): void;
  61421. protected _createTargetRenderTexture(): void;
  61422. protected _initializeShadowMap(): void;
  61423. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61424. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61425. /**
  61426. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61427. * @param defines Defines of the material we want to update
  61428. * @param lightIndex Index of the light in the enabled light list of the material
  61429. */
  61430. prepareDefines(defines: any, lightIndex: number): void;
  61431. /**
  61432. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61433. * defined in the generator but impacting the effect).
  61434. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61435. * @param effect The effect we are binfing the information for
  61436. */
  61437. bindShadowLight(lightIndex: string, effect: Effect): void;
  61438. /**
  61439. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61440. * (eq to view projection * shadow projection matrices)
  61441. * @returns The transform matrix used to create the shadow map
  61442. */
  61443. getTransformMatrix(): Matrix;
  61444. /**
  61445. * Disposes the ShadowGenerator.
  61446. * Returns nothing.
  61447. */
  61448. dispose(): void;
  61449. /**
  61450. * Serializes the shadow generator setup to a json object.
  61451. * @returns The serialized JSON object
  61452. */
  61453. serialize(): any;
  61454. /**
  61455. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61456. * @param parsedShadowGenerator The JSON object to parse
  61457. * @param scene The scene to create the shadow map for
  61458. * @returns The parsed shadow generator
  61459. */
  61460. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61461. }
  61462. }
  61463. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61464. import { Scene } from "babylonjs/scene";
  61465. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61466. import { AbstractScene } from "babylonjs/abstractScene";
  61467. /**
  61468. * Defines the shadow generator component responsible to manage any shadow generators
  61469. * in a given scene.
  61470. */
  61471. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61472. /**
  61473. * The component name helpfull to identify the component in the list of scene components.
  61474. */
  61475. readonly name: string;
  61476. /**
  61477. * The scene the component belongs to.
  61478. */
  61479. scene: Scene;
  61480. /**
  61481. * Creates a new instance of the component for the given scene
  61482. * @param scene Defines the scene to register the component in
  61483. */
  61484. constructor(scene: Scene);
  61485. /**
  61486. * Registers the component in a given scene
  61487. */
  61488. register(): void;
  61489. /**
  61490. * Rebuilds the elements related to this component in case of
  61491. * context lost for instance.
  61492. */
  61493. rebuild(): void;
  61494. /**
  61495. * Serializes the component data to the specified json object
  61496. * @param serializationObject The object to serialize to
  61497. */
  61498. serialize(serializationObject: any): void;
  61499. /**
  61500. * Adds all the elements from the container to the scene
  61501. * @param container the container holding the elements
  61502. */
  61503. addFromContainer(container: AbstractScene): void;
  61504. /**
  61505. * Removes all the elements in the container from the scene
  61506. * @param container contains the elements to remove
  61507. * @param dispose if the removed element should be disposed (default: false)
  61508. */
  61509. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61510. /**
  61511. * Rebuilds the elements related to this component in case of
  61512. * context lost for instance.
  61513. */
  61514. dispose(): void;
  61515. private _gatherRenderTargets;
  61516. }
  61517. }
  61518. declare module "babylonjs/Lights/Shadows/index" {
  61519. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61520. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61521. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61522. }
  61523. declare module "babylonjs/Lights/pointLight" {
  61524. import { Scene } from "babylonjs/scene";
  61525. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61527. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61528. import { Effect } from "babylonjs/Materials/effect";
  61529. /**
  61530. * A point light is a light defined by an unique point in world space.
  61531. * The light is emitted in every direction from this point.
  61532. * A good example of a point light is a standard light bulb.
  61533. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61534. */
  61535. export class PointLight extends ShadowLight {
  61536. private _shadowAngle;
  61537. /**
  61538. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61539. * This specifies what angle the shadow will use to be created.
  61540. *
  61541. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61542. */
  61543. get shadowAngle(): number;
  61544. /**
  61545. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61546. * This specifies what angle the shadow will use to be created.
  61547. *
  61548. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61549. */
  61550. set shadowAngle(value: number);
  61551. /**
  61552. * Gets the direction if it has been set.
  61553. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61554. */
  61555. get direction(): Vector3;
  61556. /**
  61557. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61558. */
  61559. set direction(value: Vector3);
  61560. /**
  61561. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61562. * A PointLight emits the light in every direction.
  61563. * It can cast shadows.
  61564. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61565. * ```javascript
  61566. * var pointLight = new PointLight("pl", camera.position, scene);
  61567. * ```
  61568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61569. * @param name The light friendly name
  61570. * @param position The position of the point light in the scene
  61571. * @param scene The scene the lights belongs to
  61572. */
  61573. constructor(name: string, position: Vector3, scene: Scene);
  61574. /**
  61575. * Returns the string "PointLight"
  61576. * @returns the class name
  61577. */
  61578. getClassName(): string;
  61579. /**
  61580. * Returns the integer 0.
  61581. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61582. */
  61583. getTypeID(): number;
  61584. /**
  61585. * Specifies wether or not the shadowmap should be a cube texture.
  61586. * @returns true if the shadowmap needs to be a cube texture.
  61587. */
  61588. needCube(): boolean;
  61589. /**
  61590. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61591. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61592. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61593. */
  61594. getShadowDirection(faceIndex?: number): Vector3;
  61595. /**
  61596. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61597. * - fov = PI / 2
  61598. * - aspect ratio : 1.0
  61599. * - z-near and far equal to the active camera minZ and maxZ.
  61600. * Returns the PointLight.
  61601. */
  61602. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61603. protected _buildUniformLayout(): void;
  61604. /**
  61605. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61606. * @param effect The effect to update
  61607. * @param lightIndex The index of the light in the effect to update
  61608. * @returns The point light
  61609. */
  61610. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61611. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61612. /**
  61613. * Prepares the list of defines specific to the light type.
  61614. * @param defines the list of defines
  61615. * @param lightIndex defines the index of the light for the effect
  61616. */
  61617. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61618. }
  61619. }
  61620. declare module "babylonjs/Lights/index" {
  61621. export * from "babylonjs/Lights/light";
  61622. export * from "babylonjs/Lights/shadowLight";
  61623. export * from "babylonjs/Lights/Shadows/index";
  61624. export * from "babylonjs/Lights/directionalLight";
  61625. export * from "babylonjs/Lights/hemisphericLight";
  61626. export * from "babylonjs/Lights/pointLight";
  61627. export * from "babylonjs/Lights/spotLight";
  61628. }
  61629. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61630. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61631. /**
  61632. * Header information of HDR texture files.
  61633. */
  61634. export interface HDRInfo {
  61635. /**
  61636. * The height of the texture in pixels.
  61637. */
  61638. height: number;
  61639. /**
  61640. * The width of the texture in pixels.
  61641. */
  61642. width: number;
  61643. /**
  61644. * The index of the beginning of the data in the binary file.
  61645. */
  61646. dataPosition: number;
  61647. }
  61648. /**
  61649. * This groups tools to convert HDR texture to native colors array.
  61650. */
  61651. export class HDRTools {
  61652. private static Ldexp;
  61653. private static Rgbe2float;
  61654. private static readStringLine;
  61655. /**
  61656. * Reads header information from an RGBE texture stored in a native array.
  61657. * More information on this format are available here:
  61658. * https://en.wikipedia.org/wiki/RGBE_image_format
  61659. *
  61660. * @param uint8array The binary file stored in native array.
  61661. * @return The header information.
  61662. */
  61663. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61664. /**
  61665. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61666. * This RGBE texture needs to store the information as a panorama.
  61667. *
  61668. * More information on this format are available here:
  61669. * https://en.wikipedia.org/wiki/RGBE_image_format
  61670. *
  61671. * @param buffer The binary file stored in an array buffer.
  61672. * @param size The expected size of the extracted cubemap.
  61673. * @return The Cube Map information.
  61674. */
  61675. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61676. /**
  61677. * Returns the pixels data extracted from an RGBE texture.
  61678. * This pixels will be stored left to right up to down in the R G B order in one array.
  61679. *
  61680. * More information on this format are available here:
  61681. * https://en.wikipedia.org/wiki/RGBE_image_format
  61682. *
  61683. * @param uint8array The binary file stored in an array buffer.
  61684. * @param hdrInfo The header information of the file.
  61685. * @return The pixels data in RGB right to left up to down order.
  61686. */
  61687. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61688. private static RGBE_ReadPixels_RLE;
  61689. }
  61690. }
  61691. declare module "babylonjs/Materials/effectRenderer" {
  61692. import { Nullable } from "babylonjs/types";
  61693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61695. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61696. import { Viewport } from "babylonjs/Maths/math.viewport";
  61697. import { Observable } from "babylonjs/Misc/observable";
  61698. import { Effect } from "babylonjs/Materials/effect";
  61699. import "babylonjs/Shaders/postprocess.vertex";
  61700. /**
  61701. * Effect Render Options
  61702. */
  61703. export interface IEffectRendererOptions {
  61704. /**
  61705. * Defines the vertices positions.
  61706. */
  61707. positions?: number[];
  61708. /**
  61709. * Defines the indices.
  61710. */
  61711. indices?: number[];
  61712. }
  61713. /**
  61714. * Helper class to render one or more effects.
  61715. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61716. */
  61717. export class EffectRenderer {
  61718. private engine;
  61719. private static _DefaultOptions;
  61720. private _vertexBuffers;
  61721. private _indexBuffer;
  61722. private _fullscreenViewport;
  61723. /**
  61724. * Creates an effect renderer
  61725. * @param engine the engine to use for rendering
  61726. * @param options defines the options of the effect renderer
  61727. */
  61728. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61729. /**
  61730. * Sets the current viewport in normalized coordinates 0-1
  61731. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61732. */
  61733. setViewport(viewport?: Viewport): void;
  61734. /**
  61735. * Binds the embedded attributes buffer to the effect.
  61736. * @param effect Defines the effect to bind the attributes for
  61737. */
  61738. bindBuffers(effect: Effect): void;
  61739. /**
  61740. * Sets the current effect wrapper to use during draw.
  61741. * The effect needs to be ready before calling this api.
  61742. * This also sets the default full screen position attribute.
  61743. * @param effectWrapper Defines the effect to draw with
  61744. */
  61745. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61746. /**
  61747. * Restores engine states
  61748. */
  61749. restoreStates(): void;
  61750. /**
  61751. * Draws a full screen quad.
  61752. */
  61753. draw(): void;
  61754. private isRenderTargetTexture;
  61755. /**
  61756. * renders one or more effects to a specified texture
  61757. * @param effectWrapper the effect to renderer
  61758. * @param outputTexture texture to draw to, if null it will render to the screen.
  61759. */
  61760. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61761. /**
  61762. * Disposes of the effect renderer
  61763. */
  61764. dispose(): void;
  61765. }
  61766. /**
  61767. * Options to create an EffectWrapper
  61768. */
  61769. interface EffectWrapperCreationOptions {
  61770. /**
  61771. * Engine to use to create the effect
  61772. */
  61773. engine: ThinEngine;
  61774. /**
  61775. * Fragment shader for the effect
  61776. */
  61777. fragmentShader: string;
  61778. /**
  61779. * Use the shader store instead of direct source code
  61780. */
  61781. useShaderStore?: boolean;
  61782. /**
  61783. * Vertex shader for the effect
  61784. */
  61785. vertexShader?: string;
  61786. /**
  61787. * Attributes to use in the shader
  61788. */
  61789. attributeNames?: Array<string>;
  61790. /**
  61791. * Uniforms to use in the shader
  61792. */
  61793. uniformNames?: Array<string>;
  61794. /**
  61795. * Texture sampler names to use in the shader
  61796. */
  61797. samplerNames?: Array<string>;
  61798. /**
  61799. * Defines to use in the shader
  61800. */
  61801. defines?: Array<string>;
  61802. /**
  61803. * Callback when effect is compiled
  61804. */
  61805. onCompiled?: Nullable<(effect: Effect) => void>;
  61806. /**
  61807. * The friendly name of the effect displayed in Spector.
  61808. */
  61809. name?: string;
  61810. }
  61811. /**
  61812. * Wraps an effect to be used for rendering
  61813. */
  61814. export class EffectWrapper {
  61815. /**
  61816. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61817. */
  61818. onApplyObservable: Observable<{}>;
  61819. /**
  61820. * The underlying effect
  61821. */
  61822. effect: Effect;
  61823. /**
  61824. * Creates an effect to be renderer
  61825. * @param creationOptions options to create the effect
  61826. */
  61827. constructor(creationOptions: EffectWrapperCreationOptions);
  61828. /**
  61829. * Disposes of the effect wrapper
  61830. */
  61831. dispose(): void;
  61832. }
  61833. }
  61834. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61835. /** @hidden */
  61836. export var hdrFilteringVertexShader: {
  61837. name: string;
  61838. shader: string;
  61839. };
  61840. }
  61841. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61842. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61843. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61844. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61845. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61846. /** @hidden */
  61847. export var hdrFilteringPixelShader: {
  61848. name: string;
  61849. shader: string;
  61850. };
  61851. }
  61852. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61854. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61855. import { Nullable } from "babylonjs/types";
  61856. import "babylonjs/Shaders/hdrFiltering.vertex";
  61857. import "babylonjs/Shaders/hdrFiltering.fragment";
  61858. /**
  61859. * Options for texture filtering
  61860. */
  61861. interface IHDRFilteringOptions {
  61862. /**
  61863. * Scales pixel intensity for the input HDR map.
  61864. */
  61865. hdrScale?: number;
  61866. /**
  61867. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61868. */
  61869. quality?: number;
  61870. }
  61871. /**
  61872. * Filters HDR maps to get correct renderings of PBR reflections
  61873. */
  61874. export class HDRFiltering {
  61875. private _engine;
  61876. private _effectRenderer;
  61877. private _effectWrapper;
  61878. private _lodGenerationOffset;
  61879. private _lodGenerationScale;
  61880. /**
  61881. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61882. * you care about baking speed.
  61883. */
  61884. quality: number;
  61885. /**
  61886. * Scales pixel intensity for the input HDR map.
  61887. */
  61888. hdrScale: number;
  61889. /**
  61890. * Instantiates HDR filter for reflection maps
  61891. *
  61892. * @param engine Thin engine
  61893. * @param options Options
  61894. */
  61895. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61896. private _createRenderTarget;
  61897. private _prefilterInternal;
  61898. private _createEffect;
  61899. /**
  61900. * Get a value indicating if the filter is ready to be used
  61901. * @param texture Texture to filter
  61902. * @returns true if the filter is ready
  61903. */
  61904. isReady(texture: BaseTexture): boolean;
  61905. /**
  61906. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61907. * Prefiltering will be invoked at the end of next rendering pass.
  61908. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61909. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61910. * @param texture Texture to filter
  61911. * @param onFinished Callback when filtering is done
  61912. * @return Promise called when prefiltering is done
  61913. */
  61914. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61915. }
  61916. }
  61917. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61918. import { Nullable } from "babylonjs/types";
  61919. import { Scene } from "babylonjs/scene";
  61920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61922. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61923. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61924. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61925. /**
  61926. * This represents a texture coming from an HDR input.
  61927. *
  61928. * The only supported format is currently panorama picture stored in RGBE format.
  61929. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61930. */
  61931. export class HDRCubeTexture extends BaseTexture {
  61932. private static _facesMapping;
  61933. private _generateHarmonics;
  61934. private _noMipmap;
  61935. private _prefilterOnLoad;
  61936. private _textureMatrix;
  61937. private _size;
  61938. private _onLoad;
  61939. private _onError;
  61940. /**
  61941. * The texture URL.
  61942. */
  61943. url: string;
  61944. /**
  61945. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61946. */
  61947. coordinatesMode: number;
  61948. protected _isBlocking: boolean;
  61949. /**
  61950. * Sets wether or not the texture is blocking during loading.
  61951. */
  61952. set isBlocking(value: boolean);
  61953. /**
  61954. * Gets wether or not the texture is blocking during loading.
  61955. */
  61956. get isBlocking(): boolean;
  61957. protected _rotationY: number;
  61958. /**
  61959. * Sets texture matrix rotation angle around Y axis in radians.
  61960. */
  61961. set rotationY(value: number);
  61962. /**
  61963. * Gets texture matrix rotation angle around Y axis radians.
  61964. */
  61965. get rotationY(): number;
  61966. /**
  61967. * Gets or sets the center of the bounding box associated with the cube texture
  61968. * It must define where the camera used to render the texture was set
  61969. */
  61970. boundingBoxPosition: Vector3;
  61971. private _boundingBoxSize;
  61972. /**
  61973. * Gets or sets the size of the bounding box associated with the cube texture
  61974. * When defined, the cubemap will switch to local mode
  61975. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61976. * @example https://www.babylonjs-playground.com/#RNASML
  61977. */
  61978. set boundingBoxSize(value: Vector3);
  61979. get boundingBoxSize(): Vector3;
  61980. /**
  61981. * Instantiates an HDRTexture from the following parameters.
  61982. *
  61983. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61984. * @param sceneOrEngine The scene or engine the texture will be used in
  61985. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61986. * @param noMipmap Forces to not generate the mipmap if true
  61987. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61988. * @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)
  61989. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61990. */
  61991. 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>);
  61992. /**
  61993. * Get the current class name of the texture useful for serialization or dynamic coding.
  61994. * @returns "HDRCubeTexture"
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Occurs when the file is raw .hdr file.
  61999. */
  62000. private loadTexture;
  62001. clone(): HDRCubeTexture;
  62002. delayLoad(): void;
  62003. /**
  62004. * Get the texture reflection matrix used to rotate/transform the reflection.
  62005. * @returns the reflection matrix
  62006. */
  62007. getReflectionTextureMatrix(): Matrix;
  62008. /**
  62009. * Set the texture reflection matrix used to rotate/transform the reflection.
  62010. * @param value Define the reflection matrix to set
  62011. */
  62012. setReflectionTextureMatrix(value: Matrix): void;
  62013. /**
  62014. * Parses a JSON representation of an HDR Texture in order to create the texture
  62015. * @param parsedTexture Define the JSON representation
  62016. * @param scene Define the scene the texture should be created in
  62017. * @param rootUrl Define the root url in case we need to load relative dependencies
  62018. * @returns the newly created texture after parsing
  62019. */
  62020. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62021. serialize(): any;
  62022. }
  62023. }
  62024. declare module "babylonjs/Physics/physicsEngine" {
  62025. import { Nullable } from "babylonjs/types";
  62026. import { Vector3 } from "babylonjs/Maths/math.vector";
  62027. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62028. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62029. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62030. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62031. /**
  62032. * Class used to control physics engine
  62033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62034. */
  62035. export class PhysicsEngine implements IPhysicsEngine {
  62036. private _physicsPlugin;
  62037. /**
  62038. * Global value used to control the smallest number supported by the simulation
  62039. */
  62040. static Epsilon: number;
  62041. private _impostors;
  62042. private _joints;
  62043. private _subTimeStep;
  62044. /**
  62045. * Gets the gravity vector used by the simulation
  62046. */
  62047. gravity: Vector3;
  62048. /**
  62049. * Factory used to create the default physics plugin.
  62050. * @returns The default physics plugin
  62051. */
  62052. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62053. /**
  62054. * Creates a new Physics Engine
  62055. * @param gravity defines the gravity vector used by the simulation
  62056. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62057. */
  62058. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62059. /**
  62060. * Sets the gravity vector used by the simulation
  62061. * @param gravity defines the gravity vector to use
  62062. */
  62063. setGravity(gravity: Vector3): void;
  62064. /**
  62065. * Set the time step of the physics engine.
  62066. * Default is 1/60.
  62067. * To slow it down, enter 1/600 for example.
  62068. * To speed it up, 1/30
  62069. * @param newTimeStep defines the new timestep to apply to this world.
  62070. */
  62071. setTimeStep(newTimeStep?: number): void;
  62072. /**
  62073. * Get the time step of the physics engine.
  62074. * @returns the current time step
  62075. */
  62076. getTimeStep(): number;
  62077. /**
  62078. * Set the sub time step of the physics engine.
  62079. * Default is 0 meaning there is no sub steps
  62080. * To increase physics resolution precision, set a small value (like 1 ms)
  62081. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62082. */
  62083. setSubTimeStep(subTimeStep?: number): void;
  62084. /**
  62085. * Get the sub time step of the physics engine.
  62086. * @returns the current sub time step
  62087. */
  62088. getSubTimeStep(): number;
  62089. /**
  62090. * Release all resources
  62091. */
  62092. dispose(): void;
  62093. /**
  62094. * Gets the name of the current physics plugin
  62095. * @returns the name of the plugin
  62096. */
  62097. getPhysicsPluginName(): string;
  62098. /**
  62099. * Adding a new impostor for the impostor tracking.
  62100. * This will be done by the impostor itself.
  62101. * @param impostor the impostor to add
  62102. */
  62103. addImpostor(impostor: PhysicsImpostor): void;
  62104. /**
  62105. * Remove an impostor from the engine.
  62106. * This impostor and its mesh will not longer be updated by the physics engine.
  62107. * @param impostor the impostor to remove
  62108. */
  62109. removeImpostor(impostor: PhysicsImpostor): void;
  62110. /**
  62111. * Add a joint to the physics engine
  62112. * @param mainImpostor defines the main impostor to which the joint is added.
  62113. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62114. * @param joint defines the joint that will connect both impostors.
  62115. */
  62116. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62117. /**
  62118. * Removes a joint from the simulation
  62119. * @param mainImpostor defines the impostor used with the joint
  62120. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62121. * @param joint defines the joint to remove
  62122. */
  62123. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62124. /**
  62125. * Called by the scene. No need to call it.
  62126. * @param delta defines the timespam between frames
  62127. */
  62128. _step(delta: number): void;
  62129. /**
  62130. * Gets the current plugin used to run the simulation
  62131. * @returns current plugin
  62132. */
  62133. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62134. /**
  62135. * Gets the list of physic impostors
  62136. * @returns an array of PhysicsImpostor
  62137. */
  62138. getImpostors(): Array<PhysicsImpostor>;
  62139. /**
  62140. * Gets the impostor for a physics enabled object
  62141. * @param object defines the object impersonated by the impostor
  62142. * @returns the PhysicsImpostor or null if not found
  62143. */
  62144. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62145. /**
  62146. * Gets the impostor for a physics body object
  62147. * @param body defines physics body used by the impostor
  62148. * @returns the PhysicsImpostor or null if not found
  62149. */
  62150. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62151. /**
  62152. * Does a raycast in the physics world
  62153. * @param from when should the ray start?
  62154. * @param to when should the ray end?
  62155. * @returns PhysicsRaycastResult
  62156. */
  62157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62158. }
  62159. }
  62160. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62161. import { Nullable } from "babylonjs/types";
  62162. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62164. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62165. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62166. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62167. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62168. /** @hidden */
  62169. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62170. private _useDeltaForWorldStep;
  62171. world: any;
  62172. name: string;
  62173. private _physicsMaterials;
  62174. private _fixedTimeStep;
  62175. private _cannonRaycastResult;
  62176. private _raycastResult;
  62177. private _physicsBodysToRemoveAfterStep;
  62178. private _firstFrame;
  62179. BJSCANNON: any;
  62180. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62181. setGravity(gravity: Vector3): void;
  62182. setTimeStep(timeStep: number): void;
  62183. getTimeStep(): number;
  62184. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62185. private _removeMarkedPhysicsBodiesFromWorld;
  62186. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62187. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62188. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62189. private _processChildMeshes;
  62190. removePhysicsBody(impostor: PhysicsImpostor): void;
  62191. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62192. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62193. private _addMaterial;
  62194. private _checkWithEpsilon;
  62195. private _createShape;
  62196. private _createHeightmap;
  62197. private _minus90X;
  62198. private _plus90X;
  62199. private _tmpPosition;
  62200. private _tmpDeltaPosition;
  62201. private _tmpUnityRotation;
  62202. private _updatePhysicsBodyTransformation;
  62203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62204. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62205. isSupported(): boolean;
  62206. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62207. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62208. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62209. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62210. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62211. getBodyMass(impostor: PhysicsImpostor): number;
  62212. getBodyFriction(impostor: PhysicsImpostor): number;
  62213. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62214. getBodyRestitution(impostor: PhysicsImpostor): number;
  62215. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62216. sleepBody(impostor: PhysicsImpostor): void;
  62217. wakeUpBody(impostor: PhysicsImpostor): void;
  62218. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62219. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62220. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62221. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62222. getRadius(impostor: PhysicsImpostor): number;
  62223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62224. dispose(): void;
  62225. private _extendNamespace;
  62226. /**
  62227. * Does a raycast in the physics world
  62228. * @param from when should the ray start?
  62229. * @param to when should the ray end?
  62230. * @returns PhysicsRaycastResult
  62231. */
  62232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62233. }
  62234. }
  62235. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62236. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62237. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62238. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62241. import { Nullable } from "babylonjs/types";
  62242. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62243. /** @hidden */
  62244. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62245. private _useDeltaForWorldStep;
  62246. world: any;
  62247. name: string;
  62248. BJSOIMO: any;
  62249. private _raycastResult;
  62250. private _fixedTimeStep;
  62251. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62252. setGravity(gravity: Vector3): void;
  62253. setTimeStep(timeStep: number): void;
  62254. getTimeStep(): number;
  62255. private _tmpImpostorsArray;
  62256. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62257. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62258. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62259. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62260. private _tmpPositionVector;
  62261. removePhysicsBody(impostor: PhysicsImpostor): void;
  62262. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62263. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62264. isSupported(): boolean;
  62265. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62266. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62267. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62268. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62269. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62270. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62271. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62272. getBodyMass(impostor: PhysicsImpostor): number;
  62273. getBodyFriction(impostor: PhysicsImpostor): number;
  62274. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62275. getBodyRestitution(impostor: PhysicsImpostor): number;
  62276. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62277. sleepBody(impostor: PhysicsImpostor): void;
  62278. wakeUpBody(impostor: PhysicsImpostor): void;
  62279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62280. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62281. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62282. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62283. getRadius(impostor: PhysicsImpostor): number;
  62284. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62285. dispose(): void;
  62286. /**
  62287. * Does a raycast in the physics world
  62288. * @param from when should the ray start?
  62289. * @param to when should the ray end?
  62290. * @returns PhysicsRaycastResult
  62291. */
  62292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62293. }
  62294. }
  62295. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62296. import { Nullable } from "babylonjs/types";
  62297. import { Scene } from "babylonjs/scene";
  62298. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62299. import { Color4 } from "babylonjs/Maths/math.color";
  62300. import { Mesh } from "babylonjs/Meshes/mesh";
  62301. /**
  62302. * Class containing static functions to help procedurally build meshes
  62303. */
  62304. export class RibbonBuilder {
  62305. /**
  62306. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62307. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62308. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62309. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62310. * * 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
  62311. * * 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
  62312. * * 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
  62313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62316. * * 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
  62317. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62318. * * 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
  62319. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62321. * @param name defines the name of the mesh
  62322. * @param options defines the options used to create the mesh
  62323. * @param scene defines the hosting scene
  62324. * @returns the ribbon mesh
  62325. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62327. */
  62328. static CreateRibbon(name: string, options: {
  62329. pathArray: Vector3[][];
  62330. closeArray?: boolean;
  62331. closePath?: boolean;
  62332. offset?: number;
  62333. updatable?: boolean;
  62334. sideOrientation?: number;
  62335. frontUVs?: Vector4;
  62336. backUVs?: Vector4;
  62337. instance?: Mesh;
  62338. invertUV?: boolean;
  62339. uvs?: Vector2[];
  62340. colors?: Color4[];
  62341. }, scene?: Nullable<Scene>): Mesh;
  62342. }
  62343. }
  62344. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62345. import { Nullable } from "babylonjs/types";
  62346. import { Scene } from "babylonjs/scene";
  62347. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62348. import { Mesh } from "babylonjs/Meshes/mesh";
  62349. /**
  62350. * Class containing static functions to help procedurally build meshes
  62351. */
  62352. export class ShapeBuilder {
  62353. /**
  62354. * 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.
  62355. * * 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.
  62356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62357. * * 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.
  62358. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62359. * * 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
  62360. * * 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
  62361. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62366. * @param name defines the name of the mesh
  62367. * @param options defines the options used to create the mesh
  62368. * @param scene defines the hosting scene
  62369. * @returns the extruded shape mesh
  62370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62372. */
  62373. static ExtrudeShape(name: string, options: {
  62374. shape: Vector3[];
  62375. path: Vector3[];
  62376. scale?: number;
  62377. rotation?: number;
  62378. cap?: number;
  62379. updatable?: boolean;
  62380. sideOrientation?: number;
  62381. frontUVs?: Vector4;
  62382. backUVs?: Vector4;
  62383. instance?: Mesh;
  62384. invertUV?: boolean;
  62385. }, scene?: Nullable<Scene>): Mesh;
  62386. /**
  62387. * Creates an custom extruded shape mesh.
  62388. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62389. * * 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.
  62390. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62391. * * 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
  62392. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62393. * * 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
  62394. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62395. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62396. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62397. * * 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
  62398. * * 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
  62399. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62404. * @param name defines the name of the mesh
  62405. * @param options defines the options used to create the mesh
  62406. * @param scene defines the hosting scene
  62407. * @returns the custom extruded shape mesh
  62408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62409. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62411. */
  62412. static ExtrudeShapeCustom(name: string, options: {
  62413. shape: Vector3[];
  62414. path: Vector3[];
  62415. scaleFunction?: any;
  62416. rotationFunction?: any;
  62417. ribbonCloseArray?: boolean;
  62418. ribbonClosePath?: boolean;
  62419. cap?: number;
  62420. updatable?: boolean;
  62421. sideOrientation?: number;
  62422. frontUVs?: Vector4;
  62423. backUVs?: Vector4;
  62424. instance?: Mesh;
  62425. invertUV?: boolean;
  62426. }, scene?: Nullable<Scene>): Mesh;
  62427. private static _ExtrudeShapeGeneric;
  62428. }
  62429. }
  62430. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62431. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62432. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62433. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62434. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62435. import { Nullable } from "babylonjs/types";
  62436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62437. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62438. /**
  62439. * AmmoJS Physics plugin
  62440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62441. * @see https://github.com/kripken/ammo.js/
  62442. */
  62443. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62444. private _useDeltaForWorldStep;
  62445. /**
  62446. * Reference to the Ammo library
  62447. */
  62448. bjsAMMO: any;
  62449. /**
  62450. * Created ammoJS world which physics bodies are added to
  62451. */
  62452. world: any;
  62453. /**
  62454. * Name of the plugin
  62455. */
  62456. name: string;
  62457. private _timeStep;
  62458. private _fixedTimeStep;
  62459. private _maxSteps;
  62460. private _tmpQuaternion;
  62461. private _tmpAmmoTransform;
  62462. private _tmpAmmoQuaternion;
  62463. private _tmpAmmoConcreteContactResultCallback;
  62464. private _collisionConfiguration;
  62465. private _dispatcher;
  62466. private _overlappingPairCache;
  62467. private _solver;
  62468. private _softBodySolver;
  62469. private _tmpAmmoVectorA;
  62470. private _tmpAmmoVectorB;
  62471. private _tmpAmmoVectorC;
  62472. private _tmpAmmoVectorD;
  62473. private _tmpContactCallbackResult;
  62474. private _tmpAmmoVectorRCA;
  62475. private _tmpAmmoVectorRCB;
  62476. private _raycastResult;
  62477. private static readonly DISABLE_COLLISION_FLAG;
  62478. private static readonly KINEMATIC_FLAG;
  62479. private static readonly DISABLE_DEACTIVATION_FLAG;
  62480. /**
  62481. * Initializes the ammoJS plugin
  62482. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62483. * @param ammoInjection can be used to inject your own ammo reference
  62484. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62485. */
  62486. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62487. /**
  62488. * Sets the gravity of the physics world (m/(s^2))
  62489. * @param gravity Gravity to set
  62490. */
  62491. setGravity(gravity: Vector3): void;
  62492. /**
  62493. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62494. * @param timeStep timestep to use in seconds
  62495. */
  62496. setTimeStep(timeStep: number): void;
  62497. /**
  62498. * 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)
  62499. * @param fixedTimeStep fixedTimeStep to use in seconds
  62500. */
  62501. setFixedTimeStep(fixedTimeStep: number): void;
  62502. /**
  62503. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62504. * @param maxSteps the maximum number of steps by the physics engine per frame
  62505. */
  62506. setMaxSteps(maxSteps: number): void;
  62507. /**
  62508. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62509. * @returns the current timestep in seconds
  62510. */
  62511. getTimeStep(): number;
  62512. /**
  62513. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62514. */
  62515. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62516. private _isImpostorInContact;
  62517. private _isImpostorPairInContact;
  62518. private _stepSimulation;
  62519. /**
  62520. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62521. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62522. * After the step the babylon meshes are set to the position of the physics imposters
  62523. * @param delta amount of time to step forward
  62524. * @param impostors array of imposters to update before/after the step
  62525. */
  62526. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62527. /**
  62528. * Update babylon mesh to match physics world object
  62529. * @param impostor imposter to match
  62530. */
  62531. private _afterSoftStep;
  62532. /**
  62533. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62534. * @param impostor imposter to match
  62535. */
  62536. private _ropeStep;
  62537. /**
  62538. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62539. * @param impostor imposter to match
  62540. */
  62541. private _softbodyOrClothStep;
  62542. private _tmpMatrix;
  62543. /**
  62544. * Applies an impulse on the imposter
  62545. * @param impostor imposter to apply impulse to
  62546. * @param force amount of force to be applied to the imposter
  62547. * @param contactPoint the location to apply the impulse on the imposter
  62548. */
  62549. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62550. /**
  62551. * Applies a force on the imposter
  62552. * @param impostor imposter to apply force
  62553. * @param force amount of force to be applied to the imposter
  62554. * @param contactPoint the location to apply the force on the imposter
  62555. */
  62556. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62557. /**
  62558. * Creates a physics body using the plugin
  62559. * @param impostor the imposter to create the physics body on
  62560. */
  62561. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62562. /**
  62563. * Removes the physics body from the imposter and disposes of the body's memory
  62564. * @param impostor imposter to remove the physics body from
  62565. */
  62566. removePhysicsBody(impostor: PhysicsImpostor): void;
  62567. /**
  62568. * Generates a joint
  62569. * @param impostorJoint the imposter joint to create the joint with
  62570. */
  62571. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62572. /**
  62573. * Removes a joint
  62574. * @param impostorJoint the imposter joint to remove the joint from
  62575. */
  62576. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62577. private _addMeshVerts;
  62578. /**
  62579. * Initialise the soft body vertices to match its object's (mesh) vertices
  62580. * Softbody vertices (nodes) are in world space and to match this
  62581. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62582. * @param impostor to create the softbody for
  62583. */
  62584. private _softVertexData;
  62585. /**
  62586. * Create an impostor's soft body
  62587. * @param impostor to create the softbody for
  62588. */
  62589. private _createSoftbody;
  62590. /**
  62591. * Create cloth for an impostor
  62592. * @param impostor to create the softbody for
  62593. */
  62594. private _createCloth;
  62595. /**
  62596. * Create rope for an impostor
  62597. * @param impostor to create the softbody for
  62598. */
  62599. private _createRope;
  62600. /**
  62601. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62602. * @param impostor to create the custom physics shape for
  62603. */
  62604. private _createCustom;
  62605. private _addHullVerts;
  62606. private _createShape;
  62607. /**
  62608. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62609. * @param impostor imposter containing the physics body and babylon object
  62610. */
  62611. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62612. /**
  62613. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62614. * @param impostor imposter containing the physics body and babylon object
  62615. * @param newPosition new position
  62616. * @param newRotation new rotation
  62617. */
  62618. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62619. /**
  62620. * If this plugin is supported
  62621. * @returns true if its supported
  62622. */
  62623. isSupported(): boolean;
  62624. /**
  62625. * Sets the linear velocity of the physics body
  62626. * @param impostor imposter to set the velocity on
  62627. * @param velocity velocity to set
  62628. */
  62629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62630. /**
  62631. * Sets the angular velocity of the physics body
  62632. * @param impostor imposter to set the velocity on
  62633. * @param velocity velocity to set
  62634. */
  62635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62636. /**
  62637. * gets the linear velocity
  62638. * @param impostor imposter to get linear velocity from
  62639. * @returns linear velocity
  62640. */
  62641. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62642. /**
  62643. * gets the angular velocity
  62644. * @param impostor imposter to get angular velocity from
  62645. * @returns angular velocity
  62646. */
  62647. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62648. /**
  62649. * Sets the mass of physics body
  62650. * @param impostor imposter to set the mass on
  62651. * @param mass mass to set
  62652. */
  62653. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62654. /**
  62655. * Gets the mass of the physics body
  62656. * @param impostor imposter to get the mass from
  62657. * @returns mass
  62658. */
  62659. getBodyMass(impostor: PhysicsImpostor): number;
  62660. /**
  62661. * Gets friction of the impostor
  62662. * @param impostor impostor to get friction from
  62663. * @returns friction value
  62664. */
  62665. getBodyFriction(impostor: PhysicsImpostor): number;
  62666. /**
  62667. * Sets friction of the impostor
  62668. * @param impostor impostor to set friction on
  62669. * @param friction friction value
  62670. */
  62671. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62672. /**
  62673. * Gets restitution of the impostor
  62674. * @param impostor impostor to get restitution from
  62675. * @returns restitution value
  62676. */
  62677. getBodyRestitution(impostor: PhysicsImpostor): number;
  62678. /**
  62679. * Sets resitution of the impostor
  62680. * @param impostor impostor to set resitution on
  62681. * @param restitution resitution value
  62682. */
  62683. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62684. /**
  62685. * Gets pressure inside the impostor
  62686. * @param impostor impostor to get pressure from
  62687. * @returns pressure value
  62688. */
  62689. getBodyPressure(impostor: PhysicsImpostor): number;
  62690. /**
  62691. * Sets pressure inside a soft body impostor
  62692. * Cloth and rope must remain 0 pressure
  62693. * @param impostor impostor to set pressure on
  62694. * @param pressure pressure value
  62695. */
  62696. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62697. /**
  62698. * Gets stiffness of the impostor
  62699. * @param impostor impostor to get stiffness from
  62700. * @returns pressure value
  62701. */
  62702. getBodyStiffness(impostor: PhysicsImpostor): number;
  62703. /**
  62704. * Sets stiffness of the impostor
  62705. * @param impostor impostor to set stiffness on
  62706. * @param stiffness stiffness value from 0 to 1
  62707. */
  62708. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62709. /**
  62710. * Gets velocityIterations of the impostor
  62711. * @param impostor impostor to get velocity iterations from
  62712. * @returns velocityIterations value
  62713. */
  62714. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62715. /**
  62716. * Sets velocityIterations of the impostor
  62717. * @param impostor impostor to set velocity iterations on
  62718. * @param velocityIterations velocityIterations value
  62719. */
  62720. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62721. /**
  62722. * Gets positionIterations of the impostor
  62723. * @param impostor impostor to get position iterations from
  62724. * @returns positionIterations value
  62725. */
  62726. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62727. /**
  62728. * Sets positionIterations of the impostor
  62729. * @param impostor impostor to set position on
  62730. * @param positionIterations positionIterations value
  62731. */
  62732. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62733. /**
  62734. * Append an anchor to a cloth object
  62735. * @param impostor is the cloth impostor to add anchor to
  62736. * @param otherImpostor is the rigid impostor to anchor to
  62737. * @param width ratio across width from 0 to 1
  62738. * @param height ratio up height from 0 to 1
  62739. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62740. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62741. */
  62742. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62743. /**
  62744. * Append an hook to a rope object
  62745. * @param impostor is the rope impostor to add hook to
  62746. * @param otherImpostor is the rigid impostor to hook to
  62747. * @param length ratio along the rope from 0 to 1
  62748. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62749. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62750. */
  62751. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62752. /**
  62753. * Sleeps the physics body and stops it from being active
  62754. * @param impostor impostor to sleep
  62755. */
  62756. sleepBody(impostor: PhysicsImpostor): void;
  62757. /**
  62758. * Activates the physics body
  62759. * @param impostor impostor to activate
  62760. */
  62761. wakeUpBody(impostor: PhysicsImpostor): void;
  62762. /**
  62763. * Updates the distance parameters of the joint
  62764. * @param joint joint to update
  62765. * @param maxDistance maximum distance of the joint
  62766. * @param minDistance minimum distance of the joint
  62767. */
  62768. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62769. /**
  62770. * Sets a motor on the joint
  62771. * @param joint joint to set motor on
  62772. * @param speed speed of the motor
  62773. * @param maxForce maximum force of the motor
  62774. * @param motorIndex index of the motor
  62775. */
  62776. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62777. /**
  62778. * Sets the motors limit
  62779. * @param joint joint to set limit on
  62780. * @param upperLimit upper limit
  62781. * @param lowerLimit lower limit
  62782. */
  62783. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62784. /**
  62785. * Syncs the position and rotation of a mesh with the impostor
  62786. * @param mesh mesh to sync
  62787. * @param impostor impostor to update the mesh with
  62788. */
  62789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62790. /**
  62791. * Gets the radius of the impostor
  62792. * @param impostor impostor to get radius from
  62793. * @returns the radius
  62794. */
  62795. getRadius(impostor: PhysicsImpostor): number;
  62796. /**
  62797. * Gets the box size of the impostor
  62798. * @param impostor impostor to get box size from
  62799. * @param result the resulting box size
  62800. */
  62801. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62802. /**
  62803. * Disposes of the impostor
  62804. */
  62805. dispose(): void;
  62806. /**
  62807. * Does a raycast in the physics world
  62808. * @param from when should the ray start?
  62809. * @param to when should the ray end?
  62810. * @returns PhysicsRaycastResult
  62811. */
  62812. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62813. }
  62814. }
  62815. declare module "babylonjs/Probes/reflectionProbe" {
  62816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62817. import { Vector3 } from "babylonjs/Maths/math.vector";
  62818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62819. import { Nullable } from "babylonjs/types";
  62820. import { Scene } from "babylonjs/scene";
  62821. module "babylonjs/abstractScene" {
  62822. interface AbstractScene {
  62823. /**
  62824. * The list of reflection probes added to the scene
  62825. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62826. */
  62827. reflectionProbes: Array<ReflectionProbe>;
  62828. /**
  62829. * Removes the given reflection probe from this scene.
  62830. * @param toRemove The reflection probe to remove
  62831. * @returns The index of the removed reflection probe
  62832. */
  62833. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62834. /**
  62835. * Adds the given reflection probe to this scene.
  62836. * @param newReflectionProbe The reflection probe to add
  62837. */
  62838. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62839. }
  62840. }
  62841. /**
  62842. * Class used to generate realtime reflection / refraction cube textures
  62843. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62844. */
  62845. export class ReflectionProbe {
  62846. /** defines the name of the probe */
  62847. name: string;
  62848. private _scene;
  62849. private _renderTargetTexture;
  62850. private _projectionMatrix;
  62851. private _viewMatrix;
  62852. private _target;
  62853. private _add;
  62854. private _attachedMesh;
  62855. private _invertYAxis;
  62856. /** Gets or sets probe position (center of the cube map) */
  62857. position: Vector3;
  62858. /**
  62859. * Creates a new reflection probe
  62860. * @param name defines the name of the probe
  62861. * @param size defines the texture resolution (for each face)
  62862. * @param scene defines the hosting scene
  62863. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62864. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62865. */
  62866. constructor(
  62867. /** defines the name of the probe */
  62868. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62869. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62870. get samples(): number;
  62871. set samples(value: number);
  62872. /** Gets or sets the refresh rate to use (on every frame by default) */
  62873. get refreshRate(): number;
  62874. set refreshRate(value: number);
  62875. /**
  62876. * Gets the hosting scene
  62877. * @returns a Scene
  62878. */
  62879. getScene(): Scene;
  62880. /** Gets the internal CubeTexture used to render to */
  62881. get cubeTexture(): RenderTargetTexture;
  62882. /** Gets the list of meshes to render */
  62883. get renderList(): Nullable<AbstractMesh[]>;
  62884. /**
  62885. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62886. * @param mesh defines the mesh to attach to
  62887. */
  62888. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62889. /**
  62890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62891. * @param renderingGroupId The rendering group id corresponding to its index
  62892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62893. */
  62894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62895. /**
  62896. * Clean all associated resources
  62897. */
  62898. dispose(): void;
  62899. /**
  62900. * Converts the reflection probe information to a readable string for debug purpose.
  62901. * @param fullDetails Supports for multiple levels of logging within scene loading
  62902. * @returns the human readable reflection probe info
  62903. */
  62904. toString(fullDetails?: boolean): string;
  62905. /**
  62906. * Get the class name of the relfection probe.
  62907. * @returns "ReflectionProbe"
  62908. */
  62909. getClassName(): string;
  62910. /**
  62911. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62912. * @returns The JSON representation of the texture
  62913. */
  62914. serialize(): any;
  62915. /**
  62916. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62917. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62918. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62919. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62920. * @returns The parsed reflection probe if successful
  62921. */
  62922. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62923. }
  62924. }
  62925. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62926. /** @hidden */
  62927. export var _BabylonLoaderRegistered: boolean;
  62928. /**
  62929. * Helps setting up some configuration for the babylon file loader.
  62930. */
  62931. export class BabylonFileLoaderConfiguration {
  62932. /**
  62933. * The loader does not allow injecting custom physix engine into the plugins.
  62934. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62935. * So you could set this variable to your engine import to make it work.
  62936. */
  62937. static LoaderInjectedPhysicsEngine: any;
  62938. }
  62939. }
  62940. declare module "babylonjs/Loading/Plugins/index" {
  62941. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62942. }
  62943. declare module "babylonjs/Loading/index" {
  62944. export * from "babylonjs/Loading/loadingScreen";
  62945. export * from "babylonjs/Loading/Plugins/index";
  62946. export * from "babylonjs/Loading/sceneLoader";
  62947. export * from "babylonjs/Loading/sceneLoaderFlags";
  62948. }
  62949. declare module "babylonjs/Materials/Background/index" {
  62950. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62951. }
  62952. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62953. import { Scene } from "babylonjs/scene";
  62954. import { Color3 } from "babylonjs/Maths/math.color";
  62955. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62956. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62957. /**
  62958. * The Physically based simple base material of BJS.
  62959. *
  62960. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62961. * It is used as the base class for both the specGloss and metalRough conventions.
  62962. */
  62963. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62964. /**
  62965. * Number of Simultaneous lights allowed on the material.
  62966. */
  62967. maxSimultaneousLights: number;
  62968. /**
  62969. * If sets to true, disables all the lights affecting the material.
  62970. */
  62971. disableLighting: boolean;
  62972. /**
  62973. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62974. */
  62975. environmentTexture: BaseTexture;
  62976. /**
  62977. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62978. */
  62979. invertNormalMapX: boolean;
  62980. /**
  62981. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62982. */
  62983. invertNormalMapY: boolean;
  62984. /**
  62985. * Normal map used in the model.
  62986. */
  62987. normalTexture: BaseTexture;
  62988. /**
  62989. * Emissivie color used to self-illuminate the model.
  62990. */
  62991. emissiveColor: Color3;
  62992. /**
  62993. * Emissivie texture used to self-illuminate the model.
  62994. */
  62995. emissiveTexture: BaseTexture;
  62996. /**
  62997. * Occlusion Channel Strenght.
  62998. */
  62999. occlusionStrength: number;
  63000. /**
  63001. * Occlusion Texture of the material (adding extra occlusion effects).
  63002. */
  63003. occlusionTexture: BaseTexture;
  63004. /**
  63005. * Defines the alpha limits in alpha test mode.
  63006. */
  63007. alphaCutOff: number;
  63008. /**
  63009. * Gets the current double sided mode.
  63010. */
  63011. get doubleSided(): boolean;
  63012. /**
  63013. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63014. */
  63015. set doubleSided(value: boolean);
  63016. /**
  63017. * Stores the pre-calculated light information of a mesh in a texture.
  63018. */
  63019. lightmapTexture: BaseTexture;
  63020. /**
  63021. * If true, the light map contains occlusion information instead of lighting info.
  63022. */
  63023. useLightmapAsShadowmap: boolean;
  63024. /**
  63025. * Instantiates a new PBRMaterial instance.
  63026. *
  63027. * @param name The material name
  63028. * @param scene The scene the material will be use in.
  63029. */
  63030. constructor(name: string, scene: Scene);
  63031. getClassName(): string;
  63032. }
  63033. }
  63034. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63035. import { Scene } from "babylonjs/scene";
  63036. import { Color3 } from "babylonjs/Maths/math.color";
  63037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63038. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63039. /**
  63040. * The PBR material of BJS following the metal roughness convention.
  63041. *
  63042. * This fits to the PBR convention in the GLTF definition:
  63043. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63044. */
  63045. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63046. /**
  63047. * The base color has two different interpretations depending on the value of metalness.
  63048. * When the material is a metal, the base color is the specific measured reflectance value
  63049. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63050. * of the material.
  63051. */
  63052. baseColor: Color3;
  63053. /**
  63054. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63055. * well as opacity information in the alpha channel.
  63056. */
  63057. baseTexture: BaseTexture;
  63058. /**
  63059. * Specifies the metallic scalar value of the material.
  63060. * Can also be used to scale the metalness values of the metallic texture.
  63061. */
  63062. metallic: number;
  63063. /**
  63064. * Specifies the roughness scalar value of the material.
  63065. * Can also be used to scale the roughness values of the metallic texture.
  63066. */
  63067. roughness: number;
  63068. /**
  63069. * Texture containing both the metallic value in the B channel and the
  63070. * roughness value in the G channel to keep better precision.
  63071. */
  63072. metallicRoughnessTexture: BaseTexture;
  63073. /**
  63074. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63075. *
  63076. * @param name The material name
  63077. * @param scene The scene the material will be use in.
  63078. */
  63079. constructor(name: string, scene: Scene);
  63080. /**
  63081. * Return the currrent class name of the material.
  63082. */
  63083. getClassName(): string;
  63084. /**
  63085. * Makes a duplicate of the current material.
  63086. * @param name - name to use for the new material.
  63087. */
  63088. clone(name: string): PBRMetallicRoughnessMaterial;
  63089. /**
  63090. * Serialize the material to a parsable JSON object.
  63091. */
  63092. serialize(): any;
  63093. /**
  63094. * Parses a JSON object correponding to the serialize function.
  63095. */
  63096. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63097. }
  63098. }
  63099. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63100. import { Scene } from "babylonjs/scene";
  63101. import { Color3 } from "babylonjs/Maths/math.color";
  63102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63103. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63104. /**
  63105. * The PBR material of BJS following the specular glossiness convention.
  63106. *
  63107. * This fits to the PBR convention in the GLTF definition:
  63108. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63109. */
  63110. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63111. /**
  63112. * Specifies the diffuse color of the material.
  63113. */
  63114. diffuseColor: Color3;
  63115. /**
  63116. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63117. * channel.
  63118. */
  63119. diffuseTexture: BaseTexture;
  63120. /**
  63121. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63122. */
  63123. specularColor: Color3;
  63124. /**
  63125. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63126. */
  63127. glossiness: number;
  63128. /**
  63129. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63130. */
  63131. specularGlossinessTexture: BaseTexture;
  63132. /**
  63133. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63134. *
  63135. * @param name The material name
  63136. * @param scene The scene the material will be use in.
  63137. */
  63138. constructor(name: string, scene: Scene);
  63139. /**
  63140. * Return the currrent class name of the material.
  63141. */
  63142. getClassName(): string;
  63143. /**
  63144. * Makes a duplicate of the current material.
  63145. * @param name - name to use for the new material.
  63146. */
  63147. clone(name: string): PBRSpecularGlossinessMaterial;
  63148. /**
  63149. * Serialize the material to a parsable JSON object.
  63150. */
  63151. serialize(): any;
  63152. /**
  63153. * Parses a JSON object correponding to the serialize function.
  63154. */
  63155. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63156. }
  63157. }
  63158. declare module "babylonjs/Materials/PBR/index" {
  63159. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63160. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63161. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63162. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63163. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63164. }
  63165. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63166. import { Nullable } from "babylonjs/types";
  63167. import { Scene } from "babylonjs/scene";
  63168. import { Matrix } from "babylonjs/Maths/math.vector";
  63169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63170. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63171. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63172. /**
  63173. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63174. * It can help converting any input color in a desired output one. This can then be used to create effects
  63175. * from sepia, black and white to sixties or futuristic rendering...
  63176. *
  63177. * The only supported format is currently 3dl.
  63178. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63179. */
  63180. export class ColorGradingTexture extends BaseTexture {
  63181. /**
  63182. * The texture URL.
  63183. */
  63184. url: string;
  63185. /**
  63186. * Empty line regex stored for GC.
  63187. */
  63188. private static _noneEmptyLineRegex;
  63189. private _textureMatrix;
  63190. private _onLoad;
  63191. /**
  63192. * Instantiates a ColorGradingTexture from the following parameters.
  63193. *
  63194. * @param url The location of the color gradind data (currently only supporting 3dl)
  63195. * @param sceneOrEngine The scene or engine the texture will be used in
  63196. * @param onLoad defines a callback triggered when the texture has been loaded
  63197. */
  63198. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63199. /**
  63200. * Fires the onload event from the constructor if requested.
  63201. */
  63202. private _triggerOnLoad;
  63203. /**
  63204. * Returns the texture matrix used in most of the material.
  63205. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63206. */
  63207. getTextureMatrix(): Matrix;
  63208. /**
  63209. * Occurs when the file being loaded is a .3dl LUT file.
  63210. */
  63211. private load3dlTexture;
  63212. /**
  63213. * Starts the loading process of the texture.
  63214. */
  63215. private loadTexture;
  63216. /**
  63217. * Clones the color gradind texture.
  63218. */
  63219. clone(): ColorGradingTexture;
  63220. /**
  63221. * Called during delayed load for textures.
  63222. */
  63223. delayLoad(): void;
  63224. /**
  63225. * Parses a color grading texture serialized by Babylon.
  63226. * @param parsedTexture The texture information being parsedTexture
  63227. * @param scene The scene to load the texture in
  63228. * @param rootUrl The root url of the data assets to load
  63229. * @return A color gradind texture
  63230. */
  63231. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63232. /**
  63233. * Serializes the LUT texture to json format.
  63234. */
  63235. serialize(): any;
  63236. }
  63237. }
  63238. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63240. import { Scene } from "babylonjs/scene";
  63241. import { Nullable } from "babylonjs/types";
  63242. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63243. /**
  63244. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63245. */
  63246. export class EquiRectangularCubeTexture extends BaseTexture {
  63247. /** The six faces of the cube. */
  63248. private static _FacesMapping;
  63249. private _noMipmap;
  63250. private _onLoad;
  63251. private _onError;
  63252. /** The size of the cubemap. */
  63253. private _size;
  63254. /** The buffer of the image. */
  63255. private _buffer;
  63256. /** The width of the input image. */
  63257. private _width;
  63258. /** The height of the input image. */
  63259. private _height;
  63260. /** The URL to the image. */
  63261. url: string;
  63262. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63263. coordinatesMode: number;
  63264. /**
  63265. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63266. * @param url The location of the image
  63267. * @param scene The scene the texture will be used in
  63268. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63269. * @param noMipmap Forces to not generate the mipmap if true
  63270. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63271. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63272. * @param onLoad — defines a callback called when texture is loaded
  63273. * @param onError — defines a callback called if there is an error
  63274. */
  63275. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63276. /**
  63277. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63278. */
  63279. private loadImage;
  63280. /**
  63281. * Convert the image buffer into a cubemap and create a CubeTexture.
  63282. */
  63283. private loadTexture;
  63284. /**
  63285. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63286. * @param buffer The ArrayBuffer that should be converted.
  63287. * @returns The buffer as Float32Array.
  63288. */
  63289. private getFloat32ArrayFromArrayBuffer;
  63290. /**
  63291. * Get the current class name of the texture useful for serialization or dynamic coding.
  63292. * @returns "EquiRectangularCubeTexture"
  63293. */
  63294. getClassName(): string;
  63295. /**
  63296. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63297. * @returns A clone of the current EquiRectangularCubeTexture.
  63298. */
  63299. clone(): EquiRectangularCubeTexture;
  63300. }
  63301. }
  63302. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63303. import { Nullable } from "babylonjs/types";
  63304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63305. import { Matrix } from "babylonjs/Maths/math.vector";
  63306. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63307. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63308. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63309. import { Scene } from "babylonjs/scene";
  63310. /**
  63311. * Defines the options related to the creation of an HtmlElementTexture
  63312. */
  63313. export interface IHtmlElementTextureOptions {
  63314. /**
  63315. * Defines wether mip maps should be created or not.
  63316. */
  63317. generateMipMaps?: boolean;
  63318. /**
  63319. * Defines the sampling mode of the texture.
  63320. */
  63321. samplingMode?: number;
  63322. /**
  63323. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63324. */
  63325. engine: Nullable<ThinEngine>;
  63326. /**
  63327. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63328. */
  63329. scene: Nullable<Scene>;
  63330. }
  63331. /**
  63332. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63333. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63334. * is automatically managed.
  63335. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63336. * in your application.
  63337. *
  63338. * As the update is not automatic, you need to call them manually.
  63339. */
  63340. export class HtmlElementTexture extends BaseTexture {
  63341. /**
  63342. * The texture URL.
  63343. */
  63344. element: HTMLVideoElement | HTMLCanvasElement;
  63345. private static readonly DefaultOptions;
  63346. private _textureMatrix;
  63347. private _isVideo;
  63348. private _generateMipMaps;
  63349. private _samplingMode;
  63350. /**
  63351. * Instantiates a HtmlElementTexture from the following parameters.
  63352. *
  63353. * @param name Defines the name of the texture
  63354. * @param element Defines the video or canvas the texture is filled with
  63355. * @param options Defines the other none mandatory texture creation options
  63356. */
  63357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63358. private _createInternalTexture;
  63359. /**
  63360. * Returns the texture matrix used in most of the material.
  63361. */
  63362. getTextureMatrix(): Matrix;
  63363. /**
  63364. * Updates the content of the texture.
  63365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63366. */
  63367. update(invertY?: Nullable<boolean>): void;
  63368. }
  63369. }
  63370. declare module "babylonjs/Misc/tga" {
  63371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63372. /**
  63373. * Based on jsTGALoader - Javascript loader for TGA file
  63374. * By Vincent Thibault
  63375. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63376. */
  63377. export class TGATools {
  63378. private static _TYPE_INDEXED;
  63379. private static _TYPE_RGB;
  63380. private static _TYPE_GREY;
  63381. private static _TYPE_RLE_INDEXED;
  63382. private static _TYPE_RLE_RGB;
  63383. private static _TYPE_RLE_GREY;
  63384. private static _ORIGIN_MASK;
  63385. private static _ORIGIN_SHIFT;
  63386. private static _ORIGIN_BL;
  63387. private static _ORIGIN_BR;
  63388. private static _ORIGIN_UL;
  63389. private static _ORIGIN_UR;
  63390. /**
  63391. * Gets the header of a TGA file
  63392. * @param data defines the TGA data
  63393. * @returns the header
  63394. */
  63395. static GetTGAHeader(data: Uint8Array): any;
  63396. /**
  63397. * Uploads TGA content to a Babylon Texture
  63398. * @hidden
  63399. */
  63400. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63401. /** @hidden */
  63402. 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;
  63403. /** @hidden */
  63404. 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;
  63405. /** @hidden */
  63406. 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;
  63407. /** @hidden */
  63408. 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;
  63409. /** @hidden */
  63410. 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;
  63411. /** @hidden */
  63412. 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;
  63413. }
  63414. }
  63415. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63416. import { Nullable } from "babylonjs/types";
  63417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63418. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63419. /**
  63420. * Implementation of the TGA Texture Loader.
  63421. * @hidden
  63422. */
  63423. export class _TGATextureLoader implements IInternalTextureLoader {
  63424. /**
  63425. * Defines wether the loader supports cascade loading the different faces.
  63426. */
  63427. readonly supportCascades: boolean;
  63428. /**
  63429. * This returns if the loader support the current file information.
  63430. * @param extension defines the file extension of the file being loaded
  63431. * @returns true if the loader can load the specified file
  63432. */
  63433. canLoad(extension: string): boolean;
  63434. /**
  63435. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63436. * @param data contains the texture data
  63437. * @param texture defines the BabylonJS internal texture
  63438. * @param createPolynomials will be true if polynomials have been requested
  63439. * @param onLoad defines the callback to trigger once the texture is ready
  63440. * @param onError defines the callback to trigger in case of error
  63441. */
  63442. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63443. /**
  63444. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63445. * @param data contains the texture data
  63446. * @param texture defines the BabylonJS internal texture
  63447. * @param callback defines the method to call once ready to upload
  63448. */
  63449. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63450. }
  63451. }
  63452. declare module "babylonjs/Misc/basis" {
  63453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63454. /**
  63455. * Info about the .basis files
  63456. */
  63457. class BasisFileInfo {
  63458. /**
  63459. * If the file has alpha
  63460. */
  63461. hasAlpha: boolean;
  63462. /**
  63463. * Info about each image of the basis file
  63464. */
  63465. images: Array<{
  63466. levels: Array<{
  63467. width: number;
  63468. height: number;
  63469. transcodedPixels: ArrayBufferView;
  63470. }>;
  63471. }>;
  63472. }
  63473. /**
  63474. * Result of transcoding a basis file
  63475. */
  63476. class TranscodeResult {
  63477. /**
  63478. * Info about the .basis file
  63479. */
  63480. fileInfo: BasisFileInfo;
  63481. /**
  63482. * Format to use when loading the file
  63483. */
  63484. format: number;
  63485. }
  63486. /**
  63487. * Configuration options for the Basis transcoder
  63488. */
  63489. export class BasisTranscodeConfiguration {
  63490. /**
  63491. * Supported compression formats used to determine the supported output format of the transcoder
  63492. */
  63493. supportedCompressionFormats?: {
  63494. /**
  63495. * etc1 compression format
  63496. */
  63497. etc1?: boolean;
  63498. /**
  63499. * s3tc compression format
  63500. */
  63501. s3tc?: boolean;
  63502. /**
  63503. * pvrtc compression format
  63504. */
  63505. pvrtc?: boolean;
  63506. /**
  63507. * etc2 compression format
  63508. */
  63509. etc2?: boolean;
  63510. };
  63511. /**
  63512. * If mipmap levels should be loaded for transcoded images (Default: true)
  63513. */
  63514. loadMipmapLevels?: boolean;
  63515. /**
  63516. * Index of a single image to load (Default: all images)
  63517. */
  63518. loadSingleImage?: number;
  63519. }
  63520. /**
  63521. * Used to load .Basis files
  63522. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63523. */
  63524. export class BasisTools {
  63525. private static _IgnoreSupportedFormats;
  63526. /**
  63527. * URL to use when loading the basis transcoder
  63528. */
  63529. static JSModuleURL: string;
  63530. /**
  63531. * URL to use when loading the wasm module for the transcoder
  63532. */
  63533. static WasmModuleURL: string;
  63534. /**
  63535. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63536. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63537. * @returns internal format corresponding to the Basis format
  63538. */
  63539. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63540. private static _WorkerPromise;
  63541. private static _Worker;
  63542. private static _actionId;
  63543. private static _CreateWorkerAsync;
  63544. /**
  63545. * Transcodes a loaded image file to compressed pixel data
  63546. * @param data image data to transcode
  63547. * @param config configuration options for the transcoding
  63548. * @returns a promise resulting in the transcoded image
  63549. */
  63550. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63551. /**
  63552. * Loads a texture from the transcode result
  63553. * @param texture texture load to
  63554. * @param transcodeResult the result of transcoding the basis file to load from
  63555. */
  63556. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63557. }
  63558. }
  63559. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63560. import { Nullable } from "babylonjs/types";
  63561. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63562. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63563. /**
  63564. * Loader for .basis file format
  63565. */
  63566. export class _BasisTextureLoader implements IInternalTextureLoader {
  63567. /**
  63568. * Defines whether the loader supports cascade loading the different faces.
  63569. */
  63570. readonly supportCascades: boolean;
  63571. /**
  63572. * This returns if the loader support the current file information.
  63573. * @param extension defines the file extension of the file being loaded
  63574. * @returns true if the loader can load the specified file
  63575. */
  63576. canLoad(extension: string): boolean;
  63577. /**
  63578. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63579. * @param data contains the texture data
  63580. * @param texture defines the BabylonJS internal texture
  63581. * @param createPolynomials will be true if polynomials have been requested
  63582. * @param onLoad defines the callback to trigger once the texture is ready
  63583. * @param onError defines the callback to trigger in case of error
  63584. */
  63585. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63586. /**
  63587. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63588. * @param data contains the texture data
  63589. * @param texture defines the BabylonJS internal texture
  63590. * @param callback defines the method to call once ready to upload
  63591. */
  63592. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63593. }
  63594. }
  63595. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63596. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63597. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63598. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63599. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63600. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63601. }
  63602. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63603. import { Vector2 } from "babylonjs/Maths/math.vector";
  63604. /**
  63605. * Defines the basic options interface of a TexturePacker Frame
  63606. */
  63607. export interface ITexturePackerFrame {
  63608. /**
  63609. * The frame ID
  63610. */
  63611. id: number;
  63612. /**
  63613. * The frames Scale
  63614. */
  63615. scale: Vector2;
  63616. /**
  63617. * The Frames offset
  63618. */
  63619. offset: Vector2;
  63620. }
  63621. /**
  63622. * This is a support class for frame Data on texture packer sets.
  63623. */
  63624. export class TexturePackerFrame implements ITexturePackerFrame {
  63625. /**
  63626. * The frame ID
  63627. */
  63628. id: number;
  63629. /**
  63630. * The frames Scale
  63631. */
  63632. scale: Vector2;
  63633. /**
  63634. * The Frames offset
  63635. */
  63636. offset: Vector2;
  63637. /**
  63638. * Initializes a texture package frame.
  63639. * @param id The numerical frame identifier
  63640. * @param scale Scalar Vector2 for UV frame
  63641. * @param offset Vector2 for the frame position in UV units.
  63642. * @returns TexturePackerFrame
  63643. */
  63644. constructor(id: number, scale: Vector2, offset: Vector2);
  63645. }
  63646. }
  63647. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63649. import { Scene } from "babylonjs/scene";
  63650. import { Nullable } from "babylonjs/types";
  63651. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63652. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63653. /**
  63654. * Defines the basic options interface of a TexturePacker
  63655. */
  63656. export interface ITexturePackerOptions {
  63657. /**
  63658. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63659. */
  63660. map?: string[];
  63661. /**
  63662. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63663. */
  63664. uvsIn?: string;
  63665. /**
  63666. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63667. */
  63668. uvsOut?: string;
  63669. /**
  63670. * number representing the layout style. Defaults to LAYOUT_STRIP
  63671. */
  63672. layout?: number;
  63673. /**
  63674. * number of columns if using custom column count layout(2). This defaults to 4.
  63675. */
  63676. colnum?: number;
  63677. /**
  63678. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63679. */
  63680. updateInputMeshes?: boolean;
  63681. /**
  63682. * boolean flag to dispose all the source textures. Defaults to true.
  63683. */
  63684. disposeSources?: boolean;
  63685. /**
  63686. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63687. */
  63688. fillBlanks?: boolean;
  63689. /**
  63690. * string value representing the context fill style color. Defaults to 'black'.
  63691. */
  63692. customFillColor?: string;
  63693. /**
  63694. * Width and Height Value of each Frame in the TexturePacker Sets
  63695. */
  63696. frameSize?: number;
  63697. /**
  63698. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63699. */
  63700. paddingRatio?: number;
  63701. /**
  63702. * Number that declares the fill method for the padding gutter.
  63703. */
  63704. paddingMode?: number;
  63705. /**
  63706. * If in SUBUV_COLOR padding mode what color to use.
  63707. */
  63708. paddingColor?: Color3 | Color4;
  63709. }
  63710. /**
  63711. * Defines the basic interface of a TexturePacker JSON File
  63712. */
  63713. export interface ITexturePackerJSON {
  63714. /**
  63715. * The frame ID
  63716. */
  63717. name: string;
  63718. /**
  63719. * The base64 channel data
  63720. */
  63721. sets: any;
  63722. /**
  63723. * The options of the Packer
  63724. */
  63725. options: ITexturePackerOptions;
  63726. /**
  63727. * The frame data of the Packer
  63728. */
  63729. frames: Array<number>;
  63730. }
  63731. /**
  63732. * This is a support class that generates a series of packed texture sets.
  63733. * @see https://doc.babylonjs.com/babylon101/materials
  63734. */
  63735. export class TexturePacker {
  63736. /** Packer Layout Constant 0 */
  63737. static readonly LAYOUT_STRIP: number;
  63738. /** Packer Layout Constant 1 */
  63739. static readonly LAYOUT_POWER2: number;
  63740. /** Packer Layout Constant 2 */
  63741. static readonly LAYOUT_COLNUM: number;
  63742. /** Packer Layout Constant 0 */
  63743. static readonly SUBUV_WRAP: number;
  63744. /** Packer Layout Constant 1 */
  63745. static readonly SUBUV_EXTEND: number;
  63746. /** Packer Layout Constant 2 */
  63747. static readonly SUBUV_COLOR: number;
  63748. /** The Name of the Texture Package */
  63749. name: string;
  63750. /** The scene scope of the TexturePacker */
  63751. scene: Scene;
  63752. /** The Meshes to target */
  63753. meshes: AbstractMesh[];
  63754. /** Arguments passed with the Constructor */
  63755. options: ITexturePackerOptions;
  63756. /** The promise that is started upon initialization */
  63757. promise: Nullable<Promise<TexturePacker | string>>;
  63758. /** The Container object for the channel sets that are generated */
  63759. sets: object;
  63760. /** The Container array for the frames that are generated */
  63761. frames: TexturePackerFrame[];
  63762. /** The expected number of textures the system is parsing. */
  63763. private _expecting;
  63764. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63765. private _paddingValue;
  63766. /**
  63767. * Initializes a texture package series from an array of meshes or a single mesh.
  63768. * @param name The name of the package
  63769. * @param meshes The target meshes to compose the package from
  63770. * @param options The arguments that texture packer should follow while building.
  63771. * @param scene The scene which the textures are scoped to.
  63772. * @returns TexturePacker
  63773. */
  63774. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63775. /**
  63776. * Starts the package process
  63777. * @param resolve The promises resolution function
  63778. * @returns TexturePacker
  63779. */
  63780. private _createFrames;
  63781. /**
  63782. * Calculates the Size of the Channel Sets
  63783. * @returns Vector2
  63784. */
  63785. private _calculateSize;
  63786. /**
  63787. * Calculates the UV data for the frames.
  63788. * @param baseSize the base frameSize
  63789. * @param padding the base frame padding
  63790. * @param dtSize size of the Dynamic Texture for that channel
  63791. * @param dtUnits is 1/dtSize
  63792. * @param update flag to update the input meshes
  63793. */
  63794. private _calculateMeshUVFrames;
  63795. /**
  63796. * Calculates the frames Offset.
  63797. * @param index of the frame
  63798. * @returns Vector2
  63799. */
  63800. private _getFrameOffset;
  63801. /**
  63802. * Updates a Mesh to the frame data
  63803. * @param mesh that is the target
  63804. * @param frameID or the frame index
  63805. */
  63806. private _updateMeshUV;
  63807. /**
  63808. * Updates a Meshes materials to use the texture packer channels
  63809. * @param m is the mesh to target
  63810. * @param force all channels on the packer to be set.
  63811. */
  63812. private _updateTextureReferences;
  63813. /**
  63814. * Public method to set a Mesh to a frame
  63815. * @param m that is the target
  63816. * @param frameID or the frame index
  63817. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63818. */
  63819. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63820. /**
  63821. * Starts the async promise to compile the texture packer.
  63822. * @returns Promise<void>
  63823. */
  63824. processAsync(): Promise<void>;
  63825. /**
  63826. * Disposes all textures associated with this packer
  63827. */
  63828. dispose(): void;
  63829. /**
  63830. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63831. * @param imageType is the image type to use.
  63832. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63833. */
  63834. download(imageType?: string, quality?: number): void;
  63835. /**
  63836. * Public method to load a texturePacker JSON file.
  63837. * @param data of the JSON file in string format.
  63838. */
  63839. updateFromJSON(data: string): void;
  63840. }
  63841. }
  63842. declare module "babylonjs/Materials/Textures/Packer/index" {
  63843. export * from "babylonjs/Materials/Textures/Packer/packer";
  63844. export * from "babylonjs/Materials/Textures/Packer/frame";
  63845. }
  63846. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63847. import { Scene } from "babylonjs/scene";
  63848. import { Texture } from "babylonjs/Materials/Textures/texture";
  63849. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63850. /**
  63851. * 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.
  63852. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63853. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63854. */
  63855. export class CustomProceduralTexture extends ProceduralTexture {
  63856. private _animate;
  63857. private _time;
  63858. private _config;
  63859. private _texturePath;
  63860. /**
  63861. * Instantiates a new Custom Procedural Texture.
  63862. * 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.
  63863. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63864. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63865. * @param name Define the name of the texture
  63866. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63867. * @param size Define the size of the texture to create
  63868. * @param scene Define the scene the texture belongs to
  63869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63870. * @param generateMipMaps Define if the texture should creates mip maps or not
  63871. */
  63872. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63873. private _loadJson;
  63874. /**
  63875. * Is the texture ready to be used ? (rendered at least once)
  63876. * @returns true if ready, otherwise, false.
  63877. */
  63878. isReady(): boolean;
  63879. /**
  63880. * Render the texture to its associated render target.
  63881. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63882. */
  63883. render(useCameraPostProcess?: boolean): void;
  63884. /**
  63885. * Update the list of dependant textures samplers in the shader.
  63886. */
  63887. updateTextures(): void;
  63888. /**
  63889. * Update the uniform values of the procedural texture in the shader.
  63890. */
  63891. updateShaderUniforms(): void;
  63892. /**
  63893. * Define if the texture animates or not.
  63894. */
  63895. get animate(): boolean;
  63896. set animate(value: boolean);
  63897. }
  63898. }
  63899. declare module "babylonjs/Shaders/noise.fragment" {
  63900. /** @hidden */
  63901. export var noisePixelShader: {
  63902. name: string;
  63903. shader: string;
  63904. };
  63905. }
  63906. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63907. import { Nullable } from "babylonjs/types";
  63908. import { Scene } from "babylonjs/scene";
  63909. import { Texture } from "babylonjs/Materials/Textures/texture";
  63910. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63911. import "babylonjs/Shaders/noise.fragment";
  63912. /**
  63913. * Class used to generate noise procedural textures
  63914. */
  63915. export class NoiseProceduralTexture extends ProceduralTexture {
  63916. private _time;
  63917. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63918. brightness: number;
  63919. /** Defines the number of octaves to process */
  63920. octaves: number;
  63921. /** Defines the level of persistence (0.8 by default) */
  63922. persistence: number;
  63923. /** Gets or sets animation speed factor (default is 1) */
  63924. animationSpeedFactor: number;
  63925. /**
  63926. * Creates a new NoiseProceduralTexture
  63927. * @param name defines the name fo the texture
  63928. * @param size defines the size of the texture (default is 256)
  63929. * @param scene defines the hosting scene
  63930. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63931. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63932. */
  63933. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63934. private _updateShaderUniforms;
  63935. protected _getDefines(): string;
  63936. /** Generate the current state of the procedural texture */
  63937. render(useCameraPostProcess?: boolean): void;
  63938. /**
  63939. * Serializes this noise procedural texture
  63940. * @returns a serialized noise procedural texture object
  63941. */
  63942. serialize(): any;
  63943. /**
  63944. * Clone the texture.
  63945. * @returns the cloned texture
  63946. */
  63947. clone(): NoiseProceduralTexture;
  63948. /**
  63949. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63950. * @param parsedTexture defines parsed texture data
  63951. * @param scene defines the current scene
  63952. * @param rootUrl defines the root URL containing noise procedural texture information
  63953. * @returns a parsed NoiseProceduralTexture
  63954. */
  63955. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63956. }
  63957. }
  63958. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63959. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63960. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63961. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63962. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63963. }
  63964. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63965. import { Nullable } from "babylonjs/types";
  63966. import { Scene } from "babylonjs/scene";
  63967. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63969. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63970. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63971. /**
  63972. * Raw cube texture where the raw buffers are passed in
  63973. */
  63974. export class RawCubeTexture extends CubeTexture {
  63975. /**
  63976. * Creates a cube texture where the raw buffers are passed in.
  63977. * @param scene defines the scene the texture is attached to
  63978. * @param data defines the array of data to use to create each face
  63979. * @param size defines the size of the textures
  63980. * @param format defines the format of the data
  63981. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63982. * @param generateMipMaps defines if the engine should generate the mip levels
  63983. * @param invertY defines if data must be stored with Y axis inverted
  63984. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63985. * @param compression defines the compression used (null by default)
  63986. */
  63987. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63988. /**
  63989. * Updates the raw cube texture.
  63990. * @param data defines the data to store
  63991. * @param format defines the data format
  63992. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63993. * @param invertY defines if data must be stored with Y axis inverted
  63994. * @param compression defines the compression used (null by default)
  63995. * @param level defines which level of the texture to update
  63996. */
  63997. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63998. /**
  63999. * Updates a raw cube texture with RGBD encoded data.
  64000. * @param data defines the array of data [mipmap][face] to use to create each face
  64001. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64002. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64003. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64004. * @returns a promsie that resolves when the operation is complete
  64005. */
  64006. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64007. /**
  64008. * Clones the raw cube texture.
  64009. * @return a new cube texture
  64010. */
  64011. clone(): CubeTexture;
  64012. /** @hidden */
  64013. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64014. }
  64015. }
  64016. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64017. import { Scene } from "babylonjs/scene";
  64018. import { Texture } from "babylonjs/Materials/Textures/texture";
  64019. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64020. /**
  64021. * Class used to store 2D array textures containing user data
  64022. */
  64023. export class RawTexture2DArray extends Texture {
  64024. /** Gets or sets the texture format to use */
  64025. format: number;
  64026. /**
  64027. * Create a new RawTexture2DArray
  64028. * @param data defines the data of the texture
  64029. * @param width defines the width of the texture
  64030. * @param height defines the height of the texture
  64031. * @param depth defines the number of layers of the texture
  64032. * @param format defines the texture format to use
  64033. * @param scene defines the hosting scene
  64034. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64035. * @param invertY defines if texture must be stored with Y axis inverted
  64036. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64038. */
  64039. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64040. /** Gets or sets the texture format to use */
  64041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64042. /**
  64043. * Update the texture with new data
  64044. * @param data defines the data to store in the texture
  64045. */
  64046. update(data: ArrayBufferView): void;
  64047. }
  64048. }
  64049. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64050. import { Scene } from "babylonjs/scene";
  64051. import { Texture } from "babylonjs/Materials/Textures/texture";
  64052. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64053. /**
  64054. * Class used to store 3D textures containing user data
  64055. */
  64056. export class RawTexture3D extends Texture {
  64057. /** Gets or sets the texture format to use */
  64058. format: number;
  64059. /**
  64060. * Create a new RawTexture3D
  64061. * @param data defines the data of the texture
  64062. * @param width defines the width of the texture
  64063. * @param height defines the height of the texture
  64064. * @param depth defines the depth of the texture
  64065. * @param format defines the texture format to use
  64066. * @param scene defines the hosting scene
  64067. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64068. * @param invertY defines if texture must be stored with Y axis inverted
  64069. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64070. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64071. */
  64072. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64073. /** Gets or sets the texture format to use */
  64074. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64075. /**
  64076. * Update the texture with new data
  64077. * @param data defines the data to store in the texture
  64078. */
  64079. update(data: ArrayBufferView): void;
  64080. }
  64081. }
  64082. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64083. import { Scene } from "babylonjs/scene";
  64084. import { Plane } from "babylonjs/Maths/math.plane";
  64085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64086. /**
  64087. * Creates a refraction texture used by refraction channel of the standard material.
  64088. * It is like a mirror but to see through a material.
  64089. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64090. */
  64091. export class RefractionTexture extends RenderTargetTexture {
  64092. /**
  64093. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64094. * 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.
  64095. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64096. */
  64097. refractionPlane: Plane;
  64098. /**
  64099. * Define how deep under the surface we should see.
  64100. */
  64101. depth: number;
  64102. /**
  64103. * Creates a refraction texture used by refraction channel of the standard material.
  64104. * It is like a mirror but to see through a material.
  64105. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64106. * @param name Define the texture name
  64107. * @param size Define the size of the underlying texture
  64108. * @param scene Define the scene the refraction belongs to
  64109. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64110. */
  64111. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64112. /**
  64113. * Clone the refraction texture.
  64114. * @returns the cloned texture
  64115. */
  64116. clone(): RefractionTexture;
  64117. /**
  64118. * Serialize the texture to a JSON representation you could use in Parse later on
  64119. * @returns the serialized JSON representation
  64120. */
  64121. serialize(): any;
  64122. }
  64123. }
  64124. declare module "babylonjs/Materials/Textures/index" {
  64125. export * from "babylonjs/Materials/Textures/baseTexture";
  64126. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64127. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64128. export * from "babylonjs/Materials/Textures/cubeTexture";
  64129. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64130. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64131. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64132. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64133. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64134. export * from "babylonjs/Materials/Textures/internalTexture";
  64135. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64136. export * from "babylonjs/Materials/Textures/Loaders/index";
  64137. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64138. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64139. export * from "babylonjs/Materials/Textures/Packer/index";
  64140. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64141. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64142. export * from "babylonjs/Materials/Textures/rawTexture";
  64143. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64144. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64145. export * from "babylonjs/Materials/Textures/refractionTexture";
  64146. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64147. export * from "babylonjs/Materials/Textures/texture";
  64148. export * from "babylonjs/Materials/Textures/videoTexture";
  64149. }
  64150. declare module "babylonjs/Materials/Node/Enums/index" {
  64151. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64152. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64153. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64154. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64155. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64156. }
  64157. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64161. import { Mesh } from "babylonjs/Meshes/mesh";
  64162. import { Effect } from "babylonjs/Materials/effect";
  64163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64164. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64165. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64166. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64167. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64168. /**
  64169. * Block used to add support for vertex skinning (bones)
  64170. */
  64171. export class BonesBlock extends NodeMaterialBlock {
  64172. /**
  64173. * Creates a new BonesBlock
  64174. * @param name defines the block name
  64175. */
  64176. constructor(name: string);
  64177. /**
  64178. * Initialize the block and prepare the context for build
  64179. * @param state defines the state that will be used for the build
  64180. */
  64181. initialize(state: NodeMaterialBuildState): void;
  64182. /**
  64183. * Gets the current class name
  64184. * @returns the class name
  64185. */
  64186. getClassName(): string;
  64187. /**
  64188. * Gets the matrix indices input component
  64189. */
  64190. get matricesIndices(): NodeMaterialConnectionPoint;
  64191. /**
  64192. * Gets the matrix weights input component
  64193. */
  64194. get matricesWeights(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the extra matrix indices input component
  64197. */
  64198. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the extra matrix weights input component
  64201. */
  64202. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the world input component
  64205. */
  64206. get world(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the output component
  64209. */
  64210. get output(): NodeMaterialConnectionPoint;
  64211. autoConfigure(material: NodeMaterial): void;
  64212. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64223. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64225. /**
  64226. * Block used to add support for instances
  64227. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64228. */
  64229. export class InstancesBlock extends NodeMaterialBlock {
  64230. /**
  64231. * Creates a new InstancesBlock
  64232. * @param name defines the block name
  64233. */
  64234. constructor(name: string);
  64235. /**
  64236. * Gets the current class name
  64237. * @returns the class name
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * Gets the first world row input component
  64242. */
  64243. get world0(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the second world row input component
  64246. */
  64247. get world1(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the third world row input component
  64250. */
  64251. get world2(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the forth world row input component
  64254. */
  64255. get world3(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the world input component
  64258. */
  64259. get world(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the output component
  64262. */
  64263. get output(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the isntanceID component
  64266. */
  64267. get instanceID(): NodeMaterialConnectionPoint;
  64268. autoConfigure(material: NodeMaterial): void;
  64269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64270. protected _buildBlock(state: NodeMaterialBuildState): this;
  64271. }
  64272. }
  64273. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64278. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64279. import { Effect } from "babylonjs/Materials/effect";
  64280. import { Mesh } from "babylonjs/Meshes/mesh";
  64281. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64283. /**
  64284. * Block used to add morph targets support to vertex shader
  64285. */
  64286. export class MorphTargetsBlock extends NodeMaterialBlock {
  64287. private _repeatableContentAnchor;
  64288. /**
  64289. * Create a new MorphTargetsBlock
  64290. * @param name defines the block name
  64291. */
  64292. constructor(name: string);
  64293. /**
  64294. * Gets the current class name
  64295. * @returns the class name
  64296. */
  64297. getClassName(): string;
  64298. /**
  64299. * Gets the position input component
  64300. */
  64301. get position(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the normal input component
  64304. */
  64305. get normal(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the tangent input component
  64308. */
  64309. get tangent(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the tangent input component
  64312. */
  64313. get uv(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the position output component
  64316. */
  64317. get positionOutput(): NodeMaterialConnectionPoint;
  64318. /**
  64319. * Gets the normal output component
  64320. */
  64321. get normalOutput(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the tangent output component
  64324. */
  64325. get tangentOutput(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the tangent output component
  64328. */
  64329. get uvOutput(): NodeMaterialConnectionPoint;
  64330. initialize(state: NodeMaterialBuildState): void;
  64331. autoConfigure(material: NodeMaterial): void;
  64332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64334. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64335. protected _buildBlock(state: NodeMaterialBuildState): this;
  64336. }
  64337. }
  64338. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64341. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64342. import { Nullable } from "babylonjs/types";
  64343. import { Scene } from "babylonjs/scene";
  64344. import { Effect } from "babylonjs/Materials/effect";
  64345. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64346. import { Mesh } from "babylonjs/Meshes/mesh";
  64347. import { Light } from "babylonjs/Lights/light";
  64348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64349. /**
  64350. * Block used to get data information from a light
  64351. */
  64352. export class LightInformationBlock extends NodeMaterialBlock {
  64353. private _lightDataUniformName;
  64354. private _lightColorUniformName;
  64355. private _lightTypeDefineName;
  64356. /**
  64357. * Gets or sets the light associated with this block
  64358. */
  64359. light: Nullable<Light>;
  64360. /**
  64361. * Creates a new LightInformationBlock
  64362. * @param name defines the block name
  64363. */
  64364. constructor(name: string);
  64365. /**
  64366. * Gets the current class name
  64367. * @returns the class name
  64368. */
  64369. getClassName(): string;
  64370. /**
  64371. * Gets the world position input component
  64372. */
  64373. get worldPosition(): NodeMaterialConnectionPoint;
  64374. /**
  64375. * Gets the direction output component
  64376. */
  64377. get direction(): NodeMaterialConnectionPoint;
  64378. /**
  64379. * Gets the direction output component
  64380. */
  64381. get color(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the direction output component
  64384. */
  64385. get intensity(): NodeMaterialConnectionPoint;
  64386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64388. protected _buildBlock(state: NodeMaterialBuildState): this;
  64389. serialize(): any;
  64390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64391. }
  64392. }
  64393. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64394. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64395. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64396. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64397. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64398. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64399. }
  64400. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64405. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64406. import { Effect } from "babylonjs/Materials/effect";
  64407. import { Mesh } from "babylonjs/Meshes/mesh";
  64408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64409. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64410. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64411. /**
  64412. * Block used to add image processing support to fragment shader
  64413. */
  64414. export class ImageProcessingBlock extends NodeMaterialBlock {
  64415. /**
  64416. * Create a new ImageProcessingBlock
  64417. * @param name defines the block name
  64418. */
  64419. constructor(name: string);
  64420. /**
  64421. * Gets the current class name
  64422. * @returns the class name
  64423. */
  64424. getClassName(): string;
  64425. /**
  64426. * Gets the color input component
  64427. */
  64428. get color(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the output component
  64431. */
  64432. get output(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Initialize the block and prepare the context for build
  64435. * @param state defines the state that will be used for the build
  64436. */
  64437. initialize(state: NodeMaterialBuildState): void;
  64438. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64439. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64441. protected _buildBlock(state: NodeMaterialBuildState): this;
  64442. }
  64443. }
  64444. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64450. import { Effect } from "babylonjs/Materials/effect";
  64451. import { Mesh } from "babylonjs/Meshes/mesh";
  64452. import { Scene } from "babylonjs/scene";
  64453. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64454. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64455. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64456. /**
  64457. * Block used to pertub normals based on a normal map
  64458. */
  64459. export class PerturbNormalBlock extends NodeMaterialBlock {
  64460. private _tangentSpaceParameterName;
  64461. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64462. invertX: boolean;
  64463. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64464. invertY: boolean;
  64465. /**
  64466. * Create a new PerturbNormalBlock
  64467. * @param name defines the block name
  64468. */
  64469. constructor(name: string);
  64470. /**
  64471. * Gets the current class name
  64472. * @returns the class name
  64473. */
  64474. getClassName(): string;
  64475. /**
  64476. * Gets the world position input component
  64477. */
  64478. get worldPosition(): NodeMaterialConnectionPoint;
  64479. /**
  64480. * Gets the world normal input component
  64481. */
  64482. get worldNormal(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the world tangent input component
  64485. */
  64486. get worldTangent(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the uv input component
  64489. */
  64490. get uv(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the normal map color input component
  64493. */
  64494. get normalMapColor(): NodeMaterialConnectionPoint;
  64495. /**
  64496. * Gets the strength input component
  64497. */
  64498. get strength(): NodeMaterialConnectionPoint;
  64499. /**
  64500. * Gets the output component
  64501. */
  64502. get output(): NodeMaterialConnectionPoint;
  64503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64505. autoConfigure(material: NodeMaterial): void;
  64506. protected _buildBlock(state: NodeMaterialBuildState): this;
  64507. protected _dumpPropertiesCode(): string;
  64508. serialize(): any;
  64509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64510. }
  64511. }
  64512. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64516. /**
  64517. * Block used to discard a pixel if a value is smaller than a cutoff
  64518. */
  64519. export class DiscardBlock extends NodeMaterialBlock {
  64520. /**
  64521. * Create a new DiscardBlock
  64522. * @param name defines the block name
  64523. */
  64524. constructor(name: string);
  64525. /**
  64526. * Gets the current class name
  64527. * @returns the class name
  64528. */
  64529. getClassName(): string;
  64530. /**
  64531. * Gets the color input component
  64532. */
  64533. get value(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the cutoff input component
  64536. */
  64537. get cutoff(): NodeMaterialConnectionPoint;
  64538. protected _buildBlock(state: NodeMaterialBuildState): this;
  64539. }
  64540. }
  64541. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64545. /**
  64546. * Block used to test if the fragment shader is front facing
  64547. */
  64548. export class FrontFacingBlock extends NodeMaterialBlock {
  64549. /**
  64550. * Creates a new FrontFacingBlock
  64551. * @param name defines the block name
  64552. */
  64553. constructor(name: string);
  64554. /**
  64555. * Gets the current class name
  64556. * @returns the class name
  64557. */
  64558. getClassName(): string;
  64559. /**
  64560. * Gets the output component
  64561. */
  64562. get output(): NodeMaterialConnectionPoint;
  64563. protected _buildBlock(state: NodeMaterialBuildState): this;
  64564. }
  64565. }
  64566. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64570. /**
  64571. * Block used to get the derivative value on x and y of a given input
  64572. */
  64573. export class DerivativeBlock extends NodeMaterialBlock {
  64574. /**
  64575. * Create a new DerivativeBlock
  64576. * @param name defines the block name
  64577. */
  64578. constructor(name: string);
  64579. /**
  64580. * Gets the current class name
  64581. * @returns the class name
  64582. */
  64583. getClassName(): string;
  64584. /**
  64585. * Gets the input component
  64586. */
  64587. get input(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the derivative output on x
  64590. */
  64591. get dx(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the derivative output on y
  64594. */
  64595. get dy(): NodeMaterialConnectionPoint;
  64596. protected _buildBlock(state: NodeMaterialBuildState): this;
  64597. }
  64598. }
  64599. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64603. /**
  64604. * Block used to make gl_FragCoord available
  64605. */
  64606. export class FragCoordBlock extends NodeMaterialBlock {
  64607. /**
  64608. * Creates a new FragCoordBlock
  64609. * @param name defines the block name
  64610. */
  64611. constructor(name: string);
  64612. /**
  64613. * Gets the current class name
  64614. * @returns the class name
  64615. */
  64616. getClassName(): string;
  64617. /**
  64618. * Gets the xy component
  64619. */
  64620. get xy(): NodeMaterialConnectionPoint;
  64621. /**
  64622. * Gets the xyz component
  64623. */
  64624. get xyz(): NodeMaterialConnectionPoint;
  64625. /**
  64626. * Gets the xyzw component
  64627. */
  64628. get xyzw(): NodeMaterialConnectionPoint;
  64629. /**
  64630. * Gets the x component
  64631. */
  64632. get x(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the y component
  64635. */
  64636. get y(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the z component
  64639. */
  64640. get z(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the w component
  64643. */
  64644. get output(): NodeMaterialConnectionPoint;
  64645. protected writeOutputs(state: NodeMaterialBuildState): string;
  64646. protected _buildBlock(state: NodeMaterialBuildState): this;
  64647. }
  64648. }
  64649. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64653. import { Effect } from "babylonjs/Materials/effect";
  64654. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64655. import { Mesh } from "babylonjs/Meshes/mesh";
  64656. /**
  64657. * Block used to get the screen sizes
  64658. */
  64659. export class ScreenSizeBlock extends NodeMaterialBlock {
  64660. private _varName;
  64661. private _scene;
  64662. /**
  64663. * Creates a new ScreenSizeBlock
  64664. * @param name defines the block name
  64665. */
  64666. constructor(name: string);
  64667. /**
  64668. * Gets the current class name
  64669. * @returns the class name
  64670. */
  64671. getClassName(): string;
  64672. /**
  64673. * Gets the xy component
  64674. */
  64675. get xy(): NodeMaterialConnectionPoint;
  64676. /**
  64677. * Gets the x component
  64678. */
  64679. get x(): NodeMaterialConnectionPoint;
  64680. /**
  64681. * Gets the y component
  64682. */
  64683. get y(): NodeMaterialConnectionPoint;
  64684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64685. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64690. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64691. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64692. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64693. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64694. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64695. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64697. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64698. }
  64699. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64702. import { Mesh } from "babylonjs/Meshes/mesh";
  64703. import { Effect } from "babylonjs/Materials/effect";
  64704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64706. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64707. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64708. /**
  64709. * Block used to add support for scene fog
  64710. */
  64711. export class FogBlock extends NodeMaterialBlock {
  64712. private _fogDistanceName;
  64713. private _fogParameters;
  64714. /**
  64715. * Create a new FogBlock
  64716. * @param name defines the block name
  64717. */
  64718. constructor(name: string);
  64719. /**
  64720. * Gets the current class name
  64721. * @returns the class name
  64722. */
  64723. getClassName(): string;
  64724. /**
  64725. * Gets the world position input component
  64726. */
  64727. get worldPosition(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the view input component
  64730. */
  64731. get view(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the color input component
  64734. */
  64735. get input(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the fog color input component
  64738. */
  64739. get fogColor(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the output component
  64742. */
  64743. get output(): NodeMaterialConnectionPoint;
  64744. autoConfigure(material: NodeMaterial): void;
  64745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64747. protected _buildBlock(state: NodeMaterialBuildState): this;
  64748. }
  64749. }
  64750. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64755. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64756. import { Effect } from "babylonjs/Materials/effect";
  64757. import { Mesh } from "babylonjs/Meshes/mesh";
  64758. import { Light } from "babylonjs/Lights/light";
  64759. import { Nullable } from "babylonjs/types";
  64760. import { Scene } from "babylonjs/scene";
  64761. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64762. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64763. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64764. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64765. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64766. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64767. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64768. /**
  64769. * Block used to add light in the fragment shader
  64770. */
  64771. export class LightBlock extends NodeMaterialBlock {
  64772. private _lightId;
  64773. /**
  64774. * Gets or sets the light associated with this block
  64775. */
  64776. light: Nullable<Light>;
  64777. /**
  64778. * Create a new LightBlock
  64779. * @param name defines the block name
  64780. */
  64781. constructor(name: string);
  64782. /**
  64783. * Gets the current class name
  64784. * @returns the class name
  64785. */
  64786. getClassName(): string;
  64787. /**
  64788. * Gets the world position input component
  64789. */
  64790. get worldPosition(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the world normal input component
  64793. */
  64794. get worldNormal(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the camera (or eye) position component
  64797. */
  64798. get cameraPosition(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the glossiness component
  64801. */
  64802. get glossiness(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the glossinness power component
  64805. */
  64806. get glossPower(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the diffuse color component
  64809. */
  64810. get diffuseColor(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the specular color component
  64813. */
  64814. get specularColor(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the diffuse output component
  64817. */
  64818. get diffuseOutput(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the specular output component
  64821. */
  64822. get specularOutput(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the shadow output component
  64825. */
  64826. get shadow(): NodeMaterialConnectionPoint;
  64827. autoConfigure(material: NodeMaterial): void;
  64828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64829. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64831. private _injectVertexCode;
  64832. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64833. serialize(): any;
  64834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64835. }
  64836. }
  64837. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64840. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64841. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64842. /**
  64843. * Block used to read a reflection texture from a sampler
  64844. */
  64845. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64846. /**
  64847. * Create a new ReflectionTextureBlock
  64848. * @param name defines the block name
  64849. */
  64850. constructor(name: string);
  64851. /**
  64852. * Gets the current class name
  64853. * @returns the class name
  64854. */
  64855. getClassName(): string;
  64856. /**
  64857. * Gets the world position input component
  64858. */
  64859. get position(): NodeMaterialConnectionPoint;
  64860. /**
  64861. * Gets the world position input component
  64862. */
  64863. get worldPosition(): NodeMaterialConnectionPoint;
  64864. /**
  64865. * Gets the world normal input component
  64866. */
  64867. get worldNormal(): NodeMaterialConnectionPoint;
  64868. /**
  64869. * Gets the world input component
  64870. */
  64871. get world(): NodeMaterialConnectionPoint;
  64872. /**
  64873. * Gets the camera (or eye) position component
  64874. */
  64875. get cameraPosition(): NodeMaterialConnectionPoint;
  64876. /**
  64877. * Gets the view input component
  64878. */
  64879. get view(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the rgb output component
  64882. */
  64883. get rgb(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the rgba output component
  64886. */
  64887. get rgba(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the r output component
  64890. */
  64891. get r(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the g output component
  64894. */
  64895. get g(): NodeMaterialConnectionPoint;
  64896. /**
  64897. * Gets the b output component
  64898. */
  64899. get b(): NodeMaterialConnectionPoint;
  64900. /**
  64901. * Gets the a output component
  64902. */
  64903. get a(): NodeMaterialConnectionPoint;
  64904. autoConfigure(material: NodeMaterial): void;
  64905. protected _buildBlock(state: NodeMaterialBuildState): this;
  64906. }
  64907. }
  64908. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64909. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64910. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64911. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64912. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64913. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64914. }
  64915. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64916. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64917. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64918. }
  64919. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64923. /**
  64924. * Block used to add 2 vectors
  64925. */
  64926. export class AddBlock extends NodeMaterialBlock {
  64927. /**
  64928. * Creates a new AddBlock
  64929. * @param name defines the block name
  64930. */
  64931. constructor(name: string);
  64932. /**
  64933. * Gets the current class name
  64934. * @returns the class name
  64935. */
  64936. getClassName(): string;
  64937. /**
  64938. * Gets the left operand input component
  64939. */
  64940. get left(): NodeMaterialConnectionPoint;
  64941. /**
  64942. * Gets the right operand input component
  64943. */
  64944. get right(): NodeMaterialConnectionPoint;
  64945. /**
  64946. * Gets the output component
  64947. */
  64948. get output(): NodeMaterialConnectionPoint;
  64949. protected _buildBlock(state: NodeMaterialBuildState): this;
  64950. }
  64951. }
  64952. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64956. /**
  64957. * Block used to scale a vector by a float
  64958. */
  64959. export class ScaleBlock extends NodeMaterialBlock {
  64960. /**
  64961. * Creates a new ScaleBlock
  64962. * @param name defines the block name
  64963. */
  64964. constructor(name: string);
  64965. /**
  64966. * Gets the current class name
  64967. * @returns the class name
  64968. */
  64969. getClassName(): string;
  64970. /**
  64971. * Gets the input component
  64972. */
  64973. get input(): NodeMaterialConnectionPoint;
  64974. /**
  64975. * Gets the factor input component
  64976. */
  64977. get factor(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the output component
  64980. */
  64981. get output(): NodeMaterialConnectionPoint;
  64982. protected _buildBlock(state: NodeMaterialBuildState): this;
  64983. }
  64984. }
  64985. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64989. import { Scene } from "babylonjs/scene";
  64990. /**
  64991. * Block used to clamp a float
  64992. */
  64993. export class ClampBlock extends NodeMaterialBlock {
  64994. /** Gets or sets the minimum range */
  64995. minimum: number;
  64996. /** Gets or sets the maximum range */
  64997. maximum: number;
  64998. /**
  64999. * Creates a new ClampBlock
  65000. * @param name defines the block name
  65001. */
  65002. constructor(name: string);
  65003. /**
  65004. * Gets the current class name
  65005. * @returns the class name
  65006. */
  65007. getClassName(): string;
  65008. /**
  65009. * Gets the value input component
  65010. */
  65011. get value(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the output component
  65014. */
  65015. get output(): NodeMaterialConnectionPoint;
  65016. protected _buildBlock(state: NodeMaterialBuildState): this;
  65017. protected _dumpPropertiesCode(): string;
  65018. serialize(): any;
  65019. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65020. }
  65021. }
  65022. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65026. /**
  65027. * Block used to apply a cross product between 2 vectors
  65028. */
  65029. export class CrossBlock extends NodeMaterialBlock {
  65030. /**
  65031. * Creates a new CrossBlock
  65032. * @param name defines the block name
  65033. */
  65034. constructor(name: string);
  65035. /**
  65036. * Gets the current class name
  65037. * @returns the class name
  65038. */
  65039. getClassName(): string;
  65040. /**
  65041. * Gets the left operand input component
  65042. */
  65043. get left(): NodeMaterialConnectionPoint;
  65044. /**
  65045. * Gets the right operand input component
  65046. */
  65047. get right(): NodeMaterialConnectionPoint;
  65048. /**
  65049. * Gets the output component
  65050. */
  65051. get output(): NodeMaterialConnectionPoint;
  65052. protected _buildBlock(state: NodeMaterialBuildState): this;
  65053. }
  65054. }
  65055. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65059. /**
  65060. * Block used to apply a dot product between 2 vectors
  65061. */
  65062. export class DotBlock extends NodeMaterialBlock {
  65063. /**
  65064. * Creates a new DotBlock
  65065. * @param name defines the block name
  65066. */
  65067. constructor(name: string);
  65068. /**
  65069. * Gets the current class name
  65070. * @returns the class name
  65071. */
  65072. getClassName(): string;
  65073. /**
  65074. * Gets the left operand input component
  65075. */
  65076. get left(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the right operand input component
  65079. */
  65080. get right(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the output component
  65083. */
  65084. get output(): NodeMaterialConnectionPoint;
  65085. protected _buildBlock(state: NodeMaterialBuildState): this;
  65086. }
  65087. }
  65088. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65092. /**
  65093. * Block used to normalize a vector
  65094. */
  65095. export class NormalizeBlock extends NodeMaterialBlock {
  65096. /**
  65097. * Creates a new NormalizeBlock
  65098. * @param name defines the block name
  65099. */
  65100. constructor(name: string);
  65101. /**
  65102. * Gets the current class name
  65103. * @returns the class name
  65104. */
  65105. getClassName(): string;
  65106. /**
  65107. * Gets the input component
  65108. */
  65109. get input(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the output component
  65112. */
  65113. get output(): NodeMaterialConnectionPoint;
  65114. protected _buildBlock(state: NodeMaterialBuildState): this;
  65115. }
  65116. }
  65117. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65121. import { Scene } from "babylonjs/scene";
  65122. /**
  65123. * Operations supported by the Trigonometry block
  65124. */
  65125. export enum TrigonometryBlockOperations {
  65126. /** Cos */
  65127. Cos = 0,
  65128. /** Sin */
  65129. Sin = 1,
  65130. /** Abs */
  65131. Abs = 2,
  65132. /** Exp */
  65133. Exp = 3,
  65134. /** Exp2 */
  65135. Exp2 = 4,
  65136. /** Round */
  65137. Round = 5,
  65138. /** Floor */
  65139. Floor = 6,
  65140. /** Ceiling */
  65141. Ceiling = 7,
  65142. /** Square root */
  65143. Sqrt = 8,
  65144. /** Log */
  65145. Log = 9,
  65146. /** Tangent */
  65147. Tan = 10,
  65148. /** Arc tangent */
  65149. ArcTan = 11,
  65150. /** Arc cosinus */
  65151. ArcCos = 12,
  65152. /** Arc sinus */
  65153. ArcSin = 13,
  65154. /** Fraction */
  65155. Fract = 14,
  65156. /** Sign */
  65157. Sign = 15,
  65158. /** To radians (from degrees) */
  65159. Radians = 16,
  65160. /** To degrees (from radians) */
  65161. Degrees = 17
  65162. }
  65163. /**
  65164. * Block used to apply trigonometry operation to floats
  65165. */
  65166. export class TrigonometryBlock extends NodeMaterialBlock {
  65167. /**
  65168. * Gets or sets the operation applied by the block
  65169. */
  65170. operation: TrigonometryBlockOperations;
  65171. /**
  65172. * Creates a new TrigonometryBlock
  65173. * @param name defines the block name
  65174. */
  65175. constructor(name: string);
  65176. /**
  65177. * Gets the current class name
  65178. * @returns the class name
  65179. */
  65180. getClassName(): string;
  65181. /**
  65182. * Gets the input component
  65183. */
  65184. get input(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the output component
  65187. */
  65188. get output(): NodeMaterialConnectionPoint;
  65189. protected _buildBlock(state: NodeMaterialBuildState): this;
  65190. serialize(): any;
  65191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65192. protected _dumpPropertiesCode(): string;
  65193. }
  65194. }
  65195. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65199. /**
  65200. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65201. */
  65202. export class ColorMergerBlock extends NodeMaterialBlock {
  65203. /**
  65204. * Create a new ColorMergerBlock
  65205. * @param name defines the block name
  65206. */
  65207. constructor(name: string);
  65208. /**
  65209. * Gets the current class name
  65210. * @returns the class name
  65211. */
  65212. getClassName(): string;
  65213. /**
  65214. * Gets the rgb component (input)
  65215. */
  65216. get rgbIn(): NodeMaterialConnectionPoint;
  65217. /**
  65218. * Gets the r component (input)
  65219. */
  65220. get r(): NodeMaterialConnectionPoint;
  65221. /**
  65222. * Gets the g component (input)
  65223. */
  65224. get g(): NodeMaterialConnectionPoint;
  65225. /**
  65226. * Gets the b component (input)
  65227. */
  65228. get b(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the a component (input)
  65231. */
  65232. get a(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the rgba component (output)
  65235. */
  65236. get rgba(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the rgb component (output)
  65239. */
  65240. get rgbOut(): NodeMaterialConnectionPoint;
  65241. /**
  65242. * Gets the rgb component (output)
  65243. * @deprecated Please use rgbOut instead.
  65244. */
  65245. get rgb(): NodeMaterialConnectionPoint;
  65246. protected _buildBlock(state: NodeMaterialBuildState): this;
  65247. }
  65248. }
  65249. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65253. /**
  65254. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65255. */
  65256. export class VectorSplitterBlock extends NodeMaterialBlock {
  65257. /**
  65258. * Create a new VectorSplitterBlock
  65259. * @param name defines the block name
  65260. */
  65261. constructor(name: string);
  65262. /**
  65263. * Gets the current class name
  65264. * @returns the class name
  65265. */
  65266. getClassName(): string;
  65267. /**
  65268. * Gets the xyzw component (input)
  65269. */
  65270. get xyzw(): NodeMaterialConnectionPoint;
  65271. /**
  65272. * Gets the xyz component (input)
  65273. */
  65274. get xyzIn(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the xy component (input)
  65277. */
  65278. get xyIn(): NodeMaterialConnectionPoint;
  65279. /**
  65280. * Gets the xyz component (output)
  65281. */
  65282. get xyzOut(): NodeMaterialConnectionPoint;
  65283. /**
  65284. * Gets the xy component (output)
  65285. */
  65286. get xyOut(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the x component (output)
  65289. */
  65290. get x(): NodeMaterialConnectionPoint;
  65291. /**
  65292. * Gets the y component (output)
  65293. */
  65294. get y(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the z component (output)
  65297. */
  65298. get z(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the w component (output)
  65301. */
  65302. get w(): NodeMaterialConnectionPoint;
  65303. protected _inputRename(name: string): string;
  65304. protected _outputRename(name: string): string;
  65305. protected _buildBlock(state: NodeMaterialBuildState): this;
  65306. }
  65307. }
  65308. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65312. /**
  65313. * Block used to lerp between 2 values
  65314. */
  65315. export class LerpBlock extends NodeMaterialBlock {
  65316. /**
  65317. * Creates a new LerpBlock
  65318. * @param name defines the block name
  65319. */
  65320. constructor(name: string);
  65321. /**
  65322. * Gets the current class name
  65323. * @returns the class name
  65324. */
  65325. getClassName(): string;
  65326. /**
  65327. * Gets the left operand input component
  65328. */
  65329. get left(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the right operand input component
  65332. */
  65333. get right(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the gradient operand input component
  65336. */
  65337. get gradient(): NodeMaterialConnectionPoint;
  65338. /**
  65339. * Gets the output component
  65340. */
  65341. get output(): NodeMaterialConnectionPoint;
  65342. protected _buildBlock(state: NodeMaterialBuildState): this;
  65343. }
  65344. }
  65345. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65349. /**
  65350. * Block used to divide 2 vectors
  65351. */
  65352. export class DivideBlock extends NodeMaterialBlock {
  65353. /**
  65354. * Creates a new DivideBlock
  65355. * @param name defines the block name
  65356. */
  65357. constructor(name: string);
  65358. /**
  65359. * Gets the current class name
  65360. * @returns the class name
  65361. */
  65362. getClassName(): string;
  65363. /**
  65364. * Gets the left operand input component
  65365. */
  65366. get left(): NodeMaterialConnectionPoint;
  65367. /**
  65368. * Gets the right operand input component
  65369. */
  65370. get right(): NodeMaterialConnectionPoint;
  65371. /**
  65372. * Gets the output component
  65373. */
  65374. get output(): NodeMaterialConnectionPoint;
  65375. protected _buildBlock(state: NodeMaterialBuildState): this;
  65376. }
  65377. }
  65378. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65382. /**
  65383. * Block used to subtract 2 vectors
  65384. */
  65385. export class SubtractBlock extends NodeMaterialBlock {
  65386. /**
  65387. * Creates a new SubtractBlock
  65388. * @param name defines the block name
  65389. */
  65390. constructor(name: string);
  65391. /**
  65392. * Gets the current class name
  65393. * @returns the class name
  65394. */
  65395. getClassName(): string;
  65396. /**
  65397. * Gets the left operand input component
  65398. */
  65399. get left(): NodeMaterialConnectionPoint;
  65400. /**
  65401. * Gets the right operand input component
  65402. */
  65403. get right(): NodeMaterialConnectionPoint;
  65404. /**
  65405. * Gets the output component
  65406. */
  65407. get output(): NodeMaterialConnectionPoint;
  65408. protected _buildBlock(state: NodeMaterialBuildState): this;
  65409. }
  65410. }
  65411. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65415. /**
  65416. * Block used to step a value
  65417. */
  65418. export class StepBlock extends NodeMaterialBlock {
  65419. /**
  65420. * Creates a new StepBlock
  65421. * @param name defines the block name
  65422. */
  65423. constructor(name: string);
  65424. /**
  65425. * Gets the current class name
  65426. * @returns the class name
  65427. */
  65428. getClassName(): string;
  65429. /**
  65430. * Gets the value operand input component
  65431. */
  65432. get value(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the edge operand input component
  65435. */
  65436. get edge(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the output component
  65439. */
  65440. get output(): NodeMaterialConnectionPoint;
  65441. protected _buildBlock(state: NodeMaterialBuildState): this;
  65442. }
  65443. }
  65444. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65448. /**
  65449. * Block used to get the opposite (1 - x) of a value
  65450. */
  65451. export class OneMinusBlock extends NodeMaterialBlock {
  65452. /**
  65453. * Creates a new OneMinusBlock
  65454. * @param name defines the block name
  65455. */
  65456. constructor(name: string);
  65457. /**
  65458. * Gets the current class name
  65459. * @returns the class name
  65460. */
  65461. getClassName(): string;
  65462. /**
  65463. * Gets the input component
  65464. */
  65465. get input(): NodeMaterialConnectionPoint;
  65466. /**
  65467. * Gets the output component
  65468. */
  65469. get output(): NodeMaterialConnectionPoint;
  65470. protected _buildBlock(state: NodeMaterialBuildState): this;
  65471. }
  65472. }
  65473. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65477. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65478. /**
  65479. * Block used to get the view direction
  65480. */
  65481. export class ViewDirectionBlock extends NodeMaterialBlock {
  65482. /**
  65483. * Creates a new ViewDirectionBlock
  65484. * @param name defines the block name
  65485. */
  65486. constructor(name: string);
  65487. /**
  65488. * Gets the current class name
  65489. * @returns the class name
  65490. */
  65491. getClassName(): string;
  65492. /**
  65493. * Gets the world position component
  65494. */
  65495. get worldPosition(): NodeMaterialConnectionPoint;
  65496. /**
  65497. * Gets the camera position component
  65498. */
  65499. get cameraPosition(): NodeMaterialConnectionPoint;
  65500. /**
  65501. * Gets the output component
  65502. */
  65503. get output(): NodeMaterialConnectionPoint;
  65504. autoConfigure(material: NodeMaterial): void;
  65505. protected _buildBlock(state: NodeMaterialBuildState): this;
  65506. }
  65507. }
  65508. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65512. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65513. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65514. /**
  65515. * Block used to compute fresnel value
  65516. */
  65517. export class FresnelBlock extends NodeMaterialBlock {
  65518. /**
  65519. * Create a new FresnelBlock
  65520. * @param name defines the block name
  65521. */
  65522. constructor(name: string);
  65523. /**
  65524. * Gets the current class name
  65525. * @returns the class name
  65526. */
  65527. getClassName(): string;
  65528. /**
  65529. * Gets the world normal input component
  65530. */
  65531. get worldNormal(): NodeMaterialConnectionPoint;
  65532. /**
  65533. * Gets the view direction input component
  65534. */
  65535. get viewDirection(): NodeMaterialConnectionPoint;
  65536. /**
  65537. * Gets the bias input component
  65538. */
  65539. get bias(): NodeMaterialConnectionPoint;
  65540. /**
  65541. * Gets the camera (or eye) position component
  65542. */
  65543. get power(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the fresnel output component
  65546. */
  65547. get fresnel(): NodeMaterialConnectionPoint;
  65548. autoConfigure(material: NodeMaterial): void;
  65549. protected _buildBlock(state: NodeMaterialBuildState): this;
  65550. }
  65551. }
  65552. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65556. /**
  65557. * Block used to get the max of 2 values
  65558. */
  65559. export class MaxBlock extends NodeMaterialBlock {
  65560. /**
  65561. * Creates a new MaxBlock
  65562. * @param name defines the block name
  65563. */
  65564. constructor(name: string);
  65565. /**
  65566. * Gets the current class name
  65567. * @returns the class name
  65568. */
  65569. getClassName(): string;
  65570. /**
  65571. * Gets the left operand input component
  65572. */
  65573. get left(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the right operand input component
  65576. */
  65577. get right(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the output component
  65580. */
  65581. get output(): NodeMaterialConnectionPoint;
  65582. protected _buildBlock(state: NodeMaterialBuildState): this;
  65583. }
  65584. }
  65585. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65589. /**
  65590. * Block used to get the min of 2 values
  65591. */
  65592. export class MinBlock extends NodeMaterialBlock {
  65593. /**
  65594. * Creates a new MinBlock
  65595. * @param name defines the block name
  65596. */
  65597. constructor(name: string);
  65598. /**
  65599. * Gets the current class name
  65600. * @returns the class name
  65601. */
  65602. getClassName(): string;
  65603. /**
  65604. * Gets the left operand input component
  65605. */
  65606. get left(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the right operand input component
  65609. */
  65610. get right(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the output component
  65613. */
  65614. get output(): NodeMaterialConnectionPoint;
  65615. protected _buildBlock(state: NodeMaterialBuildState): this;
  65616. }
  65617. }
  65618. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65622. /**
  65623. * Block used to get the distance between 2 values
  65624. */
  65625. export class DistanceBlock extends NodeMaterialBlock {
  65626. /**
  65627. * Creates a new DistanceBlock
  65628. * @param name defines the block name
  65629. */
  65630. constructor(name: string);
  65631. /**
  65632. * Gets the current class name
  65633. * @returns the class name
  65634. */
  65635. getClassName(): string;
  65636. /**
  65637. * Gets the left operand input component
  65638. */
  65639. get left(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the right operand input component
  65642. */
  65643. get right(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the output component
  65646. */
  65647. get output(): NodeMaterialConnectionPoint;
  65648. protected _buildBlock(state: NodeMaterialBuildState): this;
  65649. }
  65650. }
  65651. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65655. /**
  65656. * Block used to get the length of a vector
  65657. */
  65658. export class LengthBlock extends NodeMaterialBlock {
  65659. /**
  65660. * Creates a new LengthBlock
  65661. * @param name defines the block name
  65662. */
  65663. constructor(name: string);
  65664. /**
  65665. * Gets the current class name
  65666. * @returns the class name
  65667. */
  65668. getClassName(): string;
  65669. /**
  65670. * Gets the value input component
  65671. */
  65672. get value(): NodeMaterialConnectionPoint;
  65673. /**
  65674. * Gets the output component
  65675. */
  65676. get output(): NodeMaterialConnectionPoint;
  65677. protected _buildBlock(state: NodeMaterialBuildState): this;
  65678. }
  65679. }
  65680. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65684. /**
  65685. * Block used to get negative version of a value (i.e. x * -1)
  65686. */
  65687. export class NegateBlock extends NodeMaterialBlock {
  65688. /**
  65689. * Creates a new NegateBlock
  65690. * @param name defines the block name
  65691. */
  65692. constructor(name: string);
  65693. /**
  65694. * Gets the current class name
  65695. * @returns the class name
  65696. */
  65697. getClassName(): string;
  65698. /**
  65699. * Gets the value input component
  65700. */
  65701. get value(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the output component
  65704. */
  65705. get output(): NodeMaterialConnectionPoint;
  65706. protected _buildBlock(state: NodeMaterialBuildState): this;
  65707. }
  65708. }
  65709. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65713. /**
  65714. * Block used to get the value of the first parameter raised to the power of the second
  65715. */
  65716. export class PowBlock extends NodeMaterialBlock {
  65717. /**
  65718. * Creates a new PowBlock
  65719. * @param name defines the block name
  65720. */
  65721. constructor(name: string);
  65722. /**
  65723. * Gets the current class name
  65724. * @returns the class name
  65725. */
  65726. getClassName(): string;
  65727. /**
  65728. * Gets the value operand input component
  65729. */
  65730. get value(): NodeMaterialConnectionPoint;
  65731. /**
  65732. * Gets the power operand input component
  65733. */
  65734. get power(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the output component
  65737. */
  65738. get output(): NodeMaterialConnectionPoint;
  65739. protected _buildBlock(state: NodeMaterialBuildState): this;
  65740. }
  65741. }
  65742. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65746. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65747. /**
  65748. * Block used to get a random number
  65749. */
  65750. export class RandomNumberBlock extends NodeMaterialBlock {
  65751. /**
  65752. * Creates a new RandomNumberBlock
  65753. * @param name defines the block name
  65754. */
  65755. constructor(name: string);
  65756. /**
  65757. * Gets the current class name
  65758. * @returns the class name
  65759. */
  65760. getClassName(): string;
  65761. /**
  65762. * Gets the seed input component
  65763. */
  65764. get seed(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the output component
  65767. */
  65768. get output(): NodeMaterialConnectionPoint;
  65769. protected _buildBlock(state: NodeMaterialBuildState): this;
  65770. }
  65771. }
  65772. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65776. /**
  65777. * Block used to compute arc tangent of 2 values
  65778. */
  65779. export class ArcTan2Block extends NodeMaterialBlock {
  65780. /**
  65781. * Creates a new ArcTan2Block
  65782. * @param name defines the block name
  65783. */
  65784. constructor(name: string);
  65785. /**
  65786. * Gets the current class name
  65787. * @returns the class name
  65788. */
  65789. getClassName(): string;
  65790. /**
  65791. * Gets the x operand input component
  65792. */
  65793. get x(): NodeMaterialConnectionPoint;
  65794. /**
  65795. * Gets the y operand input component
  65796. */
  65797. get y(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the output component
  65800. */
  65801. get output(): NodeMaterialConnectionPoint;
  65802. protected _buildBlock(state: NodeMaterialBuildState): this;
  65803. }
  65804. }
  65805. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65809. /**
  65810. * Block used to smooth step a value
  65811. */
  65812. export class SmoothStepBlock extends NodeMaterialBlock {
  65813. /**
  65814. * Creates a new SmoothStepBlock
  65815. * @param name defines the block name
  65816. */
  65817. constructor(name: string);
  65818. /**
  65819. * Gets the current class name
  65820. * @returns the class name
  65821. */
  65822. getClassName(): string;
  65823. /**
  65824. * Gets the value operand input component
  65825. */
  65826. get value(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the first edge operand input component
  65829. */
  65830. get edge0(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the second edge operand input component
  65833. */
  65834. get edge1(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the output component
  65837. */
  65838. get output(): NodeMaterialConnectionPoint;
  65839. protected _buildBlock(state: NodeMaterialBuildState): this;
  65840. }
  65841. }
  65842. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65846. /**
  65847. * Block used to get the reciprocal (1 / x) of a value
  65848. */
  65849. export class ReciprocalBlock extends NodeMaterialBlock {
  65850. /**
  65851. * Creates a new ReciprocalBlock
  65852. * @param name defines the block name
  65853. */
  65854. constructor(name: string);
  65855. /**
  65856. * Gets the current class name
  65857. * @returns the class name
  65858. */
  65859. getClassName(): string;
  65860. /**
  65861. * Gets the input component
  65862. */
  65863. get input(): NodeMaterialConnectionPoint;
  65864. /**
  65865. * Gets the output component
  65866. */
  65867. get output(): NodeMaterialConnectionPoint;
  65868. protected _buildBlock(state: NodeMaterialBuildState): this;
  65869. }
  65870. }
  65871. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65875. /**
  65876. * Block used to replace a color by another one
  65877. */
  65878. export class ReplaceColorBlock extends NodeMaterialBlock {
  65879. /**
  65880. * Creates a new ReplaceColorBlock
  65881. * @param name defines the block name
  65882. */
  65883. constructor(name: string);
  65884. /**
  65885. * Gets the current class name
  65886. * @returns the class name
  65887. */
  65888. getClassName(): string;
  65889. /**
  65890. * Gets the value input component
  65891. */
  65892. get value(): NodeMaterialConnectionPoint;
  65893. /**
  65894. * Gets the reference input component
  65895. */
  65896. get reference(): NodeMaterialConnectionPoint;
  65897. /**
  65898. * Gets the distance input component
  65899. */
  65900. get distance(): NodeMaterialConnectionPoint;
  65901. /**
  65902. * Gets the replacement input component
  65903. */
  65904. get replacement(): NodeMaterialConnectionPoint;
  65905. /**
  65906. * Gets the output component
  65907. */
  65908. get output(): NodeMaterialConnectionPoint;
  65909. protected _buildBlock(state: NodeMaterialBuildState): this;
  65910. }
  65911. }
  65912. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65916. /**
  65917. * Block used to posterize a value
  65918. * @see https://en.wikipedia.org/wiki/Posterization
  65919. */
  65920. export class PosterizeBlock extends NodeMaterialBlock {
  65921. /**
  65922. * Creates a new PosterizeBlock
  65923. * @param name defines the block name
  65924. */
  65925. constructor(name: string);
  65926. /**
  65927. * Gets the current class name
  65928. * @returns the class name
  65929. */
  65930. getClassName(): string;
  65931. /**
  65932. * Gets the value input component
  65933. */
  65934. get value(): NodeMaterialConnectionPoint;
  65935. /**
  65936. * Gets the steps input component
  65937. */
  65938. get steps(): NodeMaterialConnectionPoint;
  65939. /**
  65940. * Gets the output component
  65941. */
  65942. get output(): NodeMaterialConnectionPoint;
  65943. protected _buildBlock(state: NodeMaterialBuildState): this;
  65944. }
  65945. }
  65946. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65950. import { Scene } from "babylonjs/scene";
  65951. /**
  65952. * Operations supported by the Wave block
  65953. */
  65954. export enum WaveBlockKind {
  65955. /** SawTooth */
  65956. SawTooth = 0,
  65957. /** Square */
  65958. Square = 1,
  65959. /** Triangle */
  65960. Triangle = 2
  65961. }
  65962. /**
  65963. * Block used to apply wave operation to floats
  65964. */
  65965. export class WaveBlock extends NodeMaterialBlock {
  65966. /**
  65967. * Gets or sets the kibnd of wave to be applied by the block
  65968. */
  65969. kind: WaveBlockKind;
  65970. /**
  65971. * Creates a new WaveBlock
  65972. * @param name defines the block name
  65973. */
  65974. constructor(name: string);
  65975. /**
  65976. * Gets the current class name
  65977. * @returns the class name
  65978. */
  65979. getClassName(): string;
  65980. /**
  65981. * Gets the input component
  65982. */
  65983. get input(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the output component
  65986. */
  65987. get output(): NodeMaterialConnectionPoint;
  65988. protected _buildBlock(state: NodeMaterialBuildState): this;
  65989. serialize(): any;
  65990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65991. }
  65992. }
  65993. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65997. import { Color3 } from "babylonjs/Maths/math.color";
  65998. import { Scene } from "babylonjs/scene";
  65999. /**
  66000. * Class used to store a color step for the GradientBlock
  66001. */
  66002. export class GradientBlockColorStep {
  66003. /**
  66004. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66005. */
  66006. step: number;
  66007. /**
  66008. * Gets or sets the color associated with this step
  66009. */
  66010. color: Color3;
  66011. /**
  66012. * Creates a new GradientBlockColorStep
  66013. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66014. * @param color defines the color associated with this step
  66015. */
  66016. constructor(
  66017. /**
  66018. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66019. */
  66020. step: number,
  66021. /**
  66022. * Gets or sets the color associated with this step
  66023. */
  66024. color: Color3);
  66025. }
  66026. /**
  66027. * Block used to return a color from a gradient based on an input value between 0 and 1
  66028. */
  66029. export class GradientBlock extends NodeMaterialBlock {
  66030. /**
  66031. * Gets or sets the list of color steps
  66032. */
  66033. colorSteps: GradientBlockColorStep[];
  66034. /**
  66035. * Creates a new GradientBlock
  66036. * @param name defines the block name
  66037. */
  66038. constructor(name: string);
  66039. /**
  66040. * Gets the current class name
  66041. * @returns the class name
  66042. */
  66043. getClassName(): string;
  66044. /**
  66045. * Gets the gradient input component
  66046. */
  66047. get gradient(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the output component
  66050. */
  66051. get output(): NodeMaterialConnectionPoint;
  66052. private _writeColorConstant;
  66053. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66054. serialize(): any;
  66055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66056. protected _dumpPropertiesCode(): string;
  66057. }
  66058. }
  66059. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66063. /**
  66064. * Block used to normalize lerp between 2 values
  66065. */
  66066. export class NLerpBlock extends NodeMaterialBlock {
  66067. /**
  66068. * Creates a new NLerpBlock
  66069. * @param name defines the block name
  66070. */
  66071. constructor(name: string);
  66072. /**
  66073. * Gets the current class name
  66074. * @returns the class name
  66075. */
  66076. getClassName(): string;
  66077. /**
  66078. * Gets the left operand input component
  66079. */
  66080. get left(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the right operand input component
  66083. */
  66084. get right(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the gradient operand input component
  66087. */
  66088. get gradient(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the output component
  66091. */
  66092. get output(): NodeMaterialConnectionPoint;
  66093. protected _buildBlock(state: NodeMaterialBuildState): this;
  66094. }
  66095. }
  66096. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66100. import { Scene } from "babylonjs/scene";
  66101. /**
  66102. * block used to Generate a Worley Noise 3D Noise Pattern
  66103. */
  66104. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66105. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66106. manhattanDistance: boolean;
  66107. /**
  66108. * Creates a new WorleyNoise3DBlock
  66109. * @param name defines the block name
  66110. */
  66111. constructor(name: string);
  66112. /**
  66113. * Gets the current class name
  66114. * @returns the class name
  66115. */
  66116. getClassName(): string;
  66117. /**
  66118. * Gets the seed input component
  66119. */
  66120. get seed(): NodeMaterialConnectionPoint;
  66121. /**
  66122. * Gets the jitter input component
  66123. */
  66124. get jitter(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the output component
  66127. */
  66128. get output(): NodeMaterialConnectionPoint;
  66129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66130. /**
  66131. * Exposes the properties to the UI?
  66132. */
  66133. protected _dumpPropertiesCode(): string;
  66134. /**
  66135. * Exposes the properties to the Seralize?
  66136. */
  66137. serialize(): any;
  66138. /**
  66139. * Exposes the properties to the deseralize?
  66140. */
  66141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66142. }
  66143. }
  66144. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66148. /**
  66149. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66150. */
  66151. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66152. /**
  66153. * Creates a new SimplexPerlin3DBlock
  66154. * @param name defines the block name
  66155. */
  66156. constructor(name: string);
  66157. /**
  66158. * Gets the current class name
  66159. * @returns the class name
  66160. */
  66161. getClassName(): string;
  66162. /**
  66163. * Gets the seed operand input component
  66164. */
  66165. get seed(): NodeMaterialConnectionPoint;
  66166. /**
  66167. * Gets the output component
  66168. */
  66169. get output(): NodeMaterialConnectionPoint;
  66170. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66171. }
  66172. }
  66173. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66177. /**
  66178. * Block used to blend normals
  66179. */
  66180. export class NormalBlendBlock extends NodeMaterialBlock {
  66181. /**
  66182. * Creates a new NormalBlendBlock
  66183. * @param name defines the block name
  66184. */
  66185. constructor(name: string);
  66186. /**
  66187. * Gets the current class name
  66188. * @returns the class name
  66189. */
  66190. getClassName(): string;
  66191. /**
  66192. * Gets the first input component
  66193. */
  66194. get normalMap0(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the second input component
  66197. */
  66198. get normalMap1(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the output component
  66201. */
  66202. get output(): NodeMaterialConnectionPoint;
  66203. protected _buildBlock(state: NodeMaterialBuildState): this;
  66204. }
  66205. }
  66206. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66210. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66211. /**
  66212. * Block used to rotate a 2d vector by a given angle
  66213. */
  66214. export class Rotate2dBlock extends NodeMaterialBlock {
  66215. /**
  66216. * Creates a new Rotate2dBlock
  66217. * @param name defines the block name
  66218. */
  66219. constructor(name: string);
  66220. /**
  66221. * Gets the current class name
  66222. * @returns the class name
  66223. */
  66224. getClassName(): string;
  66225. /**
  66226. * Gets the input vector
  66227. */
  66228. get input(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the input angle
  66231. */
  66232. get angle(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the output component
  66235. */
  66236. get output(): NodeMaterialConnectionPoint;
  66237. autoConfigure(material: NodeMaterial): void;
  66238. protected _buildBlock(state: NodeMaterialBuildState): this;
  66239. }
  66240. }
  66241. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  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. /**
  66246. * Block used to get the reflected vector from a direction and a normal
  66247. */
  66248. export class ReflectBlock extends NodeMaterialBlock {
  66249. /**
  66250. * Creates a new ReflectBlock
  66251. * @param name defines the block name
  66252. */
  66253. constructor(name: string);
  66254. /**
  66255. * Gets the current class name
  66256. * @returns the class name
  66257. */
  66258. getClassName(): string;
  66259. /**
  66260. * Gets the incident component
  66261. */
  66262. get incident(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the normal component
  66265. */
  66266. get normal(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the output component
  66269. */
  66270. get output(): NodeMaterialConnectionPoint;
  66271. protected _buildBlock(state: NodeMaterialBuildState): this;
  66272. }
  66273. }
  66274. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66278. /**
  66279. * Block used to get the refracted vector from a direction and a normal
  66280. */
  66281. export class RefractBlock extends NodeMaterialBlock {
  66282. /**
  66283. * Creates a new RefractBlock
  66284. * @param name defines the block name
  66285. */
  66286. constructor(name: string);
  66287. /**
  66288. * Gets the current class name
  66289. * @returns the class name
  66290. */
  66291. getClassName(): string;
  66292. /**
  66293. * Gets the incident component
  66294. */
  66295. get incident(): NodeMaterialConnectionPoint;
  66296. /**
  66297. * Gets the normal component
  66298. */
  66299. get normal(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the index of refraction component
  66302. */
  66303. get ior(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the output component
  66306. */
  66307. get output(): NodeMaterialConnectionPoint;
  66308. protected _buildBlock(state: NodeMaterialBuildState): this;
  66309. }
  66310. }
  66311. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66315. /**
  66316. * Block used to desaturate a color
  66317. */
  66318. export class DesaturateBlock extends NodeMaterialBlock {
  66319. /**
  66320. * Creates a new DesaturateBlock
  66321. * @param name defines the block name
  66322. */
  66323. constructor(name: string);
  66324. /**
  66325. * Gets the current class name
  66326. * @returns the class name
  66327. */
  66328. getClassName(): string;
  66329. /**
  66330. * Gets the color operand input component
  66331. */
  66332. get color(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the level operand input component
  66335. */
  66336. get level(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the output component
  66339. */
  66340. get output(): NodeMaterialConnectionPoint;
  66341. protected _buildBlock(state: NodeMaterialBuildState): this;
  66342. }
  66343. }
  66344. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66348. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66349. import { Nullable } from "babylonjs/types";
  66350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66351. import { Scene } from "babylonjs/scene";
  66352. /**
  66353. * Block used to implement the ambient occlusion module of the PBR material
  66354. */
  66355. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66356. /**
  66357. * Create a new AmbientOcclusionBlock
  66358. * @param name defines the block name
  66359. */
  66360. constructor(name: string);
  66361. /**
  66362. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66363. */
  66364. useAmbientInGrayScale: boolean;
  66365. /**
  66366. * Initialize the block and prepare the context for build
  66367. * @param state defines the state that will be used for the build
  66368. */
  66369. initialize(state: NodeMaterialBuildState): void;
  66370. /**
  66371. * Gets the current class name
  66372. * @returns the class name
  66373. */
  66374. getClassName(): string;
  66375. /**
  66376. * Gets the texture input component
  66377. */
  66378. get texture(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the texture intensity component
  66381. */
  66382. get intensity(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the direct light intensity input component
  66385. */
  66386. get directLightIntensity(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the ambient occlusion object output component
  66389. */
  66390. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the main code of the block (fragment side)
  66393. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66394. * @returns the shader code
  66395. */
  66396. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66398. protected _buildBlock(state: NodeMaterialBuildState): this;
  66399. protected _dumpPropertiesCode(): string;
  66400. serialize(): any;
  66401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66402. }
  66403. }
  66404. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66408. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66410. import { Nullable } from "babylonjs/types";
  66411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66412. import { Mesh } from "babylonjs/Meshes/mesh";
  66413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66414. import { Effect } from "babylonjs/Materials/effect";
  66415. import { Scene } from "babylonjs/scene";
  66416. /**
  66417. * Block used to implement the reflection module of the PBR material
  66418. */
  66419. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66420. /** @hidden */
  66421. _defineLODReflectionAlpha: string;
  66422. /** @hidden */
  66423. _defineLinearSpecularReflection: string;
  66424. private _vEnvironmentIrradianceName;
  66425. /** @hidden */
  66426. _vReflectionMicrosurfaceInfosName: string;
  66427. /** @hidden */
  66428. _vReflectionInfosName: string;
  66429. /** @hidden */
  66430. _vReflectionFilteringInfoName: string;
  66431. private _scene;
  66432. /**
  66433. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66434. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66435. * It's less burden on the user side in the editor part.
  66436. */
  66437. /** @hidden */
  66438. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66439. /** @hidden */
  66440. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66441. /** @hidden */
  66442. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66443. /**
  66444. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66445. * diffuse part of the IBL.
  66446. */
  66447. useSphericalHarmonics: boolean;
  66448. /**
  66449. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66450. */
  66451. forceIrradianceInFragment: boolean;
  66452. /**
  66453. * Create a new ReflectionBlock
  66454. * @param name defines the block name
  66455. */
  66456. constructor(name: string);
  66457. /**
  66458. * Gets the current class name
  66459. * @returns the class name
  66460. */
  66461. getClassName(): string;
  66462. /**
  66463. * Gets the position input component
  66464. */
  66465. get position(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the world position input component
  66468. */
  66469. get worldPosition(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the world normal input component
  66472. */
  66473. get worldNormal(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the world input component
  66476. */
  66477. get world(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the camera (or eye) position component
  66480. */
  66481. get cameraPosition(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the view input component
  66484. */
  66485. get view(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the color input component
  66488. */
  66489. get color(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the reflection object output component
  66492. */
  66493. get reflection(): NodeMaterialConnectionPoint;
  66494. /**
  66495. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66496. */
  66497. get hasTexture(): boolean;
  66498. /**
  66499. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66500. */
  66501. get reflectionColor(): string;
  66502. protected _getTexture(): Nullable<BaseTexture>;
  66503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66505. /**
  66506. * Gets the code to inject in the vertex shader
  66507. * @param state current state of the node material building
  66508. * @returns the shader code
  66509. */
  66510. handleVertexSide(state: NodeMaterialBuildState): string;
  66511. /**
  66512. * Gets the main code of the block (fragment side)
  66513. * @param state current state of the node material building
  66514. * @param normalVarName name of the existing variable corresponding to the normal
  66515. * @returns the shader code
  66516. */
  66517. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66518. protected _buildBlock(state: NodeMaterialBuildState): this;
  66519. protected _dumpPropertiesCode(): string;
  66520. serialize(): any;
  66521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66522. }
  66523. }
  66524. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66528. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66530. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66531. import { Scene } from "babylonjs/scene";
  66532. import { Nullable } from "babylonjs/types";
  66533. /**
  66534. * Block used to implement the sheen module of the PBR material
  66535. */
  66536. export class SheenBlock extends NodeMaterialBlock {
  66537. /**
  66538. * Create a new SheenBlock
  66539. * @param name defines the block name
  66540. */
  66541. constructor(name: string);
  66542. /**
  66543. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66544. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66545. * making it easier to setup and tweak the effect
  66546. */
  66547. albedoScaling: boolean;
  66548. /**
  66549. * Defines if the sheen is linked to the sheen color.
  66550. */
  66551. linkSheenWithAlbedo: boolean;
  66552. /**
  66553. * Initialize the block and prepare the context for build
  66554. * @param state defines the state that will be used for the build
  66555. */
  66556. initialize(state: NodeMaterialBuildState): void;
  66557. /**
  66558. * Gets the current class name
  66559. * @returns the class name
  66560. */
  66561. getClassName(): string;
  66562. /**
  66563. * Gets the intensity input component
  66564. */
  66565. get intensity(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the color input component
  66568. */
  66569. get color(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the roughness input component
  66572. */
  66573. get roughness(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the sheen object output component
  66576. */
  66577. get sheen(): NodeMaterialConnectionPoint;
  66578. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66579. /**
  66580. * Gets the main code of the block (fragment side)
  66581. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66582. * @returns the shader code
  66583. */
  66584. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66585. protected _buildBlock(state: NodeMaterialBuildState): this;
  66586. protected _dumpPropertiesCode(): string;
  66587. serialize(): any;
  66588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66589. }
  66590. }
  66591. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66592. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66597. import { Scene } from "babylonjs/scene";
  66598. import { Nullable } from "babylonjs/types";
  66599. import { Mesh } from "babylonjs/Meshes/mesh";
  66600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66601. import { Effect } from "babylonjs/Materials/effect";
  66602. /**
  66603. * Block used to implement the reflectivity module of the PBR material
  66604. */
  66605. export class ReflectivityBlock extends NodeMaterialBlock {
  66606. private _metallicReflectanceColor;
  66607. private _metallicF0Factor;
  66608. /** @hidden */
  66609. _vMetallicReflectanceFactorsName: string;
  66610. /**
  66611. * The property below is set by the main PBR block prior to calling methods of this class.
  66612. */
  66613. /** @hidden */
  66614. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66615. /**
  66616. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66617. */
  66618. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66619. /**
  66620. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66621. */
  66622. useMetallnessFromMetallicTextureBlue: boolean;
  66623. /**
  66624. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66625. */
  66626. useRoughnessFromMetallicTextureAlpha: boolean;
  66627. /**
  66628. * Specifies if the metallic texture contains the roughness information in its green channel.
  66629. */
  66630. useRoughnessFromMetallicTextureGreen: boolean;
  66631. /**
  66632. * Create a new ReflectivityBlock
  66633. * @param name defines the block name
  66634. */
  66635. constructor(name: string);
  66636. /**
  66637. * Initialize the block and prepare the context for build
  66638. * @param state defines the state that will be used for the build
  66639. */
  66640. initialize(state: NodeMaterialBuildState): void;
  66641. /**
  66642. * Gets the current class name
  66643. * @returns the class name
  66644. */
  66645. getClassName(): string;
  66646. /**
  66647. * Gets the metallic input component
  66648. */
  66649. get metallic(): NodeMaterialConnectionPoint;
  66650. /**
  66651. * Gets the roughness input component
  66652. */
  66653. get roughness(): NodeMaterialConnectionPoint;
  66654. /**
  66655. * Gets the texture input component
  66656. */
  66657. get texture(): NodeMaterialConnectionPoint;
  66658. /**
  66659. * Gets the reflectivity object output component
  66660. */
  66661. get reflectivity(): NodeMaterialConnectionPoint;
  66662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66663. /**
  66664. * Gets the main code of the block (fragment side)
  66665. * @param state current state of the node material building
  66666. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66667. * @returns the shader code
  66668. */
  66669. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66671. protected _buildBlock(state: NodeMaterialBuildState): this;
  66672. protected _dumpPropertiesCode(): string;
  66673. serialize(): any;
  66674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66675. }
  66676. }
  66677. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66678. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66683. /**
  66684. * Block used to implement the anisotropy module of the PBR material
  66685. */
  66686. export class AnisotropyBlock extends NodeMaterialBlock {
  66687. /**
  66688. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66689. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66690. * It's less burden on the user side in the editor part.
  66691. */
  66692. /** @hidden */
  66693. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66694. /** @hidden */
  66695. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66696. /**
  66697. * Create a new AnisotropyBlock
  66698. * @param name defines the block name
  66699. */
  66700. constructor(name: string);
  66701. /**
  66702. * Initialize the block and prepare the context for build
  66703. * @param state defines the state that will be used for the build
  66704. */
  66705. initialize(state: NodeMaterialBuildState): void;
  66706. /**
  66707. * Gets the current class name
  66708. * @returns the class name
  66709. */
  66710. getClassName(): string;
  66711. /**
  66712. * Gets the intensity input component
  66713. */
  66714. get intensity(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the direction input component
  66717. */
  66718. get direction(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the texture input component
  66721. */
  66722. get texture(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the uv input component
  66725. */
  66726. get uv(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the worldTangent input component
  66729. */
  66730. get worldTangent(): NodeMaterialConnectionPoint;
  66731. /**
  66732. * Gets the anisotropy object output component
  66733. */
  66734. get anisotropy(): NodeMaterialConnectionPoint;
  66735. private _generateTBNSpace;
  66736. /**
  66737. * Gets the main code of the block (fragment side)
  66738. * @param state current state of the node material building
  66739. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66740. * @returns the shader code
  66741. */
  66742. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66744. protected _buildBlock(state: NodeMaterialBuildState): this;
  66745. }
  66746. }
  66747. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66751. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66753. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66754. import { Nullable } from "babylonjs/types";
  66755. import { Mesh } from "babylonjs/Meshes/mesh";
  66756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66757. import { Effect } from "babylonjs/Materials/effect";
  66758. /**
  66759. * Block used to implement the clear coat module of the PBR material
  66760. */
  66761. export class ClearCoatBlock extends NodeMaterialBlock {
  66762. private _scene;
  66763. /**
  66764. * Create a new ClearCoatBlock
  66765. * @param name defines the block name
  66766. */
  66767. constructor(name: string);
  66768. /**
  66769. * Initialize the block and prepare the context for build
  66770. * @param state defines the state that will be used for the build
  66771. */
  66772. initialize(state: NodeMaterialBuildState): void;
  66773. /**
  66774. * Gets the current class name
  66775. * @returns the class name
  66776. */
  66777. getClassName(): string;
  66778. /**
  66779. * Gets the intensity input component
  66780. */
  66781. get intensity(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the roughness input component
  66784. */
  66785. get roughness(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the ior input component
  66788. */
  66789. get ior(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the texture input component
  66792. */
  66793. get texture(): NodeMaterialConnectionPoint;
  66794. /**
  66795. * Gets the bump texture input component
  66796. */
  66797. get bumpTexture(): NodeMaterialConnectionPoint;
  66798. /**
  66799. * Gets the uv input component
  66800. */
  66801. get uv(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the tint color input component
  66804. */
  66805. get tintColor(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the tint "at distance" input component
  66808. */
  66809. get tintAtDistance(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the tint thickness input component
  66812. */
  66813. get tintThickness(): NodeMaterialConnectionPoint;
  66814. /**
  66815. * Gets the world tangent input component
  66816. */
  66817. get worldTangent(): NodeMaterialConnectionPoint;
  66818. /**
  66819. * Gets the clear coat object output component
  66820. */
  66821. get clearcoat(): NodeMaterialConnectionPoint;
  66822. autoConfigure(material: NodeMaterial): void;
  66823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66825. private _generateTBNSpace;
  66826. /**
  66827. * Gets the main code of the block (fragment side)
  66828. * @param state current state of the node material building
  66829. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66830. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66831. * @param worldPosVarName name of the variable holding the world position
  66832. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66833. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66834. * @param worldNormalVarName name of the variable holding the world normal
  66835. * @returns the shader code
  66836. */
  66837. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66838. protected _buildBlock(state: NodeMaterialBuildState): this;
  66839. }
  66840. }
  66841. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66845. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66847. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66848. import { Nullable } from "babylonjs/types";
  66849. /**
  66850. * Block used to implement the sub surface module of the PBR material
  66851. */
  66852. export class SubSurfaceBlock extends NodeMaterialBlock {
  66853. /**
  66854. * Create a new SubSurfaceBlock
  66855. * @param name defines the block name
  66856. */
  66857. constructor(name: string);
  66858. /**
  66859. * Stores the intensity of the different subsurface effects in the thickness texture.
  66860. * * the green channel is the translucency intensity.
  66861. * * the blue channel is the scattering intensity.
  66862. * * the alpha channel is the refraction intensity.
  66863. */
  66864. useMaskFromThicknessTexture: boolean;
  66865. /**
  66866. * Initialize the block and prepare the context for build
  66867. * @param state defines the state that will be used for the build
  66868. */
  66869. initialize(state: NodeMaterialBuildState): void;
  66870. /**
  66871. * Gets the current class name
  66872. * @returns the class name
  66873. */
  66874. getClassName(): string;
  66875. /**
  66876. * Gets the min thickness input component
  66877. */
  66878. get minThickness(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the max thickness input component
  66881. */
  66882. get maxThickness(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the thickness texture component
  66885. */
  66886. get thicknessTexture(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the tint color input component
  66889. */
  66890. get tintColor(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the translucency intensity input component
  66893. */
  66894. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66895. /**
  66896. * Gets the translucency diffusion distance input component
  66897. */
  66898. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the refraction object parameters
  66901. */
  66902. get refraction(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the sub surface object output component
  66905. */
  66906. get subsurface(): NodeMaterialConnectionPoint;
  66907. autoConfigure(material: NodeMaterial): void;
  66908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66909. /**
  66910. * Gets the main code of the block (fragment side)
  66911. * @param state current state of the node material building
  66912. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66913. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66914. * @param worldPosVarName name of the variable holding the world position
  66915. * @returns the shader code
  66916. */
  66917. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66918. protected _buildBlock(state: NodeMaterialBuildState): this;
  66919. }
  66920. }
  66921. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66925. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66926. import { Light } from "babylonjs/Lights/light";
  66927. import { Nullable } from "babylonjs/types";
  66928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66929. import { Effect } from "babylonjs/Materials/effect";
  66930. import { Mesh } from "babylonjs/Meshes/mesh";
  66931. import { Scene } from "babylonjs/scene";
  66932. /**
  66933. * Block used to implement the PBR metallic/roughness model
  66934. */
  66935. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66936. /**
  66937. * Gets or sets the light associated with this block
  66938. */
  66939. light: Nullable<Light>;
  66940. private _lightId;
  66941. private _scene;
  66942. private _environmentBRDFTexture;
  66943. private _environmentBrdfSamplerName;
  66944. private _vNormalWName;
  66945. private _invertNormalName;
  66946. /**
  66947. * Create a new ReflectionBlock
  66948. * @param name defines the block name
  66949. */
  66950. constructor(name: string);
  66951. /**
  66952. * Intensity of the direct lights e.g. the four lights available in your scene.
  66953. * This impacts both the direct diffuse and specular highlights.
  66954. */
  66955. directIntensity: number;
  66956. /**
  66957. * Intensity of the environment e.g. how much the environment will light the object
  66958. * either through harmonics for rough material or through the refelction for shiny ones.
  66959. */
  66960. environmentIntensity: number;
  66961. /**
  66962. * This is a special control allowing the reduction of the specular highlights coming from the
  66963. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66964. */
  66965. specularIntensity: number;
  66966. /**
  66967. * Defines the falloff type used in this material.
  66968. * It by default is Physical.
  66969. */
  66970. lightFalloff: number;
  66971. /**
  66972. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66973. */
  66974. useAlphaFromAlbedoTexture: boolean;
  66975. /**
  66976. * Specifies that alpha test should be used
  66977. */
  66978. useAlphaTest: boolean;
  66979. /**
  66980. * Defines the alpha limits in alpha test mode.
  66981. */
  66982. alphaTestCutoff: number;
  66983. /**
  66984. * Specifies that alpha blending should be used
  66985. */
  66986. useAlphaBlending: boolean;
  66987. /**
  66988. * Defines if the alpha value should be determined via the rgb values.
  66989. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66990. */
  66991. opacityRGB: boolean;
  66992. /**
  66993. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66994. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66995. */
  66996. useRadianceOverAlpha: boolean;
  66997. /**
  66998. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67000. */
  67001. useSpecularOverAlpha: boolean;
  67002. /**
  67003. * Enables specular anti aliasing in the PBR shader.
  67004. * It will both interacts on the Geometry for analytical and IBL lighting.
  67005. * It also prefilter the roughness map based on the bump values.
  67006. */
  67007. enableSpecularAntiAliasing: boolean;
  67008. /**
  67009. * Enables realtime filtering on the texture.
  67010. */
  67011. realTimeFiltering: boolean;
  67012. /**
  67013. * Quality switch for realtime filtering
  67014. */
  67015. realTimeFilteringQuality: number;
  67016. /**
  67017. * Defines if the material uses energy conservation.
  67018. */
  67019. useEnergyConservation: boolean;
  67020. /**
  67021. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67022. * too much the area relying on ambient texture to define their ambient occlusion.
  67023. */
  67024. useRadianceOcclusion: boolean;
  67025. /**
  67026. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67027. * makes the reflect vector face the model (under horizon).
  67028. */
  67029. useHorizonOcclusion: boolean;
  67030. /**
  67031. * If set to true, no lighting calculations will be applied.
  67032. */
  67033. unlit: boolean;
  67034. /**
  67035. * Force normal to face away from face.
  67036. */
  67037. forceNormalForward: boolean;
  67038. /**
  67039. * Defines the material debug mode.
  67040. * It helps seeing only some components of the material while troubleshooting.
  67041. */
  67042. debugMode: number;
  67043. /**
  67044. * Specify from where on screen the debug mode should start.
  67045. * The value goes from -1 (full screen) to 1 (not visible)
  67046. * It helps with side by side comparison against the final render
  67047. * This defaults to 0
  67048. */
  67049. debugLimit: number;
  67050. /**
  67051. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67052. * You can use the factor to better multiply the final value.
  67053. */
  67054. debugFactor: number;
  67055. /**
  67056. * Initialize the block and prepare the context for build
  67057. * @param state defines the state that will be used for the build
  67058. */
  67059. initialize(state: NodeMaterialBuildState): void;
  67060. /**
  67061. * Gets the current class name
  67062. * @returns the class name
  67063. */
  67064. getClassName(): string;
  67065. /**
  67066. * Gets the world position input component
  67067. */
  67068. get worldPosition(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the world normal input component
  67071. */
  67072. get worldNormal(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the perturbed normal input component
  67075. */
  67076. get perturbedNormal(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the camera position input component
  67079. */
  67080. get cameraPosition(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the base color input component
  67083. */
  67084. get baseColor(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the opacity texture input component
  67087. */
  67088. get opacityTexture(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the ambient color input component
  67091. */
  67092. get ambientColor(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the reflectivity object parameters
  67095. */
  67096. get reflectivity(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the ambient occlusion object parameters
  67099. */
  67100. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the reflection object parameters
  67103. */
  67104. get reflection(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the sheen object parameters
  67107. */
  67108. get sheen(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the clear coat object parameters
  67111. */
  67112. get clearcoat(): NodeMaterialConnectionPoint;
  67113. /**
  67114. * Gets the sub surface object parameters
  67115. */
  67116. get subsurface(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the anisotropy object parameters
  67119. */
  67120. get anisotropy(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the ambient output component
  67123. */
  67124. get ambient(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the diffuse output component
  67127. */
  67128. get diffuse(): NodeMaterialConnectionPoint;
  67129. /**
  67130. * Gets the specular output component
  67131. */
  67132. get specular(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the sheen output component
  67135. */
  67136. get sheenDir(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the clear coat output component
  67139. */
  67140. get clearcoatDir(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the indirect diffuse output component
  67143. */
  67144. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the indirect specular output component
  67147. */
  67148. get specularIndirect(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the indirect sheen output component
  67151. */
  67152. get sheenIndirect(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the indirect clear coat output component
  67155. */
  67156. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the refraction output component
  67159. */
  67160. get refraction(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the global lighting output component
  67163. */
  67164. get lighting(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the shadow output component
  67167. */
  67168. get shadow(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the alpha output component
  67171. */
  67172. get alpha(): NodeMaterialConnectionPoint;
  67173. autoConfigure(material: NodeMaterial): void;
  67174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67175. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67176. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67177. private _injectVertexCode;
  67178. /**
  67179. * Gets the code corresponding to the albedo/opacity module
  67180. * @returns the shader code
  67181. */
  67182. getAlbedoOpacityCode(): string;
  67183. protected _buildBlock(state: NodeMaterialBuildState): this;
  67184. protected _dumpPropertiesCode(): string;
  67185. serialize(): any;
  67186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67187. }
  67188. }
  67189. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67190. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67191. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67192. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67193. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67194. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67199. }
  67200. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67201. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67202. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67203. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67204. }
  67205. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67209. /**
  67210. * Block used to compute value of one parameter modulo another
  67211. */
  67212. export class ModBlock extends NodeMaterialBlock {
  67213. /**
  67214. * Creates a new ModBlock
  67215. * @param name defines the block name
  67216. */
  67217. constructor(name: string);
  67218. /**
  67219. * Gets the current class name
  67220. * @returns the class name
  67221. */
  67222. getClassName(): string;
  67223. /**
  67224. * Gets the left operand input component
  67225. */
  67226. get left(): NodeMaterialConnectionPoint;
  67227. /**
  67228. * Gets the right operand input component
  67229. */
  67230. get right(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the output component
  67233. */
  67234. get output(): NodeMaterialConnectionPoint;
  67235. protected _buildBlock(state: NodeMaterialBuildState): this;
  67236. }
  67237. }
  67238. declare module "babylonjs/Materials/Node/Blocks/index" {
  67239. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67240. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67241. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67242. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67243. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67244. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67245. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67246. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67247. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67251. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67252. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67253. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67255. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67256. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67257. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67258. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67259. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67260. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67261. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67262. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67263. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67264. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67265. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67266. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67267. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67268. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67271. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67272. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67275. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67276. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67277. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67278. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67279. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67280. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67281. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67282. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67283. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67284. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67285. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67286. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67287. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67288. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67289. }
  67290. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67291. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67292. }
  67293. declare module "babylonjs/Materials/Node/index" {
  67294. export * from "babylonjs/Materials/Node/Enums/index";
  67295. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67296. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67297. export * from "babylonjs/Materials/Node/nodeMaterial";
  67298. export * from "babylonjs/Materials/Node/Blocks/index";
  67299. export * from "babylonjs/Materials/Node/Optimizers/index";
  67300. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67301. }
  67302. declare module "babylonjs/Materials/index" {
  67303. export * from "babylonjs/Materials/Background/index";
  67304. export * from "babylonjs/Materials/colorCurves";
  67305. export * from "babylonjs/Materials/iEffectFallbacks";
  67306. export * from "babylonjs/Materials/effectFallbacks";
  67307. export * from "babylonjs/Materials/effect";
  67308. export * from "babylonjs/Materials/fresnelParameters";
  67309. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67310. export * from "babylonjs/Materials/material";
  67311. export * from "babylonjs/Materials/materialDefines";
  67312. export * from "babylonjs/Materials/materialHelper";
  67313. export * from "babylonjs/Materials/multiMaterial";
  67314. export * from "babylonjs/Materials/PBR/index";
  67315. export * from "babylonjs/Materials/pushMaterial";
  67316. export * from "babylonjs/Materials/shaderMaterial";
  67317. export * from "babylonjs/Materials/standardMaterial";
  67318. export * from "babylonjs/Materials/Textures/index";
  67319. export * from "babylonjs/Materials/uniformBuffer";
  67320. export * from "babylonjs/Materials/materialFlags";
  67321. export * from "babylonjs/Materials/Node/index";
  67322. export * from "babylonjs/Materials/effectRenderer";
  67323. export * from "babylonjs/Materials/shadowDepthWrapper";
  67324. }
  67325. declare module "babylonjs/Maths/index" {
  67326. export * from "babylonjs/Maths/math.scalar";
  67327. export * from "babylonjs/Maths/math";
  67328. export * from "babylonjs/Maths/sphericalPolynomial";
  67329. }
  67330. declare module "babylonjs/Misc/workerPool" {
  67331. import { IDisposable } from "babylonjs/scene";
  67332. /**
  67333. * Helper class to push actions to a pool of workers.
  67334. */
  67335. export class WorkerPool implements IDisposable {
  67336. private _workerInfos;
  67337. private _pendingActions;
  67338. /**
  67339. * Constructor
  67340. * @param workers Array of workers to use for actions
  67341. */
  67342. constructor(workers: Array<Worker>);
  67343. /**
  67344. * Terminates all workers and clears any pending actions.
  67345. */
  67346. dispose(): void;
  67347. /**
  67348. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67349. * pended until a worker has completed its action.
  67350. * @param action The action to perform. Call onComplete when the action is complete.
  67351. */
  67352. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67353. private _execute;
  67354. }
  67355. }
  67356. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67357. import { IDisposable } from "babylonjs/scene";
  67358. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67359. /**
  67360. * Configuration for Draco compression
  67361. */
  67362. export interface IDracoCompressionConfiguration {
  67363. /**
  67364. * Configuration for the decoder.
  67365. */
  67366. decoder: {
  67367. /**
  67368. * The url to the WebAssembly module.
  67369. */
  67370. wasmUrl?: string;
  67371. /**
  67372. * The url to the WebAssembly binary.
  67373. */
  67374. wasmBinaryUrl?: string;
  67375. /**
  67376. * The url to the fallback JavaScript module.
  67377. */
  67378. fallbackUrl?: string;
  67379. };
  67380. }
  67381. /**
  67382. * Draco compression (https://google.github.io/draco/)
  67383. *
  67384. * This class wraps the Draco module.
  67385. *
  67386. * **Encoder**
  67387. *
  67388. * The encoder is not currently implemented.
  67389. *
  67390. * **Decoder**
  67391. *
  67392. * 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.
  67393. *
  67394. * To update the configuration, use the following code:
  67395. * ```javascript
  67396. * DracoCompression.Configuration = {
  67397. * decoder: {
  67398. * wasmUrl: "<url to the WebAssembly library>",
  67399. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67400. * fallbackUrl: "<url to the fallback JavaScript library>",
  67401. * }
  67402. * };
  67403. * ```
  67404. *
  67405. * 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.
  67406. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67407. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67408. *
  67409. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67410. * ```javascript
  67411. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67412. * ```
  67413. *
  67414. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67415. */
  67416. export class DracoCompression implements IDisposable {
  67417. private _workerPoolPromise?;
  67418. private _decoderModulePromise?;
  67419. /**
  67420. * The configuration. Defaults to the following urls:
  67421. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67422. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67423. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67424. */
  67425. static Configuration: IDracoCompressionConfiguration;
  67426. /**
  67427. * Returns true if the decoder configuration is available.
  67428. */
  67429. static get DecoderAvailable(): boolean;
  67430. /**
  67431. * Default number of workers to create when creating the draco compression object.
  67432. */
  67433. static DefaultNumWorkers: number;
  67434. private static GetDefaultNumWorkers;
  67435. private static _Default;
  67436. /**
  67437. * Default instance for the draco compression object.
  67438. */
  67439. static get Default(): DracoCompression;
  67440. /**
  67441. * Constructor
  67442. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67443. */
  67444. constructor(numWorkers?: number);
  67445. /**
  67446. * Stop all async operations and release resources.
  67447. */
  67448. dispose(): void;
  67449. /**
  67450. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67451. * @returns a promise that resolves when ready
  67452. */
  67453. whenReadyAsync(): Promise<void>;
  67454. /**
  67455. * Decode Draco compressed mesh data to vertex data.
  67456. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67457. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67458. * @returns A promise that resolves with the decoded vertex data
  67459. */
  67460. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67461. [kind: string]: number;
  67462. }): Promise<VertexData>;
  67463. }
  67464. }
  67465. declare module "babylonjs/Meshes/Compression/index" {
  67466. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67467. }
  67468. declare module "babylonjs/Meshes/csg" {
  67469. import { Nullable } from "babylonjs/types";
  67470. import { Scene } from "babylonjs/scene";
  67471. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67472. import { Mesh } from "babylonjs/Meshes/mesh";
  67473. import { Material } from "babylonjs/Materials/material";
  67474. /**
  67475. * Class for building Constructive Solid Geometry
  67476. */
  67477. export class CSG {
  67478. private polygons;
  67479. /**
  67480. * The world matrix
  67481. */
  67482. matrix: Matrix;
  67483. /**
  67484. * Stores the position
  67485. */
  67486. position: Vector3;
  67487. /**
  67488. * Stores the rotation
  67489. */
  67490. rotation: Vector3;
  67491. /**
  67492. * Stores the rotation quaternion
  67493. */
  67494. rotationQuaternion: Nullable<Quaternion>;
  67495. /**
  67496. * Stores the scaling vector
  67497. */
  67498. scaling: Vector3;
  67499. /**
  67500. * Convert the Mesh to CSG
  67501. * @param mesh The Mesh to convert to CSG
  67502. * @returns A new CSG from the Mesh
  67503. */
  67504. static FromMesh(mesh: Mesh): CSG;
  67505. /**
  67506. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67507. * @param polygons Polygons used to construct a CSG solid
  67508. */
  67509. private static FromPolygons;
  67510. /**
  67511. * Clones, or makes a deep copy, of the CSG
  67512. * @returns A new CSG
  67513. */
  67514. clone(): CSG;
  67515. /**
  67516. * Unions this CSG with another CSG
  67517. * @param csg The CSG to union against this CSG
  67518. * @returns The unioned CSG
  67519. */
  67520. union(csg: CSG): CSG;
  67521. /**
  67522. * Unions this CSG with another CSG in place
  67523. * @param csg The CSG to union against this CSG
  67524. */
  67525. unionInPlace(csg: CSG): void;
  67526. /**
  67527. * Subtracts this CSG with another CSG
  67528. * @param csg The CSG to subtract against this CSG
  67529. * @returns A new CSG
  67530. */
  67531. subtract(csg: CSG): CSG;
  67532. /**
  67533. * Subtracts this CSG with another CSG in place
  67534. * @param csg The CSG to subtact against this CSG
  67535. */
  67536. subtractInPlace(csg: CSG): void;
  67537. /**
  67538. * Intersect this CSG with another CSG
  67539. * @param csg The CSG to intersect against this CSG
  67540. * @returns A new CSG
  67541. */
  67542. intersect(csg: CSG): CSG;
  67543. /**
  67544. * Intersects this CSG with another CSG in place
  67545. * @param csg The CSG to intersect against this CSG
  67546. */
  67547. intersectInPlace(csg: CSG): void;
  67548. /**
  67549. * Return a new CSG solid with solid and empty space switched. This solid is
  67550. * not modified.
  67551. * @returns A new CSG solid with solid and empty space switched
  67552. */
  67553. inverse(): CSG;
  67554. /**
  67555. * Inverses the CSG in place
  67556. */
  67557. inverseInPlace(): void;
  67558. /**
  67559. * This is used to keep meshes transformations so they can be restored
  67560. * when we build back a Babylon Mesh
  67561. * NB : All CSG operations are performed in world coordinates
  67562. * @param csg The CSG to copy the transform attributes from
  67563. * @returns This CSG
  67564. */
  67565. copyTransformAttributes(csg: CSG): CSG;
  67566. /**
  67567. * Build Raw mesh from CSG
  67568. * Coordinates here are in world space
  67569. * @param name The name of the mesh geometry
  67570. * @param scene The Scene
  67571. * @param keepSubMeshes Specifies if the submeshes should be kept
  67572. * @returns A new Mesh
  67573. */
  67574. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67575. /**
  67576. * Build Mesh from CSG taking material and transforms into account
  67577. * @param name The name of the Mesh
  67578. * @param material The material of the Mesh
  67579. * @param scene The Scene
  67580. * @param keepSubMeshes Specifies if submeshes should be kept
  67581. * @returns The new Mesh
  67582. */
  67583. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67584. }
  67585. }
  67586. declare module "babylonjs/Meshes/trailMesh" {
  67587. import { Mesh } from "babylonjs/Meshes/mesh";
  67588. import { Scene } from "babylonjs/scene";
  67589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67590. /**
  67591. * Class used to create a trail following a mesh
  67592. */
  67593. export class TrailMesh extends Mesh {
  67594. private _generator;
  67595. private _autoStart;
  67596. private _running;
  67597. private _diameter;
  67598. private _length;
  67599. private _sectionPolygonPointsCount;
  67600. private _sectionVectors;
  67601. private _sectionNormalVectors;
  67602. private _beforeRenderObserver;
  67603. /**
  67604. * @constructor
  67605. * @param name The value used by scene.getMeshByName() to do a lookup.
  67606. * @param generator The mesh or transform node to generate a trail.
  67607. * @param scene The scene to add this mesh to.
  67608. * @param diameter Diameter of trailing mesh. Default is 1.
  67609. * @param length Length of trailing mesh. Default is 60.
  67610. * @param autoStart Automatically start trailing mesh. Default true.
  67611. */
  67612. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67613. /**
  67614. * "TrailMesh"
  67615. * @returns "TrailMesh"
  67616. */
  67617. getClassName(): string;
  67618. private _createMesh;
  67619. /**
  67620. * Start trailing mesh.
  67621. */
  67622. start(): void;
  67623. /**
  67624. * Stop trailing mesh.
  67625. */
  67626. stop(): void;
  67627. /**
  67628. * Update trailing mesh geometry.
  67629. */
  67630. update(): void;
  67631. /**
  67632. * Returns a new TrailMesh object.
  67633. * @param name is a string, the name given to the new mesh
  67634. * @param newGenerator use new generator object for cloned trail mesh
  67635. * @returns a new mesh
  67636. */
  67637. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67638. /**
  67639. * Serializes this trail mesh
  67640. * @param serializationObject object to write serialization to
  67641. */
  67642. serialize(serializationObject: any): void;
  67643. /**
  67644. * Parses a serialized trail mesh
  67645. * @param parsedMesh the serialized mesh
  67646. * @param scene the scene to create the trail mesh in
  67647. * @returns the created trail mesh
  67648. */
  67649. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67650. }
  67651. }
  67652. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67653. import { Nullable } from "babylonjs/types";
  67654. import { Scene } from "babylonjs/scene";
  67655. import { Vector4 } from "babylonjs/Maths/math.vector";
  67656. import { Color4 } from "babylonjs/Maths/math.color";
  67657. import { Mesh } from "babylonjs/Meshes/mesh";
  67658. /**
  67659. * Class containing static functions to help procedurally build meshes
  67660. */
  67661. export class TiledBoxBuilder {
  67662. /**
  67663. * Creates a box mesh
  67664. * 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)
  67665. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67669. * @param name defines the name of the mesh
  67670. * @param options defines the options used to create the mesh
  67671. * @param scene defines the hosting scene
  67672. * @returns the box mesh
  67673. */
  67674. static CreateTiledBox(name: string, options: {
  67675. pattern?: number;
  67676. width?: number;
  67677. height?: number;
  67678. depth?: number;
  67679. tileSize?: number;
  67680. tileWidth?: number;
  67681. tileHeight?: number;
  67682. alignHorizontal?: number;
  67683. alignVertical?: number;
  67684. faceUV?: Vector4[];
  67685. faceColors?: Color4[];
  67686. sideOrientation?: number;
  67687. updatable?: boolean;
  67688. }, scene?: Nullable<Scene>): Mesh;
  67689. }
  67690. }
  67691. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67692. import { Vector4 } from "babylonjs/Maths/math.vector";
  67693. import { Mesh } from "babylonjs/Meshes/mesh";
  67694. /**
  67695. * Class containing static functions to help procedurally build meshes
  67696. */
  67697. export class TorusKnotBuilder {
  67698. /**
  67699. * Creates a torus knot mesh
  67700. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67701. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67702. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67703. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67707. * @param name defines the name of the mesh
  67708. * @param options defines the options used to create the mesh
  67709. * @param scene defines the hosting scene
  67710. * @returns the torus knot mesh
  67711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67712. */
  67713. static CreateTorusKnot(name: string, options: {
  67714. radius?: number;
  67715. tube?: number;
  67716. radialSegments?: number;
  67717. tubularSegments?: number;
  67718. p?: number;
  67719. q?: number;
  67720. updatable?: boolean;
  67721. sideOrientation?: number;
  67722. frontUVs?: Vector4;
  67723. backUVs?: Vector4;
  67724. }, scene: any): Mesh;
  67725. }
  67726. }
  67727. declare module "babylonjs/Meshes/polygonMesh" {
  67728. import { Scene } from "babylonjs/scene";
  67729. import { Vector2 } from "babylonjs/Maths/math.vector";
  67730. import { Mesh } from "babylonjs/Meshes/mesh";
  67731. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67732. import { Path2 } from "babylonjs/Maths/math.path";
  67733. /**
  67734. * Polygon
  67735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67736. */
  67737. export class Polygon {
  67738. /**
  67739. * Creates a rectangle
  67740. * @param xmin bottom X coord
  67741. * @param ymin bottom Y coord
  67742. * @param xmax top X coord
  67743. * @param ymax top Y coord
  67744. * @returns points that make the resulting rectation
  67745. */
  67746. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67747. /**
  67748. * Creates a circle
  67749. * @param radius radius of circle
  67750. * @param cx scale in x
  67751. * @param cy scale in y
  67752. * @param numberOfSides number of sides that make up the circle
  67753. * @returns points that make the resulting circle
  67754. */
  67755. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67756. /**
  67757. * Creates a polygon from input string
  67758. * @param input Input polygon data
  67759. * @returns the parsed points
  67760. */
  67761. static Parse(input: string): Vector2[];
  67762. /**
  67763. * Starts building a polygon from x and y coordinates
  67764. * @param x x coordinate
  67765. * @param y y coordinate
  67766. * @returns the started path2
  67767. */
  67768. static StartingAt(x: number, y: number): Path2;
  67769. }
  67770. /**
  67771. * Builds a polygon
  67772. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67773. */
  67774. export class PolygonMeshBuilder {
  67775. private _points;
  67776. private _outlinepoints;
  67777. private _holes;
  67778. private _name;
  67779. private _scene;
  67780. private _epoints;
  67781. private _eholes;
  67782. private _addToepoint;
  67783. /**
  67784. * Babylon reference to the earcut plugin.
  67785. */
  67786. bjsEarcut: any;
  67787. /**
  67788. * Creates a PolygonMeshBuilder
  67789. * @param name name of the builder
  67790. * @param contours Path of the polygon
  67791. * @param scene scene to add to when creating the mesh
  67792. * @param earcutInjection can be used to inject your own earcut reference
  67793. */
  67794. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67795. /**
  67796. * Adds a whole within the polygon
  67797. * @param hole Array of points defining the hole
  67798. * @returns this
  67799. */
  67800. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67801. /**
  67802. * Creates the polygon
  67803. * @param updatable If the mesh should be updatable
  67804. * @param depth The depth of the mesh created
  67805. * @returns the created mesh
  67806. */
  67807. build(updatable?: boolean, depth?: number): Mesh;
  67808. /**
  67809. * Creates the polygon
  67810. * @param depth The depth of the mesh created
  67811. * @returns the created VertexData
  67812. */
  67813. buildVertexData(depth?: number): VertexData;
  67814. /**
  67815. * Adds a side to the polygon
  67816. * @param positions points that make the polygon
  67817. * @param normals normals of the polygon
  67818. * @param uvs uvs of the polygon
  67819. * @param indices indices of the polygon
  67820. * @param bounds bounds of the polygon
  67821. * @param points points of the polygon
  67822. * @param depth depth of the polygon
  67823. * @param flip flip of the polygon
  67824. */
  67825. private addSide;
  67826. }
  67827. }
  67828. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67829. import { Scene } from "babylonjs/scene";
  67830. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67831. import { Color4 } from "babylonjs/Maths/math.color";
  67832. import { Mesh } from "babylonjs/Meshes/mesh";
  67833. import { Nullable } from "babylonjs/types";
  67834. /**
  67835. * Class containing static functions to help procedurally build meshes
  67836. */
  67837. export class PolygonBuilder {
  67838. /**
  67839. * Creates a polygon mesh
  67840. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67841. * * 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
  67842. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67845. * * Remember you can only change the shape positions, not their number when updating a polygon
  67846. * @param name defines the name of the mesh
  67847. * @param options defines the options used to create the mesh
  67848. * @param scene defines the hosting scene
  67849. * @param earcutInjection can be used to inject your own earcut reference
  67850. * @returns the polygon mesh
  67851. */
  67852. static CreatePolygon(name: string, options: {
  67853. shape: Vector3[];
  67854. holes?: Vector3[][];
  67855. depth?: number;
  67856. faceUV?: Vector4[];
  67857. faceColors?: Color4[];
  67858. updatable?: boolean;
  67859. sideOrientation?: number;
  67860. frontUVs?: Vector4;
  67861. backUVs?: Vector4;
  67862. wrap?: boolean;
  67863. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67864. /**
  67865. * Creates an extruded polygon mesh, with depth in the Y direction.
  67866. * * 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)
  67867. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67868. * @param name defines the name of the mesh
  67869. * @param options defines the options used to create the mesh
  67870. * @param scene defines the hosting scene
  67871. * @param earcutInjection can be used to inject your own earcut reference
  67872. * @returns the polygon mesh
  67873. */
  67874. static ExtrudePolygon(name: string, options: {
  67875. shape: Vector3[];
  67876. holes?: Vector3[][];
  67877. depth?: number;
  67878. faceUV?: Vector4[];
  67879. faceColors?: Color4[];
  67880. updatable?: boolean;
  67881. sideOrientation?: number;
  67882. frontUVs?: Vector4;
  67883. backUVs?: Vector4;
  67884. wrap?: boolean;
  67885. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67886. }
  67887. }
  67888. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67889. import { Scene } from "babylonjs/scene";
  67890. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67891. import { Mesh } from "babylonjs/Meshes/mesh";
  67892. import { Nullable } from "babylonjs/types";
  67893. /**
  67894. * Class containing static functions to help procedurally build meshes
  67895. */
  67896. export class LatheBuilder {
  67897. /**
  67898. * Creates lathe mesh.
  67899. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67900. * * 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
  67901. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67902. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67903. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67904. * * 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
  67905. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67906. * * 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
  67907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67911. * @param name defines the name of the mesh
  67912. * @param options defines the options used to create the mesh
  67913. * @param scene defines the hosting scene
  67914. * @returns the lathe mesh
  67915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67916. */
  67917. static CreateLathe(name: string, options: {
  67918. shape: Vector3[];
  67919. radius?: number;
  67920. tessellation?: number;
  67921. clip?: number;
  67922. arc?: number;
  67923. closed?: boolean;
  67924. updatable?: boolean;
  67925. sideOrientation?: number;
  67926. frontUVs?: Vector4;
  67927. backUVs?: Vector4;
  67928. cap?: number;
  67929. invertUV?: boolean;
  67930. }, scene?: Nullable<Scene>): Mesh;
  67931. }
  67932. }
  67933. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67934. import { Nullable } from "babylonjs/types";
  67935. import { Scene } from "babylonjs/scene";
  67936. import { Vector4 } from "babylonjs/Maths/math.vector";
  67937. import { Mesh } from "babylonjs/Meshes/mesh";
  67938. /**
  67939. * Class containing static functions to help procedurally build meshes
  67940. */
  67941. export class TiledPlaneBuilder {
  67942. /**
  67943. * Creates a tiled plane mesh
  67944. * * The parameter `pattern` will, depending on value, do nothing or
  67945. * * * flip (reflect about central vertical) alternate tiles across and up
  67946. * * * flip every tile on alternate rows
  67947. * * * rotate (180 degs) alternate tiles across and up
  67948. * * * rotate every tile on alternate rows
  67949. * * * flip and rotate alternate tiles across and up
  67950. * * * flip and rotate every tile on alternate rows
  67951. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67952. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67955. * * 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)
  67956. * * 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)
  67957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67958. * @param name defines the name of the mesh
  67959. * @param options defines the options used to create the mesh
  67960. * @param scene defines the hosting scene
  67961. * @returns the box mesh
  67962. */
  67963. static CreateTiledPlane(name: string, options: {
  67964. pattern?: number;
  67965. tileSize?: number;
  67966. tileWidth?: number;
  67967. tileHeight?: number;
  67968. size?: number;
  67969. width?: number;
  67970. height?: number;
  67971. alignHorizontal?: number;
  67972. alignVertical?: number;
  67973. sideOrientation?: number;
  67974. frontUVs?: Vector4;
  67975. backUVs?: Vector4;
  67976. updatable?: boolean;
  67977. }, scene?: Nullable<Scene>): Mesh;
  67978. }
  67979. }
  67980. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67981. import { Nullable } from "babylonjs/types";
  67982. import { Scene } from "babylonjs/scene";
  67983. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67984. import { Mesh } from "babylonjs/Meshes/mesh";
  67985. /**
  67986. * Class containing static functions to help procedurally build meshes
  67987. */
  67988. export class TubeBuilder {
  67989. /**
  67990. * Creates a tube mesh.
  67991. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67992. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67993. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67994. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67995. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67996. * * 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)
  67997. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67998. * * 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
  67999. * * 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
  68000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68004. * @param name defines the name of the mesh
  68005. * @param options defines the options used to create the mesh
  68006. * @param scene defines the hosting scene
  68007. * @returns the tube mesh
  68008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68009. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68010. */
  68011. static CreateTube(name: string, options: {
  68012. path: Vector3[];
  68013. radius?: number;
  68014. tessellation?: number;
  68015. radiusFunction?: {
  68016. (i: number, distance: number): number;
  68017. };
  68018. cap?: number;
  68019. arc?: number;
  68020. updatable?: boolean;
  68021. sideOrientation?: number;
  68022. frontUVs?: Vector4;
  68023. backUVs?: Vector4;
  68024. instance?: Mesh;
  68025. invertUV?: boolean;
  68026. }, scene?: Nullable<Scene>): Mesh;
  68027. }
  68028. }
  68029. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68030. import { Scene } from "babylonjs/scene";
  68031. import { Vector4 } from "babylonjs/Maths/math.vector";
  68032. import { Mesh } from "babylonjs/Meshes/mesh";
  68033. import { Nullable } from "babylonjs/types";
  68034. /**
  68035. * Class containing static functions to help procedurally build meshes
  68036. */
  68037. export class IcoSphereBuilder {
  68038. /**
  68039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68041. * * 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`)
  68042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68043. * * 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
  68044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68047. * @param name defines the name of the mesh
  68048. * @param options defines the options used to create the mesh
  68049. * @param scene defines the hosting scene
  68050. * @returns the icosahedron mesh
  68051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68052. */
  68053. static CreateIcoSphere(name: string, options: {
  68054. radius?: number;
  68055. radiusX?: number;
  68056. radiusY?: number;
  68057. radiusZ?: number;
  68058. flat?: boolean;
  68059. subdivisions?: number;
  68060. sideOrientation?: number;
  68061. frontUVs?: Vector4;
  68062. backUVs?: Vector4;
  68063. updatable?: boolean;
  68064. }, scene?: Nullable<Scene>): Mesh;
  68065. }
  68066. }
  68067. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68068. import { Vector3 } from "babylonjs/Maths/math.vector";
  68069. import { Mesh } from "babylonjs/Meshes/mesh";
  68070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68071. /**
  68072. * Class containing static functions to help procedurally build meshes
  68073. */
  68074. export class DecalBuilder {
  68075. /**
  68076. * Creates a decal mesh.
  68077. * 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
  68078. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68079. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68080. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68081. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68082. * @param name defines the name of the mesh
  68083. * @param sourceMesh defines the mesh where the decal must be applied
  68084. * @param options defines the options used to create the mesh
  68085. * @param scene defines the hosting scene
  68086. * @returns the decal mesh
  68087. * @see https://doc.babylonjs.com/how_to/decals
  68088. */
  68089. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68090. position?: Vector3;
  68091. normal?: Vector3;
  68092. size?: Vector3;
  68093. angle?: number;
  68094. }): Mesh;
  68095. }
  68096. }
  68097. declare module "babylonjs/Meshes/meshBuilder" {
  68098. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68099. import { Nullable } from "babylonjs/types";
  68100. import { Scene } from "babylonjs/scene";
  68101. import { Mesh } from "babylonjs/Meshes/mesh";
  68102. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68103. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68105. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68106. import { Plane } from "babylonjs/Maths/math.plane";
  68107. /**
  68108. * Class containing static functions to help procedurally build meshes
  68109. */
  68110. export class MeshBuilder {
  68111. /**
  68112. * Creates a box mesh
  68113. * * The parameter `size` sets the size (float) of each box side (default 1)
  68114. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68115. * * 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)
  68116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68120. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68121. * @param name defines the name of the mesh
  68122. * @param options defines the options used to create the mesh
  68123. * @param scene defines the hosting scene
  68124. * @returns the box mesh
  68125. */
  68126. static CreateBox(name: string, options: {
  68127. size?: number;
  68128. width?: number;
  68129. height?: number;
  68130. depth?: number;
  68131. faceUV?: Vector4[];
  68132. faceColors?: Color4[];
  68133. sideOrientation?: number;
  68134. frontUVs?: Vector4;
  68135. backUVs?: Vector4;
  68136. wrap?: boolean;
  68137. topBaseAt?: number;
  68138. bottomBaseAt?: number;
  68139. updatable?: boolean;
  68140. }, scene?: Nullable<Scene>): Mesh;
  68141. /**
  68142. * Creates a tiled box mesh
  68143. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68145. * @param name defines the name of the mesh
  68146. * @param options defines the options used to create the mesh
  68147. * @param scene defines the hosting scene
  68148. * @returns the tiled box mesh
  68149. */
  68150. static CreateTiledBox(name: string, options: {
  68151. pattern?: number;
  68152. size?: number;
  68153. width?: number;
  68154. height?: number;
  68155. depth: number;
  68156. tileSize?: number;
  68157. tileWidth?: number;
  68158. tileHeight?: number;
  68159. faceUV?: Vector4[];
  68160. faceColors?: Color4[];
  68161. alignHorizontal?: number;
  68162. alignVertical?: number;
  68163. sideOrientation?: number;
  68164. updatable?: boolean;
  68165. }, scene?: Nullable<Scene>): Mesh;
  68166. /**
  68167. * Creates a sphere mesh
  68168. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68169. * * 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`)
  68170. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68171. * * 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
  68172. * * 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)
  68173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68176. * @param name defines the name of the mesh
  68177. * @param options defines the options used to create the mesh
  68178. * @param scene defines the hosting scene
  68179. * @returns the sphere mesh
  68180. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68181. */
  68182. static CreateSphere(name: string, options: {
  68183. segments?: number;
  68184. diameter?: number;
  68185. diameterX?: number;
  68186. diameterY?: number;
  68187. diameterZ?: number;
  68188. arc?: number;
  68189. slice?: number;
  68190. sideOrientation?: number;
  68191. frontUVs?: Vector4;
  68192. backUVs?: Vector4;
  68193. updatable?: boolean;
  68194. }, scene?: Nullable<Scene>): Mesh;
  68195. /**
  68196. * Creates a plane polygonal mesh. By default, this is a disc
  68197. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68198. * * 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
  68199. * * 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
  68200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68203. * @param name defines the name of the mesh
  68204. * @param options defines the options used to create the mesh
  68205. * @param scene defines the hosting scene
  68206. * @returns the plane polygonal mesh
  68207. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68208. */
  68209. static CreateDisc(name: string, options: {
  68210. radius?: number;
  68211. tessellation?: number;
  68212. arc?: number;
  68213. updatable?: boolean;
  68214. sideOrientation?: number;
  68215. frontUVs?: Vector4;
  68216. backUVs?: Vector4;
  68217. }, scene?: Nullable<Scene>): Mesh;
  68218. /**
  68219. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68220. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68221. * * 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`)
  68222. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68223. * * 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
  68224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68227. * @param name defines the name of the mesh
  68228. * @param options defines the options used to create the mesh
  68229. * @param scene defines the hosting scene
  68230. * @returns the icosahedron mesh
  68231. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68232. */
  68233. static CreateIcoSphere(name: string, options: {
  68234. radius?: number;
  68235. radiusX?: number;
  68236. radiusY?: number;
  68237. radiusZ?: number;
  68238. flat?: boolean;
  68239. subdivisions?: number;
  68240. sideOrientation?: number;
  68241. frontUVs?: Vector4;
  68242. backUVs?: Vector4;
  68243. updatable?: boolean;
  68244. }, scene?: Nullable<Scene>): Mesh;
  68245. /**
  68246. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68247. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68248. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68249. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68250. * * 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
  68251. * * 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
  68252. * * 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
  68253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68256. * * 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
  68257. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68258. * * 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
  68259. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68261. * @param name defines the name of the mesh
  68262. * @param options defines the options used to create the mesh
  68263. * @param scene defines the hosting scene
  68264. * @returns the ribbon mesh
  68265. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68267. */
  68268. static CreateRibbon(name: string, options: {
  68269. pathArray: Vector3[][];
  68270. closeArray?: boolean;
  68271. closePath?: boolean;
  68272. offset?: number;
  68273. updatable?: boolean;
  68274. sideOrientation?: number;
  68275. frontUVs?: Vector4;
  68276. backUVs?: Vector4;
  68277. instance?: Mesh;
  68278. invertUV?: boolean;
  68279. uvs?: Vector2[];
  68280. colors?: Color4[];
  68281. }, scene?: Nullable<Scene>): Mesh;
  68282. /**
  68283. * Creates a cylinder or a cone mesh
  68284. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68285. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68286. * * 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.
  68287. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68288. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68289. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68290. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68291. * * 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).
  68292. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68293. * * 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).
  68294. * * 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
  68295. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68296. * * 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
  68297. * * 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.
  68298. * * If `enclose` is false, a ring surface is one element.
  68299. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68300. * * 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
  68301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68304. * @param name defines the name of the mesh
  68305. * @param options defines the options used to create the mesh
  68306. * @param scene defines the hosting scene
  68307. * @returns the cylinder mesh
  68308. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68309. */
  68310. static CreateCylinder(name: string, options: {
  68311. height?: number;
  68312. diameterTop?: number;
  68313. diameterBottom?: number;
  68314. diameter?: number;
  68315. tessellation?: number;
  68316. subdivisions?: number;
  68317. arc?: number;
  68318. faceColors?: Color4[];
  68319. faceUV?: Vector4[];
  68320. updatable?: boolean;
  68321. hasRings?: boolean;
  68322. enclose?: boolean;
  68323. cap?: number;
  68324. sideOrientation?: number;
  68325. frontUVs?: Vector4;
  68326. backUVs?: Vector4;
  68327. }, scene?: Nullable<Scene>): Mesh;
  68328. /**
  68329. * Creates a torus mesh
  68330. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68331. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68332. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68336. * @param name defines the name of the mesh
  68337. * @param options defines the options used to create the mesh
  68338. * @param scene defines the hosting scene
  68339. * @returns the torus mesh
  68340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68341. */
  68342. static CreateTorus(name: string, options: {
  68343. diameter?: number;
  68344. thickness?: number;
  68345. tessellation?: number;
  68346. updatable?: boolean;
  68347. sideOrientation?: number;
  68348. frontUVs?: Vector4;
  68349. backUVs?: Vector4;
  68350. }, scene?: Nullable<Scene>): Mesh;
  68351. /**
  68352. * Creates a torus knot mesh
  68353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68360. * @param name defines the name of the mesh
  68361. * @param options defines the options used to create the mesh
  68362. * @param scene defines the hosting scene
  68363. * @returns the torus knot mesh
  68364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68365. */
  68366. static CreateTorusKnot(name: string, options: {
  68367. radius?: number;
  68368. tube?: number;
  68369. radialSegments?: number;
  68370. tubularSegments?: number;
  68371. p?: number;
  68372. q?: number;
  68373. updatable?: boolean;
  68374. sideOrientation?: number;
  68375. frontUVs?: Vector4;
  68376. backUVs?: Vector4;
  68377. }, scene?: Nullable<Scene>): Mesh;
  68378. /**
  68379. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68380. * * 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
  68381. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68382. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68383. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68384. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68386. * * 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
  68387. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68390. * @param name defines the name of the new line system
  68391. * @param options defines the options used to create the line system
  68392. * @param scene defines the hosting scene
  68393. * @returns a new line system mesh
  68394. */
  68395. static CreateLineSystem(name: string, options: {
  68396. lines: Vector3[][];
  68397. updatable?: boolean;
  68398. instance?: Nullable<LinesMesh>;
  68399. colors?: Nullable<Color4[][]>;
  68400. useVertexAlpha?: boolean;
  68401. }, scene: Nullable<Scene>): LinesMesh;
  68402. /**
  68403. * Creates a line mesh
  68404. * 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
  68405. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68406. * * The parameter `points` is an array successive Vector3
  68407. * * 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
  68408. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68410. * * When updating an instance, remember that only point positions can change, not the number of points
  68411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68413. * @param name defines the name of the new line system
  68414. * @param options defines the options used to create the line system
  68415. * @param scene defines the hosting scene
  68416. * @returns a new line mesh
  68417. */
  68418. static CreateLines(name: string, options: {
  68419. points: Vector3[];
  68420. updatable?: boolean;
  68421. instance?: Nullable<LinesMesh>;
  68422. colors?: Color4[];
  68423. useVertexAlpha?: boolean;
  68424. }, scene?: Nullable<Scene>): LinesMesh;
  68425. /**
  68426. * Creates a dashed line mesh
  68427. * * 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
  68428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68429. * * The parameter `points` is an array successive Vector3
  68430. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68431. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68432. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68433. * * 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
  68434. * * When updating an instance, remember that only point positions can change, not the number of points
  68435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68436. * @param name defines the name of the mesh
  68437. * @param options defines the options used to create the mesh
  68438. * @param scene defines the hosting scene
  68439. * @returns the dashed line mesh
  68440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68441. */
  68442. static CreateDashedLines(name: string, options: {
  68443. points: Vector3[];
  68444. dashSize?: number;
  68445. gapSize?: number;
  68446. dashNb?: number;
  68447. updatable?: boolean;
  68448. instance?: LinesMesh;
  68449. }, scene?: Nullable<Scene>): LinesMesh;
  68450. /**
  68451. * 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.
  68452. * * 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.
  68453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68454. * * 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.
  68455. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68456. * * 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
  68457. * * 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
  68458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68463. * @param name defines the name of the mesh
  68464. * @param options defines the options used to create the mesh
  68465. * @param scene defines the hosting scene
  68466. * @returns the extruded shape mesh
  68467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68469. */
  68470. static ExtrudeShape(name: string, options: {
  68471. shape: Vector3[];
  68472. path: Vector3[];
  68473. scale?: number;
  68474. rotation?: number;
  68475. cap?: number;
  68476. updatable?: boolean;
  68477. sideOrientation?: number;
  68478. frontUVs?: Vector4;
  68479. backUVs?: Vector4;
  68480. instance?: Mesh;
  68481. invertUV?: boolean;
  68482. }, scene?: Nullable<Scene>): Mesh;
  68483. /**
  68484. * Creates an custom extruded shape mesh.
  68485. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68486. * * 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.
  68487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68488. * * 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
  68489. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68490. * * 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
  68491. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68492. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68493. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68494. * * 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
  68495. * * 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
  68496. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68501. * @param name defines the name of the mesh
  68502. * @param options defines the options used to create the mesh
  68503. * @param scene defines the hosting scene
  68504. * @returns the custom extruded shape mesh
  68505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68508. */
  68509. static ExtrudeShapeCustom(name: string, options: {
  68510. shape: Vector3[];
  68511. path: Vector3[];
  68512. scaleFunction?: any;
  68513. rotationFunction?: any;
  68514. ribbonCloseArray?: boolean;
  68515. ribbonClosePath?: boolean;
  68516. cap?: number;
  68517. updatable?: boolean;
  68518. sideOrientation?: number;
  68519. frontUVs?: Vector4;
  68520. backUVs?: Vector4;
  68521. instance?: Mesh;
  68522. invertUV?: boolean;
  68523. }, scene?: Nullable<Scene>): Mesh;
  68524. /**
  68525. * Creates lathe mesh.
  68526. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68527. * * 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
  68528. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68529. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68530. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68531. * * 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
  68532. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68533. * * 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
  68534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68538. * @param name defines the name of the mesh
  68539. * @param options defines the options used to create the mesh
  68540. * @param scene defines the hosting scene
  68541. * @returns the lathe mesh
  68542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68543. */
  68544. static CreateLathe(name: string, options: {
  68545. shape: Vector3[];
  68546. radius?: number;
  68547. tessellation?: number;
  68548. clip?: number;
  68549. arc?: number;
  68550. closed?: boolean;
  68551. updatable?: boolean;
  68552. sideOrientation?: number;
  68553. frontUVs?: Vector4;
  68554. backUVs?: Vector4;
  68555. cap?: number;
  68556. invertUV?: boolean;
  68557. }, scene?: Nullable<Scene>): Mesh;
  68558. /**
  68559. * Creates a tiled plane mesh
  68560. * * You can set a limited pattern arrangement with the tiles
  68561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68564. * @param name defines the name of the mesh
  68565. * @param options defines the options used to create the mesh
  68566. * @param scene defines the hosting scene
  68567. * @returns the plane mesh
  68568. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68569. */
  68570. static CreateTiledPlane(name: string, options: {
  68571. pattern?: number;
  68572. tileSize?: number;
  68573. tileWidth?: number;
  68574. tileHeight?: number;
  68575. size?: number;
  68576. width?: number;
  68577. height?: number;
  68578. alignHorizontal?: number;
  68579. alignVertical?: number;
  68580. sideOrientation?: number;
  68581. frontUVs?: Vector4;
  68582. backUVs?: Vector4;
  68583. updatable?: boolean;
  68584. }, scene?: Nullable<Scene>): Mesh;
  68585. /**
  68586. * Creates a plane mesh
  68587. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68588. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68589. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68593. * @param name defines the name of the mesh
  68594. * @param options defines the options used to create the mesh
  68595. * @param scene defines the hosting scene
  68596. * @returns the plane mesh
  68597. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68598. */
  68599. static CreatePlane(name: string, options: {
  68600. size?: number;
  68601. width?: number;
  68602. height?: number;
  68603. sideOrientation?: number;
  68604. frontUVs?: Vector4;
  68605. backUVs?: Vector4;
  68606. updatable?: boolean;
  68607. sourcePlane?: Plane;
  68608. }, scene?: Nullable<Scene>): Mesh;
  68609. /**
  68610. * Creates a ground mesh
  68611. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68612. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68614. * @param name defines the name of the mesh
  68615. * @param options defines the options used to create the mesh
  68616. * @param scene defines the hosting scene
  68617. * @returns the ground mesh
  68618. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68619. */
  68620. static CreateGround(name: string, options: {
  68621. width?: number;
  68622. height?: number;
  68623. subdivisions?: number;
  68624. subdivisionsX?: number;
  68625. subdivisionsY?: number;
  68626. updatable?: boolean;
  68627. }, scene?: Nullable<Scene>): Mesh;
  68628. /**
  68629. * Creates a tiled ground mesh
  68630. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68631. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68632. * * 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
  68633. * * 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
  68634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68635. * @param name defines the name of the mesh
  68636. * @param options defines the options used to create the mesh
  68637. * @param scene defines the hosting scene
  68638. * @returns the tiled ground mesh
  68639. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68640. */
  68641. static CreateTiledGround(name: string, options: {
  68642. xmin: number;
  68643. zmin: number;
  68644. xmax: number;
  68645. zmax: number;
  68646. subdivisions?: {
  68647. w: number;
  68648. h: number;
  68649. };
  68650. precision?: {
  68651. w: number;
  68652. h: number;
  68653. };
  68654. updatable?: boolean;
  68655. }, scene?: Nullable<Scene>): Mesh;
  68656. /**
  68657. * Creates a ground mesh from a height map
  68658. * * The parameter `url` sets the URL of the height map image resource.
  68659. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68660. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68661. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68662. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68663. * * 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.
  68664. * * 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).
  68665. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68667. * @param name defines the name of the mesh
  68668. * @param url defines the url to the height map
  68669. * @param options defines the options used to create the mesh
  68670. * @param scene defines the hosting scene
  68671. * @returns the ground mesh
  68672. * @see https://doc.babylonjs.com/babylon101/height_map
  68673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68674. */
  68675. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68676. width?: number;
  68677. height?: number;
  68678. subdivisions?: number;
  68679. minHeight?: number;
  68680. maxHeight?: number;
  68681. colorFilter?: Color3;
  68682. alphaFilter?: number;
  68683. updatable?: boolean;
  68684. onReady?: (mesh: GroundMesh) => void;
  68685. }, scene?: Nullable<Scene>): GroundMesh;
  68686. /**
  68687. * Creates a polygon mesh
  68688. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68689. * * 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
  68690. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68693. * * Remember you can only change the shape positions, not their number when updating a polygon
  68694. * @param name defines the name of the mesh
  68695. * @param options defines the options used to create the mesh
  68696. * @param scene defines the hosting scene
  68697. * @param earcutInjection can be used to inject your own earcut reference
  68698. * @returns the polygon mesh
  68699. */
  68700. static CreatePolygon(name: string, options: {
  68701. shape: Vector3[];
  68702. holes?: Vector3[][];
  68703. depth?: number;
  68704. faceUV?: Vector4[];
  68705. faceColors?: Color4[];
  68706. updatable?: boolean;
  68707. sideOrientation?: number;
  68708. frontUVs?: Vector4;
  68709. backUVs?: Vector4;
  68710. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68711. /**
  68712. * Creates an extruded polygon mesh, with depth in the Y direction.
  68713. * * 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)
  68714. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68715. * @param name defines the name of the mesh
  68716. * @param options defines the options used to create the mesh
  68717. * @param scene defines the hosting scene
  68718. * @param earcutInjection can be used to inject your own earcut reference
  68719. * @returns the polygon mesh
  68720. */
  68721. static ExtrudePolygon(name: string, options: {
  68722. shape: Vector3[];
  68723. holes?: Vector3[][];
  68724. depth?: number;
  68725. faceUV?: Vector4[];
  68726. faceColors?: Color4[];
  68727. updatable?: boolean;
  68728. sideOrientation?: number;
  68729. frontUVs?: Vector4;
  68730. backUVs?: Vector4;
  68731. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68732. /**
  68733. * Creates a tube mesh.
  68734. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68735. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68736. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68737. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68738. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68739. * * 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)
  68740. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68741. * * 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
  68742. * * 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
  68743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68747. * @param name defines the name of the mesh
  68748. * @param options defines the options used to create the mesh
  68749. * @param scene defines the hosting scene
  68750. * @returns the tube mesh
  68751. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68752. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68753. */
  68754. static CreateTube(name: string, options: {
  68755. path: Vector3[];
  68756. radius?: number;
  68757. tessellation?: number;
  68758. radiusFunction?: {
  68759. (i: number, distance: number): number;
  68760. };
  68761. cap?: number;
  68762. arc?: number;
  68763. updatable?: boolean;
  68764. sideOrientation?: number;
  68765. frontUVs?: Vector4;
  68766. backUVs?: Vector4;
  68767. instance?: Mesh;
  68768. invertUV?: boolean;
  68769. }, scene?: Nullable<Scene>): Mesh;
  68770. /**
  68771. * Creates a polyhedron mesh
  68772. * * 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
  68773. * * The parameter `size` (positive float, default 1) sets the polygon size
  68774. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68775. * * 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`
  68776. * * 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
  68777. * * 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)`)
  68778. * * 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
  68779. * * 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
  68780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68783. * @param name defines the name of the mesh
  68784. * @param options defines the options used to create the mesh
  68785. * @param scene defines the hosting scene
  68786. * @returns the polyhedron mesh
  68787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68788. */
  68789. static CreatePolyhedron(name: string, options: {
  68790. type?: number;
  68791. size?: number;
  68792. sizeX?: number;
  68793. sizeY?: number;
  68794. sizeZ?: number;
  68795. custom?: any;
  68796. faceUV?: Vector4[];
  68797. faceColors?: Color4[];
  68798. flat?: boolean;
  68799. updatable?: boolean;
  68800. sideOrientation?: number;
  68801. frontUVs?: Vector4;
  68802. backUVs?: Vector4;
  68803. }, scene?: Nullable<Scene>): Mesh;
  68804. /**
  68805. * Creates a decal mesh.
  68806. * 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
  68807. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68808. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68809. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68810. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68811. * @param name defines the name of the mesh
  68812. * @param sourceMesh defines the mesh where the decal must be applied
  68813. * @param options defines the options used to create the mesh
  68814. * @param scene defines the hosting scene
  68815. * @returns the decal mesh
  68816. * @see https://doc.babylonjs.com/how_to/decals
  68817. */
  68818. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68819. position?: Vector3;
  68820. normal?: Vector3;
  68821. size?: Vector3;
  68822. angle?: number;
  68823. }): Mesh;
  68824. }
  68825. }
  68826. declare module "babylonjs/Meshes/meshSimplification" {
  68827. import { Mesh } from "babylonjs/Meshes/mesh";
  68828. /**
  68829. * A simplifier interface for future simplification implementations
  68830. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68831. */
  68832. export interface ISimplifier {
  68833. /**
  68834. * Simplification of a given mesh according to the given settings.
  68835. * Since this requires computation, it is assumed that the function runs async.
  68836. * @param settings The settings of the simplification, including quality and distance
  68837. * @param successCallback A callback that will be called after the mesh was simplified.
  68838. * @param errorCallback in case of an error, this callback will be called. optional.
  68839. */
  68840. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68841. }
  68842. /**
  68843. * Expected simplification settings.
  68844. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68845. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68846. */
  68847. export interface ISimplificationSettings {
  68848. /**
  68849. * Gets or sets the expected quality
  68850. */
  68851. quality: number;
  68852. /**
  68853. * Gets or sets the distance when this optimized version should be used
  68854. */
  68855. distance: number;
  68856. /**
  68857. * Gets an already optimized mesh
  68858. */
  68859. optimizeMesh?: boolean;
  68860. }
  68861. /**
  68862. * Class used to specify simplification options
  68863. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68864. */
  68865. export class SimplificationSettings implements ISimplificationSettings {
  68866. /** expected quality */
  68867. quality: number;
  68868. /** distance when this optimized version should be used */
  68869. distance: number;
  68870. /** already optimized mesh */
  68871. optimizeMesh?: boolean | undefined;
  68872. /**
  68873. * Creates a SimplificationSettings
  68874. * @param quality expected quality
  68875. * @param distance distance when this optimized version should be used
  68876. * @param optimizeMesh already optimized mesh
  68877. */
  68878. constructor(
  68879. /** expected quality */
  68880. quality: number,
  68881. /** distance when this optimized version should be used */
  68882. distance: number,
  68883. /** already optimized mesh */
  68884. optimizeMesh?: boolean | undefined);
  68885. }
  68886. /**
  68887. * Interface used to define a simplification task
  68888. */
  68889. export interface ISimplificationTask {
  68890. /**
  68891. * Array of settings
  68892. */
  68893. settings: Array<ISimplificationSettings>;
  68894. /**
  68895. * Simplification type
  68896. */
  68897. simplificationType: SimplificationType;
  68898. /**
  68899. * Mesh to simplify
  68900. */
  68901. mesh: Mesh;
  68902. /**
  68903. * Callback called on success
  68904. */
  68905. successCallback?: () => void;
  68906. /**
  68907. * Defines if parallel processing can be used
  68908. */
  68909. parallelProcessing: boolean;
  68910. }
  68911. /**
  68912. * Queue used to order the simplification tasks
  68913. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68914. */
  68915. export class SimplificationQueue {
  68916. private _simplificationArray;
  68917. /**
  68918. * Gets a boolean indicating that the process is still running
  68919. */
  68920. running: boolean;
  68921. /**
  68922. * Creates a new queue
  68923. */
  68924. constructor();
  68925. /**
  68926. * Adds a new simplification task
  68927. * @param task defines a task to add
  68928. */
  68929. addTask(task: ISimplificationTask): void;
  68930. /**
  68931. * Execute next task
  68932. */
  68933. executeNext(): void;
  68934. /**
  68935. * Execute a simplification task
  68936. * @param task defines the task to run
  68937. */
  68938. runSimplification(task: ISimplificationTask): void;
  68939. private getSimplifier;
  68940. }
  68941. /**
  68942. * The implemented types of simplification
  68943. * At the moment only Quadratic Error Decimation is implemented
  68944. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68945. */
  68946. export enum SimplificationType {
  68947. /** Quadratic error decimation */
  68948. QUADRATIC = 0
  68949. }
  68950. /**
  68951. * An implementation of the Quadratic Error simplification algorithm.
  68952. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68953. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68954. * @author RaananW
  68955. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68956. */
  68957. export class QuadraticErrorSimplification implements ISimplifier {
  68958. private _mesh;
  68959. private triangles;
  68960. private vertices;
  68961. private references;
  68962. private _reconstructedMesh;
  68963. /** Gets or sets the number pf sync interations */
  68964. syncIterations: number;
  68965. /** Gets or sets the aggressiveness of the simplifier */
  68966. aggressiveness: number;
  68967. /** Gets or sets the number of allowed iterations for decimation */
  68968. decimationIterations: number;
  68969. /** Gets or sets the espilon to use for bounding box computation */
  68970. boundingBoxEpsilon: number;
  68971. /**
  68972. * Creates a new QuadraticErrorSimplification
  68973. * @param _mesh defines the target mesh
  68974. */
  68975. constructor(_mesh: Mesh);
  68976. /**
  68977. * Simplification of a given mesh according to the given settings.
  68978. * Since this requires computation, it is assumed that the function runs async.
  68979. * @param settings The settings of the simplification, including quality and distance
  68980. * @param successCallback A callback that will be called after the mesh was simplified.
  68981. */
  68982. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68983. private runDecimation;
  68984. private initWithMesh;
  68985. private init;
  68986. private reconstructMesh;
  68987. private initDecimatedMesh;
  68988. private isFlipped;
  68989. private updateTriangles;
  68990. private identifyBorder;
  68991. private updateMesh;
  68992. private vertexError;
  68993. private calculateError;
  68994. }
  68995. }
  68996. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68997. import { Scene } from "babylonjs/scene";
  68998. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68999. import { ISceneComponent } from "babylonjs/sceneComponent";
  69000. module "babylonjs/scene" {
  69001. interface Scene {
  69002. /** @hidden (Backing field) */
  69003. _simplificationQueue: SimplificationQueue;
  69004. /**
  69005. * Gets or sets the simplification queue attached to the scene
  69006. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69007. */
  69008. simplificationQueue: SimplificationQueue;
  69009. }
  69010. }
  69011. module "babylonjs/Meshes/mesh" {
  69012. interface Mesh {
  69013. /**
  69014. * Simplify the mesh according to the given array of settings.
  69015. * Function will return immediately and will simplify async
  69016. * @param settings a collection of simplification settings
  69017. * @param parallelProcessing should all levels calculate parallel or one after the other
  69018. * @param simplificationType the type of simplification to run
  69019. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69020. * @returns the current mesh
  69021. */
  69022. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69023. }
  69024. }
  69025. /**
  69026. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69027. * created in a scene
  69028. */
  69029. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69030. /**
  69031. * The component name helpfull to identify the component in the list of scene components.
  69032. */
  69033. readonly name: string;
  69034. /**
  69035. * The scene the component belongs to.
  69036. */
  69037. scene: Scene;
  69038. /**
  69039. * Creates a new instance of the component for the given scene
  69040. * @param scene Defines the scene to register the component in
  69041. */
  69042. constructor(scene: Scene);
  69043. /**
  69044. * Registers the component in a given scene
  69045. */
  69046. register(): void;
  69047. /**
  69048. * Rebuilds the elements related to this component in case of
  69049. * context lost for instance.
  69050. */
  69051. rebuild(): void;
  69052. /**
  69053. * Disposes the component and the associated ressources
  69054. */
  69055. dispose(): void;
  69056. private _beforeCameraUpdate;
  69057. }
  69058. }
  69059. declare module "babylonjs/Meshes/Builders/index" {
  69060. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69061. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69062. export * from "babylonjs/Meshes/Builders/discBuilder";
  69063. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69064. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69065. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69066. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69067. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69068. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69069. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69070. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69071. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69072. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69073. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69074. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69075. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69076. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69077. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69078. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69079. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69080. }
  69081. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69082. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69084. import { Matrix } from "babylonjs/Maths/math.vector";
  69085. module "babylonjs/Meshes/mesh" {
  69086. interface Mesh {
  69087. /**
  69088. * Creates a new thin instance
  69089. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69090. * @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
  69091. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69092. */
  69093. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69094. /**
  69095. * Adds the transformation (matrix) of the current mesh as a thin instance
  69096. * @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
  69097. * @returns the thin instance index number
  69098. */
  69099. thinInstanceAddSelf(refresh: boolean): number;
  69100. /**
  69101. * Registers a custom attribute to be used with thin instances
  69102. * @param kind name of the attribute
  69103. * @param stride size in floats of the attribute
  69104. */
  69105. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69106. /**
  69107. * Sets the matrix of a thin instance
  69108. * @param index index of the thin instance
  69109. * @param matrix matrix to set
  69110. * @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
  69111. */
  69112. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69113. /**
  69114. * Sets the value of a custom attribute for a thin instance
  69115. * @param kind name of the attribute
  69116. * @param index index of the thin instance
  69117. * @param value value to set
  69118. * @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
  69119. */
  69120. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69121. /**
  69122. * 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.
  69123. */
  69124. thinInstanceCount: number;
  69125. /**
  69126. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69127. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69128. * @param buffer buffer to set
  69129. * @param stride size in floats of each value of the buffer
  69130. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69131. */
  69132. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69133. /**
  69134. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69135. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69136. */
  69137. thinInstanceBufferUpdated(kind: string): void;
  69138. /**
  69139. * Refreshes the bounding info, taking into account all the thin instances defined
  69140. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69141. */
  69142. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69143. /** @hidden */
  69144. _thinInstanceInitializeUserStorage(): void;
  69145. /** @hidden */
  69146. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69147. /** @hidden */
  69148. _userThinInstanceBuffersStorage: {
  69149. data: {
  69150. [key: string]: Float32Array;
  69151. };
  69152. sizes: {
  69153. [key: string]: number;
  69154. };
  69155. vertexBuffers: {
  69156. [key: string]: Nullable<VertexBuffer>;
  69157. };
  69158. strides: {
  69159. [key: string]: number;
  69160. };
  69161. };
  69162. }
  69163. }
  69164. }
  69165. declare module "babylonjs/Meshes/index" {
  69166. export * from "babylonjs/Meshes/abstractMesh";
  69167. export * from "babylonjs/Meshes/buffer";
  69168. export * from "babylonjs/Meshes/Compression/index";
  69169. export * from "babylonjs/Meshes/csg";
  69170. export * from "babylonjs/Meshes/geometry";
  69171. export * from "babylonjs/Meshes/groundMesh";
  69172. export * from "babylonjs/Meshes/trailMesh";
  69173. export * from "babylonjs/Meshes/instancedMesh";
  69174. export * from "babylonjs/Meshes/linesMesh";
  69175. export * from "babylonjs/Meshes/mesh";
  69176. export * from "babylonjs/Meshes/mesh.vertexData";
  69177. export * from "babylonjs/Meshes/meshBuilder";
  69178. export * from "babylonjs/Meshes/meshSimplification";
  69179. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69180. export * from "babylonjs/Meshes/polygonMesh";
  69181. export * from "babylonjs/Meshes/subMesh";
  69182. export * from "babylonjs/Meshes/meshLODLevel";
  69183. export * from "babylonjs/Meshes/transformNode";
  69184. export * from "babylonjs/Meshes/Builders/index";
  69185. export * from "babylonjs/Meshes/dataBuffer";
  69186. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69187. import "babylonjs/Meshes/thinInstanceMesh";
  69188. export * from "babylonjs/Meshes/thinInstanceMesh";
  69189. }
  69190. declare module "babylonjs/Morph/index" {
  69191. export * from "babylonjs/Morph/morphTarget";
  69192. export * from "babylonjs/Morph/morphTargetManager";
  69193. }
  69194. declare module "babylonjs/Navigation/INavigationEngine" {
  69195. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69196. import { Vector3 } from "babylonjs/Maths/math";
  69197. import { Mesh } from "babylonjs/Meshes/mesh";
  69198. import { Scene } from "babylonjs/scene";
  69199. /**
  69200. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69201. */
  69202. export interface INavigationEnginePlugin {
  69203. /**
  69204. * plugin name
  69205. */
  69206. name: string;
  69207. /**
  69208. * Creates a navigation mesh
  69209. * @param meshes array of all the geometry used to compute the navigatio mesh
  69210. * @param parameters bunch of parameters used to filter geometry
  69211. */
  69212. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69213. /**
  69214. * Create a navigation mesh debug mesh
  69215. * @param scene is where the mesh will be added
  69216. * @returns debug display mesh
  69217. */
  69218. createDebugNavMesh(scene: Scene): Mesh;
  69219. /**
  69220. * Get a navigation mesh constrained position, closest to the parameter position
  69221. * @param position world position
  69222. * @returns the closest point to position constrained by the navigation mesh
  69223. */
  69224. getClosestPoint(position: Vector3): Vector3;
  69225. /**
  69226. * Get a navigation mesh constrained position, closest to the parameter position
  69227. * @param position world position
  69228. * @param result output the closest point to position constrained by the navigation mesh
  69229. */
  69230. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69231. /**
  69232. * Get a navigation mesh constrained position, within a particular radius
  69233. * @param position world position
  69234. * @param maxRadius the maximum distance to the constrained world position
  69235. * @returns the closest point to position constrained by the navigation mesh
  69236. */
  69237. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69238. /**
  69239. * Get a navigation mesh constrained position, within a particular radius
  69240. * @param position world position
  69241. * @param maxRadius the maximum distance to the constrained world position
  69242. * @param result output the closest point to position constrained by the navigation mesh
  69243. */
  69244. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69245. /**
  69246. * Compute the final position from a segment made of destination-position
  69247. * @param position world position
  69248. * @param destination world position
  69249. * @returns the resulting point along the navmesh
  69250. */
  69251. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69252. /**
  69253. * Compute the final position from a segment made of destination-position
  69254. * @param position world position
  69255. * @param destination world position
  69256. * @param result output the resulting point along the navmesh
  69257. */
  69258. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69259. /**
  69260. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69261. * @param start world position
  69262. * @param end world position
  69263. * @returns array containing world position composing the path
  69264. */
  69265. computePath(start: Vector3, end: Vector3): Vector3[];
  69266. /**
  69267. * If this plugin is supported
  69268. * @returns true if plugin is supported
  69269. */
  69270. isSupported(): boolean;
  69271. /**
  69272. * Create a new Crowd so you can add agents
  69273. * @param maxAgents the maximum agent count in the crowd
  69274. * @param maxAgentRadius the maximum radius an agent can have
  69275. * @param scene to attach the crowd to
  69276. * @returns the crowd you can add agents to
  69277. */
  69278. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69279. /**
  69280. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69281. * The queries will try to find a solution within those bounds
  69282. * default is (1,1,1)
  69283. * @param extent x,y,z value that define the extent around the queries point of reference
  69284. */
  69285. setDefaultQueryExtent(extent: Vector3): void;
  69286. /**
  69287. * Get the Bounding box extent specified by setDefaultQueryExtent
  69288. * @returns the box extent values
  69289. */
  69290. getDefaultQueryExtent(): Vector3;
  69291. /**
  69292. * build the navmesh from a previously saved state using getNavmeshData
  69293. * @param data the Uint8Array returned by getNavmeshData
  69294. */
  69295. buildFromNavmeshData(data: Uint8Array): void;
  69296. /**
  69297. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69298. * @returns data the Uint8Array that can be saved and reused
  69299. */
  69300. getNavmeshData(): Uint8Array;
  69301. /**
  69302. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69303. * @param result output the box extent values
  69304. */
  69305. getDefaultQueryExtentToRef(result: Vector3): void;
  69306. /**
  69307. * Release all resources
  69308. */
  69309. dispose(): void;
  69310. }
  69311. /**
  69312. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69313. */
  69314. export interface ICrowd {
  69315. /**
  69316. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69317. * You can attach anything to that node. The node position is updated in the scene update tick.
  69318. * @param pos world position that will be constrained by the navigation mesh
  69319. * @param parameters agent parameters
  69320. * @param transform hooked to the agent that will be update by the scene
  69321. * @returns agent index
  69322. */
  69323. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69324. /**
  69325. * Returns the agent position in world space
  69326. * @param index agent index returned by addAgent
  69327. * @returns world space position
  69328. */
  69329. getAgentPosition(index: number): Vector3;
  69330. /**
  69331. * Gets the agent position result in world space
  69332. * @param index agent index returned by addAgent
  69333. * @param result output world space position
  69334. */
  69335. getAgentPositionToRef(index: number, result: Vector3): void;
  69336. /**
  69337. * Gets the agent velocity in world space
  69338. * @param index agent index returned by addAgent
  69339. * @returns world space velocity
  69340. */
  69341. getAgentVelocity(index: number): Vector3;
  69342. /**
  69343. * Gets the agent velocity result in world space
  69344. * @param index agent index returned by addAgent
  69345. * @param result output world space velocity
  69346. */
  69347. getAgentVelocityToRef(index: number, result: Vector3): void;
  69348. /**
  69349. * remove a particular agent previously created
  69350. * @param index agent index returned by addAgent
  69351. */
  69352. removeAgent(index: number): void;
  69353. /**
  69354. * get the list of all agents attached to this crowd
  69355. * @returns list of agent indices
  69356. */
  69357. getAgents(): number[];
  69358. /**
  69359. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69360. * @param deltaTime in seconds
  69361. */
  69362. update(deltaTime: number): void;
  69363. /**
  69364. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69365. * @param index agent index returned by addAgent
  69366. * @param destination targeted world position
  69367. */
  69368. agentGoto(index: number, destination: Vector3): void;
  69369. /**
  69370. * Teleport the agent to a new position
  69371. * @param index agent index returned by addAgent
  69372. * @param destination targeted world position
  69373. */
  69374. agentTeleport(index: number, destination: Vector3): void;
  69375. /**
  69376. * Update agent parameters
  69377. * @param index agent index returned by addAgent
  69378. * @param parameters agent parameters
  69379. */
  69380. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69381. /**
  69382. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69383. * The queries will try to find a solution within those bounds
  69384. * default is (1,1,1)
  69385. * @param extent x,y,z value that define the extent around the queries point of reference
  69386. */
  69387. setDefaultQueryExtent(extent: Vector3): void;
  69388. /**
  69389. * Get the Bounding box extent specified by setDefaultQueryExtent
  69390. * @returns the box extent values
  69391. */
  69392. getDefaultQueryExtent(): Vector3;
  69393. /**
  69394. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69395. * @param result output the box extent values
  69396. */
  69397. getDefaultQueryExtentToRef(result: Vector3): void;
  69398. /**
  69399. * Release all resources
  69400. */
  69401. dispose(): void;
  69402. }
  69403. /**
  69404. * Configures an agent
  69405. */
  69406. export interface IAgentParameters {
  69407. /**
  69408. * Agent radius. [Limit: >= 0]
  69409. */
  69410. radius: number;
  69411. /**
  69412. * Agent height. [Limit: > 0]
  69413. */
  69414. height: number;
  69415. /**
  69416. * Maximum allowed acceleration. [Limit: >= 0]
  69417. */
  69418. maxAcceleration: number;
  69419. /**
  69420. * Maximum allowed speed. [Limit: >= 0]
  69421. */
  69422. maxSpeed: number;
  69423. /**
  69424. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69425. */
  69426. collisionQueryRange: number;
  69427. /**
  69428. * The path visibility optimization range. [Limit: > 0]
  69429. */
  69430. pathOptimizationRange: number;
  69431. /**
  69432. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69433. */
  69434. separationWeight: number;
  69435. }
  69436. /**
  69437. * Configures the navigation mesh creation
  69438. */
  69439. export interface INavMeshParameters {
  69440. /**
  69441. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69442. */
  69443. cs: number;
  69444. /**
  69445. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69446. */
  69447. ch: number;
  69448. /**
  69449. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69450. */
  69451. walkableSlopeAngle: number;
  69452. /**
  69453. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69454. * be considered walkable. [Limit: >= 3] [Units: vx]
  69455. */
  69456. walkableHeight: number;
  69457. /**
  69458. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69459. */
  69460. walkableClimb: number;
  69461. /**
  69462. * The distance to erode/shrink the walkable area of the heightfield away from
  69463. * obstructions. [Limit: >=0] [Units: vx]
  69464. */
  69465. walkableRadius: number;
  69466. /**
  69467. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69468. */
  69469. maxEdgeLen: number;
  69470. /**
  69471. * The maximum distance a simplfied contour's border edges should deviate
  69472. * the original raw contour. [Limit: >=0] [Units: vx]
  69473. */
  69474. maxSimplificationError: number;
  69475. /**
  69476. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69477. */
  69478. minRegionArea: number;
  69479. /**
  69480. * Any regions with a span count smaller than this value will, if possible,
  69481. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69482. */
  69483. mergeRegionArea: number;
  69484. /**
  69485. * The maximum number of vertices allowed for polygons generated during the
  69486. * contour to polygon conversion process. [Limit: >= 3]
  69487. */
  69488. maxVertsPerPoly: number;
  69489. /**
  69490. * Sets the sampling distance to use when generating the detail mesh.
  69491. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69492. */
  69493. detailSampleDist: number;
  69494. /**
  69495. * The maximum distance the detail mesh surface should deviate from heightfield
  69496. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69497. */
  69498. detailSampleMaxError: number;
  69499. }
  69500. }
  69501. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69502. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69503. import { Mesh } from "babylonjs/Meshes/mesh";
  69504. import { Scene } from "babylonjs/scene";
  69505. import { Vector3 } from "babylonjs/Maths/math";
  69506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69507. /**
  69508. * RecastJS navigation plugin
  69509. */
  69510. export class RecastJSPlugin implements INavigationEnginePlugin {
  69511. /**
  69512. * Reference to the Recast library
  69513. */
  69514. bjsRECAST: any;
  69515. /**
  69516. * plugin name
  69517. */
  69518. name: string;
  69519. /**
  69520. * the first navmesh created. We might extend this to support multiple navmeshes
  69521. */
  69522. navMesh: any;
  69523. /**
  69524. * Initializes the recastJS plugin
  69525. * @param recastInjection can be used to inject your own recast reference
  69526. */
  69527. constructor(recastInjection?: any);
  69528. /**
  69529. * Creates a navigation mesh
  69530. * @param meshes array of all the geometry used to compute the navigatio mesh
  69531. * @param parameters bunch of parameters used to filter geometry
  69532. */
  69533. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69534. /**
  69535. * Create a navigation mesh debug mesh
  69536. * @param scene is where the mesh will be added
  69537. * @returns debug display mesh
  69538. */
  69539. createDebugNavMesh(scene: Scene): Mesh;
  69540. /**
  69541. * Get a navigation mesh constrained position, closest to the parameter position
  69542. * @param position world position
  69543. * @returns the closest point to position constrained by the navigation mesh
  69544. */
  69545. getClosestPoint(position: Vector3): Vector3;
  69546. /**
  69547. * Get a navigation mesh constrained position, closest to the parameter position
  69548. * @param position world position
  69549. * @param result output the closest point to position constrained by the navigation mesh
  69550. */
  69551. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69552. /**
  69553. * Get a navigation mesh constrained position, within a particular radius
  69554. * @param position world position
  69555. * @param maxRadius the maximum distance to the constrained world position
  69556. * @returns the closest point to position constrained by the navigation mesh
  69557. */
  69558. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69559. /**
  69560. * Get a navigation mesh constrained position, within a particular radius
  69561. * @param position world position
  69562. * @param maxRadius the maximum distance to the constrained world position
  69563. * @param result output the closest point to position constrained by the navigation mesh
  69564. */
  69565. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69566. /**
  69567. * Compute the final position from a segment made of destination-position
  69568. * @param position world position
  69569. * @param destination world position
  69570. * @returns the resulting point along the navmesh
  69571. */
  69572. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69573. /**
  69574. * Compute the final position from a segment made of destination-position
  69575. * @param position world position
  69576. * @param destination world position
  69577. * @param result output the resulting point along the navmesh
  69578. */
  69579. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69580. /**
  69581. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69582. * @param start world position
  69583. * @param end world position
  69584. * @returns array containing world position composing the path
  69585. */
  69586. computePath(start: Vector3, end: Vector3): Vector3[];
  69587. /**
  69588. * Create a new Crowd so you can add agents
  69589. * @param maxAgents the maximum agent count in the crowd
  69590. * @param maxAgentRadius the maximum radius an agent can have
  69591. * @param scene to attach the crowd to
  69592. * @returns the crowd you can add agents to
  69593. */
  69594. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69595. /**
  69596. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69597. * The queries will try to find a solution within those bounds
  69598. * default is (1,1,1)
  69599. * @param extent x,y,z value that define the extent around the queries point of reference
  69600. */
  69601. setDefaultQueryExtent(extent: Vector3): void;
  69602. /**
  69603. * Get the Bounding box extent specified by setDefaultQueryExtent
  69604. * @returns the box extent values
  69605. */
  69606. getDefaultQueryExtent(): Vector3;
  69607. /**
  69608. * build the navmesh from a previously saved state using getNavmeshData
  69609. * @param data the Uint8Array returned by getNavmeshData
  69610. */
  69611. buildFromNavmeshData(data: Uint8Array): void;
  69612. /**
  69613. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69614. * @returns data the Uint8Array that can be saved and reused
  69615. */
  69616. getNavmeshData(): Uint8Array;
  69617. /**
  69618. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69619. * @param result output the box extent values
  69620. */
  69621. getDefaultQueryExtentToRef(result: Vector3): void;
  69622. /**
  69623. * Disposes
  69624. */
  69625. dispose(): void;
  69626. /**
  69627. * If this plugin is supported
  69628. * @returns true if plugin is supported
  69629. */
  69630. isSupported(): boolean;
  69631. }
  69632. /**
  69633. * Recast detour crowd implementation
  69634. */
  69635. export class RecastJSCrowd implements ICrowd {
  69636. /**
  69637. * Recast/detour plugin
  69638. */
  69639. bjsRECASTPlugin: RecastJSPlugin;
  69640. /**
  69641. * Link to the detour crowd
  69642. */
  69643. recastCrowd: any;
  69644. /**
  69645. * One transform per agent
  69646. */
  69647. transforms: TransformNode[];
  69648. /**
  69649. * All agents created
  69650. */
  69651. agents: number[];
  69652. /**
  69653. * Link to the scene is kept to unregister the crowd from the scene
  69654. */
  69655. private _scene;
  69656. /**
  69657. * Observer for crowd updates
  69658. */
  69659. private _onBeforeAnimationsObserver;
  69660. /**
  69661. * Constructor
  69662. * @param plugin recastJS plugin
  69663. * @param maxAgents the maximum agent count in the crowd
  69664. * @param maxAgentRadius the maximum radius an agent can have
  69665. * @param scene to attach the crowd to
  69666. * @returns the crowd you can add agents to
  69667. */
  69668. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69669. /**
  69670. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69671. * You can attach anything to that node. The node position is updated in the scene update tick.
  69672. * @param pos world position that will be constrained by the navigation mesh
  69673. * @param parameters agent parameters
  69674. * @param transform hooked to the agent that will be update by the scene
  69675. * @returns agent index
  69676. */
  69677. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69678. /**
  69679. * Returns the agent position in world space
  69680. * @param index agent index returned by addAgent
  69681. * @returns world space position
  69682. */
  69683. getAgentPosition(index: number): Vector3;
  69684. /**
  69685. * Returns the agent position result in world space
  69686. * @param index agent index returned by addAgent
  69687. * @param result output world space position
  69688. */
  69689. getAgentPositionToRef(index: number, result: Vector3): void;
  69690. /**
  69691. * Returns the agent velocity in world space
  69692. * @param index agent index returned by addAgent
  69693. * @returns world space velocity
  69694. */
  69695. getAgentVelocity(index: number): Vector3;
  69696. /**
  69697. * Returns the agent velocity result in world space
  69698. * @param index agent index returned by addAgent
  69699. * @param result output world space velocity
  69700. */
  69701. getAgentVelocityToRef(index: number, result: Vector3): void;
  69702. /**
  69703. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69704. * @param index agent index returned by addAgent
  69705. * @param destination targeted world position
  69706. */
  69707. agentGoto(index: number, destination: Vector3): void;
  69708. /**
  69709. * Teleport the agent to a new position
  69710. * @param index agent index returned by addAgent
  69711. * @param destination targeted world position
  69712. */
  69713. agentTeleport(index: number, destination: Vector3): void;
  69714. /**
  69715. * Update agent parameters
  69716. * @param index agent index returned by addAgent
  69717. * @param parameters agent parameters
  69718. */
  69719. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69720. /**
  69721. * remove a particular agent previously created
  69722. * @param index agent index returned by addAgent
  69723. */
  69724. removeAgent(index: number): void;
  69725. /**
  69726. * get the list of all agents attached to this crowd
  69727. * @returns list of agent indices
  69728. */
  69729. getAgents(): number[];
  69730. /**
  69731. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69732. * @param deltaTime in seconds
  69733. */
  69734. update(deltaTime: number): void;
  69735. /**
  69736. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69737. * The queries will try to find a solution within those bounds
  69738. * default is (1,1,1)
  69739. * @param extent x,y,z value that define the extent around the queries point of reference
  69740. */
  69741. setDefaultQueryExtent(extent: Vector3): void;
  69742. /**
  69743. * Get the Bounding box extent specified by setDefaultQueryExtent
  69744. * @returns the box extent values
  69745. */
  69746. getDefaultQueryExtent(): Vector3;
  69747. /**
  69748. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69749. * @param result output the box extent values
  69750. */
  69751. getDefaultQueryExtentToRef(result: Vector3): void;
  69752. /**
  69753. * Release all resources
  69754. */
  69755. dispose(): void;
  69756. }
  69757. }
  69758. declare module "babylonjs/Navigation/Plugins/index" {
  69759. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69760. }
  69761. declare module "babylonjs/Navigation/index" {
  69762. export * from "babylonjs/Navigation/INavigationEngine";
  69763. export * from "babylonjs/Navigation/Plugins/index";
  69764. }
  69765. declare module "babylonjs/Offline/database" {
  69766. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69767. /**
  69768. * Class used to enable access to IndexedDB
  69769. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69770. */
  69771. export class Database implements IOfflineProvider {
  69772. private _callbackManifestChecked;
  69773. private _currentSceneUrl;
  69774. private _db;
  69775. private _enableSceneOffline;
  69776. private _enableTexturesOffline;
  69777. private _manifestVersionFound;
  69778. private _mustUpdateRessources;
  69779. private _hasReachedQuota;
  69780. private _isSupported;
  69781. private _idbFactory;
  69782. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69783. private static IsUASupportingBlobStorage;
  69784. /**
  69785. * Gets a boolean indicating if Database storate is enabled (off by default)
  69786. */
  69787. static IDBStorageEnabled: boolean;
  69788. /**
  69789. * Gets a boolean indicating if scene must be saved in the database
  69790. */
  69791. get enableSceneOffline(): boolean;
  69792. /**
  69793. * Gets a boolean indicating if textures must be saved in the database
  69794. */
  69795. get enableTexturesOffline(): boolean;
  69796. /**
  69797. * Creates a new Database
  69798. * @param urlToScene defines the url to load the scene
  69799. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69800. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69801. */
  69802. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69803. private static _ParseURL;
  69804. private static _ReturnFullUrlLocation;
  69805. private _checkManifestFile;
  69806. /**
  69807. * Open the database and make it available
  69808. * @param successCallback defines the callback to call on success
  69809. * @param errorCallback defines the callback to call on error
  69810. */
  69811. open(successCallback: () => void, errorCallback: () => void): void;
  69812. /**
  69813. * Loads an image from the database
  69814. * @param url defines the url to load from
  69815. * @param image defines the target DOM image
  69816. */
  69817. loadImage(url: string, image: HTMLImageElement): void;
  69818. private _loadImageFromDBAsync;
  69819. private _saveImageIntoDBAsync;
  69820. private _checkVersionFromDB;
  69821. private _loadVersionFromDBAsync;
  69822. private _saveVersionIntoDBAsync;
  69823. /**
  69824. * Loads a file from database
  69825. * @param url defines the URL to load from
  69826. * @param sceneLoaded defines a callback to call on success
  69827. * @param progressCallBack defines a callback to call when progress changed
  69828. * @param errorCallback defines a callback to call on error
  69829. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69830. */
  69831. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69832. private _loadFileAsync;
  69833. private _saveFileAsync;
  69834. /**
  69835. * Validates if xhr data is correct
  69836. * @param xhr defines the request to validate
  69837. * @param dataType defines the expected data type
  69838. * @returns true if data is correct
  69839. */
  69840. private static _ValidateXHRData;
  69841. }
  69842. }
  69843. declare module "babylonjs/Offline/index" {
  69844. export * from "babylonjs/Offline/database";
  69845. export * from "babylonjs/Offline/IOfflineProvider";
  69846. }
  69847. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69848. /** @hidden */
  69849. export var gpuUpdateParticlesPixelShader: {
  69850. name: string;
  69851. shader: string;
  69852. };
  69853. }
  69854. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69855. /** @hidden */
  69856. export var gpuUpdateParticlesVertexShader: {
  69857. name: string;
  69858. shader: string;
  69859. };
  69860. }
  69861. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69862. /** @hidden */
  69863. export var clipPlaneFragmentDeclaration2: {
  69864. name: string;
  69865. shader: string;
  69866. };
  69867. }
  69868. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69870. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69872. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69874. /** @hidden */
  69875. export var gpuRenderParticlesPixelShader: {
  69876. name: string;
  69877. shader: string;
  69878. };
  69879. }
  69880. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69881. /** @hidden */
  69882. export var clipPlaneVertexDeclaration2: {
  69883. name: string;
  69884. shader: string;
  69885. };
  69886. }
  69887. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69888. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69889. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69890. /** @hidden */
  69891. export var gpuRenderParticlesVertexShader: {
  69892. name: string;
  69893. shader: string;
  69894. };
  69895. }
  69896. declare module "babylonjs/Particles/gpuParticleSystem" {
  69897. import { Nullable } from "babylonjs/types";
  69898. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69899. import { Observable } from "babylonjs/Misc/observable";
  69900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69901. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69902. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69903. import { Scene, IDisposable } from "babylonjs/scene";
  69904. import { Effect } from "babylonjs/Materials/effect";
  69905. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69906. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69907. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69908. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69909. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69910. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69911. /**
  69912. * This represents a GPU particle system in Babylon
  69913. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69914. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69915. */
  69916. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69917. /**
  69918. * The layer mask we are rendering the particles through.
  69919. */
  69920. layerMask: number;
  69921. private _capacity;
  69922. private _activeCount;
  69923. private _currentActiveCount;
  69924. private _accumulatedCount;
  69925. private _renderEffect;
  69926. private _updateEffect;
  69927. private _buffer0;
  69928. private _buffer1;
  69929. private _spriteBuffer;
  69930. private _updateVAO;
  69931. private _renderVAO;
  69932. private _targetIndex;
  69933. private _sourceBuffer;
  69934. private _targetBuffer;
  69935. private _engine;
  69936. private _currentRenderId;
  69937. private _started;
  69938. private _stopped;
  69939. private _timeDelta;
  69940. private _randomTexture;
  69941. private _randomTexture2;
  69942. private _attributesStrideSize;
  69943. private _updateEffectOptions;
  69944. private _randomTextureSize;
  69945. private _actualFrame;
  69946. private _customEffect;
  69947. private readonly _rawTextureWidth;
  69948. /**
  69949. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69950. */
  69951. static get IsSupported(): boolean;
  69952. /**
  69953. * An event triggered when the system is disposed.
  69954. */
  69955. onDisposeObservable: Observable<IParticleSystem>;
  69956. /**
  69957. * Gets the maximum number of particles active at the same time.
  69958. * @returns The max number of active particles.
  69959. */
  69960. getCapacity(): number;
  69961. /**
  69962. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69963. * to override the particles.
  69964. */
  69965. forceDepthWrite: boolean;
  69966. /**
  69967. * Gets or set the number of active particles
  69968. */
  69969. get activeParticleCount(): number;
  69970. set activeParticleCount(value: number);
  69971. private _preWarmDone;
  69972. /**
  69973. * Specifies if the particles are updated in emitter local space or world space.
  69974. */
  69975. isLocal: boolean;
  69976. /**
  69977. * Is this system ready to be used/rendered
  69978. * @return true if the system is ready
  69979. */
  69980. isReady(): boolean;
  69981. /**
  69982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69983. * @returns True if it has been started, otherwise false.
  69984. */
  69985. isStarted(): boolean;
  69986. /**
  69987. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69988. * @returns True if it has been stopped, otherwise false.
  69989. */
  69990. isStopped(): boolean;
  69991. /**
  69992. * Gets a boolean indicating that the system is stopping
  69993. * @returns true if the system is currently stopping
  69994. */
  69995. isStopping(): boolean;
  69996. /**
  69997. * Gets the number of particles active at the same time.
  69998. * @returns The number of active particles.
  69999. */
  70000. getActiveCount(): number;
  70001. /**
  70002. * Starts the particle system and begins to emit
  70003. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70004. */
  70005. start(delay?: number): void;
  70006. /**
  70007. * Stops the particle system.
  70008. */
  70009. stop(): void;
  70010. /**
  70011. * Remove all active particles
  70012. */
  70013. reset(): void;
  70014. /**
  70015. * Returns the string "GPUParticleSystem"
  70016. * @returns a string containing the class name
  70017. */
  70018. getClassName(): string;
  70019. /**
  70020. * Gets the custom effect used to render the particles
  70021. * @param blendMode Blend mode for which the effect should be retrieved
  70022. * @returns The effect
  70023. */
  70024. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70025. /**
  70026. * Sets the custom effect used to render the particles
  70027. * @param effect The effect to set
  70028. * @param blendMode Blend mode for which the effect should be set
  70029. */
  70030. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70031. /** @hidden */
  70032. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70033. /**
  70034. * Observable that will be called just before the particles are drawn
  70035. */
  70036. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70037. /**
  70038. * Gets the name of the particle vertex shader
  70039. */
  70040. get vertexShaderName(): string;
  70041. private _colorGradientsTexture;
  70042. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70043. /**
  70044. * Adds a new color gradient
  70045. * @param gradient defines the gradient to use (between 0 and 1)
  70046. * @param color1 defines the color to affect to the specified gradient
  70047. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70048. * @returns the current particle system
  70049. */
  70050. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70051. private _refreshColorGradient;
  70052. /** Force the system to rebuild all gradients that need to be resync */
  70053. forceRefreshGradients(): void;
  70054. /**
  70055. * Remove a specific color gradient
  70056. * @param gradient defines the gradient to remove
  70057. * @returns the current particle system
  70058. */
  70059. removeColorGradient(gradient: number): GPUParticleSystem;
  70060. private _angularSpeedGradientsTexture;
  70061. private _sizeGradientsTexture;
  70062. private _velocityGradientsTexture;
  70063. private _limitVelocityGradientsTexture;
  70064. private _dragGradientsTexture;
  70065. private _addFactorGradient;
  70066. /**
  70067. * Adds a new size gradient
  70068. * @param gradient defines the gradient to use (between 0 and 1)
  70069. * @param factor defines the size factor to affect to the specified gradient
  70070. * @returns the current particle system
  70071. */
  70072. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70073. /**
  70074. * Remove a specific size gradient
  70075. * @param gradient defines the gradient to remove
  70076. * @returns the current particle system
  70077. */
  70078. removeSizeGradient(gradient: number): GPUParticleSystem;
  70079. private _refreshFactorGradient;
  70080. /**
  70081. * Adds a new angular speed gradient
  70082. * @param gradient defines the gradient to use (between 0 and 1)
  70083. * @param factor defines the angular speed to affect to the specified gradient
  70084. * @returns the current particle system
  70085. */
  70086. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70087. /**
  70088. * Remove a specific angular speed gradient
  70089. * @param gradient defines the gradient to remove
  70090. * @returns the current particle system
  70091. */
  70092. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70093. /**
  70094. * Adds a new velocity gradient
  70095. * @param gradient defines the gradient to use (between 0 and 1)
  70096. * @param factor defines the velocity to affect to the specified gradient
  70097. * @returns the current particle system
  70098. */
  70099. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70100. /**
  70101. * Remove a specific velocity gradient
  70102. * @param gradient defines the gradient to remove
  70103. * @returns the current particle system
  70104. */
  70105. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70106. /**
  70107. * Adds a new limit velocity gradient
  70108. * @param gradient defines the gradient to use (between 0 and 1)
  70109. * @param factor defines the limit velocity value to affect to the specified gradient
  70110. * @returns the current particle system
  70111. */
  70112. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70113. /**
  70114. * Remove a specific limit velocity gradient
  70115. * @param gradient defines the gradient to remove
  70116. * @returns the current particle system
  70117. */
  70118. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70119. /**
  70120. * Adds a new drag gradient
  70121. * @param gradient defines the gradient to use (between 0 and 1)
  70122. * @param factor defines the drag value to affect to the specified gradient
  70123. * @returns the current particle system
  70124. */
  70125. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70126. /**
  70127. * Remove a specific drag gradient
  70128. * @param gradient defines the gradient to remove
  70129. * @returns the current particle system
  70130. */
  70131. removeDragGradient(gradient: number): GPUParticleSystem;
  70132. /**
  70133. * Not supported by GPUParticleSystem
  70134. * @param gradient defines the gradient to use (between 0 and 1)
  70135. * @param factor defines the emit rate value to affect to the specified gradient
  70136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70137. * @returns the current particle system
  70138. */
  70139. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70140. /**
  70141. * Not supported by GPUParticleSystem
  70142. * @param gradient defines the gradient to remove
  70143. * @returns the current particle system
  70144. */
  70145. removeEmitRateGradient(gradient: number): IParticleSystem;
  70146. /**
  70147. * Not supported by GPUParticleSystem
  70148. * @param gradient defines the gradient to use (between 0 and 1)
  70149. * @param factor defines the start size value to affect to the specified gradient
  70150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70151. * @returns the current particle system
  70152. */
  70153. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70154. /**
  70155. * Not supported by GPUParticleSystem
  70156. * @param gradient defines the gradient to remove
  70157. * @returns the current particle system
  70158. */
  70159. removeStartSizeGradient(gradient: number): IParticleSystem;
  70160. /**
  70161. * Not supported by GPUParticleSystem
  70162. * @param gradient defines the gradient to use (between 0 and 1)
  70163. * @param min defines the color remap minimal range
  70164. * @param max defines the color remap maximal range
  70165. * @returns the current particle system
  70166. */
  70167. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70168. /**
  70169. * Not supported by GPUParticleSystem
  70170. * @param gradient defines the gradient to remove
  70171. * @returns the current particle system
  70172. */
  70173. removeColorRemapGradient(): IParticleSystem;
  70174. /**
  70175. * Not supported by GPUParticleSystem
  70176. * @param gradient defines the gradient to use (between 0 and 1)
  70177. * @param min defines the alpha remap minimal range
  70178. * @param max defines the alpha remap maximal range
  70179. * @returns the current particle system
  70180. */
  70181. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70182. /**
  70183. * Not supported by GPUParticleSystem
  70184. * @param gradient defines the gradient to remove
  70185. * @returns the current particle system
  70186. */
  70187. removeAlphaRemapGradient(): IParticleSystem;
  70188. /**
  70189. * Not supported by GPUParticleSystem
  70190. * @param gradient defines the gradient to use (between 0 and 1)
  70191. * @param color defines the color to affect to the specified gradient
  70192. * @returns the current particle system
  70193. */
  70194. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70195. /**
  70196. * Not supported by GPUParticleSystem
  70197. * @param gradient defines the gradient to remove
  70198. * @returns the current particle system
  70199. */
  70200. removeRampGradient(): IParticleSystem;
  70201. /**
  70202. * Not supported by GPUParticleSystem
  70203. * @returns the list of ramp gradients
  70204. */
  70205. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70206. /**
  70207. * Not supported by GPUParticleSystem
  70208. * Gets or sets a boolean indicating that ramp gradients must be used
  70209. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70210. */
  70211. get useRampGradients(): boolean;
  70212. set useRampGradients(value: boolean);
  70213. /**
  70214. * Not supported by GPUParticleSystem
  70215. * @param gradient defines the gradient to use (between 0 and 1)
  70216. * @param factor defines the life time factor to affect to the specified gradient
  70217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70218. * @returns the current particle system
  70219. */
  70220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70221. /**
  70222. * Not supported by GPUParticleSystem
  70223. * @param gradient defines the gradient to remove
  70224. * @returns the current particle system
  70225. */
  70226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70227. /**
  70228. * Instantiates a GPU particle system.
  70229. * 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.
  70230. * @param name The name of the particle system
  70231. * @param options The options used to create the system
  70232. * @param scene The scene the particle system belongs to
  70233. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70234. * @param customEffect a custom effect used to change the way particles are rendered by default
  70235. */
  70236. constructor(name: string, options: Partial<{
  70237. capacity: number;
  70238. randomTextureSize: number;
  70239. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70240. protected _reset(): void;
  70241. private _createUpdateVAO;
  70242. private _createRenderVAO;
  70243. private _initialize;
  70244. /** @hidden */
  70245. _recreateUpdateEffect(): void;
  70246. private _getEffect;
  70247. /**
  70248. * Fill the defines array according to the current settings of the particle system
  70249. * @param defines Array to be updated
  70250. * @param blendMode blend mode to take into account when updating the array
  70251. */
  70252. fillDefines(defines: Array<string>, blendMode?: number): void;
  70253. /**
  70254. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70255. * @param uniforms Uniforms array to fill
  70256. * @param attributes Attributes array to fill
  70257. * @param samplers Samplers array to fill
  70258. */
  70259. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70260. /** @hidden */
  70261. _recreateRenderEffect(): Effect;
  70262. /**
  70263. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70264. * @param preWarm defines if we are in the pre-warmimg phase
  70265. */
  70266. animate(preWarm?: boolean): void;
  70267. private _createFactorGradientTexture;
  70268. private _createSizeGradientTexture;
  70269. private _createAngularSpeedGradientTexture;
  70270. private _createVelocityGradientTexture;
  70271. private _createLimitVelocityGradientTexture;
  70272. private _createDragGradientTexture;
  70273. private _createColorGradientTexture;
  70274. /**
  70275. * Renders the particle system in its current state
  70276. * @param preWarm defines if the system should only update the particles but not render them
  70277. * @returns the current number of particles
  70278. */
  70279. render(preWarm?: boolean): number;
  70280. /**
  70281. * Rebuilds the particle system
  70282. */
  70283. rebuild(): void;
  70284. private _releaseBuffers;
  70285. private _releaseVAOs;
  70286. /**
  70287. * Disposes the particle system and free the associated resources
  70288. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70289. */
  70290. dispose(disposeTexture?: boolean): void;
  70291. /**
  70292. * Clones the particle system.
  70293. * @param name The name of the cloned object
  70294. * @param newEmitter The new emitter to use
  70295. * @returns the cloned particle system
  70296. */
  70297. clone(name: string, newEmitter: any): GPUParticleSystem;
  70298. /**
  70299. * Serializes the particle system to a JSON object
  70300. * @param serializeTexture defines if the texture must be serialized as well
  70301. * @returns the JSON object
  70302. */
  70303. serialize(serializeTexture?: boolean): any;
  70304. /**
  70305. * Parses a JSON object to create a GPU particle system.
  70306. * @param parsedParticleSystem The JSON object to parse
  70307. * @param scene The scene to create the particle system in
  70308. * @param rootUrl The root url to use to load external dependencies like texture
  70309. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70310. * @returns the parsed GPU particle system
  70311. */
  70312. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70313. }
  70314. }
  70315. declare module "babylonjs/Particles/particleSystemSet" {
  70316. import { Nullable } from "babylonjs/types";
  70317. import { Color3 } from "babylonjs/Maths/math.color";
  70318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70320. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70321. import { Scene, IDisposable } from "babylonjs/scene";
  70322. /**
  70323. * Represents a set of particle systems working together to create a specific effect
  70324. */
  70325. export class ParticleSystemSet implements IDisposable {
  70326. /**
  70327. * Gets or sets base Assets URL
  70328. */
  70329. static BaseAssetsUrl: string;
  70330. private _emitterCreationOptions;
  70331. private _emitterNode;
  70332. /**
  70333. * Gets the particle system list
  70334. */
  70335. systems: IParticleSystem[];
  70336. /**
  70337. * Gets the emitter node used with this set
  70338. */
  70339. get emitterNode(): Nullable<TransformNode>;
  70340. /**
  70341. * Creates a new emitter mesh as a sphere
  70342. * @param options defines the options used to create the sphere
  70343. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70344. * @param scene defines the hosting scene
  70345. */
  70346. setEmitterAsSphere(options: {
  70347. diameter: number;
  70348. segments: number;
  70349. color: Color3;
  70350. }, renderingGroupId: number, scene: Scene): void;
  70351. /**
  70352. * Starts all particle systems of the set
  70353. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70354. */
  70355. start(emitter?: AbstractMesh): void;
  70356. /**
  70357. * Release all associated resources
  70358. */
  70359. dispose(): void;
  70360. /**
  70361. * Serialize the set into a JSON compatible object
  70362. * @param serializeTexture defines if the texture must be serialized as well
  70363. * @returns a JSON compatible representation of the set
  70364. */
  70365. serialize(serializeTexture?: boolean): any;
  70366. /**
  70367. * Parse a new ParticleSystemSet from a serialized source
  70368. * @param data defines a JSON compatible representation of the set
  70369. * @param scene defines the hosting scene
  70370. * @param gpu defines if we want GPU particles or CPU particles
  70371. * @returns a new ParticleSystemSet
  70372. */
  70373. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70374. }
  70375. }
  70376. declare module "babylonjs/Particles/particleHelper" {
  70377. import { Nullable } from "babylonjs/types";
  70378. import { Scene } from "babylonjs/scene";
  70379. import { Vector3 } from "babylonjs/Maths/math.vector";
  70380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70381. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70382. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70383. /**
  70384. * This class is made for on one-liner static method to help creating particle system set.
  70385. */
  70386. export class ParticleHelper {
  70387. /**
  70388. * Gets or sets base Assets URL
  70389. */
  70390. static BaseAssetsUrl: string;
  70391. /** Define the Url to load snippets */
  70392. static SnippetUrl: string;
  70393. /**
  70394. * Create a default particle system that you can tweak
  70395. * @param emitter defines the emitter to use
  70396. * @param capacity defines the system capacity (default is 500 particles)
  70397. * @param scene defines the hosting scene
  70398. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70399. * @returns the new Particle system
  70400. */
  70401. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70402. /**
  70403. * This is the main static method (one-liner) of this helper to create different particle systems
  70404. * @param type This string represents the type to the particle system to create
  70405. * @param scene The scene where the particle system should live
  70406. * @param gpu If the system will use gpu
  70407. * @returns the ParticleSystemSet created
  70408. */
  70409. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70410. /**
  70411. * Static function used to export a particle system to a ParticleSystemSet variable.
  70412. * Please note that the emitter shape is not exported
  70413. * @param systems defines the particle systems to export
  70414. * @returns the created particle system set
  70415. */
  70416. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70417. /**
  70418. * Creates a particle system from a snippet saved in a remote file
  70419. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70420. * @param url defines the url to load from
  70421. * @param scene defines the hosting scene
  70422. * @param gpu If the system will use gpu
  70423. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70424. * @returns a promise that will resolve to the new particle system
  70425. */
  70426. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70427. /**
  70428. * Creates a particle system from a snippet saved by the particle system editor
  70429. * @param snippetId defines the snippet to load
  70430. * @param scene defines the hosting scene
  70431. * @param gpu If the system will use gpu
  70432. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70433. * @returns a promise that will resolve to the new particle system
  70434. */
  70435. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70436. }
  70437. }
  70438. declare module "babylonjs/Particles/particleSystemComponent" {
  70439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70440. import { Effect } from "babylonjs/Materials/effect";
  70441. import "babylonjs/Shaders/particles.vertex";
  70442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70443. module "babylonjs/Engines/engine" {
  70444. interface Engine {
  70445. /**
  70446. * Create an effect to use with particle systems.
  70447. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70448. * the particle system for which you want to create a custom effect in the last parameter
  70449. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70450. * @param uniformsNames defines a list of attribute names
  70451. * @param samplers defines an array of string used to represent textures
  70452. * @param defines defines the string containing the defines to use to compile the shaders
  70453. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70454. * @param onCompiled defines a function to call when the effect creation is successful
  70455. * @param onError defines a function to call when the effect creation has failed
  70456. * @param particleSystem the particle system you want to create the effect for
  70457. * @returns the new Effect
  70458. */
  70459. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70460. }
  70461. }
  70462. module "babylonjs/Meshes/mesh" {
  70463. interface Mesh {
  70464. /**
  70465. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70466. * @returns an array of IParticleSystem
  70467. */
  70468. getEmittedParticleSystems(): IParticleSystem[];
  70469. /**
  70470. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70471. * @returns an array of IParticleSystem
  70472. */
  70473. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70474. }
  70475. }
  70476. }
  70477. declare module "babylonjs/Particles/pointsCloudSystem" {
  70478. import { Color4 } from "babylonjs/Maths/math";
  70479. import { Mesh } from "babylonjs/Meshes/mesh";
  70480. import { Scene, IDisposable } from "babylonjs/scene";
  70481. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70482. /** Defines the 4 color options */
  70483. export enum PointColor {
  70484. /** color value */
  70485. Color = 2,
  70486. /** uv value */
  70487. UV = 1,
  70488. /** random value */
  70489. Random = 0,
  70490. /** stated value */
  70491. Stated = 3
  70492. }
  70493. /**
  70494. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70495. * 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.
  70496. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70497. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70498. *
  70499. * Full documentation here : TO BE ENTERED
  70500. */
  70501. export class PointsCloudSystem implements IDisposable {
  70502. /**
  70503. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70504. * Example : var p = SPS.particles[i];
  70505. */
  70506. particles: CloudPoint[];
  70507. /**
  70508. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70509. */
  70510. nbParticles: number;
  70511. /**
  70512. * This a counter for your own usage. It's not set by any SPS functions.
  70513. */
  70514. counter: number;
  70515. /**
  70516. * The PCS name. This name is also given to the underlying mesh.
  70517. */
  70518. name: string;
  70519. /**
  70520. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70521. */
  70522. mesh: Mesh;
  70523. /**
  70524. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70525. * Please read :
  70526. */
  70527. vars: any;
  70528. /**
  70529. * @hidden
  70530. */
  70531. _size: number;
  70532. private _scene;
  70533. private _promises;
  70534. private _positions;
  70535. private _indices;
  70536. private _normals;
  70537. private _colors;
  70538. private _uvs;
  70539. private _indices32;
  70540. private _positions32;
  70541. private _colors32;
  70542. private _uvs32;
  70543. private _updatable;
  70544. private _isVisibilityBoxLocked;
  70545. private _alwaysVisible;
  70546. private _groups;
  70547. private _groupCounter;
  70548. private _computeParticleColor;
  70549. private _computeParticleTexture;
  70550. private _computeParticleRotation;
  70551. private _computeBoundingBox;
  70552. private _isReady;
  70553. /**
  70554. * Creates a PCS (Points Cloud System) object
  70555. * @param name (String) is the PCS name, this will be the underlying mesh name
  70556. * @param pointSize (number) is the size for each point
  70557. * @param scene (Scene) is the scene in which the PCS is added
  70558. * @param options defines the options of the PCS e.g.
  70559. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70560. */
  70561. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70562. updatable?: boolean;
  70563. });
  70564. /**
  70565. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70566. * If no points were added to the PCS, the returned mesh is just a single point.
  70567. * @returns a promise for the created mesh
  70568. */
  70569. buildMeshAsync(): Promise<Mesh>;
  70570. /**
  70571. * @hidden
  70572. */
  70573. private _buildMesh;
  70574. private _addParticle;
  70575. private _randomUnitVector;
  70576. private _getColorIndicesForCoord;
  70577. private _setPointsColorOrUV;
  70578. private _colorFromTexture;
  70579. private _calculateDensity;
  70580. /**
  70581. * Adds points to the PCS in random positions within a unit sphere
  70582. * @param nb (positive integer) the number of particles to be created from this model
  70583. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70584. * @returns the number of groups in the system
  70585. */
  70586. addPoints(nb: number, pointFunction?: any): number;
  70587. /**
  70588. * Adds points to the PCS from the surface of the model shape
  70589. * @param mesh is any Mesh object that will be used as a surface model for the points
  70590. * @param nb (positive integer) the number of particles to be created from this model
  70591. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70592. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70593. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70594. * @returns the number of groups in the system
  70595. */
  70596. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70597. /**
  70598. * Adds points to the PCS inside the model shape
  70599. * @param mesh is any Mesh object that will be used as a surface model for the points
  70600. * @param nb (positive integer) the number of particles to be created from this model
  70601. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70602. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70603. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70604. * @returns the number of groups in the system
  70605. */
  70606. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70607. /**
  70608. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70609. * This method calls `updateParticle()` for each particle of the SPS.
  70610. * For an animated SPS, it is usually called within the render loop.
  70611. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70612. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70613. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70614. * @returns the PCS.
  70615. */
  70616. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70617. /**
  70618. * Disposes the PCS.
  70619. */
  70620. dispose(): void;
  70621. /**
  70622. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70623. * doc :
  70624. * @returns the PCS.
  70625. */
  70626. refreshVisibleSize(): PointsCloudSystem;
  70627. /**
  70628. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70629. * @param size the size (float) of the visibility box
  70630. * note : this doesn't lock the PCS mesh bounding box.
  70631. * doc :
  70632. */
  70633. setVisibilityBox(size: number): void;
  70634. /**
  70635. * Gets whether the PCS is always visible or not
  70636. * doc :
  70637. */
  70638. get isAlwaysVisible(): boolean;
  70639. /**
  70640. * Sets the PCS as always visible or not
  70641. * doc :
  70642. */
  70643. set isAlwaysVisible(val: boolean);
  70644. /**
  70645. * Tells to `setParticles()` to compute the particle rotations or not
  70646. * Default value : false. The PCS is faster when it's set to false
  70647. * Note : particle rotations are only applied to parent particles
  70648. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70649. */
  70650. set computeParticleRotation(val: boolean);
  70651. /**
  70652. * Tells to `setParticles()` to compute the particle colors or not.
  70653. * Default value : true. The PCS is faster when it's set to false.
  70654. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70655. */
  70656. set computeParticleColor(val: boolean);
  70657. set computeParticleTexture(val: boolean);
  70658. /**
  70659. * Gets if `setParticles()` computes the particle colors or not.
  70660. * Default value : false. The PCS is faster when it's set to false.
  70661. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70662. */
  70663. get computeParticleColor(): boolean;
  70664. /**
  70665. * Gets if `setParticles()` computes the particle textures or not.
  70666. * Default value : false. The PCS is faster when it's set to false.
  70667. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70668. */
  70669. get computeParticleTexture(): boolean;
  70670. /**
  70671. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70672. */
  70673. set computeBoundingBox(val: boolean);
  70674. /**
  70675. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70676. */
  70677. get computeBoundingBox(): boolean;
  70678. /**
  70679. * This function does nothing. It may be overwritten to set all the particle first values.
  70680. * The PCS doesn't call this function, you may have to call it by your own.
  70681. * doc :
  70682. */
  70683. initParticles(): void;
  70684. /**
  70685. * This function does nothing. It may be overwritten to recycle a particle
  70686. * The PCS doesn't call this function, you can to call it
  70687. * doc :
  70688. * @param particle The particle to recycle
  70689. * @returns the recycled particle
  70690. */
  70691. recycleParticle(particle: CloudPoint): CloudPoint;
  70692. /**
  70693. * Updates a particle : this function should be overwritten by the user.
  70694. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70695. * doc :
  70696. * @example : just set a particle position or velocity and recycle conditions
  70697. * @param particle The particle to update
  70698. * @returns the updated particle
  70699. */
  70700. updateParticle(particle: CloudPoint): CloudPoint;
  70701. /**
  70702. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70703. * This does nothing and may be overwritten by the user.
  70704. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70705. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70706. * @param update the boolean update value actually passed to setParticles()
  70707. */
  70708. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70709. /**
  70710. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70711. * This will be passed three parameters.
  70712. * This does nothing and may be overwritten by the user.
  70713. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70714. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70715. * @param update the boolean update value actually passed to setParticles()
  70716. */
  70717. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70718. }
  70719. }
  70720. declare module "babylonjs/Particles/cloudPoint" {
  70721. import { Nullable } from "babylonjs/types";
  70722. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70723. import { Mesh } from "babylonjs/Meshes/mesh";
  70724. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70725. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70726. /**
  70727. * Represents one particle of a points cloud system.
  70728. */
  70729. export class CloudPoint {
  70730. /**
  70731. * particle global index
  70732. */
  70733. idx: number;
  70734. /**
  70735. * The color of the particle
  70736. */
  70737. color: Nullable<Color4>;
  70738. /**
  70739. * The world space position of the particle.
  70740. */
  70741. position: Vector3;
  70742. /**
  70743. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70744. */
  70745. rotation: Vector3;
  70746. /**
  70747. * The world space rotation quaternion of the particle.
  70748. */
  70749. rotationQuaternion: Nullable<Quaternion>;
  70750. /**
  70751. * The uv of the particle.
  70752. */
  70753. uv: Nullable<Vector2>;
  70754. /**
  70755. * The current speed of the particle.
  70756. */
  70757. velocity: Vector3;
  70758. /**
  70759. * The pivot point in the particle local space.
  70760. */
  70761. pivot: Vector3;
  70762. /**
  70763. * Must the particle be translated from its pivot point in its local space ?
  70764. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70765. * Default : false
  70766. */
  70767. translateFromPivot: boolean;
  70768. /**
  70769. * Index of this particle in the global "positions" array (Internal use)
  70770. * @hidden
  70771. */
  70772. _pos: number;
  70773. /**
  70774. * @hidden Index of this particle in the global "indices" array (Internal use)
  70775. */
  70776. _ind: number;
  70777. /**
  70778. * Group this particle belongs to
  70779. */
  70780. _group: PointsGroup;
  70781. /**
  70782. * Group id of this particle
  70783. */
  70784. groupId: number;
  70785. /**
  70786. * Index of the particle in its group id (Internal use)
  70787. */
  70788. idxInGroup: number;
  70789. /**
  70790. * @hidden Particle BoundingInfo object (Internal use)
  70791. */
  70792. _boundingInfo: BoundingInfo;
  70793. /**
  70794. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70795. */
  70796. _pcs: PointsCloudSystem;
  70797. /**
  70798. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70799. */
  70800. _stillInvisible: boolean;
  70801. /**
  70802. * @hidden Last computed particle rotation matrix
  70803. */
  70804. _rotationMatrix: number[];
  70805. /**
  70806. * Parent particle Id, if any.
  70807. * Default null.
  70808. */
  70809. parentId: Nullable<number>;
  70810. /**
  70811. * @hidden Internal global position in the PCS.
  70812. */
  70813. _globalPosition: Vector3;
  70814. /**
  70815. * Creates a Point Cloud object.
  70816. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70817. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70818. * @param group (PointsGroup) is the group the particle belongs to
  70819. * @param groupId (integer) is the group identifier in the PCS.
  70820. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70821. * @param pcs defines the PCS it is associated to
  70822. */
  70823. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70824. /**
  70825. * get point size
  70826. */
  70827. get size(): Vector3;
  70828. /**
  70829. * Set point size
  70830. */
  70831. set size(scale: Vector3);
  70832. /**
  70833. * Legacy support, changed quaternion to rotationQuaternion
  70834. */
  70835. get quaternion(): Nullable<Quaternion>;
  70836. /**
  70837. * Legacy support, changed quaternion to rotationQuaternion
  70838. */
  70839. set quaternion(q: Nullable<Quaternion>);
  70840. /**
  70841. * Returns a boolean. True if the particle intersects a mesh, else false
  70842. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70843. * @param target is the object (point or mesh) what the intersection is computed against
  70844. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70845. * @returns true if it intersects
  70846. */
  70847. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70848. /**
  70849. * get the rotation matrix of the particle
  70850. * @hidden
  70851. */
  70852. getRotationMatrix(m: Matrix): void;
  70853. }
  70854. /**
  70855. * Represents a group of points in a points cloud system
  70856. * * PCS internal tool, don't use it manually.
  70857. */
  70858. export class PointsGroup {
  70859. /**
  70860. * The group id
  70861. * @hidden
  70862. */
  70863. groupID: number;
  70864. /**
  70865. * image data for group (internal use)
  70866. * @hidden
  70867. */
  70868. _groupImageData: Nullable<ArrayBufferView>;
  70869. /**
  70870. * Image Width (internal use)
  70871. * @hidden
  70872. */
  70873. _groupImgWidth: number;
  70874. /**
  70875. * Image Height (internal use)
  70876. * @hidden
  70877. */
  70878. _groupImgHeight: number;
  70879. /**
  70880. * Custom position function (internal use)
  70881. * @hidden
  70882. */
  70883. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70884. /**
  70885. * density per facet for surface points
  70886. * @hidden
  70887. */
  70888. _groupDensity: number[];
  70889. /**
  70890. * Only when points are colored by texture carries pointer to texture list array
  70891. * @hidden
  70892. */
  70893. _textureNb: number;
  70894. /**
  70895. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70896. * PCS internal tool, don't use it manually.
  70897. * @hidden
  70898. */
  70899. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70900. }
  70901. }
  70902. declare module "babylonjs/Particles/index" {
  70903. export * from "babylonjs/Particles/baseParticleSystem";
  70904. export * from "babylonjs/Particles/EmitterTypes/index";
  70905. export * from "babylonjs/Particles/gpuParticleSystem";
  70906. export * from "babylonjs/Particles/IParticleSystem";
  70907. export * from "babylonjs/Particles/particle";
  70908. export * from "babylonjs/Particles/particleHelper";
  70909. export * from "babylonjs/Particles/particleSystem";
  70910. import "babylonjs/Particles/particleSystemComponent";
  70911. export * from "babylonjs/Particles/particleSystemComponent";
  70912. export * from "babylonjs/Particles/particleSystemSet";
  70913. export * from "babylonjs/Particles/solidParticle";
  70914. export * from "babylonjs/Particles/solidParticleSystem";
  70915. export * from "babylonjs/Particles/cloudPoint";
  70916. export * from "babylonjs/Particles/pointsCloudSystem";
  70917. export * from "babylonjs/Particles/subEmitter";
  70918. }
  70919. declare module "babylonjs/Physics/physicsEngineComponent" {
  70920. import { Nullable } from "babylonjs/types";
  70921. import { Observable, Observer } from "babylonjs/Misc/observable";
  70922. import { Vector3 } from "babylonjs/Maths/math.vector";
  70923. import { Mesh } from "babylonjs/Meshes/mesh";
  70924. import { ISceneComponent } from "babylonjs/sceneComponent";
  70925. import { Scene } from "babylonjs/scene";
  70926. import { Node } from "babylonjs/node";
  70927. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70928. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70929. module "babylonjs/scene" {
  70930. interface Scene {
  70931. /** @hidden (Backing field) */
  70932. _physicsEngine: Nullable<IPhysicsEngine>;
  70933. /** @hidden */
  70934. _physicsTimeAccumulator: number;
  70935. /**
  70936. * Gets the current physics engine
  70937. * @returns a IPhysicsEngine or null if none attached
  70938. */
  70939. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70940. /**
  70941. * Enables physics to the current scene
  70942. * @param gravity defines the scene's gravity for the physics engine
  70943. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70944. * @return a boolean indicating if the physics engine was initialized
  70945. */
  70946. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70947. /**
  70948. * Disables and disposes the physics engine associated with the scene
  70949. */
  70950. disablePhysicsEngine(): void;
  70951. /**
  70952. * Gets a boolean indicating if there is an active physics engine
  70953. * @returns a boolean indicating if there is an active physics engine
  70954. */
  70955. isPhysicsEnabled(): boolean;
  70956. /**
  70957. * Deletes a physics compound impostor
  70958. * @param compound defines the compound to delete
  70959. */
  70960. deleteCompoundImpostor(compound: any): void;
  70961. /**
  70962. * An event triggered when physic simulation is about to be run
  70963. */
  70964. onBeforePhysicsObservable: Observable<Scene>;
  70965. /**
  70966. * An event triggered when physic simulation has been done
  70967. */
  70968. onAfterPhysicsObservable: Observable<Scene>;
  70969. }
  70970. }
  70971. module "babylonjs/Meshes/abstractMesh" {
  70972. interface AbstractMesh {
  70973. /** @hidden */
  70974. _physicsImpostor: Nullable<PhysicsImpostor>;
  70975. /**
  70976. * Gets or sets impostor used for physic simulation
  70977. * @see https://doc.babylonjs.com/features/physics_engine
  70978. */
  70979. physicsImpostor: Nullable<PhysicsImpostor>;
  70980. /**
  70981. * Gets the current physics impostor
  70982. * @see https://doc.babylonjs.com/features/physics_engine
  70983. * @returns a physics impostor or null
  70984. */
  70985. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70986. /** Apply a physic impulse to the mesh
  70987. * @param force defines the force to apply
  70988. * @param contactPoint defines where to apply the force
  70989. * @returns the current mesh
  70990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70991. */
  70992. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70993. /**
  70994. * Creates a physic joint between two meshes
  70995. * @param otherMesh defines the other mesh to use
  70996. * @param pivot1 defines the pivot to use on this mesh
  70997. * @param pivot2 defines the pivot to use on the other mesh
  70998. * @param options defines additional options (can be plugin dependent)
  70999. * @returns the current mesh
  71000. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71001. */
  71002. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71003. /** @hidden */
  71004. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71005. }
  71006. }
  71007. /**
  71008. * Defines the physics engine scene component responsible to manage a physics engine
  71009. */
  71010. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71011. /**
  71012. * The component name helpful to identify the component in the list of scene components.
  71013. */
  71014. readonly name: string;
  71015. /**
  71016. * The scene the component belongs to.
  71017. */
  71018. scene: Scene;
  71019. /**
  71020. * Creates a new instance of the component for the given scene
  71021. * @param scene Defines the scene to register the component in
  71022. */
  71023. constructor(scene: Scene);
  71024. /**
  71025. * Registers the component in a given scene
  71026. */
  71027. register(): void;
  71028. /**
  71029. * Rebuilds the elements related to this component in case of
  71030. * context lost for instance.
  71031. */
  71032. rebuild(): void;
  71033. /**
  71034. * Disposes the component and the associated ressources
  71035. */
  71036. dispose(): void;
  71037. }
  71038. }
  71039. declare module "babylonjs/Physics/physicsHelper" {
  71040. import { Nullable } from "babylonjs/types";
  71041. import { Vector3 } from "babylonjs/Maths/math.vector";
  71042. import { Mesh } from "babylonjs/Meshes/mesh";
  71043. import { Scene } from "babylonjs/scene";
  71044. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71045. /**
  71046. * A helper for physics simulations
  71047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71048. */
  71049. export class PhysicsHelper {
  71050. private _scene;
  71051. private _physicsEngine;
  71052. /**
  71053. * Initializes the Physics helper
  71054. * @param scene Babylon.js scene
  71055. */
  71056. constructor(scene: Scene);
  71057. /**
  71058. * Applies a radial explosion impulse
  71059. * @param origin the origin of the explosion
  71060. * @param radiusOrEventOptions the radius or the options of radial explosion
  71061. * @param strength the explosion strength
  71062. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71063. * @returns A physics radial explosion event, or null
  71064. */
  71065. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71066. /**
  71067. * Applies a radial explosion force
  71068. * @param origin the origin of the explosion
  71069. * @param radiusOrEventOptions the radius or the options of radial explosion
  71070. * @param strength the explosion strength
  71071. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71072. * @returns A physics radial explosion event, or null
  71073. */
  71074. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71075. /**
  71076. * Creates a gravitational field
  71077. * @param origin the origin of the explosion
  71078. * @param radiusOrEventOptions the radius or the options of radial explosion
  71079. * @param strength the explosion strength
  71080. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71081. * @returns A physics gravitational field event, or null
  71082. */
  71083. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71084. /**
  71085. * Creates a physics updraft event
  71086. * @param origin the origin of the updraft
  71087. * @param radiusOrEventOptions the radius or the options of the updraft
  71088. * @param strength the strength of the updraft
  71089. * @param height the height of the updraft
  71090. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71091. * @returns A physics updraft event, or null
  71092. */
  71093. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71094. /**
  71095. * Creates a physics vortex event
  71096. * @param origin the of the vortex
  71097. * @param radiusOrEventOptions the radius or the options of the vortex
  71098. * @param strength the strength of the vortex
  71099. * @param height the height of the vortex
  71100. * @returns a Physics vortex event, or null
  71101. * A physics vortex event or null
  71102. */
  71103. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71104. }
  71105. /**
  71106. * Represents a physics radial explosion event
  71107. */
  71108. class PhysicsRadialExplosionEvent {
  71109. private _scene;
  71110. private _options;
  71111. private _sphere;
  71112. private _dataFetched;
  71113. /**
  71114. * Initializes a radial explosioin event
  71115. * @param _scene BabylonJS scene
  71116. * @param _options The options for the vortex event
  71117. */
  71118. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71119. /**
  71120. * Returns the data related to the radial explosion event (sphere).
  71121. * @returns The radial explosion event data
  71122. */
  71123. getData(): PhysicsRadialExplosionEventData;
  71124. /**
  71125. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71126. * @param impostor A physics imposter
  71127. * @param origin the origin of the explosion
  71128. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71129. */
  71130. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71131. /**
  71132. * Triggers affecterd impostors callbacks
  71133. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71134. */
  71135. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71136. /**
  71137. * Disposes the sphere.
  71138. * @param force Specifies if the sphere should be disposed by force
  71139. */
  71140. dispose(force?: boolean): void;
  71141. /*** Helpers ***/
  71142. private _prepareSphere;
  71143. private _intersectsWithSphere;
  71144. }
  71145. /**
  71146. * Represents a gravitational field event
  71147. */
  71148. class PhysicsGravitationalFieldEvent {
  71149. private _physicsHelper;
  71150. private _scene;
  71151. private _origin;
  71152. private _options;
  71153. private _tickCallback;
  71154. private _sphere;
  71155. private _dataFetched;
  71156. /**
  71157. * Initializes the physics gravitational field event
  71158. * @param _physicsHelper A physics helper
  71159. * @param _scene BabylonJS scene
  71160. * @param _origin The origin position of the gravitational field event
  71161. * @param _options The options for the vortex event
  71162. */
  71163. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71164. /**
  71165. * Returns the data related to the gravitational field event (sphere).
  71166. * @returns A gravitational field event
  71167. */
  71168. getData(): PhysicsGravitationalFieldEventData;
  71169. /**
  71170. * Enables the gravitational field.
  71171. */
  71172. enable(): void;
  71173. /**
  71174. * Disables the gravitational field.
  71175. */
  71176. disable(): void;
  71177. /**
  71178. * Disposes the sphere.
  71179. * @param force The force to dispose from the gravitational field event
  71180. */
  71181. dispose(force?: boolean): void;
  71182. private _tick;
  71183. }
  71184. /**
  71185. * Represents a physics updraft event
  71186. */
  71187. class PhysicsUpdraftEvent {
  71188. private _scene;
  71189. private _origin;
  71190. private _options;
  71191. private _physicsEngine;
  71192. private _originTop;
  71193. private _originDirection;
  71194. private _tickCallback;
  71195. private _cylinder;
  71196. private _cylinderPosition;
  71197. private _dataFetched;
  71198. /**
  71199. * Initializes the physics updraft event
  71200. * @param _scene BabylonJS scene
  71201. * @param _origin The origin position of the updraft
  71202. * @param _options The options for the updraft event
  71203. */
  71204. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71205. /**
  71206. * Returns the data related to the updraft event (cylinder).
  71207. * @returns A physics updraft event
  71208. */
  71209. getData(): PhysicsUpdraftEventData;
  71210. /**
  71211. * Enables the updraft.
  71212. */
  71213. enable(): void;
  71214. /**
  71215. * Disables the updraft.
  71216. */
  71217. disable(): void;
  71218. /**
  71219. * Disposes the cylinder.
  71220. * @param force Specifies if the updraft should be disposed by force
  71221. */
  71222. dispose(force?: boolean): void;
  71223. private getImpostorHitData;
  71224. private _tick;
  71225. /*** Helpers ***/
  71226. private _prepareCylinder;
  71227. private _intersectsWithCylinder;
  71228. }
  71229. /**
  71230. * Represents a physics vortex event
  71231. */
  71232. class PhysicsVortexEvent {
  71233. private _scene;
  71234. private _origin;
  71235. private _options;
  71236. private _physicsEngine;
  71237. private _originTop;
  71238. private _tickCallback;
  71239. private _cylinder;
  71240. private _cylinderPosition;
  71241. private _dataFetched;
  71242. /**
  71243. * Initializes the physics vortex event
  71244. * @param _scene The BabylonJS scene
  71245. * @param _origin The origin position of the vortex
  71246. * @param _options The options for the vortex event
  71247. */
  71248. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71249. /**
  71250. * Returns the data related to the vortex event (cylinder).
  71251. * @returns The physics vortex event data
  71252. */
  71253. getData(): PhysicsVortexEventData;
  71254. /**
  71255. * Enables the vortex.
  71256. */
  71257. enable(): void;
  71258. /**
  71259. * Disables the cortex.
  71260. */
  71261. disable(): void;
  71262. /**
  71263. * Disposes the sphere.
  71264. * @param force
  71265. */
  71266. dispose(force?: boolean): void;
  71267. private getImpostorHitData;
  71268. private _tick;
  71269. /*** Helpers ***/
  71270. private _prepareCylinder;
  71271. private _intersectsWithCylinder;
  71272. }
  71273. /**
  71274. * Options fot the radial explosion event
  71275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71276. */
  71277. export class PhysicsRadialExplosionEventOptions {
  71278. /**
  71279. * The radius of the sphere for the radial explosion.
  71280. */
  71281. radius: number;
  71282. /**
  71283. * The strenth of the explosion.
  71284. */
  71285. strength: number;
  71286. /**
  71287. * The strenght of the force in correspondence to the distance of the affected object
  71288. */
  71289. falloff: PhysicsRadialImpulseFalloff;
  71290. /**
  71291. * Sphere options for the radial explosion.
  71292. */
  71293. sphere: {
  71294. segments: number;
  71295. diameter: number;
  71296. };
  71297. /**
  71298. * Sphere options for the radial explosion.
  71299. */
  71300. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71301. }
  71302. /**
  71303. * Options fot the updraft event
  71304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71305. */
  71306. export class PhysicsUpdraftEventOptions {
  71307. /**
  71308. * The radius of the cylinder for the vortex
  71309. */
  71310. radius: number;
  71311. /**
  71312. * The strenth of the updraft.
  71313. */
  71314. strength: number;
  71315. /**
  71316. * The height of the cylinder for the updraft.
  71317. */
  71318. height: number;
  71319. /**
  71320. * The mode for the the updraft.
  71321. */
  71322. updraftMode: PhysicsUpdraftMode;
  71323. }
  71324. /**
  71325. * Options fot the vortex event
  71326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71327. */
  71328. export class PhysicsVortexEventOptions {
  71329. /**
  71330. * The radius of the cylinder for the vortex
  71331. */
  71332. radius: number;
  71333. /**
  71334. * The strenth of the vortex.
  71335. */
  71336. strength: number;
  71337. /**
  71338. * The height of the cylinder for the vortex.
  71339. */
  71340. height: number;
  71341. /**
  71342. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71343. */
  71344. centripetalForceThreshold: number;
  71345. /**
  71346. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71347. */
  71348. centripetalForceMultiplier: number;
  71349. /**
  71350. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71351. */
  71352. centrifugalForceMultiplier: number;
  71353. /**
  71354. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71355. */
  71356. updraftForceMultiplier: number;
  71357. }
  71358. /**
  71359. * The strenght of the force in correspondence to the distance of the affected object
  71360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71361. */
  71362. export enum PhysicsRadialImpulseFalloff {
  71363. /** Defines that impulse is constant in strength across it's whole radius */
  71364. Constant = 0,
  71365. /** Defines that impulse gets weaker if it's further from the origin */
  71366. Linear = 1
  71367. }
  71368. /**
  71369. * The strength of the force in correspondence to the distance of the affected object
  71370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71371. */
  71372. export enum PhysicsUpdraftMode {
  71373. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71374. Center = 0,
  71375. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71376. Perpendicular = 1
  71377. }
  71378. /**
  71379. * Interface for a physics hit data
  71380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71381. */
  71382. export interface PhysicsHitData {
  71383. /**
  71384. * The force applied at the contact point
  71385. */
  71386. force: Vector3;
  71387. /**
  71388. * The contact point
  71389. */
  71390. contactPoint: Vector3;
  71391. /**
  71392. * The distance from the origin to the contact point
  71393. */
  71394. distanceFromOrigin: number;
  71395. }
  71396. /**
  71397. * Interface for radial explosion event data
  71398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71399. */
  71400. export interface PhysicsRadialExplosionEventData {
  71401. /**
  71402. * A sphere used for the radial explosion event
  71403. */
  71404. sphere: Mesh;
  71405. }
  71406. /**
  71407. * Interface for gravitational field event data
  71408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71409. */
  71410. export interface PhysicsGravitationalFieldEventData {
  71411. /**
  71412. * A sphere mesh used for the gravitational field event
  71413. */
  71414. sphere: Mesh;
  71415. }
  71416. /**
  71417. * Interface for updraft event data
  71418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71419. */
  71420. export interface PhysicsUpdraftEventData {
  71421. /**
  71422. * A cylinder used for the updraft event
  71423. */
  71424. cylinder: Mesh;
  71425. }
  71426. /**
  71427. * Interface for vortex event data
  71428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71429. */
  71430. export interface PhysicsVortexEventData {
  71431. /**
  71432. * A cylinder used for the vortex event
  71433. */
  71434. cylinder: Mesh;
  71435. }
  71436. /**
  71437. * Interface for an affected physics impostor
  71438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71439. */
  71440. export interface PhysicsAffectedImpostorWithData {
  71441. /**
  71442. * The impostor affected by the effect
  71443. */
  71444. impostor: PhysicsImpostor;
  71445. /**
  71446. * The data about the hit/horce from the explosion
  71447. */
  71448. hitData: PhysicsHitData;
  71449. }
  71450. }
  71451. declare module "babylonjs/Physics/Plugins/index" {
  71452. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71453. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71454. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71455. }
  71456. declare module "babylonjs/Physics/index" {
  71457. export * from "babylonjs/Physics/IPhysicsEngine";
  71458. export * from "babylonjs/Physics/physicsEngine";
  71459. export * from "babylonjs/Physics/physicsEngineComponent";
  71460. export * from "babylonjs/Physics/physicsHelper";
  71461. export * from "babylonjs/Physics/physicsImpostor";
  71462. export * from "babylonjs/Physics/physicsJoint";
  71463. export * from "babylonjs/Physics/Plugins/index";
  71464. }
  71465. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71466. /** @hidden */
  71467. export var blackAndWhitePixelShader: {
  71468. name: string;
  71469. shader: string;
  71470. };
  71471. }
  71472. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71474. import { Camera } from "babylonjs/Cameras/camera";
  71475. import { Engine } from "babylonjs/Engines/engine";
  71476. import "babylonjs/Shaders/blackAndWhite.fragment";
  71477. /**
  71478. * Post process used to render in black and white
  71479. */
  71480. export class BlackAndWhitePostProcess extends PostProcess {
  71481. /**
  71482. * Linear about to convert he result to black and white (default: 1)
  71483. */
  71484. degree: number;
  71485. /**
  71486. * Creates a black and white post process
  71487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71488. * @param name The name of the effect.
  71489. * @param options The required width/height ratio to downsize to before computing the render pass.
  71490. * @param camera The camera to apply the render pass to.
  71491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71492. * @param engine The engine which the post process will be applied. (default: current engine)
  71493. * @param reusable If the post process can be reused on the same frame. (default: false)
  71494. */
  71495. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71496. }
  71497. }
  71498. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71499. import { Nullable } from "babylonjs/types";
  71500. import { Camera } from "babylonjs/Cameras/camera";
  71501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71502. import { Engine } from "babylonjs/Engines/engine";
  71503. /**
  71504. * This represents a set of one or more post processes in Babylon.
  71505. * A post process can be used to apply a shader to a texture after it is rendered.
  71506. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71507. */
  71508. export class PostProcessRenderEffect {
  71509. private _postProcesses;
  71510. private _getPostProcesses;
  71511. private _singleInstance;
  71512. private _cameras;
  71513. private _indicesForCamera;
  71514. /**
  71515. * Name of the effect
  71516. * @hidden
  71517. */
  71518. _name: string;
  71519. /**
  71520. * Instantiates a post process render effect.
  71521. * A post process can be used to apply a shader to a texture after it is rendered.
  71522. * @param engine The engine the effect is tied to
  71523. * @param name The name of the effect
  71524. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71525. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71526. */
  71527. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71528. /**
  71529. * Checks if all the post processes in the effect are supported.
  71530. */
  71531. get isSupported(): boolean;
  71532. /**
  71533. * Updates the current state of the effect
  71534. * @hidden
  71535. */
  71536. _update(): void;
  71537. /**
  71538. * Attaches the effect on cameras
  71539. * @param cameras The camera to attach to.
  71540. * @hidden
  71541. */
  71542. _attachCameras(cameras: Camera): void;
  71543. /**
  71544. * Attaches the effect on cameras
  71545. * @param cameras The camera to attach to.
  71546. * @hidden
  71547. */
  71548. _attachCameras(cameras: Camera[]): void;
  71549. /**
  71550. * Detaches the effect on cameras
  71551. * @param cameras The camera to detatch from.
  71552. * @hidden
  71553. */
  71554. _detachCameras(cameras: Camera): void;
  71555. /**
  71556. * Detatches the effect on cameras
  71557. * @param cameras The camera to detatch from.
  71558. * @hidden
  71559. */
  71560. _detachCameras(cameras: Camera[]): void;
  71561. /**
  71562. * Enables the effect on given cameras
  71563. * @param cameras The camera to enable.
  71564. * @hidden
  71565. */
  71566. _enable(cameras: Camera): void;
  71567. /**
  71568. * Enables the effect on given cameras
  71569. * @param cameras The camera to enable.
  71570. * @hidden
  71571. */
  71572. _enable(cameras: Nullable<Camera[]>): void;
  71573. /**
  71574. * Disables the effect on the given cameras
  71575. * @param cameras The camera to disable.
  71576. * @hidden
  71577. */
  71578. _disable(cameras: Camera): void;
  71579. /**
  71580. * Disables the effect on the given cameras
  71581. * @param cameras The camera to disable.
  71582. * @hidden
  71583. */
  71584. _disable(cameras: Nullable<Camera[]>): void;
  71585. /**
  71586. * Gets a list of the post processes contained in the effect.
  71587. * @param camera The camera to get the post processes on.
  71588. * @returns The list of the post processes in the effect.
  71589. */
  71590. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71591. }
  71592. }
  71593. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71594. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71595. /** @hidden */
  71596. export var extractHighlightsPixelShader: {
  71597. name: string;
  71598. shader: string;
  71599. };
  71600. }
  71601. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71602. import { Nullable } from "babylonjs/types";
  71603. import { Camera } from "babylonjs/Cameras/camera";
  71604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71605. import { Engine } from "babylonjs/Engines/engine";
  71606. import "babylonjs/Shaders/extractHighlights.fragment";
  71607. /**
  71608. * 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.
  71609. */
  71610. export class ExtractHighlightsPostProcess extends PostProcess {
  71611. /**
  71612. * The luminance threshold, pixels below this value will be set to black.
  71613. */
  71614. threshold: number;
  71615. /** @hidden */
  71616. _exposure: number;
  71617. /**
  71618. * Post process which has the input texture to be used when performing highlight extraction
  71619. * @hidden
  71620. */
  71621. _inputPostProcess: Nullable<PostProcess>;
  71622. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71623. }
  71624. }
  71625. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71626. /** @hidden */
  71627. export var bloomMergePixelShader: {
  71628. name: string;
  71629. shader: string;
  71630. };
  71631. }
  71632. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71634. import { Nullable } from "babylonjs/types";
  71635. import { Engine } from "babylonjs/Engines/engine";
  71636. import { Camera } from "babylonjs/Cameras/camera";
  71637. import "babylonjs/Shaders/bloomMerge.fragment";
  71638. /**
  71639. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71640. */
  71641. export class BloomMergePostProcess extends PostProcess {
  71642. /** Weight of the bloom to be added to the original input. */
  71643. weight: number;
  71644. /**
  71645. * Creates a new instance of @see BloomMergePostProcess
  71646. * @param name The name of the effect.
  71647. * @param originalFromInput Post process which's input will be used for the merge.
  71648. * @param blurred Blurred highlights post process which's output will be used.
  71649. * @param weight Weight of the bloom to be added to the original input.
  71650. * @param options The required width/height ratio to downsize to before computing the render pass.
  71651. * @param camera The camera to apply the render pass to.
  71652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71653. * @param engine The engine which the post process will be applied. (default: current engine)
  71654. * @param reusable If the post process can be reused on the same frame. (default: false)
  71655. * @param textureType Type of textures used when performing the post process. (default: 0)
  71656. * @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)
  71657. */
  71658. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71659. /** Weight of the bloom to be added to the original input. */
  71660. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71661. }
  71662. }
  71663. declare module "babylonjs/PostProcesses/bloomEffect" {
  71664. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71665. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71666. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71667. import { Camera } from "babylonjs/Cameras/camera";
  71668. import { Scene } from "babylonjs/scene";
  71669. /**
  71670. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71671. */
  71672. export class BloomEffect extends PostProcessRenderEffect {
  71673. private bloomScale;
  71674. /**
  71675. * @hidden Internal
  71676. */
  71677. _effects: Array<PostProcess>;
  71678. /**
  71679. * @hidden Internal
  71680. */
  71681. _downscale: ExtractHighlightsPostProcess;
  71682. private _blurX;
  71683. private _blurY;
  71684. private _merge;
  71685. /**
  71686. * The luminance threshold to find bright areas of the image to bloom.
  71687. */
  71688. get threshold(): number;
  71689. set threshold(value: number);
  71690. /**
  71691. * The strength of the bloom.
  71692. */
  71693. get weight(): number;
  71694. set weight(value: number);
  71695. /**
  71696. * Specifies the size of the bloom blur kernel, relative to the final output size
  71697. */
  71698. get kernel(): number;
  71699. set kernel(value: number);
  71700. /**
  71701. * Creates a new instance of @see BloomEffect
  71702. * @param scene The scene the effect belongs to.
  71703. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71704. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71705. * @param bloomWeight The the strength of bloom.
  71706. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71707. * @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)
  71708. */
  71709. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71710. /**
  71711. * Disposes each of the internal effects for a given camera.
  71712. * @param camera The camera to dispose the effect on.
  71713. */
  71714. disposeEffects(camera: Camera): void;
  71715. /**
  71716. * @hidden Internal
  71717. */
  71718. _updateEffects(): void;
  71719. /**
  71720. * Internal
  71721. * @returns if all the contained post processes are ready.
  71722. * @hidden
  71723. */
  71724. _isReady(): boolean;
  71725. }
  71726. }
  71727. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71728. /** @hidden */
  71729. export var chromaticAberrationPixelShader: {
  71730. name: string;
  71731. shader: string;
  71732. };
  71733. }
  71734. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71735. import { Vector2 } from "babylonjs/Maths/math.vector";
  71736. import { Nullable } from "babylonjs/types";
  71737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71738. import { Camera } from "babylonjs/Cameras/camera";
  71739. import { Engine } from "babylonjs/Engines/engine";
  71740. import "babylonjs/Shaders/chromaticAberration.fragment";
  71741. /**
  71742. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71743. */
  71744. export class ChromaticAberrationPostProcess extends PostProcess {
  71745. /**
  71746. * The amount of seperation of rgb channels (default: 30)
  71747. */
  71748. aberrationAmount: number;
  71749. /**
  71750. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71751. */
  71752. radialIntensity: number;
  71753. /**
  71754. * 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))
  71755. */
  71756. direction: Vector2;
  71757. /**
  71758. * 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))
  71759. */
  71760. centerPosition: Vector2;
  71761. /**
  71762. * Creates a new instance ChromaticAberrationPostProcess
  71763. * @param name The name of the effect.
  71764. * @param screenWidth The width of the screen to apply the effect on.
  71765. * @param screenHeight The height of the screen to apply the effect on.
  71766. * @param options The required width/height ratio to downsize to before computing the render pass.
  71767. * @param camera The camera to apply the render pass to.
  71768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71769. * @param engine The engine which the post process will be applied. (default: current engine)
  71770. * @param reusable If the post process can be reused on the same frame. (default: false)
  71771. * @param textureType Type of textures used when performing the post process. (default: 0)
  71772. * @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)
  71773. */
  71774. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71775. }
  71776. }
  71777. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71778. /** @hidden */
  71779. export var circleOfConfusionPixelShader: {
  71780. name: string;
  71781. shader: string;
  71782. };
  71783. }
  71784. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71785. import { Nullable } from "babylonjs/types";
  71786. import { Engine } from "babylonjs/Engines/engine";
  71787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71789. import { Camera } from "babylonjs/Cameras/camera";
  71790. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71791. /**
  71792. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71793. */
  71794. export class CircleOfConfusionPostProcess extends PostProcess {
  71795. /**
  71796. * 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.
  71797. */
  71798. lensSize: number;
  71799. /**
  71800. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71801. */
  71802. fStop: number;
  71803. /**
  71804. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71805. */
  71806. focusDistance: number;
  71807. /**
  71808. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71809. */
  71810. focalLength: number;
  71811. private _depthTexture;
  71812. /**
  71813. * Creates a new instance CircleOfConfusionPostProcess
  71814. * @param name The name of the effect.
  71815. * @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.
  71816. * @param options The required width/height ratio to downsize to before computing the render pass.
  71817. * @param camera The camera to apply the render pass to.
  71818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71819. * @param engine The engine which the post process will be applied. (default: current engine)
  71820. * @param reusable If the post process can be reused on the same frame. (default: false)
  71821. * @param textureType Type of textures used when performing the post process. (default: 0)
  71822. * @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)
  71823. */
  71824. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71825. /**
  71826. * 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.
  71827. */
  71828. set depthTexture(value: RenderTargetTexture);
  71829. }
  71830. }
  71831. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71832. /** @hidden */
  71833. export var colorCorrectionPixelShader: {
  71834. name: string;
  71835. shader: string;
  71836. };
  71837. }
  71838. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71840. import { Engine } from "babylonjs/Engines/engine";
  71841. import { Camera } from "babylonjs/Cameras/camera";
  71842. import "babylonjs/Shaders/colorCorrection.fragment";
  71843. /**
  71844. *
  71845. * This post-process allows the modification of rendered colors by using
  71846. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71847. *
  71848. * The object needs to be provided an url to a texture containing the color
  71849. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71850. * Use an image editing software to tweak the LUT to match your needs.
  71851. *
  71852. * For an example of a color LUT, see here:
  71853. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71854. * For explanations on color grading, see here:
  71855. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71856. *
  71857. */
  71858. export class ColorCorrectionPostProcess extends PostProcess {
  71859. private _colorTableTexture;
  71860. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71861. }
  71862. }
  71863. declare module "babylonjs/Shaders/convolution.fragment" {
  71864. /** @hidden */
  71865. export var convolutionPixelShader: {
  71866. name: string;
  71867. shader: string;
  71868. };
  71869. }
  71870. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71872. import { Nullable } from "babylonjs/types";
  71873. import { Camera } from "babylonjs/Cameras/camera";
  71874. import { Engine } from "babylonjs/Engines/engine";
  71875. import "babylonjs/Shaders/convolution.fragment";
  71876. /**
  71877. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71878. * input texture to perform effects such as edge detection or sharpening
  71879. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71880. */
  71881. export class ConvolutionPostProcess extends PostProcess {
  71882. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71883. kernel: number[];
  71884. /**
  71885. * Creates a new instance ConvolutionPostProcess
  71886. * @param name The name of the effect.
  71887. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71888. * @param options The required width/height ratio to downsize to before computing the render pass.
  71889. * @param camera The camera to apply the render pass to.
  71890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71891. * @param engine The engine which the post process will be applied. (default: current engine)
  71892. * @param reusable If the post process can be reused on the same frame. (default: false)
  71893. * @param textureType Type of textures used when performing the post process. (default: 0)
  71894. */
  71895. constructor(name: string,
  71896. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71897. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71898. /**
  71899. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71900. */
  71901. static EdgeDetect0Kernel: number[];
  71902. /**
  71903. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71904. */
  71905. static EdgeDetect1Kernel: number[];
  71906. /**
  71907. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71908. */
  71909. static EdgeDetect2Kernel: number[];
  71910. /**
  71911. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71912. */
  71913. static SharpenKernel: number[];
  71914. /**
  71915. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71916. */
  71917. static EmbossKernel: number[];
  71918. /**
  71919. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71920. */
  71921. static GaussianKernel: number[];
  71922. }
  71923. }
  71924. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71925. import { Nullable } from "babylonjs/types";
  71926. import { Vector2 } from "babylonjs/Maths/math.vector";
  71927. import { Camera } from "babylonjs/Cameras/camera";
  71928. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71929. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71930. import { Engine } from "babylonjs/Engines/engine";
  71931. import { Scene } from "babylonjs/scene";
  71932. /**
  71933. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71934. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71935. * based on samples that have a large difference in distance than the center pixel.
  71936. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71937. */
  71938. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71939. direction: Vector2;
  71940. /**
  71941. * Creates a new instance CircleOfConfusionPostProcess
  71942. * @param name The name of the effect.
  71943. * @param scene The scene the effect belongs to.
  71944. * @param direction The direction the blur should be applied.
  71945. * @param kernel The size of the kernel used to blur.
  71946. * @param options The required width/height ratio to downsize to before computing the render pass.
  71947. * @param camera The camera to apply the render pass to.
  71948. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71949. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71951. * @param engine The engine which the post process will be applied. (default: current engine)
  71952. * @param reusable If the post process can be reused on the same frame. (default: false)
  71953. * @param textureType Type of textures used when performing the post process. (default: 0)
  71954. * @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)
  71955. */
  71956. 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);
  71957. }
  71958. }
  71959. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71960. /** @hidden */
  71961. export var depthOfFieldMergePixelShader: {
  71962. name: string;
  71963. shader: string;
  71964. };
  71965. }
  71966. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71967. import { Nullable } from "babylonjs/types";
  71968. import { Camera } from "babylonjs/Cameras/camera";
  71969. import { Effect } from "babylonjs/Materials/effect";
  71970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71971. import { Engine } from "babylonjs/Engines/engine";
  71972. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71973. /**
  71974. * Options to be set when merging outputs from the default pipeline.
  71975. */
  71976. export class DepthOfFieldMergePostProcessOptions {
  71977. /**
  71978. * The original image to merge on top of
  71979. */
  71980. originalFromInput: PostProcess;
  71981. /**
  71982. * Parameters to perform the merge of the depth of field effect
  71983. */
  71984. depthOfField?: {
  71985. circleOfConfusion: PostProcess;
  71986. blurSteps: Array<PostProcess>;
  71987. };
  71988. /**
  71989. * Parameters to perform the merge of bloom effect
  71990. */
  71991. bloom?: {
  71992. blurred: PostProcess;
  71993. weight: number;
  71994. };
  71995. }
  71996. /**
  71997. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71998. */
  71999. export class DepthOfFieldMergePostProcess extends PostProcess {
  72000. private blurSteps;
  72001. /**
  72002. * Creates a new instance of DepthOfFieldMergePostProcess
  72003. * @param name The name of the effect.
  72004. * @param originalFromInput Post process which's input will be used for the merge.
  72005. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72006. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72007. * @param options The required width/height ratio to downsize to before computing the render pass.
  72008. * @param camera The camera to apply the render pass to.
  72009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72010. * @param engine The engine which the post process will be applied. (default: current engine)
  72011. * @param reusable If the post process can be reused on the same frame. (default: false)
  72012. * @param textureType Type of textures used when performing the post process. (default: 0)
  72013. * @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)
  72014. */
  72015. 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);
  72016. /**
  72017. * Updates the effect with the current post process compile time values and recompiles the shader.
  72018. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72019. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72020. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72021. * @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
  72022. * @param onCompiled Called when the shader has been compiled.
  72023. * @param onError Called if there is an error when compiling a shader.
  72024. */
  72025. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72026. }
  72027. }
  72028. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72029. import { Nullable } from "babylonjs/types";
  72030. import { Camera } from "babylonjs/Cameras/camera";
  72031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72033. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72034. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72035. import { Scene } from "babylonjs/scene";
  72036. /**
  72037. * Specifies the level of max blur that should be applied when using the depth of field effect
  72038. */
  72039. export enum DepthOfFieldEffectBlurLevel {
  72040. /**
  72041. * Subtle blur
  72042. */
  72043. Low = 0,
  72044. /**
  72045. * Medium blur
  72046. */
  72047. Medium = 1,
  72048. /**
  72049. * Large blur
  72050. */
  72051. High = 2
  72052. }
  72053. /**
  72054. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72055. */
  72056. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72057. private _circleOfConfusion;
  72058. /**
  72059. * @hidden Internal, blurs from high to low
  72060. */
  72061. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72062. private _depthOfFieldBlurY;
  72063. private _dofMerge;
  72064. /**
  72065. * @hidden Internal post processes in depth of field effect
  72066. */
  72067. _effects: Array<PostProcess>;
  72068. /**
  72069. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72070. */
  72071. set focalLength(value: number);
  72072. get focalLength(): number;
  72073. /**
  72074. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72075. */
  72076. set fStop(value: number);
  72077. get fStop(): number;
  72078. /**
  72079. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72080. */
  72081. set focusDistance(value: number);
  72082. get focusDistance(): number;
  72083. /**
  72084. * 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.
  72085. */
  72086. set lensSize(value: number);
  72087. get lensSize(): number;
  72088. /**
  72089. * Creates a new instance DepthOfFieldEffect
  72090. * @param scene The scene the effect belongs to.
  72091. * @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.
  72092. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72093. * @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)
  72094. */
  72095. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72096. /**
  72097. * Get the current class name of the current effet
  72098. * @returns "DepthOfFieldEffect"
  72099. */
  72100. getClassName(): string;
  72101. /**
  72102. * 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.
  72103. */
  72104. set depthTexture(value: RenderTargetTexture);
  72105. /**
  72106. * Disposes each of the internal effects for a given camera.
  72107. * @param camera The camera to dispose the effect on.
  72108. */
  72109. disposeEffects(camera: Camera): void;
  72110. /**
  72111. * @hidden Internal
  72112. */
  72113. _updateEffects(): void;
  72114. /**
  72115. * Internal
  72116. * @returns if all the contained post processes are ready.
  72117. * @hidden
  72118. */
  72119. _isReady(): boolean;
  72120. }
  72121. }
  72122. declare module "babylonjs/Shaders/displayPass.fragment" {
  72123. /** @hidden */
  72124. export var displayPassPixelShader: {
  72125. name: string;
  72126. shader: string;
  72127. };
  72128. }
  72129. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72130. import { Nullable } from "babylonjs/types";
  72131. import { Camera } from "babylonjs/Cameras/camera";
  72132. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72133. import { Engine } from "babylonjs/Engines/engine";
  72134. import "babylonjs/Shaders/displayPass.fragment";
  72135. /**
  72136. * DisplayPassPostProcess which produces an output the same as it's input
  72137. */
  72138. export class DisplayPassPostProcess extends PostProcess {
  72139. /**
  72140. * Creates the DisplayPassPostProcess
  72141. * @param name The name of the effect.
  72142. * @param options The required width/height ratio to downsize to before computing the render pass.
  72143. * @param camera The camera to apply the render pass to.
  72144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72145. * @param engine The engine which the post process will be applied. (default: current engine)
  72146. * @param reusable If the post process can be reused on the same frame. (default: false)
  72147. */
  72148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72149. }
  72150. }
  72151. declare module "babylonjs/Shaders/filter.fragment" {
  72152. /** @hidden */
  72153. export var filterPixelShader: {
  72154. name: string;
  72155. shader: string;
  72156. };
  72157. }
  72158. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72159. import { Nullable } from "babylonjs/types";
  72160. import { Matrix } from "babylonjs/Maths/math.vector";
  72161. import { Camera } from "babylonjs/Cameras/camera";
  72162. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72163. import { Engine } from "babylonjs/Engines/engine";
  72164. import "babylonjs/Shaders/filter.fragment";
  72165. /**
  72166. * Applies a kernel filter to the image
  72167. */
  72168. export class FilterPostProcess extends PostProcess {
  72169. /** The matrix to be applied to the image */
  72170. kernelMatrix: Matrix;
  72171. /**
  72172. *
  72173. * @param name The name of the effect.
  72174. * @param kernelMatrix The matrix to be applied to the image
  72175. * @param options The required width/height ratio to downsize to before computing the render pass.
  72176. * @param camera The camera to apply the render pass to.
  72177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72178. * @param engine The engine which the post process will be applied. (default: current engine)
  72179. * @param reusable If the post process can be reused on the same frame. (default: false)
  72180. */
  72181. constructor(name: string,
  72182. /** The matrix to be applied to the image */
  72183. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72184. }
  72185. }
  72186. declare module "babylonjs/Shaders/fxaa.fragment" {
  72187. /** @hidden */
  72188. export var fxaaPixelShader: {
  72189. name: string;
  72190. shader: string;
  72191. };
  72192. }
  72193. declare module "babylonjs/Shaders/fxaa.vertex" {
  72194. /** @hidden */
  72195. export var fxaaVertexShader: {
  72196. name: string;
  72197. shader: string;
  72198. };
  72199. }
  72200. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72201. import { Nullable } from "babylonjs/types";
  72202. import { Camera } from "babylonjs/Cameras/camera";
  72203. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72204. import { Engine } from "babylonjs/Engines/engine";
  72205. import "babylonjs/Shaders/fxaa.fragment";
  72206. import "babylonjs/Shaders/fxaa.vertex";
  72207. /**
  72208. * Fxaa post process
  72209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72210. */
  72211. export class FxaaPostProcess extends PostProcess {
  72212. /** @hidden */
  72213. texelWidth: number;
  72214. /** @hidden */
  72215. texelHeight: number;
  72216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72217. private _getDefines;
  72218. }
  72219. }
  72220. declare module "babylonjs/Shaders/grain.fragment" {
  72221. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72222. /** @hidden */
  72223. export var grainPixelShader: {
  72224. name: string;
  72225. shader: string;
  72226. };
  72227. }
  72228. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72229. import { Nullable } from "babylonjs/types";
  72230. import { Camera } from "babylonjs/Cameras/camera";
  72231. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72232. import { Engine } from "babylonjs/Engines/engine";
  72233. import "babylonjs/Shaders/grain.fragment";
  72234. /**
  72235. * The GrainPostProcess adds noise to the image at mid luminance levels
  72236. */
  72237. export class GrainPostProcess extends PostProcess {
  72238. /**
  72239. * The intensity of the grain added (default: 30)
  72240. */
  72241. intensity: number;
  72242. /**
  72243. * If the grain should be randomized on every frame
  72244. */
  72245. animated: boolean;
  72246. /**
  72247. * Creates a new instance of @see GrainPostProcess
  72248. * @param name The name of the effect.
  72249. * @param options The required width/height ratio to downsize to before computing the render pass.
  72250. * @param camera The camera to apply the render pass to.
  72251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72252. * @param engine The engine which the post process will be applied. (default: current engine)
  72253. * @param reusable If the post process can be reused on the same frame. (default: false)
  72254. * @param textureType Type of textures used when performing the post process. (default: 0)
  72255. * @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)
  72256. */
  72257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72258. }
  72259. }
  72260. declare module "babylonjs/Shaders/highlights.fragment" {
  72261. /** @hidden */
  72262. export var highlightsPixelShader: {
  72263. name: string;
  72264. shader: string;
  72265. };
  72266. }
  72267. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72268. import { Nullable } from "babylonjs/types";
  72269. import { Camera } from "babylonjs/Cameras/camera";
  72270. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72271. import { Engine } from "babylonjs/Engines/engine";
  72272. import "babylonjs/Shaders/highlights.fragment";
  72273. /**
  72274. * Extracts highlights from the image
  72275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72276. */
  72277. export class HighlightsPostProcess extends PostProcess {
  72278. /**
  72279. * Extracts highlights from the image
  72280. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72281. * @param name The name of the effect.
  72282. * @param options The required width/height ratio to downsize to before computing the render pass.
  72283. * @param camera The camera to apply the render pass to.
  72284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72285. * @param engine The engine which the post process will be applied. (default: current engine)
  72286. * @param reusable If the post process can be reused on the same frame. (default: false)
  72287. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72288. */
  72289. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72290. }
  72291. }
  72292. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72293. /** @hidden */
  72294. export var mrtFragmentDeclaration: {
  72295. name: string;
  72296. shader: string;
  72297. };
  72298. }
  72299. declare module "babylonjs/Shaders/geometry.fragment" {
  72300. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72301. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72302. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72303. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72304. /** @hidden */
  72305. export var geometryPixelShader: {
  72306. name: string;
  72307. shader: string;
  72308. };
  72309. }
  72310. declare module "babylonjs/Shaders/geometry.vertex" {
  72311. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72312. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72313. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72314. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72316. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72317. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72318. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72319. /** @hidden */
  72320. export var geometryVertexShader: {
  72321. name: string;
  72322. shader: string;
  72323. };
  72324. }
  72325. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72326. import { Matrix } from "babylonjs/Maths/math.vector";
  72327. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72328. import { Mesh } from "babylonjs/Meshes/mesh";
  72329. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72330. import { Effect } from "babylonjs/Materials/effect";
  72331. import { Scene } from "babylonjs/scene";
  72332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72333. import "babylonjs/Shaders/geometry.fragment";
  72334. import "babylonjs/Shaders/geometry.vertex";
  72335. /** @hidden */
  72336. interface ISavedTransformationMatrix {
  72337. world: Matrix;
  72338. viewProjection: Matrix;
  72339. }
  72340. /**
  72341. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72342. */
  72343. export class GeometryBufferRenderer {
  72344. /**
  72345. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72346. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72347. */
  72348. static readonly POSITION_TEXTURE_TYPE: number;
  72349. /**
  72350. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72351. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72352. */
  72353. static readonly VELOCITY_TEXTURE_TYPE: number;
  72354. /**
  72355. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72356. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72357. */
  72358. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72359. /**
  72360. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72361. * in order to compute objects velocities when enableVelocity is set to "true"
  72362. * @hidden
  72363. */
  72364. _previousTransformationMatrices: {
  72365. [index: number]: ISavedTransformationMatrix;
  72366. };
  72367. /**
  72368. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72369. * in order to compute objects velocities when enableVelocity is set to "true"
  72370. * @hidden
  72371. */
  72372. _previousBonesTransformationMatrices: {
  72373. [index: number]: Float32Array;
  72374. };
  72375. /**
  72376. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72377. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72378. */
  72379. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72380. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72381. renderTransparentMeshes: boolean;
  72382. private _scene;
  72383. private _multiRenderTarget;
  72384. private _ratio;
  72385. private _enablePosition;
  72386. private _enableVelocity;
  72387. private _enableReflectivity;
  72388. private _positionIndex;
  72389. private _velocityIndex;
  72390. private _reflectivityIndex;
  72391. protected _effect: Effect;
  72392. protected _cachedDefines: string;
  72393. /**
  72394. * Set the render list (meshes to be rendered) used in the G buffer.
  72395. */
  72396. set renderList(meshes: Mesh[]);
  72397. /**
  72398. * Gets wether or not G buffer are supported by the running hardware.
  72399. * This requires draw buffer supports
  72400. */
  72401. get isSupported(): boolean;
  72402. /**
  72403. * Returns the index of the given texture type in the G-Buffer textures array
  72404. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72405. * @returns the index of the given texture type in the G-Buffer textures array
  72406. */
  72407. getTextureIndex(textureType: number): number;
  72408. /**
  72409. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72410. */
  72411. get enablePosition(): boolean;
  72412. /**
  72413. * Sets whether or not objects positions are enabled for the G buffer.
  72414. */
  72415. set enablePosition(enable: boolean);
  72416. /**
  72417. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72418. */
  72419. get enableVelocity(): boolean;
  72420. /**
  72421. * Sets wether or not objects velocities are enabled for the G buffer.
  72422. */
  72423. set enableVelocity(enable: boolean);
  72424. /**
  72425. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72426. */
  72427. get enableReflectivity(): boolean;
  72428. /**
  72429. * Sets wether or not objects roughness are enabled for the G buffer.
  72430. */
  72431. set enableReflectivity(enable: boolean);
  72432. /**
  72433. * Gets the scene associated with the buffer.
  72434. */
  72435. get scene(): Scene;
  72436. /**
  72437. * Gets the ratio used by the buffer during its creation.
  72438. * How big is the buffer related to the main canvas.
  72439. */
  72440. get ratio(): number;
  72441. /** @hidden */
  72442. static _SceneComponentInitialization: (scene: Scene) => void;
  72443. /**
  72444. * Creates a new G Buffer for the scene
  72445. * @param scene The scene the buffer belongs to
  72446. * @param ratio How big is the buffer related to the main canvas.
  72447. */
  72448. constructor(scene: Scene, ratio?: number);
  72449. /**
  72450. * Checks wether everything is ready to render a submesh to the G buffer.
  72451. * @param subMesh the submesh to check readiness for
  72452. * @param useInstances is the mesh drawn using instance or not
  72453. * @returns true if ready otherwise false
  72454. */
  72455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72456. /**
  72457. * Gets the current underlying G Buffer.
  72458. * @returns the buffer
  72459. */
  72460. getGBuffer(): MultiRenderTarget;
  72461. /**
  72462. * Gets the number of samples used to render the buffer (anti aliasing).
  72463. */
  72464. get samples(): number;
  72465. /**
  72466. * Sets the number of samples used to render the buffer (anti aliasing).
  72467. */
  72468. set samples(value: number);
  72469. /**
  72470. * Disposes the renderer and frees up associated resources.
  72471. */
  72472. dispose(): void;
  72473. protected _createRenderTargets(): void;
  72474. private _copyBonesTransformationMatrices;
  72475. }
  72476. }
  72477. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72478. import { Nullable } from "babylonjs/types";
  72479. import { Scene } from "babylonjs/scene";
  72480. import { ISceneComponent } from "babylonjs/sceneComponent";
  72481. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72482. module "babylonjs/scene" {
  72483. interface Scene {
  72484. /** @hidden (Backing field) */
  72485. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72486. /**
  72487. * Gets or Sets the current geometry buffer associated to the scene.
  72488. */
  72489. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72490. /**
  72491. * Enables a GeometryBufferRender and associates it with the scene
  72492. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72493. * @returns the GeometryBufferRenderer
  72494. */
  72495. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72496. /**
  72497. * Disables the GeometryBufferRender associated with the scene
  72498. */
  72499. disableGeometryBufferRenderer(): void;
  72500. }
  72501. }
  72502. /**
  72503. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72504. * in several rendering techniques.
  72505. */
  72506. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72507. /**
  72508. * The component name helpful to identify the component in the list of scene components.
  72509. */
  72510. readonly name: string;
  72511. /**
  72512. * The scene the component belongs to.
  72513. */
  72514. scene: Scene;
  72515. /**
  72516. * Creates a new instance of the component for the given scene
  72517. * @param scene Defines the scene to register the component in
  72518. */
  72519. constructor(scene: Scene);
  72520. /**
  72521. * Registers the component in a given scene
  72522. */
  72523. register(): void;
  72524. /**
  72525. * Rebuilds the elements related to this component in case of
  72526. * context lost for instance.
  72527. */
  72528. rebuild(): void;
  72529. /**
  72530. * Disposes the component and the associated ressources
  72531. */
  72532. dispose(): void;
  72533. private _gatherRenderTargets;
  72534. }
  72535. }
  72536. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72537. /** @hidden */
  72538. export var motionBlurPixelShader: {
  72539. name: string;
  72540. shader: string;
  72541. };
  72542. }
  72543. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72544. import { Nullable } from "babylonjs/types";
  72545. import { Camera } from "babylonjs/Cameras/camera";
  72546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72547. import { Scene } from "babylonjs/scene";
  72548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72549. import "babylonjs/Animations/animatable";
  72550. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72551. import "babylonjs/Shaders/motionBlur.fragment";
  72552. import { Engine } from "babylonjs/Engines/engine";
  72553. /**
  72554. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72555. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72556. * As an example, all you have to do is to create the post-process:
  72557. * var mb = new BABYLON.MotionBlurPostProcess(
  72558. * 'mb', // The name of the effect.
  72559. * scene, // The scene containing the objects to blur according to their velocity.
  72560. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72561. * camera // The camera to apply the render pass to.
  72562. * );
  72563. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72564. */
  72565. export class MotionBlurPostProcess extends PostProcess {
  72566. /**
  72567. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72568. */
  72569. motionStrength: number;
  72570. /**
  72571. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72572. */
  72573. get motionBlurSamples(): number;
  72574. /**
  72575. * Sets the number of iterations to be used for motion blur quality
  72576. */
  72577. set motionBlurSamples(samples: number);
  72578. private _motionBlurSamples;
  72579. private _geometryBufferRenderer;
  72580. /**
  72581. * Creates a new instance MotionBlurPostProcess
  72582. * @param name The name of the effect.
  72583. * @param scene The scene containing the objects to blur according to their velocity.
  72584. * @param options The required width/height ratio to downsize to before computing the render pass.
  72585. * @param camera The camera to apply the render pass to.
  72586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72587. * @param engine The engine which the post process will be applied. (default: current engine)
  72588. * @param reusable If the post process can be reused on the same frame. (default: false)
  72589. * @param textureType Type of textures used when performing the post process. (default: 0)
  72590. * @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)
  72591. */
  72592. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72593. /**
  72594. * Excludes the given skinned mesh from computing bones velocities.
  72595. * 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.
  72596. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72597. */
  72598. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72599. /**
  72600. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72601. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72602. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72603. */
  72604. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72605. /**
  72606. * Disposes the post process.
  72607. * @param camera The camera to dispose the post process on.
  72608. */
  72609. dispose(camera?: Camera): void;
  72610. }
  72611. }
  72612. declare module "babylonjs/Shaders/refraction.fragment" {
  72613. /** @hidden */
  72614. export var refractionPixelShader: {
  72615. name: string;
  72616. shader: string;
  72617. };
  72618. }
  72619. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72620. import { Color3 } from "babylonjs/Maths/math.color";
  72621. import { Camera } from "babylonjs/Cameras/camera";
  72622. import { Texture } from "babylonjs/Materials/Textures/texture";
  72623. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72624. import { Engine } from "babylonjs/Engines/engine";
  72625. import "babylonjs/Shaders/refraction.fragment";
  72626. /**
  72627. * Post process which applies a refractin texture
  72628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72629. */
  72630. export class RefractionPostProcess extends PostProcess {
  72631. /** the base color of the refraction (used to taint the rendering) */
  72632. color: Color3;
  72633. /** simulated refraction depth */
  72634. depth: number;
  72635. /** the coefficient of the base color (0 to remove base color tainting) */
  72636. colorLevel: number;
  72637. private _refTexture;
  72638. private _ownRefractionTexture;
  72639. /**
  72640. * Gets or sets the refraction texture
  72641. * Please note that you are responsible for disposing the texture if you set it manually
  72642. */
  72643. get refractionTexture(): Texture;
  72644. set refractionTexture(value: Texture);
  72645. /**
  72646. * Initializes the RefractionPostProcess
  72647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72648. * @param name The name of the effect.
  72649. * @param refractionTextureUrl Url of the refraction texture to use
  72650. * @param color the base color of the refraction (used to taint the rendering)
  72651. * @param depth simulated refraction depth
  72652. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72653. * @param camera The camera to apply the render pass to.
  72654. * @param options The required width/height ratio to downsize to before computing the render pass.
  72655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72656. * @param engine The engine which the post process will be applied. (default: current engine)
  72657. * @param reusable If the post process can be reused on the same frame. (default: false)
  72658. */
  72659. constructor(name: string, refractionTextureUrl: string,
  72660. /** the base color of the refraction (used to taint the rendering) */
  72661. color: Color3,
  72662. /** simulated refraction depth */
  72663. depth: number,
  72664. /** the coefficient of the base color (0 to remove base color tainting) */
  72665. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72666. /**
  72667. * Disposes of the post process
  72668. * @param camera Camera to dispose post process on
  72669. */
  72670. dispose(camera: Camera): void;
  72671. }
  72672. }
  72673. declare module "babylonjs/Shaders/sharpen.fragment" {
  72674. /** @hidden */
  72675. export var sharpenPixelShader: {
  72676. name: string;
  72677. shader: string;
  72678. };
  72679. }
  72680. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72681. import { Nullable } from "babylonjs/types";
  72682. import { Camera } from "babylonjs/Cameras/camera";
  72683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72684. import "babylonjs/Shaders/sharpen.fragment";
  72685. import { Engine } from "babylonjs/Engines/engine";
  72686. /**
  72687. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72688. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72689. */
  72690. export class SharpenPostProcess extends PostProcess {
  72691. /**
  72692. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72693. */
  72694. colorAmount: number;
  72695. /**
  72696. * How much sharpness should be applied (default: 0.3)
  72697. */
  72698. edgeAmount: number;
  72699. /**
  72700. * Creates a new instance ConvolutionPostProcess
  72701. * @param name The name of the effect.
  72702. * @param options The required width/height ratio to downsize to before computing the render pass.
  72703. * @param camera The camera to apply the render pass to.
  72704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72705. * @param engine The engine which the post process will be applied. (default: current engine)
  72706. * @param reusable If the post process can be reused on the same frame. (default: false)
  72707. * @param textureType Type of textures used when performing the post process. (default: 0)
  72708. * @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)
  72709. */
  72710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72711. }
  72712. }
  72713. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72714. import { Nullable } from "babylonjs/types";
  72715. import { Camera } from "babylonjs/Cameras/camera";
  72716. import { Engine } from "babylonjs/Engines/engine";
  72717. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72718. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72719. /**
  72720. * PostProcessRenderPipeline
  72721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72722. */
  72723. export class PostProcessRenderPipeline {
  72724. private engine;
  72725. private _renderEffects;
  72726. private _renderEffectsForIsolatedPass;
  72727. /**
  72728. * List of inspectable custom properties (used by the Inspector)
  72729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72730. */
  72731. inspectableCustomProperties: IInspectable[];
  72732. /**
  72733. * @hidden
  72734. */
  72735. protected _cameras: Camera[];
  72736. /** @hidden */
  72737. _name: string;
  72738. /**
  72739. * Gets pipeline name
  72740. */
  72741. get name(): string;
  72742. /** Gets the list of attached cameras */
  72743. get cameras(): Camera[];
  72744. /**
  72745. * Initializes a PostProcessRenderPipeline
  72746. * @param engine engine to add the pipeline to
  72747. * @param name name of the pipeline
  72748. */
  72749. constructor(engine: Engine, name: string);
  72750. /**
  72751. * Gets the class name
  72752. * @returns "PostProcessRenderPipeline"
  72753. */
  72754. getClassName(): string;
  72755. /**
  72756. * If all the render effects in the pipeline are supported
  72757. */
  72758. get isSupported(): boolean;
  72759. /**
  72760. * Adds an effect to the pipeline
  72761. * @param renderEffect the effect to add
  72762. */
  72763. addEffect(renderEffect: PostProcessRenderEffect): void;
  72764. /** @hidden */
  72765. _rebuild(): void;
  72766. /** @hidden */
  72767. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72768. /** @hidden */
  72769. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72770. /** @hidden */
  72771. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72772. /** @hidden */
  72773. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72774. /** @hidden */
  72775. _attachCameras(cameras: Camera, unique: boolean): void;
  72776. /** @hidden */
  72777. _attachCameras(cameras: Camera[], unique: boolean): void;
  72778. /** @hidden */
  72779. _detachCameras(cameras: Camera): void;
  72780. /** @hidden */
  72781. _detachCameras(cameras: Nullable<Camera[]>): void;
  72782. /** @hidden */
  72783. _update(): void;
  72784. /** @hidden */
  72785. _reset(): void;
  72786. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72787. /**
  72788. * Disposes of the pipeline
  72789. */
  72790. dispose(): void;
  72791. }
  72792. }
  72793. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72794. import { Camera } from "babylonjs/Cameras/camera";
  72795. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72796. /**
  72797. * PostProcessRenderPipelineManager class
  72798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72799. */
  72800. export class PostProcessRenderPipelineManager {
  72801. private _renderPipelines;
  72802. /**
  72803. * Initializes a PostProcessRenderPipelineManager
  72804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72805. */
  72806. constructor();
  72807. /**
  72808. * Gets the list of supported render pipelines
  72809. */
  72810. get supportedPipelines(): PostProcessRenderPipeline[];
  72811. /**
  72812. * Adds a pipeline to the manager
  72813. * @param renderPipeline The pipeline to add
  72814. */
  72815. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72816. /**
  72817. * Attaches a camera to the pipeline
  72818. * @param renderPipelineName The name of the pipeline to attach to
  72819. * @param cameras the camera to attach
  72820. * @param unique if the camera can be attached multiple times to the pipeline
  72821. */
  72822. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72823. /**
  72824. * Detaches a camera from the pipeline
  72825. * @param renderPipelineName The name of the pipeline to detach from
  72826. * @param cameras the camera to detach
  72827. */
  72828. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72829. /**
  72830. * Enables an effect by name on a pipeline
  72831. * @param renderPipelineName the name of the pipeline to enable the effect in
  72832. * @param renderEffectName the name of the effect to enable
  72833. * @param cameras the cameras that the effect should be enabled on
  72834. */
  72835. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72836. /**
  72837. * Disables an effect by name on a pipeline
  72838. * @param renderPipelineName the name of the pipeline to disable the effect in
  72839. * @param renderEffectName the name of the effect to disable
  72840. * @param cameras the cameras that the effect should be disabled on
  72841. */
  72842. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72843. /**
  72844. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72845. */
  72846. update(): void;
  72847. /** @hidden */
  72848. _rebuild(): void;
  72849. /**
  72850. * Disposes of the manager and pipelines
  72851. */
  72852. dispose(): void;
  72853. }
  72854. }
  72855. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72856. import { ISceneComponent } from "babylonjs/sceneComponent";
  72857. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72858. import { Scene } from "babylonjs/scene";
  72859. module "babylonjs/scene" {
  72860. interface Scene {
  72861. /** @hidden (Backing field) */
  72862. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72863. /**
  72864. * Gets the postprocess render pipeline manager
  72865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72866. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72867. */
  72868. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72869. }
  72870. }
  72871. /**
  72872. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72873. */
  72874. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72875. /**
  72876. * The component name helpfull to identify the component in the list of scene components.
  72877. */
  72878. readonly name: string;
  72879. /**
  72880. * The scene the component belongs to.
  72881. */
  72882. scene: Scene;
  72883. /**
  72884. * Creates a new instance of the component for the given scene
  72885. * @param scene Defines the scene to register the component in
  72886. */
  72887. constructor(scene: Scene);
  72888. /**
  72889. * Registers the component in a given scene
  72890. */
  72891. register(): void;
  72892. /**
  72893. * Rebuilds the elements related to this component in case of
  72894. * context lost for instance.
  72895. */
  72896. rebuild(): void;
  72897. /**
  72898. * Disposes the component and the associated ressources
  72899. */
  72900. dispose(): void;
  72901. private _gatherRenderTargets;
  72902. }
  72903. }
  72904. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72905. import { Nullable } from "babylonjs/types";
  72906. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72907. import { Camera } from "babylonjs/Cameras/camera";
  72908. import { IDisposable } from "babylonjs/scene";
  72909. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72910. import { Scene } from "babylonjs/scene";
  72911. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72912. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72913. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72914. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72915. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72916. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72917. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72918. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72919. import { Animation } from "babylonjs/Animations/animation";
  72920. /**
  72921. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72922. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72923. */
  72924. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72925. private _scene;
  72926. private _camerasToBeAttached;
  72927. /**
  72928. * ID of the sharpen post process,
  72929. */
  72930. private readonly SharpenPostProcessId;
  72931. /**
  72932. * @ignore
  72933. * ID of the image processing post process;
  72934. */
  72935. readonly ImageProcessingPostProcessId: string;
  72936. /**
  72937. * @ignore
  72938. * ID of the Fast Approximate Anti-Aliasing post process;
  72939. */
  72940. readonly FxaaPostProcessId: string;
  72941. /**
  72942. * ID of the chromatic aberration post process,
  72943. */
  72944. private readonly ChromaticAberrationPostProcessId;
  72945. /**
  72946. * ID of the grain post process
  72947. */
  72948. private readonly GrainPostProcessId;
  72949. /**
  72950. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72951. */
  72952. sharpen: SharpenPostProcess;
  72953. private _sharpenEffect;
  72954. private bloom;
  72955. /**
  72956. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72957. */
  72958. depthOfField: DepthOfFieldEffect;
  72959. /**
  72960. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72961. */
  72962. fxaa: FxaaPostProcess;
  72963. /**
  72964. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72965. */
  72966. imageProcessing: ImageProcessingPostProcess;
  72967. /**
  72968. * Chromatic aberration post process which will shift rgb colors in the image
  72969. */
  72970. chromaticAberration: ChromaticAberrationPostProcess;
  72971. private _chromaticAberrationEffect;
  72972. /**
  72973. * Grain post process which add noise to the image
  72974. */
  72975. grain: GrainPostProcess;
  72976. private _grainEffect;
  72977. /**
  72978. * Glow post process which adds a glow to emissive areas of the image
  72979. */
  72980. private _glowLayer;
  72981. /**
  72982. * Animations which can be used to tweak settings over a period of time
  72983. */
  72984. animations: Animation[];
  72985. private _imageProcessingConfigurationObserver;
  72986. private _sharpenEnabled;
  72987. private _bloomEnabled;
  72988. private _depthOfFieldEnabled;
  72989. private _depthOfFieldBlurLevel;
  72990. private _fxaaEnabled;
  72991. private _imageProcessingEnabled;
  72992. private _defaultPipelineTextureType;
  72993. private _bloomScale;
  72994. private _chromaticAberrationEnabled;
  72995. private _grainEnabled;
  72996. private _buildAllowed;
  72997. /**
  72998. * Gets active scene
  72999. */
  73000. get scene(): Scene;
  73001. /**
  73002. * Enable or disable the sharpen process from the pipeline
  73003. */
  73004. set sharpenEnabled(enabled: boolean);
  73005. get sharpenEnabled(): boolean;
  73006. private _resizeObserver;
  73007. private _hardwareScaleLevel;
  73008. private _bloomKernel;
  73009. /**
  73010. * Specifies the size of the bloom blur kernel, relative to the final output size
  73011. */
  73012. get bloomKernel(): number;
  73013. set bloomKernel(value: number);
  73014. /**
  73015. * Specifies the weight of the bloom in the final rendering
  73016. */
  73017. private _bloomWeight;
  73018. /**
  73019. * Specifies the luma threshold for the area that will be blurred by the bloom
  73020. */
  73021. private _bloomThreshold;
  73022. private _hdr;
  73023. /**
  73024. * The strength of the bloom.
  73025. */
  73026. set bloomWeight(value: number);
  73027. get bloomWeight(): number;
  73028. /**
  73029. * The strength of the bloom.
  73030. */
  73031. set bloomThreshold(value: number);
  73032. get bloomThreshold(): number;
  73033. /**
  73034. * The scale of the bloom, lower value will provide better performance.
  73035. */
  73036. set bloomScale(value: number);
  73037. get bloomScale(): number;
  73038. /**
  73039. * Enable or disable the bloom from the pipeline
  73040. */
  73041. set bloomEnabled(enabled: boolean);
  73042. get bloomEnabled(): boolean;
  73043. private _rebuildBloom;
  73044. /**
  73045. * If the depth of field is enabled.
  73046. */
  73047. get depthOfFieldEnabled(): boolean;
  73048. set depthOfFieldEnabled(enabled: boolean);
  73049. /**
  73050. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73051. */
  73052. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73053. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73054. /**
  73055. * If the anti aliasing is enabled.
  73056. */
  73057. set fxaaEnabled(enabled: boolean);
  73058. get fxaaEnabled(): boolean;
  73059. private _samples;
  73060. /**
  73061. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73062. */
  73063. set samples(sampleCount: number);
  73064. get samples(): number;
  73065. /**
  73066. * If image processing is enabled.
  73067. */
  73068. set imageProcessingEnabled(enabled: boolean);
  73069. get imageProcessingEnabled(): boolean;
  73070. /**
  73071. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73072. */
  73073. set glowLayerEnabled(enabled: boolean);
  73074. get glowLayerEnabled(): boolean;
  73075. /**
  73076. * Gets the glow layer (or null if not defined)
  73077. */
  73078. get glowLayer(): Nullable<GlowLayer>;
  73079. /**
  73080. * Enable or disable the chromaticAberration process from the pipeline
  73081. */
  73082. set chromaticAberrationEnabled(enabled: boolean);
  73083. get chromaticAberrationEnabled(): boolean;
  73084. /**
  73085. * Enable or disable the grain process from the pipeline
  73086. */
  73087. set grainEnabled(enabled: boolean);
  73088. get grainEnabled(): boolean;
  73089. /**
  73090. * @constructor
  73091. * @param name - The rendering pipeline name (default: "")
  73092. * @param hdr - If high dynamic range textures should be used (default: true)
  73093. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73094. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73095. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73096. */
  73097. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73098. /**
  73099. * Get the class name
  73100. * @returns "DefaultRenderingPipeline"
  73101. */
  73102. getClassName(): string;
  73103. /**
  73104. * Force the compilation of the entire pipeline.
  73105. */
  73106. prepare(): void;
  73107. private _hasCleared;
  73108. private _prevPostProcess;
  73109. private _prevPrevPostProcess;
  73110. private _setAutoClearAndTextureSharing;
  73111. private _depthOfFieldSceneObserver;
  73112. private _buildPipeline;
  73113. private _disposePostProcesses;
  73114. /**
  73115. * Adds a camera to the pipeline
  73116. * @param camera the camera to be added
  73117. */
  73118. addCamera(camera: Camera): void;
  73119. /**
  73120. * Removes a camera from the pipeline
  73121. * @param camera the camera to remove
  73122. */
  73123. removeCamera(camera: Camera): void;
  73124. /**
  73125. * Dispose of the pipeline and stop all post processes
  73126. */
  73127. dispose(): void;
  73128. /**
  73129. * Serialize the rendering pipeline (Used when exporting)
  73130. * @returns the serialized object
  73131. */
  73132. serialize(): any;
  73133. /**
  73134. * Parse the serialized pipeline
  73135. * @param source Source pipeline.
  73136. * @param scene The scene to load the pipeline to.
  73137. * @param rootUrl The URL of the serialized pipeline.
  73138. * @returns An instantiated pipeline from the serialized object.
  73139. */
  73140. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73141. }
  73142. }
  73143. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73144. /** @hidden */
  73145. export var lensHighlightsPixelShader: {
  73146. name: string;
  73147. shader: string;
  73148. };
  73149. }
  73150. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73151. /** @hidden */
  73152. export var depthOfFieldPixelShader: {
  73153. name: string;
  73154. shader: string;
  73155. };
  73156. }
  73157. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73158. import { Camera } from "babylonjs/Cameras/camera";
  73159. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73160. import { Scene } from "babylonjs/scene";
  73161. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73162. import "babylonjs/Shaders/chromaticAberration.fragment";
  73163. import "babylonjs/Shaders/lensHighlights.fragment";
  73164. import "babylonjs/Shaders/depthOfField.fragment";
  73165. /**
  73166. * BABYLON.JS Chromatic Aberration GLSL Shader
  73167. * Author: Olivier Guyot
  73168. * Separates very slightly R, G and B colors on the edges of the screen
  73169. * Inspired by Francois Tarlier & Martins Upitis
  73170. */
  73171. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73172. /**
  73173. * @ignore
  73174. * The chromatic aberration PostProcess id in the pipeline
  73175. */
  73176. LensChromaticAberrationEffect: string;
  73177. /**
  73178. * @ignore
  73179. * The highlights enhancing PostProcess id in the pipeline
  73180. */
  73181. HighlightsEnhancingEffect: string;
  73182. /**
  73183. * @ignore
  73184. * The depth-of-field PostProcess id in the pipeline
  73185. */
  73186. LensDepthOfFieldEffect: string;
  73187. private _scene;
  73188. private _depthTexture;
  73189. private _grainTexture;
  73190. private _chromaticAberrationPostProcess;
  73191. private _highlightsPostProcess;
  73192. private _depthOfFieldPostProcess;
  73193. private _edgeBlur;
  73194. private _grainAmount;
  73195. private _chromaticAberration;
  73196. private _distortion;
  73197. private _highlightsGain;
  73198. private _highlightsThreshold;
  73199. private _dofDistance;
  73200. private _dofAperture;
  73201. private _dofDarken;
  73202. private _dofPentagon;
  73203. private _blurNoise;
  73204. /**
  73205. * @constructor
  73206. *
  73207. * Effect parameters are as follow:
  73208. * {
  73209. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73210. * edge_blur: number; // from 0 to x (1 for realism)
  73211. * distortion: number; // from 0 to x (1 for realism)
  73212. * grain_amount: number; // from 0 to 1
  73213. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73214. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73215. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73216. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73217. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73218. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73219. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73220. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73221. * }
  73222. * Note: if an effect parameter is unset, effect is disabled
  73223. *
  73224. * @param name The rendering pipeline name
  73225. * @param parameters - An object containing all parameters (see above)
  73226. * @param scene The scene linked to this pipeline
  73227. * @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)
  73228. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73229. */
  73230. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73231. /**
  73232. * Get the class name
  73233. * @returns "LensRenderingPipeline"
  73234. */
  73235. getClassName(): string;
  73236. /**
  73237. * Gets associated scene
  73238. */
  73239. get scene(): Scene;
  73240. /**
  73241. * Gets or sets the edge blur
  73242. */
  73243. get edgeBlur(): number;
  73244. set edgeBlur(value: number);
  73245. /**
  73246. * Gets or sets the grain amount
  73247. */
  73248. get grainAmount(): number;
  73249. set grainAmount(value: number);
  73250. /**
  73251. * Gets or sets the chromatic aberration amount
  73252. */
  73253. get chromaticAberration(): number;
  73254. set chromaticAberration(value: number);
  73255. /**
  73256. * Gets or sets the depth of field aperture
  73257. */
  73258. get dofAperture(): number;
  73259. set dofAperture(value: number);
  73260. /**
  73261. * Gets or sets the edge distortion
  73262. */
  73263. get edgeDistortion(): number;
  73264. set edgeDistortion(value: number);
  73265. /**
  73266. * Gets or sets the depth of field distortion
  73267. */
  73268. get dofDistortion(): number;
  73269. set dofDistortion(value: number);
  73270. /**
  73271. * Gets or sets the darken out of focus amount
  73272. */
  73273. get darkenOutOfFocus(): number;
  73274. set darkenOutOfFocus(value: number);
  73275. /**
  73276. * Gets or sets a boolean indicating if blur noise is enabled
  73277. */
  73278. get blurNoise(): boolean;
  73279. set blurNoise(value: boolean);
  73280. /**
  73281. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73282. */
  73283. get pentagonBokeh(): boolean;
  73284. set pentagonBokeh(value: boolean);
  73285. /**
  73286. * Gets or sets the highlight grain amount
  73287. */
  73288. get highlightsGain(): number;
  73289. set highlightsGain(value: number);
  73290. /**
  73291. * Gets or sets the highlight threshold
  73292. */
  73293. get highlightsThreshold(): number;
  73294. set highlightsThreshold(value: number);
  73295. /**
  73296. * Sets the amount of blur at the edges
  73297. * @param amount blur amount
  73298. */
  73299. setEdgeBlur(amount: number): void;
  73300. /**
  73301. * Sets edge blur to 0
  73302. */
  73303. disableEdgeBlur(): void;
  73304. /**
  73305. * Sets the amout of grain
  73306. * @param amount Amount of grain
  73307. */
  73308. setGrainAmount(amount: number): void;
  73309. /**
  73310. * Set grain amount to 0
  73311. */
  73312. disableGrain(): void;
  73313. /**
  73314. * Sets the chromatic aberration amount
  73315. * @param amount amount of chromatic aberration
  73316. */
  73317. setChromaticAberration(amount: number): void;
  73318. /**
  73319. * Sets chromatic aberration amount to 0
  73320. */
  73321. disableChromaticAberration(): void;
  73322. /**
  73323. * Sets the EdgeDistortion amount
  73324. * @param amount amount of EdgeDistortion
  73325. */
  73326. setEdgeDistortion(amount: number): void;
  73327. /**
  73328. * Sets edge distortion to 0
  73329. */
  73330. disableEdgeDistortion(): void;
  73331. /**
  73332. * Sets the FocusDistance amount
  73333. * @param amount amount of FocusDistance
  73334. */
  73335. setFocusDistance(amount: number): void;
  73336. /**
  73337. * Disables depth of field
  73338. */
  73339. disableDepthOfField(): void;
  73340. /**
  73341. * Sets the Aperture amount
  73342. * @param amount amount of Aperture
  73343. */
  73344. setAperture(amount: number): void;
  73345. /**
  73346. * Sets the DarkenOutOfFocus amount
  73347. * @param amount amount of DarkenOutOfFocus
  73348. */
  73349. setDarkenOutOfFocus(amount: number): void;
  73350. private _pentagonBokehIsEnabled;
  73351. /**
  73352. * Creates a pentagon bokeh effect
  73353. */
  73354. enablePentagonBokeh(): void;
  73355. /**
  73356. * Disables the pentagon bokeh effect
  73357. */
  73358. disablePentagonBokeh(): void;
  73359. /**
  73360. * Enables noise blur
  73361. */
  73362. enableNoiseBlur(): void;
  73363. /**
  73364. * Disables noise blur
  73365. */
  73366. disableNoiseBlur(): void;
  73367. /**
  73368. * Sets the HighlightsGain amount
  73369. * @param amount amount of HighlightsGain
  73370. */
  73371. setHighlightsGain(amount: number): void;
  73372. /**
  73373. * Sets the HighlightsThreshold amount
  73374. * @param amount amount of HighlightsThreshold
  73375. */
  73376. setHighlightsThreshold(amount: number): void;
  73377. /**
  73378. * Disables highlights
  73379. */
  73380. disableHighlights(): void;
  73381. /**
  73382. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73383. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73384. */
  73385. dispose(disableDepthRender?: boolean): void;
  73386. private _createChromaticAberrationPostProcess;
  73387. private _createHighlightsPostProcess;
  73388. private _createDepthOfFieldPostProcess;
  73389. private _createGrainTexture;
  73390. }
  73391. }
  73392. declare module "babylonjs/Shaders/ssao2.fragment" {
  73393. /** @hidden */
  73394. export var ssao2PixelShader: {
  73395. name: string;
  73396. shader: string;
  73397. };
  73398. }
  73399. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73400. /** @hidden */
  73401. export var ssaoCombinePixelShader: {
  73402. name: string;
  73403. shader: string;
  73404. };
  73405. }
  73406. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73407. import { Camera } from "babylonjs/Cameras/camera";
  73408. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73409. import { Scene } from "babylonjs/scene";
  73410. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73411. import "babylonjs/Shaders/ssao2.fragment";
  73412. import "babylonjs/Shaders/ssaoCombine.fragment";
  73413. /**
  73414. * Render pipeline to produce ssao effect
  73415. */
  73416. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73417. /**
  73418. * @ignore
  73419. * The PassPostProcess id in the pipeline that contains the original scene color
  73420. */
  73421. SSAOOriginalSceneColorEffect: string;
  73422. /**
  73423. * @ignore
  73424. * The SSAO PostProcess id in the pipeline
  73425. */
  73426. SSAORenderEffect: string;
  73427. /**
  73428. * @ignore
  73429. * The horizontal blur PostProcess id in the pipeline
  73430. */
  73431. SSAOBlurHRenderEffect: string;
  73432. /**
  73433. * @ignore
  73434. * The vertical blur PostProcess id in the pipeline
  73435. */
  73436. SSAOBlurVRenderEffect: string;
  73437. /**
  73438. * @ignore
  73439. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73440. */
  73441. SSAOCombineRenderEffect: string;
  73442. /**
  73443. * The output strength of the SSAO post-process. Default value is 1.0.
  73444. */
  73445. totalStrength: number;
  73446. /**
  73447. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73448. */
  73449. maxZ: number;
  73450. /**
  73451. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73452. */
  73453. minZAspect: number;
  73454. private _samples;
  73455. /**
  73456. * Number of samples used for the SSAO calculations. Default value is 8
  73457. */
  73458. set samples(n: number);
  73459. get samples(): number;
  73460. private _textureSamples;
  73461. /**
  73462. * Number of samples to use for antialiasing
  73463. */
  73464. set textureSamples(n: number);
  73465. get textureSamples(): number;
  73466. /**
  73467. * Ratio object used for SSAO ratio and blur ratio
  73468. */
  73469. private _ratio;
  73470. /**
  73471. * Dynamically generated sphere sampler.
  73472. */
  73473. private _sampleSphere;
  73474. /**
  73475. * Blur filter offsets
  73476. */
  73477. private _samplerOffsets;
  73478. private _expensiveBlur;
  73479. /**
  73480. * If bilateral blur should be used
  73481. */
  73482. set expensiveBlur(b: boolean);
  73483. get expensiveBlur(): boolean;
  73484. /**
  73485. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73486. */
  73487. radius: number;
  73488. /**
  73489. * The base color of the SSAO post-process
  73490. * The final result is "base + ssao" between [0, 1]
  73491. */
  73492. base: number;
  73493. /**
  73494. * Support test.
  73495. */
  73496. static get IsSupported(): boolean;
  73497. private _scene;
  73498. private _depthTexture;
  73499. private _normalTexture;
  73500. private _randomTexture;
  73501. private _originalColorPostProcess;
  73502. private _ssaoPostProcess;
  73503. private _blurHPostProcess;
  73504. private _blurVPostProcess;
  73505. private _ssaoCombinePostProcess;
  73506. /**
  73507. * Gets active scene
  73508. */
  73509. get scene(): Scene;
  73510. /**
  73511. * @constructor
  73512. * @param name The rendering pipeline name
  73513. * @param scene The scene linked to this pipeline
  73514. * @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 }
  73515. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73516. */
  73517. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73518. /**
  73519. * Get the class name
  73520. * @returns "SSAO2RenderingPipeline"
  73521. */
  73522. getClassName(): string;
  73523. /**
  73524. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73525. */
  73526. dispose(disableGeometryBufferRenderer?: boolean): void;
  73527. private _createBlurPostProcess;
  73528. /** @hidden */
  73529. _rebuild(): void;
  73530. private _bits;
  73531. private _radicalInverse_VdC;
  73532. private _hammersley;
  73533. private _hemisphereSample_uniform;
  73534. private _generateHemisphere;
  73535. private _createSSAOPostProcess;
  73536. private _createSSAOCombinePostProcess;
  73537. private _createRandomTexture;
  73538. /**
  73539. * Serialize the rendering pipeline (Used when exporting)
  73540. * @returns the serialized object
  73541. */
  73542. serialize(): any;
  73543. /**
  73544. * Parse the serialized pipeline
  73545. * @param source Source pipeline.
  73546. * @param scene The scene to load the pipeline to.
  73547. * @param rootUrl The URL of the serialized pipeline.
  73548. * @returns An instantiated pipeline from the serialized object.
  73549. */
  73550. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73551. }
  73552. }
  73553. declare module "babylonjs/Shaders/ssao.fragment" {
  73554. /** @hidden */
  73555. export var ssaoPixelShader: {
  73556. name: string;
  73557. shader: string;
  73558. };
  73559. }
  73560. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73561. import { Camera } from "babylonjs/Cameras/camera";
  73562. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73563. import { Scene } from "babylonjs/scene";
  73564. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73565. import "babylonjs/Shaders/ssao.fragment";
  73566. import "babylonjs/Shaders/ssaoCombine.fragment";
  73567. /**
  73568. * Render pipeline to produce ssao effect
  73569. */
  73570. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73571. /**
  73572. * @ignore
  73573. * The PassPostProcess id in the pipeline that contains the original scene color
  73574. */
  73575. SSAOOriginalSceneColorEffect: string;
  73576. /**
  73577. * @ignore
  73578. * The SSAO PostProcess id in the pipeline
  73579. */
  73580. SSAORenderEffect: string;
  73581. /**
  73582. * @ignore
  73583. * The horizontal blur PostProcess id in the pipeline
  73584. */
  73585. SSAOBlurHRenderEffect: string;
  73586. /**
  73587. * @ignore
  73588. * The vertical blur PostProcess id in the pipeline
  73589. */
  73590. SSAOBlurVRenderEffect: string;
  73591. /**
  73592. * @ignore
  73593. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73594. */
  73595. SSAOCombineRenderEffect: string;
  73596. /**
  73597. * The output strength of the SSAO post-process. Default value is 1.0.
  73598. */
  73599. totalStrength: number;
  73600. /**
  73601. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73602. */
  73603. radius: number;
  73604. /**
  73605. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73606. * Must not be equal to fallOff and superior to fallOff.
  73607. * Default value is 0.0075
  73608. */
  73609. area: number;
  73610. /**
  73611. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73612. * Must not be equal to area and inferior to area.
  73613. * Default value is 0.000001
  73614. */
  73615. fallOff: number;
  73616. /**
  73617. * The base color of the SSAO post-process
  73618. * The final result is "base + ssao" between [0, 1]
  73619. */
  73620. base: number;
  73621. private _scene;
  73622. private _depthTexture;
  73623. private _randomTexture;
  73624. private _originalColorPostProcess;
  73625. private _ssaoPostProcess;
  73626. private _blurHPostProcess;
  73627. private _blurVPostProcess;
  73628. private _ssaoCombinePostProcess;
  73629. private _firstUpdate;
  73630. /**
  73631. * Gets active scene
  73632. */
  73633. get scene(): Scene;
  73634. /**
  73635. * @constructor
  73636. * @param name - The rendering pipeline name
  73637. * @param scene - The scene linked to this pipeline
  73638. * @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 }
  73639. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73640. */
  73641. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73642. /**
  73643. * Get the class name
  73644. * @returns "SSAORenderingPipeline"
  73645. */
  73646. getClassName(): string;
  73647. /**
  73648. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73649. */
  73650. dispose(disableDepthRender?: boolean): void;
  73651. private _createBlurPostProcess;
  73652. /** @hidden */
  73653. _rebuild(): void;
  73654. private _createSSAOPostProcess;
  73655. private _createSSAOCombinePostProcess;
  73656. private _createRandomTexture;
  73657. }
  73658. }
  73659. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73660. /** @hidden */
  73661. export var screenSpaceReflectionPixelShader: {
  73662. name: string;
  73663. shader: string;
  73664. };
  73665. }
  73666. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73667. import { Nullable } from "babylonjs/types";
  73668. import { Camera } from "babylonjs/Cameras/camera";
  73669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73670. import { Scene } from "babylonjs/scene";
  73671. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73672. import { Engine } from "babylonjs/Engines/engine";
  73673. /**
  73674. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73675. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73676. */
  73677. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73678. /**
  73679. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73680. */
  73681. threshold: number;
  73682. /**
  73683. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73684. */
  73685. strength: number;
  73686. /**
  73687. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73688. */
  73689. reflectionSpecularFalloffExponent: number;
  73690. /**
  73691. * 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]
  73692. */
  73693. step: number;
  73694. /**
  73695. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73696. */
  73697. roughnessFactor: number;
  73698. private _geometryBufferRenderer;
  73699. private _enableSmoothReflections;
  73700. private _reflectionSamples;
  73701. private _smoothSteps;
  73702. /**
  73703. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73704. * @param name The name of the effect.
  73705. * @param scene The scene containing the objects to calculate reflections.
  73706. * @param options The required width/height ratio to downsize to before computing the render pass.
  73707. * @param camera The camera to apply the render pass to.
  73708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73709. * @param engine The engine which the post process will be applied. (default: current engine)
  73710. * @param reusable If the post process can be reused on the same frame. (default: false)
  73711. * @param textureType Type of textures used when performing the post process. (default: 0)
  73712. * @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)
  73713. */
  73714. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73715. /**
  73716. * Gets wether or not smoothing reflections is enabled.
  73717. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73718. */
  73719. get enableSmoothReflections(): boolean;
  73720. /**
  73721. * Sets wether or not smoothing reflections is enabled.
  73722. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73723. */
  73724. set enableSmoothReflections(enabled: boolean);
  73725. /**
  73726. * Gets the number of samples taken while computing reflections. More samples count is high,
  73727. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73728. */
  73729. get reflectionSamples(): number;
  73730. /**
  73731. * Sets the number of samples taken while computing reflections. More samples count is high,
  73732. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73733. */
  73734. set reflectionSamples(samples: number);
  73735. /**
  73736. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73737. * more the post-process will require GPU power and can generate a drop in FPS.
  73738. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73739. */
  73740. get smoothSteps(): number;
  73741. set smoothSteps(steps: number);
  73742. private _updateEffectDefines;
  73743. }
  73744. }
  73745. declare module "babylonjs/Shaders/standard.fragment" {
  73746. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73747. /** @hidden */
  73748. export var standardPixelShader: {
  73749. name: string;
  73750. shader: string;
  73751. };
  73752. }
  73753. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73754. import { Nullable } from "babylonjs/types";
  73755. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73756. import { Camera } from "babylonjs/Cameras/camera";
  73757. import { Texture } from "babylonjs/Materials/Textures/texture";
  73758. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73759. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73760. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73761. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73762. import { IDisposable } from "babylonjs/scene";
  73763. import { SpotLight } from "babylonjs/Lights/spotLight";
  73764. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73765. import { Scene } from "babylonjs/scene";
  73766. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73767. import { Animation } from "babylonjs/Animations/animation";
  73768. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73769. import "babylonjs/Shaders/standard.fragment";
  73770. /**
  73771. * Standard rendering pipeline
  73772. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73773. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73774. */
  73775. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73776. /**
  73777. * Public members
  73778. */
  73779. /**
  73780. * Post-process which contains the original scene color before the pipeline applies all the effects
  73781. */
  73782. originalPostProcess: Nullable<PostProcess>;
  73783. /**
  73784. * Post-process used to down scale an image x4
  73785. */
  73786. downSampleX4PostProcess: Nullable<PostProcess>;
  73787. /**
  73788. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73789. */
  73790. brightPassPostProcess: Nullable<PostProcess>;
  73791. /**
  73792. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73793. */
  73794. blurHPostProcesses: PostProcess[];
  73795. /**
  73796. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73797. */
  73798. blurVPostProcesses: PostProcess[];
  73799. /**
  73800. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73801. */
  73802. textureAdderPostProcess: Nullable<PostProcess>;
  73803. /**
  73804. * Post-process used to create volumetric lighting effect
  73805. */
  73806. volumetricLightPostProcess: Nullable<PostProcess>;
  73807. /**
  73808. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73809. */
  73810. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73811. /**
  73812. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73813. */
  73814. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73815. /**
  73816. * Post-process used to merge the volumetric light effect and the real scene color
  73817. */
  73818. volumetricLightMergePostProces: Nullable<PostProcess>;
  73819. /**
  73820. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73821. */
  73822. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73823. /**
  73824. * Base post-process used to calculate the average luminance of the final image for HDR
  73825. */
  73826. luminancePostProcess: Nullable<PostProcess>;
  73827. /**
  73828. * Post-processes used to create down sample post-processes in order to get
  73829. * the average luminance of the final image for HDR
  73830. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73831. */
  73832. luminanceDownSamplePostProcesses: PostProcess[];
  73833. /**
  73834. * Post-process used to create a HDR effect (light adaptation)
  73835. */
  73836. hdrPostProcess: Nullable<PostProcess>;
  73837. /**
  73838. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73839. */
  73840. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73841. /**
  73842. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73843. */
  73844. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73845. /**
  73846. * Post-process used to merge the final HDR post-process and the real scene color
  73847. */
  73848. hdrFinalPostProcess: Nullable<PostProcess>;
  73849. /**
  73850. * Post-process used to create a lens flare effect
  73851. */
  73852. lensFlarePostProcess: Nullable<PostProcess>;
  73853. /**
  73854. * Post-process that merges the result of the lens flare post-process and the real scene color
  73855. */
  73856. lensFlareComposePostProcess: Nullable<PostProcess>;
  73857. /**
  73858. * Post-process used to create a motion blur effect
  73859. */
  73860. motionBlurPostProcess: Nullable<PostProcess>;
  73861. /**
  73862. * Post-process used to create a depth of field effect
  73863. */
  73864. depthOfFieldPostProcess: Nullable<PostProcess>;
  73865. /**
  73866. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73867. */
  73868. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73869. /**
  73870. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73871. */
  73872. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73873. /**
  73874. * Represents the brightness threshold in order to configure the illuminated surfaces
  73875. */
  73876. brightThreshold: number;
  73877. /**
  73878. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73879. */
  73880. blurWidth: number;
  73881. /**
  73882. * Sets if the blur for highlighted surfaces must be only horizontal
  73883. */
  73884. horizontalBlur: boolean;
  73885. /**
  73886. * Gets the overall exposure used by the pipeline
  73887. */
  73888. get exposure(): number;
  73889. /**
  73890. * Sets the overall exposure used by the pipeline
  73891. */
  73892. set exposure(value: number);
  73893. /**
  73894. * Texture used typically to simulate "dirty" on camera lens
  73895. */
  73896. lensTexture: Nullable<Texture>;
  73897. /**
  73898. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73899. */
  73900. volumetricLightCoefficient: number;
  73901. /**
  73902. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73903. */
  73904. volumetricLightPower: number;
  73905. /**
  73906. * Used the set the blur intensity to smooth the volumetric lights
  73907. */
  73908. volumetricLightBlurScale: number;
  73909. /**
  73910. * Light (spot or directional) used to generate the volumetric lights rays
  73911. * The source light must have a shadow generate so the pipeline can get its
  73912. * depth map
  73913. */
  73914. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73915. /**
  73916. * For eye adaptation, represents the minimum luminance the eye can see
  73917. */
  73918. hdrMinimumLuminance: number;
  73919. /**
  73920. * For eye adaptation, represents the decrease luminance speed
  73921. */
  73922. hdrDecreaseRate: number;
  73923. /**
  73924. * For eye adaptation, represents the increase luminance speed
  73925. */
  73926. hdrIncreaseRate: number;
  73927. /**
  73928. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73929. */
  73930. get hdrAutoExposure(): boolean;
  73931. /**
  73932. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73933. */
  73934. set hdrAutoExposure(value: boolean);
  73935. /**
  73936. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73937. */
  73938. lensColorTexture: Nullable<Texture>;
  73939. /**
  73940. * The overall strengh for the lens flare effect
  73941. */
  73942. lensFlareStrength: number;
  73943. /**
  73944. * Dispersion coefficient for lens flare ghosts
  73945. */
  73946. lensFlareGhostDispersal: number;
  73947. /**
  73948. * Main lens flare halo width
  73949. */
  73950. lensFlareHaloWidth: number;
  73951. /**
  73952. * Based on the lens distortion effect, defines how much the lens flare result
  73953. * is distorted
  73954. */
  73955. lensFlareDistortionStrength: number;
  73956. /**
  73957. * Configures the blur intensity used for for lens flare (halo)
  73958. */
  73959. lensFlareBlurWidth: number;
  73960. /**
  73961. * Lens star texture must be used to simulate rays on the flares and is available
  73962. * in the documentation
  73963. */
  73964. lensStarTexture: Nullable<Texture>;
  73965. /**
  73966. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73967. * flare effect by taking account of the dirt texture
  73968. */
  73969. lensFlareDirtTexture: Nullable<Texture>;
  73970. /**
  73971. * Represents the focal length for the depth of field effect
  73972. */
  73973. depthOfFieldDistance: number;
  73974. /**
  73975. * Represents the blur intensity for the blurred part of the depth of field effect
  73976. */
  73977. depthOfFieldBlurWidth: number;
  73978. /**
  73979. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73980. */
  73981. get motionStrength(): number;
  73982. /**
  73983. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73984. */
  73985. set motionStrength(strength: number);
  73986. /**
  73987. * Gets wether or not the motion blur post-process is object based or screen based.
  73988. */
  73989. get objectBasedMotionBlur(): boolean;
  73990. /**
  73991. * Sets wether or not the motion blur post-process should be object based or screen based
  73992. */
  73993. set objectBasedMotionBlur(value: boolean);
  73994. /**
  73995. * List of animations for the pipeline (IAnimatable implementation)
  73996. */
  73997. animations: Animation[];
  73998. /**
  73999. * Private members
  74000. */
  74001. private _scene;
  74002. private _currentDepthOfFieldSource;
  74003. private _basePostProcess;
  74004. private _fixedExposure;
  74005. private _currentExposure;
  74006. private _hdrAutoExposure;
  74007. private _hdrCurrentLuminance;
  74008. private _motionStrength;
  74009. private _isObjectBasedMotionBlur;
  74010. private _floatTextureType;
  74011. private _camerasToBeAttached;
  74012. private _ratio;
  74013. private _bloomEnabled;
  74014. private _depthOfFieldEnabled;
  74015. private _vlsEnabled;
  74016. private _lensFlareEnabled;
  74017. private _hdrEnabled;
  74018. private _motionBlurEnabled;
  74019. private _fxaaEnabled;
  74020. private _screenSpaceReflectionsEnabled;
  74021. private _motionBlurSamples;
  74022. private _volumetricLightStepsCount;
  74023. private _samples;
  74024. /**
  74025. * @ignore
  74026. * Specifies if the bloom pipeline is enabled
  74027. */
  74028. get BloomEnabled(): boolean;
  74029. set BloomEnabled(enabled: boolean);
  74030. /**
  74031. * @ignore
  74032. * Specifies if the depth of field pipeline is enabed
  74033. */
  74034. get DepthOfFieldEnabled(): boolean;
  74035. set DepthOfFieldEnabled(enabled: boolean);
  74036. /**
  74037. * @ignore
  74038. * Specifies if the lens flare pipeline is enabed
  74039. */
  74040. get LensFlareEnabled(): boolean;
  74041. set LensFlareEnabled(enabled: boolean);
  74042. /**
  74043. * @ignore
  74044. * Specifies if the HDR pipeline is enabled
  74045. */
  74046. get HDREnabled(): boolean;
  74047. set HDREnabled(enabled: boolean);
  74048. /**
  74049. * @ignore
  74050. * Specifies if the volumetric lights scattering effect is enabled
  74051. */
  74052. get VLSEnabled(): boolean;
  74053. set VLSEnabled(enabled: boolean);
  74054. /**
  74055. * @ignore
  74056. * Specifies if the motion blur effect is enabled
  74057. */
  74058. get MotionBlurEnabled(): boolean;
  74059. set MotionBlurEnabled(enabled: boolean);
  74060. /**
  74061. * Specifies if anti-aliasing is enabled
  74062. */
  74063. get fxaaEnabled(): boolean;
  74064. set fxaaEnabled(enabled: boolean);
  74065. /**
  74066. * Specifies if screen space reflections are enabled.
  74067. */
  74068. get screenSpaceReflectionsEnabled(): boolean;
  74069. set screenSpaceReflectionsEnabled(enabled: boolean);
  74070. /**
  74071. * Specifies the number of steps used to calculate the volumetric lights
  74072. * Typically in interval [50, 200]
  74073. */
  74074. get volumetricLightStepsCount(): number;
  74075. set volumetricLightStepsCount(count: number);
  74076. /**
  74077. * Specifies the number of samples used for the motion blur effect
  74078. * Typically in interval [16, 64]
  74079. */
  74080. get motionBlurSamples(): number;
  74081. set motionBlurSamples(samples: number);
  74082. /**
  74083. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74084. */
  74085. get samples(): number;
  74086. set samples(sampleCount: number);
  74087. /**
  74088. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74089. * @constructor
  74090. * @param name The rendering pipeline name
  74091. * @param scene The scene linked to this pipeline
  74092. * @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)
  74093. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74094. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74095. */
  74096. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74097. private _buildPipeline;
  74098. private _createDownSampleX4PostProcess;
  74099. private _createBrightPassPostProcess;
  74100. private _createBlurPostProcesses;
  74101. private _createTextureAdderPostProcess;
  74102. private _createVolumetricLightPostProcess;
  74103. private _createLuminancePostProcesses;
  74104. private _createHdrPostProcess;
  74105. private _createLensFlarePostProcess;
  74106. private _createDepthOfFieldPostProcess;
  74107. private _createMotionBlurPostProcess;
  74108. private _getDepthTexture;
  74109. private _disposePostProcesses;
  74110. /**
  74111. * Dispose of the pipeline and stop all post processes
  74112. */
  74113. dispose(): void;
  74114. /**
  74115. * Serialize the rendering pipeline (Used when exporting)
  74116. * @returns the serialized object
  74117. */
  74118. serialize(): any;
  74119. /**
  74120. * Parse the serialized pipeline
  74121. * @param source Source pipeline.
  74122. * @param scene The scene to load the pipeline to.
  74123. * @param rootUrl The URL of the serialized pipeline.
  74124. * @returns An instantiated pipeline from the serialized object.
  74125. */
  74126. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74127. /**
  74128. * Luminance steps
  74129. */
  74130. static LuminanceSteps: number;
  74131. }
  74132. }
  74133. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74134. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74135. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74136. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74137. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74138. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74139. }
  74140. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74141. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74142. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74143. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74144. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74145. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74146. }
  74147. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74148. /** @hidden */
  74149. export var stereoscopicInterlacePixelShader: {
  74150. name: string;
  74151. shader: string;
  74152. };
  74153. }
  74154. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74155. import { Camera } from "babylonjs/Cameras/camera";
  74156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74157. import { Engine } from "babylonjs/Engines/engine";
  74158. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74159. /**
  74160. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74161. */
  74162. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74163. private _stepSize;
  74164. private _passedProcess;
  74165. /**
  74166. * Initializes a StereoscopicInterlacePostProcessI
  74167. * @param name The name of the effect.
  74168. * @param rigCameras The rig cameras to be appled to the post process
  74169. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74170. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74172. * @param engine The engine which the post process will be applied. (default: current engine)
  74173. * @param reusable If the post process can be reused on the same frame. (default: false)
  74174. */
  74175. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74176. }
  74177. /**
  74178. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74179. */
  74180. export class StereoscopicInterlacePostProcess extends PostProcess {
  74181. private _stepSize;
  74182. private _passedProcess;
  74183. /**
  74184. * Initializes a StereoscopicInterlacePostProcess
  74185. * @param name The name of the effect.
  74186. * @param rigCameras The rig cameras to be appled to the post process
  74187. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74189. * @param engine The engine which the post process will be applied. (default: current engine)
  74190. * @param reusable If the post process can be reused on the same frame. (default: false)
  74191. */
  74192. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74193. }
  74194. }
  74195. declare module "babylonjs/Shaders/tonemap.fragment" {
  74196. /** @hidden */
  74197. export var tonemapPixelShader: {
  74198. name: string;
  74199. shader: string;
  74200. };
  74201. }
  74202. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74203. import { Camera } from "babylonjs/Cameras/camera";
  74204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74205. import "babylonjs/Shaders/tonemap.fragment";
  74206. import { Engine } from "babylonjs/Engines/engine";
  74207. /** Defines operator used for tonemapping */
  74208. export enum TonemappingOperator {
  74209. /** Hable */
  74210. Hable = 0,
  74211. /** Reinhard */
  74212. Reinhard = 1,
  74213. /** HejiDawson */
  74214. HejiDawson = 2,
  74215. /** Photographic */
  74216. Photographic = 3
  74217. }
  74218. /**
  74219. * Defines a post process to apply tone mapping
  74220. */
  74221. export class TonemapPostProcess extends PostProcess {
  74222. private _operator;
  74223. /** Defines the required exposure adjustement */
  74224. exposureAdjustment: number;
  74225. /**
  74226. * Creates a new TonemapPostProcess
  74227. * @param name defines the name of the postprocess
  74228. * @param _operator defines the operator to use
  74229. * @param exposureAdjustment defines the required exposure adjustement
  74230. * @param camera defines the camera to use (can be null)
  74231. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74232. * @param engine defines the hosting engine (can be ignore if camera is set)
  74233. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74234. */
  74235. constructor(name: string, _operator: TonemappingOperator,
  74236. /** Defines the required exposure adjustement */
  74237. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74238. }
  74239. }
  74240. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74241. /** @hidden */
  74242. export var volumetricLightScatteringPixelShader: {
  74243. name: string;
  74244. shader: string;
  74245. };
  74246. }
  74247. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74248. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74250. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74251. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74253. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74254. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74255. /** @hidden */
  74256. export var volumetricLightScatteringPassVertexShader: {
  74257. name: string;
  74258. shader: string;
  74259. };
  74260. }
  74261. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74262. /** @hidden */
  74263. export var volumetricLightScatteringPassPixelShader: {
  74264. name: string;
  74265. shader: string;
  74266. };
  74267. }
  74268. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74269. import { Vector3 } from "babylonjs/Maths/math.vector";
  74270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74271. import { Mesh } from "babylonjs/Meshes/mesh";
  74272. import { Camera } from "babylonjs/Cameras/camera";
  74273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74274. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74275. import { Scene } from "babylonjs/scene";
  74276. import "babylonjs/Meshes/Builders/planeBuilder";
  74277. import "babylonjs/Shaders/depth.vertex";
  74278. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74279. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74280. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74281. import { Engine } from "babylonjs/Engines/engine";
  74282. /**
  74283. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74284. */
  74285. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74286. private _volumetricLightScatteringPass;
  74287. private _volumetricLightScatteringRTT;
  74288. private _viewPort;
  74289. private _screenCoordinates;
  74290. private _cachedDefines;
  74291. /**
  74292. * If not undefined, the mesh position is computed from the attached node position
  74293. */
  74294. attachedNode: {
  74295. position: Vector3;
  74296. };
  74297. /**
  74298. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74299. */
  74300. customMeshPosition: Vector3;
  74301. /**
  74302. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74303. */
  74304. useCustomMeshPosition: boolean;
  74305. /**
  74306. * If the post-process should inverse the light scattering direction
  74307. */
  74308. invert: boolean;
  74309. /**
  74310. * The internal mesh used by the post-process
  74311. */
  74312. mesh: Mesh;
  74313. /**
  74314. * @hidden
  74315. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74316. */
  74317. get useDiffuseColor(): boolean;
  74318. set useDiffuseColor(useDiffuseColor: boolean);
  74319. /**
  74320. * Array containing the excluded meshes not rendered in the internal pass
  74321. */
  74322. excludedMeshes: AbstractMesh[];
  74323. /**
  74324. * Controls the overall intensity of the post-process
  74325. */
  74326. exposure: number;
  74327. /**
  74328. * Dissipates each sample's contribution in range [0, 1]
  74329. */
  74330. decay: number;
  74331. /**
  74332. * Controls the overall intensity of each sample
  74333. */
  74334. weight: number;
  74335. /**
  74336. * Controls the density of each sample
  74337. */
  74338. density: number;
  74339. /**
  74340. * @constructor
  74341. * @param name The post-process name
  74342. * @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)
  74343. * @param camera The camera that the post-process will be attached to
  74344. * @param mesh The mesh used to create the light scattering
  74345. * @param samples The post-process quality, default 100
  74346. * @param samplingModeThe post-process filtering mode
  74347. * @param engine The babylon engine
  74348. * @param reusable If the post-process is reusable
  74349. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74350. */
  74351. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74352. /**
  74353. * Returns the string "VolumetricLightScatteringPostProcess"
  74354. * @returns "VolumetricLightScatteringPostProcess"
  74355. */
  74356. getClassName(): string;
  74357. private _isReady;
  74358. /**
  74359. * Sets the new light position for light scattering effect
  74360. * @param position The new custom light position
  74361. */
  74362. setCustomMeshPosition(position: Vector3): void;
  74363. /**
  74364. * Returns the light position for light scattering effect
  74365. * @return Vector3 The custom light position
  74366. */
  74367. getCustomMeshPosition(): Vector3;
  74368. /**
  74369. * Disposes the internal assets and detaches the post-process from the camera
  74370. */
  74371. dispose(camera: Camera): void;
  74372. /**
  74373. * Returns the render target texture used by the post-process
  74374. * @return the render target texture used by the post-process
  74375. */
  74376. getPass(): RenderTargetTexture;
  74377. private _meshExcluded;
  74378. private _createPass;
  74379. private _updateMeshScreenCoordinates;
  74380. /**
  74381. * Creates a default mesh for the Volumeric Light Scattering post-process
  74382. * @param name The mesh name
  74383. * @param scene The scene where to create the mesh
  74384. * @return the default mesh
  74385. */
  74386. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74387. }
  74388. }
  74389. declare module "babylonjs/PostProcesses/index" {
  74390. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74391. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74392. export * from "babylonjs/PostProcesses/bloomEffect";
  74393. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74394. export * from "babylonjs/PostProcesses/blurPostProcess";
  74395. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74396. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74397. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74398. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74399. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74400. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74401. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74402. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74403. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74404. export * from "babylonjs/PostProcesses/filterPostProcess";
  74405. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74406. export * from "babylonjs/PostProcesses/grainPostProcess";
  74407. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74408. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74409. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74410. export * from "babylonjs/PostProcesses/passPostProcess";
  74411. export * from "babylonjs/PostProcesses/postProcess";
  74412. export * from "babylonjs/PostProcesses/postProcessManager";
  74413. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74414. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74415. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74416. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74417. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74418. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74419. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74420. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74421. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74422. }
  74423. declare module "babylonjs/Probes/index" {
  74424. export * from "babylonjs/Probes/reflectionProbe";
  74425. }
  74426. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74427. import { Scene } from "babylonjs/scene";
  74428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74429. import { SmartArray } from "babylonjs/Misc/smartArray";
  74430. import { ISceneComponent } from "babylonjs/sceneComponent";
  74431. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74432. import "babylonjs/Meshes/Builders/boxBuilder";
  74433. import "babylonjs/Shaders/color.fragment";
  74434. import "babylonjs/Shaders/color.vertex";
  74435. import { Color3 } from "babylonjs/Maths/math.color";
  74436. import { Observable } from "babylonjs/Misc/observable";
  74437. module "babylonjs/scene" {
  74438. interface Scene {
  74439. /** @hidden (Backing field) */
  74440. _boundingBoxRenderer: BoundingBoxRenderer;
  74441. /** @hidden (Backing field) */
  74442. _forceShowBoundingBoxes: boolean;
  74443. /**
  74444. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74445. */
  74446. forceShowBoundingBoxes: boolean;
  74447. /**
  74448. * Gets the bounding box renderer associated with the scene
  74449. * @returns a BoundingBoxRenderer
  74450. */
  74451. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74452. }
  74453. }
  74454. module "babylonjs/Meshes/abstractMesh" {
  74455. interface AbstractMesh {
  74456. /** @hidden (Backing field) */
  74457. _showBoundingBox: boolean;
  74458. /**
  74459. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74460. */
  74461. showBoundingBox: boolean;
  74462. }
  74463. }
  74464. /**
  74465. * Component responsible of rendering the bounding box of the meshes in a scene.
  74466. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74467. */
  74468. export class BoundingBoxRenderer implements ISceneComponent {
  74469. /**
  74470. * The component name helpfull to identify the component in the list of scene components.
  74471. */
  74472. readonly name: string;
  74473. /**
  74474. * The scene the component belongs to.
  74475. */
  74476. scene: Scene;
  74477. /**
  74478. * Color of the bounding box lines placed in front of an object
  74479. */
  74480. frontColor: Color3;
  74481. /**
  74482. * Color of the bounding box lines placed behind an object
  74483. */
  74484. backColor: Color3;
  74485. /**
  74486. * Defines if the renderer should show the back lines or not
  74487. */
  74488. showBackLines: boolean;
  74489. /**
  74490. * Observable raised before rendering a bounding box
  74491. */
  74492. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74493. /**
  74494. * Observable raised after rendering a bounding box
  74495. */
  74496. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74497. /**
  74498. * @hidden
  74499. */
  74500. renderList: SmartArray<BoundingBox>;
  74501. private _colorShader;
  74502. private _vertexBuffers;
  74503. private _indexBuffer;
  74504. private _fillIndexBuffer;
  74505. private _fillIndexData;
  74506. /**
  74507. * Instantiates a new bounding box renderer in a scene.
  74508. * @param scene the scene the renderer renders in
  74509. */
  74510. constructor(scene: Scene);
  74511. /**
  74512. * Registers the component in a given scene
  74513. */
  74514. register(): void;
  74515. private _evaluateSubMesh;
  74516. private _activeMesh;
  74517. private _prepareRessources;
  74518. private _createIndexBuffer;
  74519. /**
  74520. * Rebuilds the elements related to this component in case of
  74521. * context lost for instance.
  74522. */
  74523. rebuild(): void;
  74524. /**
  74525. * @hidden
  74526. */
  74527. reset(): void;
  74528. /**
  74529. * Render the bounding boxes of a specific rendering group
  74530. * @param renderingGroupId defines the rendering group to render
  74531. */
  74532. render(renderingGroupId: number): void;
  74533. /**
  74534. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74535. * @param mesh Define the mesh to render the occlusion bounding box for
  74536. */
  74537. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74538. /**
  74539. * Dispose and release the resources attached to this renderer.
  74540. */
  74541. dispose(): void;
  74542. }
  74543. }
  74544. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74545. import { Nullable } from "babylonjs/types";
  74546. import { Scene } from "babylonjs/scene";
  74547. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74548. import { Camera } from "babylonjs/Cameras/camera";
  74549. import { ISceneComponent } from "babylonjs/sceneComponent";
  74550. module "babylonjs/scene" {
  74551. interface Scene {
  74552. /** @hidden (Backing field) */
  74553. _depthRenderer: {
  74554. [id: string]: DepthRenderer;
  74555. };
  74556. /**
  74557. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74558. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74559. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74560. * @returns the created depth renderer
  74561. */
  74562. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74563. /**
  74564. * Disables a depth renderer for a given camera
  74565. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74566. */
  74567. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74568. }
  74569. }
  74570. /**
  74571. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74572. * in several rendering techniques.
  74573. */
  74574. export class DepthRendererSceneComponent implements ISceneComponent {
  74575. /**
  74576. * The component name helpfull to identify the component in the list of scene components.
  74577. */
  74578. readonly name: string;
  74579. /**
  74580. * The scene the component belongs to.
  74581. */
  74582. scene: Scene;
  74583. /**
  74584. * Creates a new instance of the component for the given scene
  74585. * @param scene Defines the scene to register the component in
  74586. */
  74587. constructor(scene: Scene);
  74588. /**
  74589. * Registers the component in a given scene
  74590. */
  74591. register(): void;
  74592. /**
  74593. * Rebuilds the elements related to this component in case of
  74594. * context lost for instance.
  74595. */
  74596. rebuild(): void;
  74597. /**
  74598. * Disposes the component and the associated ressources
  74599. */
  74600. dispose(): void;
  74601. private _gatherRenderTargets;
  74602. private _gatherActiveCameraRenderTargets;
  74603. }
  74604. }
  74605. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  74606. /** @hidden */
  74607. export var fibonacci: {
  74608. name: string;
  74609. shader: string;
  74610. };
  74611. }
  74612. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  74613. /** @hidden */
  74614. export var diffusionProfile: {
  74615. name: string;
  74616. shader: string;
  74617. };
  74618. }
  74619. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  74620. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  74621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74622. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  74623. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  74624. /** @hidden */
  74625. export var subSurfaceScatteringPixelShader: {
  74626. name: string;
  74627. shader: string;
  74628. };
  74629. }
  74630. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  74631. import { Nullable } from "babylonjs/types";
  74632. import { Camera } from "babylonjs/Cameras/camera";
  74633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74634. import { Engine } from "babylonjs/Engines/engine";
  74635. import { Scene } from "babylonjs/scene";
  74636. import "babylonjs/Shaders/imageProcessing.fragment";
  74637. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  74638. import "babylonjs/Shaders/postprocess.vertex";
  74639. /**
  74640. * Sub surface scattering post process
  74641. */
  74642. export class SubSurfaceScatteringPostProcess extends PostProcess {
  74643. /** @hidden */
  74644. texelWidth: number;
  74645. /** @hidden */
  74646. texelHeight: number;
  74647. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74648. }
  74649. }
  74650. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  74651. import { Color3 } from "babylonjs/Maths/math.color";
  74652. /**
  74653. * Contains all parameters needed for the prepass to perform
  74654. * screen space subsurface scattering
  74655. */
  74656. export class SubSurfaceConfiguration {
  74657. private _ssDiffusionS;
  74658. private _ssFilterRadii;
  74659. private _ssDiffusionD;
  74660. /**
  74661. * Diffusion profile color for subsurface scattering
  74662. */
  74663. get ssDiffusionS(): number[];
  74664. /**
  74665. * Diffusion profile max color channel value for subsurface scattering
  74666. */
  74667. get ssDiffusionD(): number[];
  74668. /**
  74669. * Diffusion profile filter radius for subsurface scattering
  74670. */
  74671. get ssFilterRadii(): number[];
  74672. /**
  74673. * Diffusion profile colors for subsurface scattering
  74674. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  74675. * See ...
  74676. * Note that you can only store up to 5 of them
  74677. */
  74678. ssDiffusionProfileColors: Color3[];
  74679. /**
  74680. * Defines the ratio real world => scene units.
  74681. * Used for subsurface scattering
  74682. */
  74683. metersPerUnit: number;
  74684. /**
  74685. * Builds a subsurface configuration object
  74686. * @param scene The scene
  74687. */
  74688. constructor();
  74689. /**
  74690. * Adds a new diffusion profile.
  74691. * Useful for more realistic subsurface scattering on diverse materials.
  74692. * @param color The color of the diffusion profile. Should be the average color of the material.
  74693. * @return The index of the diffusion profile for the material subsurface configuration
  74694. */
  74695. addDiffusionProfile(color: Color3): number;
  74696. /**
  74697. * Deletes all diffusion profiles.
  74698. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  74699. */
  74700. clearAllDiffusionProfiles(): void;
  74701. /**
  74702. * Disposes this object
  74703. */
  74704. dispose(): void;
  74705. /**
  74706. * @hidden
  74707. * https://zero-radiance.github.io/post/sampling-diffusion/
  74708. *
  74709. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  74710. * ------------------------------------------------------------------------------------
  74711. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  74712. * PDF[r, phi, s] = r * R[r, phi, s]
  74713. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  74714. * ------------------------------------------------------------------------------------
  74715. * We importance sample the color channel with the widest scattering distance.
  74716. */
  74717. getDiffusionProfileParameters(color: Color3): number;
  74718. /**
  74719. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  74720. * 'u' is the random number (the value of the CDF): [0, 1).
  74721. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  74722. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  74723. */
  74724. private _sampleBurleyDiffusionProfile;
  74725. }
  74726. }
  74727. declare module "babylonjs/Rendering/prePassRenderer" {
  74728. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  74729. import { Scene } from "babylonjs/scene";
  74730. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74731. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  74732. import { Effect } from "babylonjs/Materials/effect";
  74733. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  74734. /**
  74735. * Renders a pre pass of the scene
  74736. * This means every mesh in the scene will be rendered to a render target texture
  74737. * And then this texture will be composited to the rendering canvas with post processes
  74738. * It is necessary for effects like subsurface scattering or deferred shading
  74739. */
  74740. export class PrePassRenderer {
  74741. /** @hidden */
  74742. static _SceneComponentInitialization: (scene: Scene) => void;
  74743. private _scene;
  74744. private _engine;
  74745. private _isDirty;
  74746. /**
  74747. * Number of textures in the multi render target texture where the scene is directly rendered
  74748. */
  74749. readonly mrtCount: number;
  74750. /**
  74751. * The render target where the scene is directly rendered
  74752. */
  74753. prePassRT: MultiRenderTarget;
  74754. private _mrtTypes;
  74755. private _multiRenderAttachments;
  74756. private _defaultAttachments;
  74757. private _clearAttachments;
  74758. private readonly _clearColor;
  74759. /**
  74760. * Image processing post process for composition
  74761. */
  74762. imageProcessingPostProcess: ImageProcessingPostProcess;
  74763. /**
  74764. * Post process for subsurface scattering
  74765. */
  74766. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  74767. /**
  74768. * Configuration for sub surface scattering post process
  74769. */
  74770. subSurfaceConfiguration: SubSurfaceConfiguration;
  74771. private _enabled;
  74772. /**
  74773. * Indicates if the prepass is enabled
  74774. */
  74775. get enabled(): boolean;
  74776. /**
  74777. * How many samples are used for MSAA of the scene render target
  74778. */
  74779. get samples(): number;
  74780. set samples(n: number);
  74781. /**
  74782. * Instanciates a prepass renderer
  74783. * @param scene The scene
  74784. */
  74785. constructor(scene: Scene);
  74786. private _initializeAttachments;
  74787. private _createEffects;
  74788. /**
  74789. * Indicates if rendering a prepass is supported
  74790. */
  74791. get isSupported(): boolean;
  74792. /**
  74793. * Sets the proper output textures to draw in the engine.
  74794. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  74795. */
  74796. bindAttachmentsForEffect(effect: Effect): void;
  74797. /**
  74798. * @hidden
  74799. */
  74800. _beforeCameraDraw(): void;
  74801. /**
  74802. * @hidden
  74803. */
  74804. _afterCameraDraw(): void;
  74805. private _checkRTSize;
  74806. private _bindFrameBuffer;
  74807. /**
  74808. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  74809. */
  74810. clear(): void;
  74811. private _setState;
  74812. private _enable;
  74813. private _disable;
  74814. /**
  74815. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  74816. */
  74817. markAsDirty(): void;
  74818. private _update;
  74819. /**
  74820. * Disposes the prepass renderer.
  74821. */
  74822. dispose(): void;
  74823. }
  74824. }
  74825. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74826. import { Nullable } from "babylonjs/types";
  74827. import { Scene } from "babylonjs/scene";
  74828. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74829. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74830. import { AbstractScene } from "babylonjs/abstractScene";
  74831. module "babylonjs/abstractScene" {
  74832. interface AbstractScene {
  74833. /** @hidden (Backing field) */
  74834. _prePassRenderer: Nullable<PrePassRenderer>;
  74835. /**
  74836. * Gets or Sets the current prepass renderer associated to the scene.
  74837. */
  74838. prePassRenderer: Nullable<PrePassRenderer>;
  74839. /**
  74840. * Enables the prepass and associates it with the scene
  74841. * @returns the PrePassRenderer
  74842. */
  74843. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74844. /**
  74845. * Disables the prepass associated with the scene
  74846. */
  74847. disablePrePassRenderer(): void;
  74848. }
  74849. }
  74850. /**
  74851. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74852. * in several rendering techniques.
  74853. */
  74854. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74855. /**
  74856. * The component name helpful to identify the component in the list of scene components.
  74857. */
  74858. readonly name: string;
  74859. /**
  74860. * The scene the component belongs to.
  74861. */
  74862. scene: Scene;
  74863. /**
  74864. * Creates a new instance of the component for the given scene
  74865. * @param scene Defines the scene to register the component in
  74866. */
  74867. constructor(scene: Scene);
  74868. /**
  74869. * Registers the component in a given scene
  74870. */
  74871. register(): void;
  74872. private _beforeCameraDraw;
  74873. private _afterCameraDraw;
  74874. private _beforeClearStage;
  74875. /**
  74876. * Serializes the component data to the specified json object
  74877. * @param serializationObject The object to serialize to
  74878. */
  74879. serialize(serializationObject: any): void;
  74880. /**
  74881. * Adds all the elements from the container to the scene
  74882. * @param container the container holding the elements
  74883. */
  74884. addFromContainer(container: AbstractScene): void;
  74885. /**
  74886. * Removes all the elements in the container from the scene
  74887. * @param container contains the elements to remove
  74888. * @param dispose if the removed element should be disposed (default: false)
  74889. */
  74890. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74891. /**
  74892. * Rebuilds the elements related to this component in case of
  74893. * context lost for instance.
  74894. */
  74895. rebuild(): void;
  74896. /**
  74897. * Disposes the component and the associated ressources
  74898. */
  74899. dispose(): void;
  74900. }
  74901. }
  74902. declare module "babylonjs/Shaders/outline.fragment" {
  74903. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74904. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74905. /** @hidden */
  74906. export var outlinePixelShader: {
  74907. name: string;
  74908. shader: string;
  74909. };
  74910. }
  74911. declare module "babylonjs/Shaders/outline.vertex" {
  74912. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74915. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74916. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74918. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74919. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74920. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74921. /** @hidden */
  74922. export var outlineVertexShader: {
  74923. name: string;
  74924. shader: string;
  74925. };
  74926. }
  74927. declare module "babylonjs/Rendering/outlineRenderer" {
  74928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74929. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74930. import { Scene } from "babylonjs/scene";
  74931. import { ISceneComponent } from "babylonjs/sceneComponent";
  74932. import "babylonjs/Shaders/outline.fragment";
  74933. import "babylonjs/Shaders/outline.vertex";
  74934. module "babylonjs/scene" {
  74935. interface Scene {
  74936. /** @hidden */
  74937. _outlineRenderer: OutlineRenderer;
  74938. /**
  74939. * Gets the outline renderer associated with the scene
  74940. * @returns a OutlineRenderer
  74941. */
  74942. getOutlineRenderer(): OutlineRenderer;
  74943. }
  74944. }
  74945. module "babylonjs/Meshes/abstractMesh" {
  74946. interface AbstractMesh {
  74947. /** @hidden (Backing field) */
  74948. _renderOutline: boolean;
  74949. /**
  74950. * Gets or sets a boolean indicating if the outline must be rendered as well
  74951. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74952. */
  74953. renderOutline: boolean;
  74954. /** @hidden (Backing field) */
  74955. _renderOverlay: boolean;
  74956. /**
  74957. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74958. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74959. */
  74960. renderOverlay: boolean;
  74961. }
  74962. }
  74963. /**
  74964. * This class is responsible to draw bothe outline/overlay of meshes.
  74965. * It should not be used directly but through the available method on mesh.
  74966. */
  74967. export class OutlineRenderer implements ISceneComponent {
  74968. /**
  74969. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74970. */
  74971. private static _StencilReference;
  74972. /**
  74973. * The name of the component. Each component must have a unique name.
  74974. */
  74975. name: string;
  74976. /**
  74977. * The scene the component belongs to.
  74978. */
  74979. scene: Scene;
  74980. /**
  74981. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74982. */
  74983. zOffset: number;
  74984. private _engine;
  74985. private _effect;
  74986. private _cachedDefines;
  74987. private _savedDepthWrite;
  74988. /**
  74989. * Instantiates a new outline renderer. (There could be only one per scene).
  74990. * @param scene Defines the scene it belongs to
  74991. */
  74992. constructor(scene: Scene);
  74993. /**
  74994. * Register the component to one instance of a scene.
  74995. */
  74996. register(): void;
  74997. /**
  74998. * Rebuilds the elements related to this component in case of
  74999. * context lost for instance.
  75000. */
  75001. rebuild(): void;
  75002. /**
  75003. * Disposes the component and the associated ressources.
  75004. */
  75005. dispose(): void;
  75006. /**
  75007. * Renders the outline in the canvas.
  75008. * @param subMesh Defines the sumesh to render
  75009. * @param batch Defines the batch of meshes in case of instances
  75010. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75011. */
  75012. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75013. /**
  75014. * Returns whether or not the outline renderer is ready for a given submesh.
  75015. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75016. * @param subMesh Defines the submesh to check readyness for
  75017. * @param useInstances Defines wheter wee are trying to render instances or not
  75018. * @returns true if ready otherwise false
  75019. */
  75020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75021. private _beforeRenderingMesh;
  75022. private _afterRenderingMesh;
  75023. }
  75024. }
  75025. declare module "babylonjs/Rendering/index" {
  75026. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75027. export * from "babylonjs/Rendering/depthRenderer";
  75028. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75029. export * from "babylonjs/Rendering/edgesRenderer";
  75030. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75031. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75032. export * from "babylonjs/Rendering/prePassRenderer";
  75033. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75034. export * from "babylonjs/Rendering/outlineRenderer";
  75035. export * from "babylonjs/Rendering/renderingGroup";
  75036. export * from "babylonjs/Rendering/renderingManager";
  75037. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75038. }
  75039. declare module "babylonjs/Sprites/ISprites" {
  75040. /**
  75041. * Defines the basic options interface of a Sprite Frame Source Size.
  75042. */
  75043. export interface ISpriteJSONSpriteSourceSize {
  75044. /**
  75045. * number of the original width of the Frame
  75046. */
  75047. w: number;
  75048. /**
  75049. * number of the original height of the Frame
  75050. */
  75051. h: number;
  75052. }
  75053. /**
  75054. * Defines the basic options interface of a Sprite Frame Data.
  75055. */
  75056. export interface ISpriteJSONSpriteFrameData {
  75057. /**
  75058. * number of the x offset of the Frame
  75059. */
  75060. x: number;
  75061. /**
  75062. * number of the y offset of the Frame
  75063. */
  75064. y: number;
  75065. /**
  75066. * number of the width of the Frame
  75067. */
  75068. w: number;
  75069. /**
  75070. * number of the height of the Frame
  75071. */
  75072. h: number;
  75073. }
  75074. /**
  75075. * Defines the basic options interface of a JSON Sprite.
  75076. */
  75077. export interface ISpriteJSONSprite {
  75078. /**
  75079. * string name of the Frame
  75080. */
  75081. filename: string;
  75082. /**
  75083. * ISpriteJSONSpriteFrame basic object of the frame data
  75084. */
  75085. frame: ISpriteJSONSpriteFrameData;
  75086. /**
  75087. * boolean to flag is the frame was rotated.
  75088. */
  75089. rotated: boolean;
  75090. /**
  75091. * boolean to flag is the frame was trimmed.
  75092. */
  75093. trimmed: boolean;
  75094. /**
  75095. * ISpriteJSONSpriteFrame basic object of the source data
  75096. */
  75097. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75098. /**
  75099. * ISpriteJSONSpriteFrame basic object of the source data
  75100. */
  75101. sourceSize: ISpriteJSONSpriteSourceSize;
  75102. }
  75103. /**
  75104. * Defines the basic options interface of a JSON atlas.
  75105. */
  75106. export interface ISpriteJSONAtlas {
  75107. /**
  75108. * Array of objects that contain the frame data.
  75109. */
  75110. frames: Array<ISpriteJSONSprite>;
  75111. /**
  75112. * object basic object containing the sprite meta data.
  75113. */
  75114. meta?: object;
  75115. }
  75116. }
  75117. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75118. /** @hidden */
  75119. export var spriteMapPixelShader: {
  75120. name: string;
  75121. shader: string;
  75122. };
  75123. }
  75124. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75125. /** @hidden */
  75126. export var spriteMapVertexShader: {
  75127. name: string;
  75128. shader: string;
  75129. };
  75130. }
  75131. declare module "babylonjs/Sprites/spriteMap" {
  75132. import { IDisposable, Scene } from "babylonjs/scene";
  75133. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75134. import { Texture } from "babylonjs/Materials/Textures/texture";
  75135. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75136. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75137. import "babylonjs/Meshes/Builders/planeBuilder";
  75138. import "babylonjs/Shaders/spriteMap.fragment";
  75139. import "babylonjs/Shaders/spriteMap.vertex";
  75140. /**
  75141. * Defines the basic options interface of a SpriteMap
  75142. */
  75143. export interface ISpriteMapOptions {
  75144. /**
  75145. * Vector2 of the number of cells in the grid.
  75146. */
  75147. stageSize?: Vector2;
  75148. /**
  75149. * Vector2 of the size of the output plane in World Units.
  75150. */
  75151. outputSize?: Vector2;
  75152. /**
  75153. * Vector3 of the position of the output plane in World Units.
  75154. */
  75155. outputPosition?: Vector3;
  75156. /**
  75157. * Vector3 of the rotation of the output plane.
  75158. */
  75159. outputRotation?: Vector3;
  75160. /**
  75161. * number of layers that the system will reserve in resources.
  75162. */
  75163. layerCount?: number;
  75164. /**
  75165. * number of max animation frames a single cell will reserve in resources.
  75166. */
  75167. maxAnimationFrames?: number;
  75168. /**
  75169. * number cell index of the base tile when the system compiles.
  75170. */
  75171. baseTile?: number;
  75172. /**
  75173. * boolean flip the sprite after its been repositioned by the framing data.
  75174. */
  75175. flipU?: boolean;
  75176. /**
  75177. * Vector3 scalar of the global RGB values of the SpriteMap.
  75178. */
  75179. colorMultiply?: Vector3;
  75180. }
  75181. /**
  75182. * Defines the IDisposable interface in order to be cleanable from resources.
  75183. */
  75184. export interface ISpriteMap extends IDisposable {
  75185. /**
  75186. * String name of the SpriteMap.
  75187. */
  75188. name: string;
  75189. /**
  75190. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75191. */
  75192. atlasJSON: ISpriteJSONAtlas;
  75193. /**
  75194. * Texture of the SpriteMap.
  75195. */
  75196. spriteSheet: Texture;
  75197. /**
  75198. * The parameters to initialize the SpriteMap with.
  75199. */
  75200. options: ISpriteMapOptions;
  75201. }
  75202. /**
  75203. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75204. */
  75205. export class SpriteMap implements ISpriteMap {
  75206. /** The Name of the spriteMap */
  75207. name: string;
  75208. /** The JSON file with the frame and meta data */
  75209. atlasJSON: ISpriteJSONAtlas;
  75210. /** The systems Sprite Sheet Texture */
  75211. spriteSheet: Texture;
  75212. /** Arguments passed with the Constructor */
  75213. options: ISpriteMapOptions;
  75214. /** Public Sprite Storage array, parsed from atlasJSON */
  75215. sprites: Array<ISpriteJSONSprite>;
  75216. /** Returns the Number of Sprites in the System */
  75217. get spriteCount(): number;
  75218. /** Returns the Position of Output Plane*/
  75219. get position(): Vector3;
  75220. /** Returns the Position of Output Plane*/
  75221. set position(v: Vector3);
  75222. /** Returns the Rotation of Output Plane*/
  75223. get rotation(): Vector3;
  75224. /** Returns the Rotation of Output Plane*/
  75225. set rotation(v: Vector3);
  75226. /** Sets the AnimationMap*/
  75227. get animationMap(): RawTexture;
  75228. /** Sets the AnimationMap*/
  75229. set animationMap(v: RawTexture);
  75230. /** Scene that the SpriteMap was created in */
  75231. private _scene;
  75232. /** Texture Buffer of Float32 that holds tile frame data*/
  75233. private _frameMap;
  75234. /** Texture Buffers of Float32 that holds tileMap data*/
  75235. private _tileMaps;
  75236. /** Texture Buffer of Float32 that holds Animation Data*/
  75237. private _animationMap;
  75238. /** Custom ShaderMaterial Central to the System*/
  75239. private _material;
  75240. /** Custom ShaderMaterial Central to the System*/
  75241. private _output;
  75242. /** Systems Time Ticker*/
  75243. private _time;
  75244. /**
  75245. * Creates a new SpriteMap
  75246. * @param name defines the SpriteMaps Name
  75247. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75248. * @param spriteSheet is the Texture that the Sprites are on.
  75249. * @param options a basic deployment configuration
  75250. * @param scene The Scene that the map is deployed on
  75251. */
  75252. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75253. /**
  75254. * Returns tileID location
  75255. * @returns Vector2 the cell position ID
  75256. */
  75257. getTileID(): Vector2;
  75258. /**
  75259. * Gets the UV location of the mouse over the SpriteMap.
  75260. * @returns Vector2 the UV position of the mouse interaction
  75261. */
  75262. getMousePosition(): Vector2;
  75263. /**
  75264. * Creates the "frame" texture Buffer
  75265. * -------------------------------------
  75266. * Structure of frames
  75267. * "filename": "Falling-Water-2.png",
  75268. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75269. * "rotated": true,
  75270. * "trimmed": true,
  75271. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75272. * "sourceSize": {"w":32,"h":32}
  75273. * @returns RawTexture of the frameMap
  75274. */
  75275. private _createFrameBuffer;
  75276. /**
  75277. * Creates the tileMap texture Buffer
  75278. * @param buffer normally and array of numbers, or a false to generate from scratch
  75279. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75280. * @returns RawTexture of the tileMap
  75281. */
  75282. private _createTileBuffer;
  75283. /**
  75284. * Modifies the data of the tileMaps
  75285. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75286. * @param pos is the iVector2 Coordinates of the Tile
  75287. * @param tile The SpriteIndex of the new Tile
  75288. */
  75289. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75290. /**
  75291. * Creates the animationMap texture Buffer
  75292. * @param buffer normally and array of numbers, or a false to generate from scratch
  75293. * @returns RawTexture of the animationMap
  75294. */
  75295. private _createTileAnimationBuffer;
  75296. /**
  75297. * Modifies the data of the animationMap
  75298. * @param cellID is the Index of the Sprite
  75299. * @param _frame is the target Animation frame
  75300. * @param toCell is the Target Index of the next frame of the animation
  75301. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75302. * @param speed is a global scalar of the time variable on the map.
  75303. */
  75304. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75305. /**
  75306. * Exports the .tilemaps file
  75307. */
  75308. saveTileMaps(): void;
  75309. /**
  75310. * Imports the .tilemaps file
  75311. * @param url of the .tilemaps file
  75312. */
  75313. loadTileMaps(url: string): void;
  75314. /**
  75315. * Release associated resources
  75316. */
  75317. dispose(): void;
  75318. }
  75319. }
  75320. declare module "babylonjs/Sprites/spritePackedManager" {
  75321. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75322. import { Scene } from "babylonjs/scene";
  75323. /**
  75324. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75325. * @see https://doc.babylonjs.com/babylon101/sprites
  75326. */
  75327. export class SpritePackedManager extends SpriteManager {
  75328. /** defines the packed manager's name */
  75329. name: string;
  75330. /**
  75331. * Creates a new sprite manager from a packed sprite sheet
  75332. * @param name defines the manager's name
  75333. * @param imgUrl defines the sprite sheet url
  75334. * @param capacity defines the maximum allowed number of sprites
  75335. * @param scene defines the hosting scene
  75336. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75337. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75338. * @param samplingMode defines the smapling mode to use with spritesheet
  75339. * @param fromPacked set to true; do not alter
  75340. */
  75341. constructor(
  75342. /** defines the packed manager's name */
  75343. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75344. }
  75345. }
  75346. declare module "babylonjs/Sprites/index" {
  75347. export * from "babylonjs/Sprites/sprite";
  75348. export * from "babylonjs/Sprites/ISprites";
  75349. export * from "babylonjs/Sprites/spriteManager";
  75350. export * from "babylonjs/Sprites/spriteMap";
  75351. export * from "babylonjs/Sprites/spritePackedManager";
  75352. export * from "babylonjs/Sprites/spriteSceneComponent";
  75353. }
  75354. declare module "babylonjs/States/index" {
  75355. export * from "babylonjs/States/alphaCullingState";
  75356. export * from "babylonjs/States/depthCullingState";
  75357. export * from "babylonjs/States/stencilState";
  75358. }
  75359. declare module "babylonjs/Misc/assetsManager" {
  75360. import { Scene } from "babylonjs/scene";
  75361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75362. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75363. import { Skeleton } from "babylonjs/Bones/skeleton";
  75364. import { Observable } from "babylonjs/Misc/observable";
  75365. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75366. import { Texture } from "babylonjs/Materials/Textures/texture";
  75367. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75368. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75369. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75370. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75371. /**
  75372. * Defines the list of states available for a task inside a AssetsManager
  75373. */
  75374. export enum AssetTaskState {
  75375. /**
  75376. * Initialization
  75377. */
  75378. INIT = 0,
  75379. /**
  75380. * Running
  75381. */
  75382. RUNNING = 1,
  75383. /**
  75384. * Done
  75385. */
  75386. DONE = 2,
  75387. /**
  75388. * Error
  75389. */
  75390. ERROR = 3
  75391. }
  75392. /**
  75393. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75394. */
  75395. export abstract class AbstractAssetTask {
  75396. /**
  75397. * Task name
  75398. */ name: string;
  75399. /**
  75400. * Callback called when the task is successful
  75401. */
  75402. onSuccess: (task: any) => void;
  75403. /**
  75404. * Callback called when the task is not successful
  75405. */
  75406. onError: (task: any, message?: string, exception?: any) => void;
  75407. /**
  75408. * Creates a new AssetsManager
  75409. * @param name defines the name of the task
  75410. */
  75411. constructor(
  75412. /**
  75413. * Task name
  75414. */ name: string);
  75415. private _isCompleted;
  75416. private _taskState;
  75417. private _errorObject;
  75418. /**
  75419. * Get if the task is completed
  75420. */
  75421. get isCompleted(): boolean;
  75422. /**
  75423. * Gets the current state of the task
  75424. */
  75425. get taskState(): AssetTaskState;
  75426. /**
  75427. * Gets the current error object (if task is in error)
  75428. */
  75429. get errorObject(): {
  75430. message?: string;
  75431. exception?: any;
  75432. };
  75433. /**
  75434. * Internal only
  75435. * @hidden
  75436. */
  75437. _setErrorObject(message?: string, exception?: any): void;
  75438. /**
  75439. * Execute the current task
  75440. * @param scene defines the scene where you want your assets to be loaded
  75441. * @param onSuccess is a callback called when the task is successfully executed
  75442. * @param onError is a callback called if an error occurs
  75443. */
  75444. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75445. /**
  75446. * Execute the current task
  75447. * @param scene defines the scene where you want your assets to be loaded
  75448. * @param onSuccess is a callback called when the task is successfully executed
  75449. * @param onError is a callback called if an error occurs
  75450. */
  75451. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75452. /**
  75453. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75454. * This can be used with failed tasks that have the reason for failure fixed.
  75455. */
  75456. reset(): void;
  75457. private onErrorCallback;
  75458. private onDoneCallback;
  75459. }
  75460. /**
  75461. * Define the interface used by progress events raised during assets loading
  75462. */
  75463. export interface IAssetsProgressEvent {
  75464. /**
  75465. * Defines the number of remaining tasks to process
  75466. */
  75467. remainingCount: number;
  75468. /**
  75469. * Defines the total number of tasks
  75470. */
  75471. totalCount: number;
  75472. /**
  75473. * Defines the task that was just processed
  75474. */
  75475. task: AbstractAssetTask;
  75476. }
  75477. /**
  75478. * Class used to share progress information about assets loading
  75479. */
  75480. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75481. /**
  75482. * Defines the number of remaining tasks to process
  75483. */
  75484. remainingCount: number;
  75485. /**
  75486. * Defines the total number of tasks
  75487. */
  75488. totalCount: number;
  75489. /**
  75490. * Defines the task that was just processed
  75491. */
  75492. task: AbstractAssetTask;
  75493. /**
  75494. * Creates a AssetsProgressEvent
  75495. * @param remainingCount defines the number of remaining tasks to process
  75496. * @param totalCount defines the total number of tasks
  75497. * @param task defines the task that was just processed
  75498. */
  75499. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75500. }
  75501. /**
  75502. * Define a task used by AssetsManager to load meshes
  75503. */
  75504. export class MeshAssetTask extends AbstractAssetTask {
  75505. /**
  75506. * Defines the name of the task
  75507. */
  75508. name: string;
  75509. /**
  75510. * Defines the list of mesh's names you want to load
  75511. */
  75512. meshesNames: any;
  75513. /**
  75514. * Defines the root url to use as a base to load your meshes and associated resources
  75515. */
  75516. rootUrl: string;
  75517. /**
  75518. * Defines the filename or File of the scene to load from
  75519. */
  75520. sceneFilename: string | File;
  75521. /**
  75522. * Gets the list of loaded meshes
  75523. */
  75524. loadedMeshes: Array<AbstractMesh>;
  75525. /**
  75526. * Gets the list of loaded particle systems
  75527. */
  75528. loadedParticleSystems: Array<IParticleSystem>;
  75529. /**
  75530. * Gets the list of loaded skeletons
  75531. */
  75532. loadedSkeletons: Array<Skeleton>;
  75533. /**
  75534. * Gets the list of loaded animation groups
  75535. */
  75536. loadedAnimationGroups: Array<AnimationGroup>;
  75537. /**
  75538. * Callback called when the task is successful
  75539. */
  75540. onSuccess: (task: MeshAssetTask) => void;
  75541. /**
  75542. * Callback called when the task is successful
  75543. */
  75544. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75545. /**
  75546. * Creates a new MeshAssetTask
  75547. * @param name defines the name of the task
  75548. * @param meshesNames defines the list of mesh's names you want to load
  75549. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75550. * @param sceneFilename defines the filename or File of the scene to load from
  75551. */
  75552. constructor(
  75553. /**
  75554. * Defines the name of the task
  75555. */
  75556. name: string,
  75557. /**
  75558. * Defines the list of mesh's names you want to load
  75559. */
  75560. meshesNames: any,
  75561. /**
  75562. * Defines the root url to use as a base to load your meshes and associated resources
  75563. */
  75564. rootUrl: string,
  75565. /**
  75566. * Defines the filename or File of the scene to load from
  75567. */
  75568. sceneFilename: string | File);
  75569. /**
  75570. * Execute the current task
  75571. * @param scene defines the scene where you want your assets to be loaded
  75572. * @param onSuccess is a callback called when the task is successfully executed
  75573. * @param onError is a callback called if an error occurs
  75574. */
  75575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75576. }
  75577. /**
  75578. * Define a task used by AssetsManager to load text content
  75579. */
  75580. export class TextFileAssetTask extends AbstractAssetTask {
  75581. /**
  75582. * Defines the name of the task
  75583. */
  75584. name: string;
  75585. /**
  75586. * Defines the location of the file to load
  75587. */
  75588. url: string;
  75589. /**
  75590. * Gets the loaded text string
  75591. */
  75592. text: string;
  75593. /**
  75594. * Callback called when the task is successful
  75595. */
  75596. onSuccess: (task: TextFileAssetTask) => void;
  75597. /**
  75598. * Callback called when the task is successful
  75599. */
  75600. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75601. /**
  75602. * Creates a new TextFileAssetTask object
  75603. * @param name defines the name of the task
  75604. * @param url defines the location of the file to load
  75605. */
  75606. constructor(
  75607. /**
  75608. * Defines the name of the task
  75609. */
  75610. name: string,
  75611. /**
  75612. * Defines the location of the file to load
  75613. */
  75614. url: string);
  75615. /**
  75616. * Execute the current task
  75617. * @param scene defines the scene where you want your assets to be loaded
  75618. * @param onSuccess is a callback called when the task is successfully executed
  75619. * @param onError is a callback called if an error occurs
  75620. */
  75621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75622. }
  75623. /**
  75624. * Define a task used by AssetsManager to load binary data
  75625. */
  75626. export class BinaryFileAssetTask extends AbstractAssetTask {
  75627. /**
  75628. * Defines the name of the task
  75629. */
  75630. name: string;
  75631. /**
  75632. * Defines the location of the file to load
  75633. */
  75634. url: string;
  75635. /**
  75636. * Gets the lodaded data (as an array buffer)
  75637. */
  75638. data: ArrayBuffer;
  75639. /**
  75640. * Callback called when the task is successful
  75641. */
  75642. onSuccess: (task: BinaryFileAssetTask) => void;
  75643. /**
  75644. * Callback called when the task is successful
  75645. */
  75646. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75647. /**
  75648. * Creates a new BinaryFileAssetTask object
  75649. * @param name defines the name of the new task
  75650. * @param url defines the location of the file to load
  75651. */
  75652. constructor(
  75653. /**
  75654. * Defines the name of the task
  75655. */
  75656. name: string,
  75657. /**
  75658. * Defines the location of the file to load
  75659. */
  75660. url: string);
  75661. /**
  75662. * Execute the current task
  75663. * @param scene defines the scene where you want your assets to be loaded
  75664. * @param onSuccess is a callback called when the task is successfully executed
  75665. * @param onError is a callback called if an error occurs
  75666. */
  75667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75668. }
  75669. /**
  75670. * Define a task used by AssetsManager to load images
  75671. */
  75672. export class ImageAssetTask extends AbstractAssetTask {
  75673. /**
  75674. * Defines the name of the task
  75675. */
  75676. name: string;
  75677. /**
  75678. * Defines the location of the image to load
  75679. */
  75680. url: string;
  75681. /**
  75682. * Gets the loaded images
  75683. */
  75684. image: HTMLImageElement;
  75685. /**
  75686. * Callback called when the task is successful
  75687. */
  75688. onSuccess: (task: ImageAssetTask) => void;
  75689. /**
  75690. * Callback called when the task is successful
  75691. */
  75692. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75693. /**
  75694. * Creates a new ImageAssetTask
  75695. * @param name defines the name of the task
  75696. * @param url defines the location of the image to load
  75697. */
  75698. constructor(
  75699. /**
  75700. * Defines the name of the task
  75701. */
  75702. name: string,
  75703. /**
  75704. * Defines the location of the image to load
  75705. */
  75706. url: string);
  75707. /**
  75708. * Execute the current task
  75709. * @param scene defines the scene where you want your assets to be loaded
  75710. * @param onSuccess is a callback called when the task is successfully executed
  75711. * @param onError is a callback called if an error occurs
  75712. */
  75713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75714. }
  75715. /**
  75716. * Defines the interface used by texture loading tasks
  75717. */
  75718. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75719. /**
  75720. * Gets the loaded texture
  75721. */
  75722. texture: TEX;
  75723. }
  75724. /**
  75725. * Define a task used by AssetsManager to load 2D textures
  75726. */
  75727. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75728. /**
  75729. * Defines the name of the task
  75730. */
  75731. name: string;
  75732. /**
  75733. * Defines the location of the file to load
  75734. */
  75735. url: string;
  75736. /**
  75737. * Defines if mipmap should not be generated (default is false)
  75738. */
  75739. noMipmap?: boolean | undefined;
  75740. /**
  75741. * Defines if texture must be inverted on Y axis (default is true)
  75742. */
  75743. invertY: boolean;
  75744. /**
  75745. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75746. */
  75747. samplingMode: number;
  75748. /**
  75749. * Gets the loaded texture
  75750. */
  75751. texture: Texture;
  75752. /**
  75753. * Callback called when the task is successful
  75754. */
  75755. onSuccess: (task: TextureAssetTask) => void;
  75756. /**
  75757. * Callback called when the task is successful
  75758. */
  75759. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75760. /**
  75761. * Creates a new TextureAssetTask object
  75762. * @param name defines the name of the task
  75763. * @param url defines the location of the file to load
  75764. * @param noMipmap defines if mipmap should not be generated (default is false)
  75765. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75766. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75767. */
  75768. constructor(
  75769. /**
  75770. * Defines the name of the task
  75771. */
  75772. name: string,
  75773. /**
  75774. * Defines the location of the file to load
  75775. */
  75776. url: string,
  75777. /**
  75778. * Defines if mipmap should not be generated (default is false)
  75779. */
  75780. noMipmap?: boolean | undefined,
  75781. /**
  75782. * Defines if texture must be inverted on Y axis (default is true)
  75783. */
  75784. invertY?: boolean,
  75785. /**
  75786. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75787. */
  75788. samplingMode?: number);
  75789. /**
  75790. * Execute the current task
  75791. * @param scene defines the scene where you want your assets to be loaded
  75792. * @param onSuccess is a callback called when the task is successfully executed
  75793. * @param onError is a callback called if an error occurs
  75794. */
  75795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75796. }
  75797. /**
  75798. * Define a task used by AssetsManager to load cube textures
  75799. */
  75800. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75801. /**
  75802. * Defines the name of the task
  75803. */
  75804. name: string;
  75805. /**
  75806. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75807. */
  75808. url: string;
  75809. /**
  75810. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75811. */
  75812. extensions?: string[] | undefined;
  75813. /**
  75814. * Defines if mipmaps should not be generated (default is false)
  75815. */
  75816. noMipmap?: boolean | undefined;
  75817. /**
  75818. * Defines the explicit list of files (undefined by default)
  75819. */
  75820. files?: string[] | undefined;
  75821. /**
  75822. * Gets the loaded texture
  75823. */
  75824. texture: CubeTexture;
  75825. /**
  75826. * Callback called when the task is successful
  75827. */
  75828. onSuccess: (task: CubeTextureAssetTask) => void;
  75829. /**
  75830. * Callback called when the task is successful
  75831. */
  75832. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75833. /**
  75834. * Creates a new CubeTextureAssetTask
  75835. * @param name defines the name of the task
  75836. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75837. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75838. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75839. * @param files defines the explicit list of files (undefined by default)
  75840. */
  75841. constructor(
  75842. /**
  75843. * Defines the name of the task
  75844. */
  75845. name: string,
  75846. /**
  75847. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75848. */
  75849. url: string,
  75850. /**
  75851. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75852. */
  75853. extensions?: string[] | undefined,
  75854. /**
  75855. * Defines if mipmaps should not be generated (default is false)
  75856. */
  75857. noMipmap?: boolean | undefined,
  75858. /**
  75859. * Defines the explicit list of files (undefined by default)
  75860. */
  75861. files?: string[] | undefined);
  75862. /**
  75863. * Execute the current task
  75864. * @param scene defines the scene where you want your assets to be loaded
  75865. * @param onSuccess is a callback called when the task is successfully executed
  75866. * @param onError is a callback called if an error occurs
  75867. */
  75868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75869. }
  75870. /**
  75871. * Define a task used by AssetsManager to load HDR cube textures
  75872. */
  75873. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75874. /**
  75875. * Defines the name of the task
  75876. */
  75877. name: string;
  75878. /**
  75879. * Defines the location of the file to load
  75880. */
  75881. url: string;
  75882. /**
  75883. * Defines the desired size (the more it increases the longer the generation will be)
  75884. */
  75885. size: number;
  75886. /**
  75887. * Defines if mipmaps should not be generated (default is false)
  75888. */
  75889. noMipmap: boolean;
  75890. /**
  75891. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75892. */
  75893. generateHarmonics: boolean;
  75894. /**
  75895. * 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)
  75896. */
  75897. gammaSpace: boolean;
  75898. /**
  75899. * Internal Use Only
  75900. */
  75901. reserved: boolean;
  75902. /**
  75903. * Gets the loaded texture
  75904. */
  75905. texture: HDRCubeTexture;
  75906. /**
  75907. * Callback called when the task is successful
  75908. */
  75909. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75910. /**
  75911. * Callback called when the task is successful
  75912. */
  75913. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75914. /**
  75915. * Creates a new HDRCubeTextureAssetTask object
  75916. * @param name defines the name of the task
  75917. * @param url defines the location of the file to load
  75918. * @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.
  75919. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75920. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75921. * @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)
  75922. * @param reserved Internal use only
  75923. */
  75924. constructor(
  75925. /**
  75926. * Defines the name of the task
  75927. */
  75928. name: string,
  75929. /**
  75930. * Defines the location of the file to load
  75931. */
  75932. url: string,
  75933. /**
  75934. * Defines the desired size (the more it increases the longer the generation will be)
  75935. */
  75936. size: number,
  75937. /**
  75938. * Defines if mipmaps should not be generated (default is false)
  75939. */
  75940. noMipmap?: boolean,
  75941. /**
  75942. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75943. */
  75944. generateHarmonics?: boolean,
  75945. /**
  75946. * 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)
  75947. */
  75948. gammaSpace?: boolean,
  75949. /**
  75950. * Internal Use Only
  75951. */
  75952. reserved?: boolean);
  75953. /**
  75954. * Execute the current task
  75955. * @param scene defines the scene where you want your assets to be loaded
  75956. * @param onSuccess is a callback called when the task is successfully executed
  75957. * @param onError is a callback called if an error occurs
  75958. */
  75959. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75960. }
  75961. /**
  75962. * Define a task used by AssetsManager to load Equirectangular cube textures
  75963. */
  75964. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75965. /**
  75966. * Defines the name of the task
  75967. */
  75968. name: string;
  75969. /**
  75970. * Defines the location of the file to load
  75971. */
  75972. url: string;
  75973. /**
  75974. * Defines the desired size (the more it increases the longer the generation will be)
  75975. */
  75976. size: number;
  75977. /**
  75978. * Defines if mipmaps should not be generated (default is false)
  75979. */
  75980. noMipmap: boolean;
  75981. /**
  75982. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75983. * but the standard material would require them in Gamma space) (default is true)
  75984. */
  75985. gammaSpace: boolean;
  75986. /**
  75987. * Gets the loaded texture
  75988. */
  75989. texture: EquiRectangularCubeTexture;
  75990. /**
  75991. * Callback called when the task is successful
  75992. */
  75993. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75994. /**
  75995. * Callback called when the task is successful
  75996. */
  75997. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75998. /**
  75999. * Creates a new EquiRectangularCubeTextureAssetTask object
  76000. * @param name defines the name of the task
  76001. * @param url defines the location of the file to load
  76002. * @param size defines the desired size (the more it increases the longer the generation will be)
  76003. * If the size is omitted this implies you are using a preprocessed cubemap.
  76004. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76005. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76006. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76007. * (default is true)
  76008. */
  76009. constructor(
  76010. /**
  76011. * Defines the name of the task
  76012. */
  76013. name: string,
  76014. /**
  76015. * Defines the location of the file to load
  76016. */
  76017. url: string,
  76018. /**
  76019. * Defines the desired size (the more it increases the longer the generation will be)
  76020. */
  76021. size: number,
  76022. /**
  76023. * Defines if mipmaps should not be generated (default is false)
  76024. */
  76025. noMipmap?: boolean,
  76026. /**
  76027. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76028. * but the standard material would require them in Gamma space) (default is true)
  76029. */
  76030. gammaSpace?: boolean);
  76031. /**
  76032. * Execute the current task
  76033. * @param scene defines the scene where you want your assets to be loaded
  76034. * @param onSuccess is a callback called when the task is successfully executed
  76035. * @param onError is a callback called if an error occurs
  76036. */
  76037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76038. }
  76039. /**
  76040. * This class can be used to easily import assets into a scene
  76041. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76042. */
  76043. export class AssetsManager {
  76044. private _scene;
  76045. private _isLoading;
  76046. protected _tasks: AbstractAssetTask[];
  76047. protected _waitingTasksCount: number;
  76048. protected _totalTasksCount: number;
  76049. /**
  76050. * Callback called when all tasks are processed
  76051. */
  76052. onFinish: (tasks: AbstractAssetTask[]) => void;
  76053. /**
  76054. * Callback called when a task is successful
  76055. */
  76056. onTaskSuccess: (task: AbstractAssetTask) => void;
  76057. /**
  76058. * Callback called when a task had an error
  76059. */
  76060. onTaskError: (task: AbstractAssetTask) => void;
  76061. /**
  76062. * Callback called when a task is done (whatever the result is)
  76063. */
  76064. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76065. /**
  76066. * Observable called when all tasks are processed
  76067. */
  76068. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76069. /**
  76070. * Observable called when a task had an error
  76071. */
  76072. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76073. /**
  76074. * Observable called when all tasks were executed
  76075. */
  76076. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76077. /**
  76078. * Observable called when a task is done (whatever the result is)
  76079. */
  76080. onProgressObservable: Observable<IAssetsProgressEvent>;
  76081. /**
  76082. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76083. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76084. */
  76085. useDefaultLoadingScreen: boolean;
  76086. /**
  76087. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76088. * when all assets have been downloaded.
  76089. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76090. */
  76091. autoHideLoadingUI: boolean;
  76092. /**
  76093. * Creates a new AssetsManager
  76094. * @param scene defines the scene to work on
  76095. */
  76096. constructor(scene: Scene);
  76097. /**
  76098. * Add a MeshAssetTask to the list of active tasks
  76099. * @param taskName defines the name of the new task
  76100. * @param meshesNames defines the name of meshes to load
  76101. * @param rootUrl defines the root url to use to locate files
  76102. * @param sceneFilename defines the filename of the scene file
  76103. * @returns a new MeshAssetTask object
  76104. */
  76105. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76106. /**
  76107. * Add a TextFileAssetTask to the list of active tasks
  76108. * @param taskName defines the name of the new task
  76109. * @param url defines the url of the file to load
  76110. * @returns a new TextFileAssetTask object
  76111. */
  76112. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76113. /**
  76114. * Add a BinaryFileAssetTask to the list of active tasks
  76115. * @param taskName defines the name of the new task
  76116. * @param url defines the url of the file to load
  76117. * @returns a new BinaryFileAssetTask object
  76118. */
  76119. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76120. /**
  76121. * Add a ImageAssetTask to the list of active tasks
  76122. * @param taskName defines the name of the new task
  76123. * @param url defines the url of the file to load
  76124. * @returns a new ImageAssetTask object
  76125. */
  76126. addImageTask(taskName: string, url: string): ImageAssetTask;
  76127. /**
  76128. * Add a TextureAssetTask to the list of active tasks
  76129. * @param taskName defines the name of the new task
  76130. * @param url defines the url of the file to load
  76131. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76132. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76133. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76134. * @returns a new TextureAssetTask object
  76135. */
  76136. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76137. /**
  76138. * Add a CubeTextureAssetTask to the list of active tasks
  76139. * @param taskName defines the name of the new task
  76140. * @param url defines the url of the file to load
  76141. * @param extensions defines the extension to use to load the cube map (can be null)
  76142. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76143. * @param files defines the list of files to load (can be null)
  76144. * @returns a new CubeTextureAssetTask object
  76145. */
  76146. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76147. /**
  76148. *
  76149. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76150. * @param taskName defines the name of the new task
  76151. * @param url defines the url of the file to load
  76152. * @param size defines the size you want for the cubemap (can be null)
  76153. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76154. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76155. * @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)
  76156. * @param reserved Internal use only
  76157. * @returns a new HDRCubeTextureAssetTask object
  76158. */
  76159. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76160. /**
  76161. *
  76162. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76163. * @param taskName defines the name of the new task
  76164. * @param url defines the url of the file to load
  76165. * @param size defines the size you want for the cubemap (can be null)
  76166. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76167. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76168. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76169. * @returns a new EquiRectangularCubeTextureAssetTask object
  76170. */
  76171. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76172. /**
  76173. * Remove a task from the assets manager.
  76174. * @param task the task to remove
  76175. */
  76176. removeTask(task: AbstractAssetTask): void;
  76177. private _decreaseWaitingTasksCount;
  76178. private _runTask;
  76179. /**
  76180. * Reset the AssetsManager and remove all tasks
  76181. * @return the current instance of the AssetsManager
  76182. */
  76183. reset(): AssetsManager;
  76184. /**
  76185. * Start the loading process
  76186. * @return the current instance of the AssetsManager
  76187. */
  76188. load(): AssetsManager;
  76189. /**
  76190. * Start the loading process as an async operation
  76191. * @return a promise returning the list of failed tasks
  76192. */
  76193. loadAsync(): Promise<void>;
  76194. }
  76195. }
  76196. declare module "babylonjs/Misc/deferred" {
  76197. /**
  76198. * Wrapper class for promise with external resolve and reject.
  76199. */
  76200. export class Deferred<T> {
  76201. /**
  76202. * The promise associated with this deferred object.
  76203. */
  76204. readonly promise: Promise<T>;
  76205. private _resolve;
  76206. private _reject;
  76207. /**
  76208. * The resolve method of the promise associated with this deferred object.
  76209. */
  76210. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76211. /**
  76212. * The reject method of the promise associated with this deferred object.
  76213. */
  76214. get reject(): (reason?: any) => void;
  76215. /**
  76216. * Constructor for this deferred object.
  76217. */
  76218. constructor();
  76219. }
  76220. }
  76221. declare module "babylonjs/Misc/meshExploder" {
  76222. import { Mesh } from "babylonjs/Meshes/mesh";
  76223. /**
  76224. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76225. */
  76226. export class MeshExploder {
  76227. private _centerMesh;
  76228. private _meshes;
  76229. private _meshesOrigins;
  76230. private _toCenterVectors;
  76231. private _scaledDirection;
  76232. private _newPosition;
  76233. private _centerPosition;
  76234. /**
  76235. * Explodes meshes from a center mesh.
  76236. * @param meshes The meshes to explode.
  76237. * @param centerMesh The mesh to be center of explosion.
  76238. */
  76239. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76240. private _setCenterMesh;
  76241. /**
  76242. * Get class name
  76243. * @returns "MeshExploder"
  76244. */
  76245. getClassName(): string;
  76246. /**
  76247. * "Exploded meshes"
  76248. * @returns Array of meshes with the centerMesh at index 0.
  76249. */
  76250. getMeshes(): Array<Mesh>;
  76251. /**
  76252. * Explodes meshes giving a specific direction
  76253. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76254. */
  76255. explode(direction?: number): void;
  76256. }
  76257. }
  76258. declare module "babylonjs/Misc/filesInput" {
  76259. import { Engine } from "babylonjs/Engines/engine";
  76260. import { Scene } from "babylonjs/scene";
  76261. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76262. import { Nullable } from "babylonjs/types";
  76263. /**
  76264. * Class used to help managing file picking and drag'n'drop
  76265. */
  76266. export class FilesInput {
  76267. /**
  76268. * List of files ready to be loaded
  76269. */
  76270. static get FilesToLoad(): {
  76271. [key: string]: File;
  76272. };
  76273. /**
  76274. * Callback called when a file is processed
  76275. */
  76276. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76277. private _engine;
  76278. private _currentScene;
  76279. private _sceneLoadedCallback;
  76280. private _progressCallback;
  76281. private _additionalRenderLoopLogicCallback;
  76282. private _textureLoadingCallback;
  76283. private _startingProcessingFilesCallback;
  76284. private _onReloadCallback;
  76285. private _errorCallback;
  76286. private _elementToMonitor;
  76287. private _sceneFileToLoad;
  76288. private _filesToLoad;
  76289. /**
  76290. * Creates a new FilesInput
  76291. * @param engine defines the rendering engine
  76292. * @param scene defines the hosting scene
  76293. * @param sceneLoadedCallback callback called when scene is loaded
  76294. * @param progressCallback callback called to track progress
  76295. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76296. * @param textureLoadingCallback callback called when a texture is loading
  76297. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76298. * @param onReloadCallback callback called when a reload is requested
  76299. * @param errorCallback callback call if an error occurs
  76300. */
  76301. 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>);
  76302. private _dragEnterHandler;
  76303. private _dragOverHandler;
  76304. private _dropHandler;
  76305. /**
  76306. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76307. * @param elementToMonitor defines the DOM element to track
  76308. */
  76309. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76310. /** Gets the current list of files to load */
  76311. get filesToLoad(): File[];
  76312. /**
  76313. * Release all associated resources
  76314. */
  76315. dispose(): void;
  76316. private renderFunction;
  76317. private drag;
  76318. private drop;
  76319. private _traverseFolder;
  76320. private _processFiles;
  76321. /**
  76322. * Load files from a drop event
  76323. * @param event defines the drop event to use as source
  76324. */
  76325. loadFiles(event: any): void;
  76326. private _processReload;
  76327. /**
  76328. * Reload the current scene from the loaded files
  76329. */
  76330. reload(): void;
  76331. }
  76332. }
  76333. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76334. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76335. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76336. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76337. }
  76338. declare module "babylonjs/Misc/sceneOptimizer" {
  76339. import { Scene, IDisposable } from "babylonjs/scene";
  76340. import { Observable } from "babylonjs/Misc/observable";
  76341. /**
  76342. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76343. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76344. */
  76345. export class SceneOptimization {
  76346. /**
  76347. * Defines the priority of this optimization (0 by default which means first in the list)
  76348. */
  76349. priority: number;
  76350. /**
  76351. * Gets a string describing the action executed by the current optimization
  76352. * @returns description string
  76353. */
  76354. getDescription(): string;
  76355. /**
  76356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76357. * @param scene defines the current scene where to apply this optimization
  76358. * @param optimizer defines the current optimizer
  76359. * @returns true if everything that can be done was applied
  76360. */
  76361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76362. /**
  76363. * Creates the SceneOptimization object
  76364. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76365. * @param desc defines the description associated with the optimization
  76366. */
  76367. constructor(
  76368. /**
  76369. * Defines the priority of this optimization (0 by default which means first in the list)
  76370. */
  76371. priority?: number);
  76372. }
  76373. /**
  76374. * Defines an optimization used to reduce the size of render target textures
  76375. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76376. */
  76377. export class TextureOptimization extends SceneOptimization {
  76378. /**
  76379. * Defines the priority of this optimization (0 by default which means first in the list)
  76380. */
  76381. priority: number;
  76382. /**
  76383. * 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
  76384. */
  76385. maximumSize: number;
  76386. /**
  76387. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76388. */
  76389. step: number;
  76390. /**
  76391. * Gets a string describing the action executed by the current optimization
  76392. * @returns description string
  76393. */
  76394. getDescription(): string;
  76395. /**
  76396. * Creates the TextureOptimization object
  76397. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76398. * @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
  76399. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76400. */
  76401. constructor(
  76402. /**
  76403. * Defines the priority of this optimization (0 by default which means first in the list)
  76404. */
  76405. priority?: number,
  76406. /**
  76407. * 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
  76408. */
  76409. maximumSize?: number,
  76410. /**
  76411. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76412. */
  76413. step?: number);
  76414. /**
  76415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76416. * @param scene defines the current scene where to apply this optimization
  76417. * @param optimizer defines the current optimizer
  76418. * @returns true if everything that can be done was applied
  76419. */
  76420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76421. }
  76422. /**
  76423. * Defines an optimization used to increase or decrease the rendering resolution
  76424. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76425. */
  76426. export class HardwareScalingOptimization extends SceneOptimization {
  76427. /**
  76428. * Defines the priority of this optimization (0 by default which means first in the list)
  76429. */
  76430. priority: number;
  76431. /**
  76432. * Defines the maximum scale to use (2 by default)
  76433. */
  76434. maximumScale: number;
  76435. /**
  76436. * Defines the step to use between two passes (0.5 by default)
  76437. */
  76438. step: number;
  76439. private _currentScale;
  76440. private _directionOffset;
  76441. /**
  76442. * Gets a string describing the action executed by the current optimization
  76443. * @return description string
  76444. */
  76445. getDescription(): string;
  76446. /**
  76447. * Creates the HardwareScalingOptimization object
  76448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76449. * @param maximumScale defines the maximum scale to use (2 by default)
  76450. * @param step defines the step to use between two passes (0.5 by default)
  76451. */
  76452. constructor(
  76453. /**
  76454. * Defines the priority of this optimization (0 by default which means first in the list)
  76455. */
  76456. priority?: number,
  76457. /**
  76458. * Defines the maximum scale to use (2 by default)
  76459. */
  76460. maximumScale?: number,
  76461. /**
  76462. * Defines the step to use between two passes (0.5 by default)
  76463. */
  76464. step?: number);
  76465. /**
  76466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76467. * @param scene defines the current scene where to apply this optimization
  76468. * @param optimizer defines the current optimizer
  76469. * @returns true if everything that can be done was applied
  76470. */
  76471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76472. }
  76473. /**
  76474. * Defines an optimization used to remove shadows
  76475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76476. */
  76477. export class ShadowsOptimization extends SceneOptimization {
  76478. /**
  76479. * Gets a string describing the action executed by the current optimization
  76480. * @return description string
  76481. */
  76482. getDescription(): string;
  76483. /**
  76484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76485. * @param scene defines the current scene where to apply this optimization
  76486. * @param optimizer defines the current optimizer
  76487. * @returns true if everything that can be done was applied
  76488. */
  76489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76490. }
  76491. /**
  76492. * Defines an optimization used to turn post-processes off
  76493. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76494. */
  76495. export class PostProcessesOptimization extends SceneOptimization {
  76496. /**
  76497. * Gets a string describing the action executed by the current optimization
  76498. * @return description string
  76499. */
  76500. getDescription(): string;
  76501. /**
  76502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76503. * @param scene defines the current scene where to apply this optimization
  76504. * @param optimizer defines the current optimizer
  76505. * @returns true if everything that can be done was applied
  76506. */
  76507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76508. }
  76509. /**
  76510. * Defines an optimization used to turn lens flares off
  76511. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76512. */
  76513. export class LensFlaresOptimization extends SceneOptimization {
  76514. /**
  76515. * Gets a string describing the action executed by the current optimization
  76516. * @return description string
  76517. */
  76518. getDescription(): string;
  76519. /**
  76520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76521. * @param scene defines the current scene where to apply this optimization
  76522. * @param optimizer defines the current optimizer
  76523. * @returns true if everything that can be done was applied
  76524. */
  76525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76526. }
  76527. /**
  76528. * Defines an optimization based on user defined callback.
  76529. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76530. */
  76531. export class CustomOptimization extends SceneOptimization {
  76532. /**
  76533. * Callback called to apply the custom optimization.
  76534. */
  76535. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76536. /**
  76537. * Callback called to get custom description
  76538. */
  76539. onGetDescription: () => string;
  76540. /**
  76541. * Gets a string describing the action executed by the current optimization
  76542. * @returns description string
  76543. */
  76544. getDescription(): string;
  76545. /**
  76546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76547. * @param scene defines the current scene where to apply this optimization
  76548. * @param optimizer defines the current optimizer
  76549. * @returns true if everything that can be done was applied
  76550. */
  76551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76552. }
  76553. /**
  76554. * Defines an optimization used to turn particles off
  76555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76556. */
  76557. export class ParticlesOptimization extends SceneOptimization {
  76558. /**
  76559. * Gets a string describing the action executed by the current optimization
  76560. * @return description string
  76561. */
  76562. getDescription(): string;
  76563. /**
  76564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76565. * @param scene defines the current scene where to apply this optimization
  76566. * @param optimizer defines the current optimizer
  76567. * @returns true if everything that can be done was applied
  76568. */
  76569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76570. }
  76571. /**
  76572. * Defines an optimization used to turn render targets off
  76573. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76574. */
  76575. export class RenderTargetsOptimization extends SceneOptimization {
  76576. /**
  76577. * Gets a string describing the action executed by the current optimization
  76578. * @return description string
  76579. */
  76580. getDescription(): string;
  76581. /**
  76582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76583. * @param scene defines the current scene where to apply this optimization
  76584. * @param optimizer defines the current optimizer
  76585. * @returns true if everything that can be done was applied
  76586. */
  76587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76588. }
  76589. /**
  76590. * Defines an optimization used to merge meshes with compatible materials
  76591. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76592. */
  76593. export class MergeMeshesOptimization extends SceneOptimization {
  76594. private static _UpdateSelectionTree;
  76595. /**
  76596. * Gets or sets a boolean which defines if optimization octree has to be updated
  76597. */
  76598. static get UpdateSelectionTree(): boolean;
  76599. /**
  76600. * Gets or sets a boolean which defines if optimization octree has to be updated
  76601. */
  76602. static set UpdateSelectionTree(value: boolean);
  76603. /**
  76604. * Gets a string describing the action executed by the current optimization
  76605. * @return description string
  76606. */
  76607. getDescription(): string;
  76608. private _canBeMerged;
  76609. /**
  76610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76611. * @param scene defines the current scene where to apply this optimization
  76612. * @param optimizer defines the current optimizer
  76613. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76614. * @returns true if everything that can be done was applied
  76615. */
  76616. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76617. }
  76618. /**
  76619. * Defines a list of options used by SceneOptimizer
  76620. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76621. */
  76622. export class SceneOptimizerOptions {
  76623. /**
  76624. * Defines the target frame rate to reach (60 by default)
  76625. */
  76626. targetFrameRate: number;
  76627. /**
  76628. * Defines the interval between two checkes (2000ms by default)
  76629. */
  76630. trackerDuration: number;
  76631. /**
  76632. * Gets the list of optimizations to apply
  76633. */
  76634. optimizations: SceneOptimization[];
  76635. /**
  76636. * Creates a new list of options used by SceneOptimizer
  76637. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76638. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76639. */
  76640. constructor(
  76641. /**
  76642. * Defines the target frame rate to reach (60 by default)
  76643. */
  76644. targetFrameRate?: number,
  76645. /**
  76646. * Defines the interval between two checkes (2000ms by default)
  76647. */
  76648. trackerDuration?: number);
  76649. /**
  76650. * Add a new optimization
  76651. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76652. * @returns the current SceneOptimizerOptions
  76653. */
  76654. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76655. /**
  76656. * Add a new custom optimization
  76657. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76658. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76659. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76660. * @returns the current SceneOptimizerOptions
  76661. */
  76662. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76663. /**
  76664. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76665. * @param targetFrameRate defines the target frame rate (60 by default)
  76666. * @returns a SceneOptimizerOptions object
  76667. */
  76668. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76669. /**
  76670. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76671. * @param targetFrameRate defines the target frame rate (60 by default)
  76672. * @returns a SceneOptimizerOptions object
  76673. */
  76674. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76675. /**
  76676. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76677. * @param targetFrameRate defines the target frame rate (60 by default)
  76678. * @returns a SceneOptimizerOptions object
  76679. */
  76680. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76681. }
  76682. /**
  76683. * Class used to run optimizations in order to reach a target frame rate
  76684. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76685. */
  76686. export class SceneOptimizer implements IDisposable {
  76687. private _isRunning;
  76688. private _options;
  76689. private _scene;
  76690. private _currentPriorityLevel;
  76691. private _targetFrameRate;
  76692. private _trackerDuration;
  76693. private _currentFrameRate;
  76694. private _sceneDisposeObserver;
  76695. private _improvementMode;
  76696. /**
  76697. * Defines an observable called when the optimizer reaches the target frame rate
  76698. */
  76699. onSuccessObservable: Observable<SceneOptimizer>;
  76700. /**
  76701. * Defines an observable called when the optimizer enables an optimization
  76702. */
  76703. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76704. /**
  76705. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76706. */
  76707. onFailureObservable: Observable<SceneOptimizer>;
  76708. /**
  76709. * Gets a boolean indicating if the optimizer is in improvement mode
  76710. */
  76711. get isInImprovementMode(): boolean;
  76712. /**
  76713. * Gets the current priority level (0 at start)
  76714. */
  76715. get currentPriorityLevel(): number;
  76716. /**
  76717. * Gets the current frame rate checked by the SceneOptimizer
  76718. */
  76719. get currentFrameRate(): number;
  76720. /**
  76721. * Gets or sets the current target frame rate (60 by default)
  76722. */
  76723. get targetFrameRate(): number;
  76724. /**
  76725. * Gets or sets the current target frame rate (60 by default)
  76726. */
  76727. set targetFrameRate(value: number);
  76728. /**
  76729. * Gets or sets the current interval between two checks (every 2000ms by default)
  76730. */
  76731. get trackerDuration(): number;
  76732. /**
  76733. * Gets or sets the current interval between two checks (every 2000ms by default)
  76734. */
  76735. set trackerDuration(value: number);
  76736. /**
  76737. * Gets the list of active optimizations
  76738. */
  76739. get optimizations(): SceneOptimization[];
  76740. /**
  76741. * Creates a new SceneOptimizer
  76742. * @param scene defines the scene to work on
  76743. * @param options defines the options to use with the SceneOptimizer
  76744. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76745. * @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)
  76746. */
  76747. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76748. /**
  76749. * Stops the current optimizer
  76750. */
  76751. stop(): void;
  76752. /**
  76753. * Reset the optimizer to initial step (current priority level = 0)
  76754. */
  76755. reset(): void;
  76756. /**
  76757. * Start the optimizer. By default it will try to reach a specific framerate
  76758. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76759. */
  76760. start(): void;
  76761. private _checkCurrentState;
  76762. /**
  76763. * Release all resources
  76764. */
  76765. dispose(): void;
  76766. /**
  76767. * Helper function to create a SceneOptimizer with one single line of code
  76768. * @param scene defines the scene to work on
  76769. * @param options defines the options to use with the SceneOptimizer
  76770. * @param onSuccess defines a callback to call on success
  76771. * @param onFailure defines a callback to call on failure
  76772. * @returns the new SceneOptimizer object
  76773. */
  76774. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76775. }
  76776. }
  76777. declare module "babylonjs/Misc/sceneSerializer" {
  76778. import { Scene } from "babylonjs/scene";
  76779. /**
  76780. * Class used to serialize a scene into a string
  76781. */
  76782. export class SceneSerializer {
  76783. /**
  76784. * Clear cache used by a previous serialization
  76785. */
  76786. static ClearCache(): void;
  76787. /**
  76788. * Serialize a scene into a JSON compatible object
  76789. * @param scene defines the scene to serialize
  76790. * @returns a JSON compatible object
  76791. */
  76792. static Serialize(scene: Scene): any;
  76793. /**
  76794. * Serialize a mesh into a JSON compatible object
  76795. * @param toSerialize defines the mesh to serialize
  76796. * @param withParents defines if parents must be serialized as well
  76797. * @param withChildren defines if children must be serialized as well
  76798. * @returns a JSON compatible object
  76799. */
  76800. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76801. }
  76802. }
  76803. declare module "babylonjs/Misc/textureTools" {
  76804. import { Texture } from "babylonjs/Materials/Textures/texture";
  76805. /**
  76806. * Class used to host texture specific utilities
  76807. */
  76808. export class TextureTools {
  76809. /**
  76810. * Uses the GPU to create a copy texture rescaled at a given size
  76811. * @param texture Texture to copy from
  76812. * @param width defines the desired width
  76813. * @param height defines the desired height
  76814. * @param useBilinearMode defines if bilinear mode has to be used
  76815. * @return the generated texture
  76816. */
  76817. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76818. }
  76819. }
  76820. declare module "babylonjs/Misc/videoRecorder" {
  76821. import { Nullable } from "babylonjs/types";
  76822. import { Engine } from "babylonjs/Engines/engine";
  76823. /**
  76824. * This represents the different options available for the video capture.
  76825. */
  76826. export interface VideoRecorderOptions {
  76827. /** Defines the mime type of the video. */
  76828. mimeType: string;
  76829. /** Defines the FPS the video should be recorded at. */
  76830. fps: number;
  76831. /** Defines the chunk size for the recording data. */
  76832. recordChunckSize: number;
  76833. /** The audio tracks to attach to the recording. */
  76834. audioTracks?: MediaStreamTrack[];
  76835. }
  76836. /**
  76837. * This can help with recording videos from BabylonJS.
  76838. * This is based on the available WebRTC functionalities of the browser.
  76839. *
  76840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76841. */
  76842. export class VideoRecorder {
  76843. private static readonly _defaultOptions;
  76844. /**
  76845. * Returns whether or not the VideoRecorder is available in your browser.
  76846. * @param engine Defines the Babylon Engine.
  76847. * @returns true if supported otherwise false.
  76848. */
  76849. static IsSupported(engine: Engine): boolean;
  76850. private readonly _options;
  76851. private _canvas;
  76852. private _mediaRecorder;
  76853. private _recordedChunks;
  76854. private _fileName;
  76855. private _resolve;
  76856. private _reject;
  76857. /**
  76858. * True when a recording is already in progress.
  76859. */
  76860. get isRecording(): boolean;
  76861. /**
  76862. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76863. * @param engine Defines the BabylonJS Engine you wish to record.
  76864. * @param options Defines options that can be used to customize the capture.
  76865. */
  76866. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76867. /**
  76868. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76869. */
  76870. stopRecording(): void;
  76871. /**
  76872. * Starts recording the canvas for a max duration specified in parameters.
  76873. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76874. * If null no automatic download will start and you can rely on the promise to get the data back.
  76875. * @param maxDuration Defines the maximum recording time in seconds.
  76876. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76877. * @return A promise callback at the end of the recording with the video data in Blob.
  76878. */
  76879. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76880. /**
  76881. * Releases internal resources used during the recording.
  76882. */
  76883. dispose(): void;
  76884. private _handleDataAvailable;
  76885. private _handleError;
  76886. private _handleStop;
  76887. }
  76888. }
  76889. declare module "babylonjs/Misc/screenshotTools" {
  76890. import { Camera } from "babylonjs/Cameras/camera";
  76891. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76892. import { Engine } from "babylonjs/Engines/engine";
  76893. /**
  76894. * Class containing a set of static utilities functions for screenshots
  76895. */
  76896. export class ScreenshotTools {
  76897. /**
  76898. * Captures a screenshot of the current rendering
  76899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76900. * @param engine defines the rendering engine
  76901. * @param camera defines the source camera
  76902. * @param size This parameter can be set to a single number or to an object with the
  76903. * following (optional) properties: precision, width, height. If a single number is passed,
  76904. * it will be used for both width and height. If an object is passed, the screenshot size
  76905. * will be derived from the parameters. The precision property is a multiplier allowing
  76906. * rendering at a higher or lower resolution
  76907. * @param successCallback defines the callback receives a single parameter which contains the
  76908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76909. * src parameter of an <img> to display it
  76910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76911. * Check your browser for supported MIME types
  76912. */
  76913. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76914. /**
  76915. * Captures a screenshot of the current rendering
  76916. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76917. * @param engine defines the rendering engine
  76918. * @param camera defines the source camera
  76919. * @param size This parameter can be set to a single number or to an object with the
  76920. * following (optional) properties: precision, width, height. If a single number is passed,
  76921. * it will be used for both width and height. If an object is passed, the screenshot size
  76922. * will be derived from the parameters. The precision property is a multiplier allowing
  76923. * rendering at a higher or lower resolution
  76924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76925. * Check your browser for supported MIME types
  76926. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76927. * to the src parameter of an <img> to display it
  76928. */
  76929. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76930. /**
  76931. * Generates an image screenshot from the specified camera.
  76932. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76933. * @param engine The engine to use for rendering
  76934. * @param camera The camera to use for rendering
  76935. * @param size This parameter can be set to a single number or to an object with the
  76936. * following (optional) properties: precision, width, height. If a single number is passed,
  76937. * it will be used for both width and height. If an object is passed, the screenshot size
  76938. * will be derived from the parameters. The precision property is a multiplier allowing
  76939. * rendering at a higher or lower resolution
  76940. * @param successCallback The callback receives a single parameter which contains the
  76941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76942. * src parameter of an <img> to display it
  76943. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76944. * Check your browser for supported MIME types
  76945. * @param samples Texture samples (default: 1)
  76946. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76947. * @param fileName A name for for the downloaded file.
  76948. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76949. */
  76950. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76951. /**
  76952. * Generates an image screenshot from the specified camera.
  76953. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76954. * @param engine The engine to use for rendering
  76955. * @param camera The camera to use for rendering
  76956. * @param size This parameter can be set to a single number or to an object with the
  76957. * following (optional) properties: precision, width, height. If a single number is passed,
  76958. * it will be used for both width and height. If an object is passed, the screenshot size
  76959. * will be derived from the parameters. The precision property is a multiplier allowing
  76960. * rendering at a higher or lower resolution
  76961. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76962. * Check your browser for supported MIME types
  76963. * @param samples Texture samples (default: 1)
  76964. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76965. * @param fileName A name for for the downloaded file.
  76966. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76967. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76968. * to the src parameter of an <img> to display it
  76969. */
  76970. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76971. /**
  76972. * Gets height and width for screenshot size
  76973. * @private
  76974. */
  76975. private static _getScreenshotSize;
  76976. }
  76977. }
  76978. declare module "babylonjs/Misc/dataReader" {
  76979. /**
  76980. * Interface for a data buffer
  76981. */
  76982. export interface IDataBuffer {
  76983. /**
  76984. * Reads bytes from the data buffer.
  76985. * @param byteOffset The byte offset to read
  76986. * @param byteLength The byte length to read
  76987. * @returns A promise that resolves when the bytes are read
  76988. */
  76989. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76990. /**
  76991. * The byte length of the buffer.
  76992. */
  76993. readonly byteLength: number;
  76994. }
  76995. /**
  76996. * Utility class for reading from a data buffer
  76997. */
  76998. export class DataReader {
  76999. /**
  77000. * The data buffer associated with this data reader.
  77001. */
  77002. readonly buffer: IDataBuffer;
  77003. /**
  77004. * The current byte offset from the beginning of the data buffer.
  77005. */
  77006. byteOffset: number;
  77007. private _dataView;
  77008. private _dataByteOffset;
  77009. /**
  77010. * Constructor
  77011. * @param buffer The buffer to read
  77012. */
  77013. constructor(buffer: IDataBuffer);
  77014. /**
  77015. * Loads the given byte length.
  77016. * @param byteLength The byte length to load
  77017. * @returns A promise that resolves when the load is complete
  77018. */
  77019. loadAsync(byteLength: number): Promise<void>;
  77020. /**
  77021. * Read a unsigned 32-bit integer from the currently loaded data range.
  77022. * @returns The 32-bit integer read
  77023. */
  77024. readUint32(): number;
  77025. /**
  77026. * Read a byte array from the currently loaded data range.
  77027. * @param byteLength The byte length to read
  77028. * @returns The byte array read
  77029. */
  77030. readUint8Array(byteLength: number): Uint8Array;
  77031. /**
  77032. * Read a string from the currently loaded data range.
  77033. * @param byteLength The byte length to read
  77034. * @returns The string read
  77035. */
  77036. readString(byteLength: number): string;
  77037. /**
  77038. * Skips the given byte length the currently loaded data range.
  77039. * @param byteLength The byte length to skip
  77040. */
  77041. skipBytes(byteLength: number): void;
  77042. }
  77043. }
  77044. declare module "babylonjs/Misc/dataStorage" {
  77045. /**
  77046. * Class for storing data to local storage if available or in-memory storage otherwise
  77047. */
  77048. export class DataStorage {
  77049. private static _Storage;
  77050. private static _GetStorage;
  77051. /**
  77052. * Reads a string from the data storage
  77053. * @param key The key to read
  77054. * @param defaultValue The value if the key doesn't exist
  77055. * @returns The string value
  77056. */
  77057. static ReadString(key: string, defaultValue: string): string;
  77058. /**
  77059. * Writes a string to the data storage
  77060. * @param key The key to write
  77061. * @param value The value to write
  77062. */
  77063. static WriteString(key: string, value: string): void;
  77064. /**
  77065. * Reads a boolean from the data storage
  77066. * @param key The key to read
  77067. * @param defaultValue The value if the key doesn't exist
  77068. * @returns The boolean value
  77069. */
  77070. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77071. /**
  77072. * Writes a boolean to the data storage
  77073. * @param key The key to write
  77074. * @param value The value to write
  77075. */
  77076. static WriteBoolean(key: string, value: boolean): void;
  77077. /**
  77078. * Reads a number from the data storage
  77079. * @param key The key to read
  77080. * @param defaultValue The value if the key doesn't exist
  77081. * @returns The number value
  77082. */
  77083. static ReadNumber(key: string, defaultValue: number): number;
  77084. /**
  77085. * Writes a number to the data storage
  77086. * @param key The key to write
  77087. * @param value The value to write
  77088. */
  77089. static WriteNumber(key: string, value: number): void;
  77090. }
  77091. }
  77092. declare module "babylonjs/Misc/index" {
  77093. export * from "babylonjs/Misc/andOrNotEvaluator";
  77094. export * from "babylonjs/Misc/assetsManager";
  77095. export * from "babylonjs/Misc/basis";
  77096. export * from "babylonjs/Misc/dds";
  77097. export * from "babylonjs/Misc/decorators";
  77098. export * from "babylonjs/Misc/deferred";
  77099. export * from "babylonjs/Misc/environmentTextureTools";
  77100. export * from "babylonjs/Misc/meshExploder";
  77101. export * from "babylonjs/Misc/filesInput";
  77102. export * from "babylonjs/Misc/HighDynamicRange/index";
  77103. export * from "babylonjs/Misc/khronosTextureContainer";
  77104. export * from "babylonjs/Misc/observable";
  77105. export * from "babylonjs/Misc/performanceMonitor";
  77106. export * from "babylonjs/Misc/promise";
  77107. export * from "babylonjs/Misc/sceneOptimizer";
  77108. export * from "babylonjs/Misc/sceneSerializer";
  77109. export * from "babylonjs/Misc/smartArray";
  77110. export * from "babylonjs/Misc/stringDictionary";
  77111. export * from "babylonjs/Misc/tags";
  77112. export * from "babylonjs/Misc/textureTools";
  77113. export * from "babylonjs/Misc/tga";
  77114. export * from "babylonjs/Misc/tools";
  77115. export * from "babylonjs/Misc/videoRecorder";
  77116. export * from "babylonjs/Misc/virtualJoystick";
  77117. export * from "babylonjs/Misc/workerPool";
  77118. export * from "babylonjs/Misc/logger";
  77119. export * from "babylonjs/Misc/typeStore";
  77120. export * from "babylonjs/Misc/filesInputStore";
  77121. export * from "babylonjs/Misc/deepCopier";
  77122. export * from "babylonjs/Misc/pivotTools";
  77123. export * from "babylonjs/Misc/precisionDate";
  77124. export * from "babylonjs/Misc/screenshotTools";
  77125. export * from "babylonjs/Misc/typeStore";
  77126. export * from "babylonjs/Misc/webRequest";
  77127. export * from "babylonjs/Misc/iInspectable";
  77128. export * from "babylonjs/Misc/brdfTextureTools";
  77129. export * from "babylonjs/Misc/rgbdTextureTools";
  77130. export * from "babylonjs/Misc/gradients";
  77131. export * from "babylonjs/Misc/perfCounter";
  77132. export * from "babylonjs/Misc/fileRequest";
  77133. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77134. export * from "babylonjs/Misc/retryStrategy";
  77135. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77136. export * from "babylonjs/Misc/canvasGenerator";
  77137. export * from "babylonjs/Misc/fileTools";
  77138. export * from "babylonjs/Misc/stringTools";
  77139. export * from "babylonjs/Misc/dataReader";
  77140. export * from "babylonjs/Misc/minMaxReducer";
  77141. export * from "babylonjs/Misc/depthReducer";
  77142. export * from "babylonjs/Misc/dataStorage";
  77143. }
  77144. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77145. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77146. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77147. import { Observable } from "babylonjs/Misc/observable";
  77148. import { Matrix } from "babylonjs/Maths/math.vector";
  77149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77150. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77151. /**
  77152. * An interface for all Hit test features
  77153. */
  77154. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77155. /**
  77156. * Triggered when new babylon (transformed) hit test results are available
  77157. */
  77158. onHitTestResultObservable: Observable<T[]>;
  77159. }
  77160. /**
  77161. * Options used for hit testing
  77162. */
  77163. export interface IWebXRLegacyHitTestOptions {
  77164. /**
  77165. * Only test when user interacted with the scene. Default - hit test every frame
  77166. */
  77167. testOnPointerDownOnly?: boolean;
  77168. /**
  77169. * The node to use to transform the local results to world coordinates
  77170. */
  77171. worldParentNode?: TransformNode;
  77172. }
  77173. /**
  77174. * Interface defining the babylon result of raycasting/hit-test
  77175. */
  77176. export interface IWebXRLegacyHitResult {
  77177. /**
  77178. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77179. */
  77180. transformationMatrix: Matrix;
  77181. /**
  77182. * The native hit test result
  77183. */
  77184. xrHitResult: XRHitResult | XRHitTestResult;
  77185. }
  77186. /**
  77187. * The currently-working hit-test module.
  77188. * Hit test (or Ray-casting) is used to interact with the real world.
  77189. * For further information read here - https://github.com/immersive-web/hit-test
  77190. */
  77191. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77192. /**
  77193. * options to use when constructing this feature
  77194. */
  77195. readonly options: IWebXRLegacyHitTestOptions;
  77196. private _direction;
  77197. private _mat;
  77198. private _onSelectEnabled;
  77199. private _origin;
  77200. /**
  77201. * The module's name
  77202. */
  77203. static readonly Name: string;
  77204. /**
  77205. * The (Babylon) version of this module.
  77206. * This is an integer representing the implementation version.
  77207. * This number does not correspond to the WebXR specs version
  77208. */
  77209. static readonly Version: number;
  77210. /**
  77211. * Populated with the last native XR Hit Results
  77212. */
  77213. lastNativeXRHitResults: XRHitResult[];
  77214. /**
  77215. * Triggered when new babylon (transformed) hit test results are available
  77216. */
  77217. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77218. /**
  77219. * Creates a new instance of the (legacy version) hit test feature
  77220. * @param _xrSessionManager an instance of WebXRSessionManager
  77221. * @param options options to use when constructing this feature
  77222. */
  77223. constructor(_xrSessionManager: WebXRSessionManager,
  77224. /**
  77225. * options to use when constructing this feature
  77226. */
  77227. options?: IWebXRLegacyHitTestOptions);
  77228. /**
  77229. * execute a hit test with an XR Ray
  77230. *
  77231. * @param xrSession a native xrSession that will execute this hit test
  77232. * @param xrRay the ray (position and direction) to use for ray-casting
  77233. * @param referenceSpace native XR reference space to use for the hit-test
  77234. * @param filter filter function that will filter the results
  77235. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77236. */
  77237. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77238. /**
  77239. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77240. * @param event the (select) event to use to select with
  77241. * @param referenceSpace the reference space to use for this hit test
  77242. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77243. */
  77244. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77245. /**
  77246. * attach this feature
  77247. * Will usually be called by the features manager
  77248. *
  77249. * @returns true if successful.
  77250. */
  77251. attach(): boolean;
  77252. /**
  77253. * detach this feature.
  77254. * Will usually be called by the features manager
  77255. *
  77256. * @returns true if successful.
  77257. */
  77258. detach(): boolean;
  77259. /**
  77260. * Dispose this feature and all of the resources attached
  77261. */
  77262. dispose(): void;
  77263. protected _onXRFrame(frame: XRFrame): void;
  77264. private _onHitTestResults;
  77265. private _onSelect;
  77266. }
  77267. }
  77268. declare module "babylonjs/XR/features/WebXRHitTest" {
  77269. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77270. import { Observable } from "babylonjs/Misc/observable";
  77271. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77272. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77273. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77274. /**
  77275. * Options used for hit testing (version 2)
  77276. */
  77277. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77278. /**
  77279. * Do not create a permanent hit test. Will usually be used when only
  77280. * transient inputs are needed.
  77281. */
  77282. disablePermanentHitTest?: boolean;
  77283. /**
  77284. * Enable transient (for example touch-based) hit test inspections
  77285. */
  77286. enableTransientHitTest?: boolean;
  77287. /**
  77288. * Offset ray for the permanent hit test
  77289. */
  77290. offsetRay?: Vector3;
  77291. /**
  77292. * Offset ray for the transient hit test
  77293. */
  77294. transientOffsetRay?: Vector3;
  77295. /**
  77296. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77297. */
  77298. useReferenceSpace?: boolean;
  77299. }
  77300. /**
  77301. * Interface defining the babylon result of hit-test
  77302. */
  77303. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77304. /**
  77305. * The input source that generated this hit test (if transient)
  77306. */
  77307. inputSource?: XRInputSource;
  77308. /**
  77309. * Is this a transient hit test
  77310. */
  77311. isTransient?: boolean;
  77312. /**
  77313. * Position of the hit test result
  77314. */
  77315. position: Vector3;
  77316. /**
  77317. * Rotation of the hit test result
  77318. */
  77319. rotationQuaternion: Quaternion;
  77320. /**
  77321. * The native hit test result
  77322. */
  77323. xrHitResult: XRHitTestResult;
  77324. }
  77325. /**
  77326. * The currently-working hit-test module.
  77327. * Hit test (or Ray-casting) is used to interact with the real world.
  77328. * For further information read here - https://github.com/immersive-web/hit-test
  77329. *
  77330. * Tested on chrome (mobile) 80.
  77331. */
  77332. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77333. /**
  77334. * options to use when constructing this feature
  77335. */
  77336. readonly options: IWebXRHitTestOptions;
  77337. private _tmpMat;
  77338. private _tmpPos;
  77339. private _tmpQuat;
  77340. private _transientXrHitTestSource;
  77341. private _xrHitTestSource;
  77342. private initHitTestSource;
  77343. /**
  77344. * The module's name
  77345. */
  77346. static readonly Name: string;
  77347. /**
  77348. * The (Babylon) version of this module.
  77349. * This is an integer representing the implementation version.
  77350. * This number does not correspond to the WebXR specs version
  77351. */
  77352. static readonly Version: number;
  77353. /**
  77354. * When set to true, each hit test will have its own position/rotation objects
  77355. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77356. * the developers will clone them or copy them as they see fit.
  77357. */
  77358. autoCloneTransformation: boolean;
  77359. /**
  77360. * Triggered when new babylon (transformed) hit test results are available
  77361. */
  77362. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77363. /**
  77364. * Use this to temporarily pause hit test checks.
  77365. */
  77366. paused: boolean;
  77367. /**
  77368. * Creates a new instance of the hit test feature
  77369. * @param _xrSessionManager an instance of WebXRSessionManager
  77370. * @param options options to use when constructing this feature
  77371. */
  77372. constructor(_xrSessionManager: WebXRSessionManager,
  77373. /**
  77374. * options to use when constructing this feature
  77375. */
  77376. options?: IWebXRHitTestOptions);
  77377. /**
  77378. * attach this feature
  77379. * Will usually be called by the features manager
  77380. *
  77381. * @returns true if successful.
  77382. */
  77383. attach(): boolean;
  77384. /**
  77385. * detach this feature.
  77386. * Will usually be called by the features manager
  77387. *
  77388. * @returns true if successful.
  77389. */
  77390. detach(): boolean;
  77391. /**
  77392. * Dispose this feature and all of the resources attached
  77393. */
  77394. dispose(): void;
  77395. protected _onXRFrame(frame: XRFrame): void;
  77396. private _processWebXRHitTestResult;
  77397. }
  77398. }
  77399. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77400. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77401. import { Observable } from "babylonjs/Misc/observable";
  77402. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77403. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77404. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77405. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77406. /**
  77407. * Configuration options of the anchor system
  77408. */
  77409. export interface IWebXRAnchorSystemOptions {
  77410. /**
  77411. * a node that will be used to convert local to world coordinates
  77412. */
  77413. worldParentNode?: TransformNode;
  77414. /**
  77415. * If set to true a reference of the created anchors will be kept until the next session starts
  77416. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77417. */
  77418. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77419. }
  77420. /**
  77421. * A babylon container for an XR Anchor
  77422. */
  77423. export interface IWebXRAnchor {
  77424. /**
  77425. * A babylon-assigned ID for this anchor
  77426. */
  77427. id: number;
  77428. /**
  77429. * Transformation matrix to apply to an object attached to this anchor
  77430. */
  77431. transformationMatrix: Matrix;
  77432. /**
  77433. * The native anchor object
  77434. */
  77435. xrAnchor: XRAnchor;
  77436. /**
  77437. * if defined, this object will be constantly updated by the anchor's position and rotation
  77438. */
  77439. attachedNode?: TransformNode;
  77440. }
  77441. /**
  77442. * An implementation of the anchor system for WebXR.
  77443. * For further information see https://github.com/immersive-web/anchors/
  77444. */
  77445. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77446. private _options;
  77447. private _lastFrameDetected;
  77448. private _trackedAnchors;
  77449. private _referenceSpaceForFrameAnchors;
  77450. private _futureAnchors;
  77451. /**
  77452. * The module's name
  77453. */
  77454. static readonly Name: string;
  77455. /**
  77456. * The (Babylon) version of this module.
  77457. * This is an integer representing the implementation version.
  77458. * This number does not correspond to the WebXR specs version
  77459. */
  77460. static readonly Version: number;
  77461. /**
  77462. * Observers registered here will be executed when a new anchor was added to the session
  77463. */
  77464. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77465. /**
  77466. * Observers registered here will be executed when an anchor was removed from the session
  77467. */
  77468. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77469. /**
  77470. * Observers registered here will be executed when an existing anchor updates
  77471. * This can execute N times every frame
  77472. */
  77473. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77474. /**
  77475. * Set the reference space to use for anchor creation, when not using a hit test.
  77476. * Will default to the session's reference space if not defined
  77477. */
  77478. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77479. /**
  77480. * constructs a new anchor system
  77481. * @param _xrSessionManager an instance of WebXRSessionManager
  77482. * @param _options configuration object for this feature
  77483. */
  77484. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77485. private _tmpVector;
  77486. private _tmpQuaternion;
  77487. private _populateTmpTransformation;
  77488. /**
  77489. * Create a new anchor point using a hit test result at a specific point in the scene
  77490. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77491. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77492. *
  77493. * @param hitTestResult The hit test result to use for this anchor creation
  77494. * @param position an optional position offset for this anchor
  77495. * @param rotationQuaternion an optional rotation offset for this anchor
  77496. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77497. */
  77498. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77499. /**
  77500. * Add a new anchor at a specific position and rotation
  77501. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77502. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77503. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77504. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77505. *
  77506. * @param position the position in which to add an anchor
  77507. * @param rotationQuaternion an optional rotation for the anchor transformation
  77508. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77509. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77510. */
  77511. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77512. /**
  77513. * detach this feature.
  77514. * Will usually be called by the features manager
  77515. *
  77516. * @returns true if successful.
  77517. */
  77518. detach(): boolean;
  77519. /**
  77520. * Dispose this feature and all of the resources attached
  77521. */
  77522. dispose(): void;
  77523. protected _onXRFrame(frame: XRFrame): void;
  77524. /**
  77525. * avoiding using Array.find for global support.
  77526. * @param xrAnchor the plane to find in the array
  77527. */
  77528. private _findIndexInAnchorArray;
  77529. private _updateAnchorWithXRFrame;
  77530. private _createAnchorAtTransformation;
  77531. }
  77532. }
  77533. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77535. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77536. import { Observable } from "babylonjs/Misc/observable";
  77537. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77538. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77539. /**
  77540. * Options used in the plane detector module
  77541. */
  77542. export interface IWebXRPlaneDetectorOptions {
  77543. /**
  77544. * The node to use to transform the local results to world coordinates
  77545. */
  77546. worldParentNode?: TransformNode;
  77547. /**
  77548. * If set to true a reference of the created planes will be kept until the next session starts
  77549. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77550. */
  77551. doNotRemovePlanesOnSessionEnded?: boolean;
  77552. }
  77553. /**
  77554. * A babylon interface for a WebXR plane.
  77555. * A Plane is actually a polygon, built from N points in space
  77556. *
  77557. * Supported in chrome 79, not supported in canary 81 ATM
  77558. */
  77559. export interface IWebXRPlane {
  77560. /**
  77561. * a babylon-assigned ID for this polygon
  77562. */
  77563. id: number;
  77564. /**
  77565. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77566. */
  77567. polygonDefinition: Array<Vector3>;
  77568. /**
  77569. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77570. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77571. */
  77572. transformationMatrix: Matrix;
  77573. /**
  77574. * the native xr-plane object
  77575. */
  77576. xrPlane: XRPlane;
  77577. }
  77578. /**
  77579. * The plane detector is used to detect planes in the real world when in AR
  77580. * For more information see https://github.com/immersive-web/real-world-geometry/
  77581. */
  77582. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77583. private _options;
  77584. private _detectedPlanes;
  77585. private _enabled;
  77586. private _lastFrameDetected;
  77587. /**
  77588. * The module's name
  77589. */
  77590. static readonly Name: string;
  77591. /**
  77592. * The (Babylon) version of this module.
  77593. * This is an integer representing the implementation version.
  77594. * This number does not correspond to the WebXR specs version
  77595. */
  77596. static readonly Version: number;
  77597. /**
  77598. * Observers registered here will be executed when a new plane was added to the session
  77599. */
  77600. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77601. /**
  77602. * Observers registered here will be executed when a plane is no longer detected in the session
  77603. */
  77604. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77605. /**
  77606. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77607. * This can execute N times every frame
  77608. */
  77609. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77610. /**
  77611. * construct a new Plane Detector
  77612. * @param _xrSessionManager an instance of xr Session manager
  77613. * @param _options configuration to use when constructing this feature
  77614. */
  77615. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77616. /**
  77617. * detach this feature.
  77618. * Will usually be called by the features manager
  77619. *
  77620. * @returns true if successful.
  77621. */
  77622. detach(): boolean;
  77623. /**
  77624. * Dispose this feature and all of the resources attached
  77625. */
  77626. dispose(): void;
  77627. protected _onXRFrame(frame: XRFrame): void;
  77628. private _init;
  77629. private _updatePlaneWithXRPlane;
  77630. /**
  77631. * avoiding using Array.find for global support.
  77632. * @param xrPlane the plane to find in the array
  77633. */
  77634. private findIndexInPlaneArray;
  77635. }
  77636. }
  77637. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77638. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77640. import { Observable } from "babylonjs/Misc/observable";
  77641. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77642. /**
  77643. * Options interface for the background remover plugin
  77644. */
  77645. export interface IWebXRBackgroundRemoverOptions {
  77646. /**
  77647. * Further background meshes to disable when entering AR
  77648. */
  77649. backgroundMeshes?: AbstractMesh[];
  77650. /**
  77651. * flags to configure the removal of the environment helper.
  77652. * If not set, the entire background will be removed. If set, flags should be set as well.
  77653. */
  77654. environmentHelperRemovalFlags?: {
  77655. /**
  77656. * Should the skybox be removed (default false)
  77657. */
  77658. skyBox?: boolean;
  77659. /**
  77660. * Should the ground be removed (default false)
  77661. */
  77662. ground?: boolean;
  77663. };
  77664. /**
  77665. * don't disable the environment helper
  77666. */
  77667. ignoreEnvironmentHelper?: boolean;
  77668. }
  77669. /**
  77670. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77671. */
  77672. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77673. /**
  77674. * read-only options to be used in this module
  77675. */
  77676. readonly options: IWebXRBackgroundRemoverOptions;
  77677. /**
  77678. * The module's name
  77679. */
  77680. static readonly Name: string;
  77681. /**
  77682. * The (Babylon) version of this module.
  77683. * This is an integer representing the implementation version.
  77684. * This number does not correspond to the WebXR specs version
  77685. */
  77686. static readonly Version: number;
  77687. /**
  77688. * registered observers will be triggered when the background state changes
  77689. */
  77690. onBackgroundStateChangedObservable: Observable<boolean>;
  77691. /**
  77692. * constructs a new background remover module
  77693. * @param _xrSessionManager the session manager for this module
  77694. * @param options read-only options to be used in this module
  77695. */
  77696. constructor(_xrSessionManager: WebXRSessionManager,
  77697. /**
  77698. * read-only options to be used in this module
  77699. */
  77700. options?: IWebXRBackgroundRemoverOptions);
  77701. /**
  77702. * attach this feature
  77703. * Will usually be called by the features manager
  77704. *
  77705. * @returns true if successful.
  77706. */
  77707. attach(): boolean;
  77708. /**
  77709. * detach this feature.
  77710. * Will usually be called by the features manager
  77711. *
  77712. * @returns true if successful.
  77713. */
  77714. detach(): boolean;
  77715. /**
  77716. * Dispose this feature and all of the resources attached
  77717. */
  77718. dispose(): void;
  77719. protected _onXRFrame(_xrFrame: XRFrame): void;
  77720. private _setBackgroundState;
  77721. }
  77722. }
  77723. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77724. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77725. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77726. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77727. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77729. import { Nullable } from "babylonjs/types";
  77730. /**
  77731. * Options for the controller physics feature
  77732. */
  77733. export class IWebXRControllerPhysicsOptions {
  77734. /**
  77735. * Should the headset get its own impostor
  77736. */
  77737. enableHeadsetImpostor?: boolean;
  77738. /**
  77739. * Optional parameters for the headset impostor
  77740. */
  77741. headsetImpostorParams?: {
  77742. /**
  77743. * The type of impostor to create. Default is sphere
  77744. */
  77745. impostorType: number;
  77746. /**
  77747. * the size of the impostor. Defaults to 10cm
  77748. */
  77749. impostorSize?: number | {
  77750. width: number;
  77751. height: number;
  77752. depth: number;
  77753. };
  77754. /**
  77755. * Friction definitions
  77756. */
  77757. friction?: number;
  77758. /**
  77759. * Restitution
  77760. */
  77761. restitution?: number;
  77762. };
  77763. /**
  77764. * The physics properties of the future impostors
  77765. */
  77766. physicsProperties?: {
  77767. /**
  77768. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77769. * Note that this requires a physics engine that supports mesh impostors!
  77770. */
  77771. useControllerMesh?: boolean;
  77772. /**
  77773. * The type of impostor to create. Default is sphere
  77774. */
  77775. impostorType?: number;
  77776. /**
  77777. * the size of the impostor. Defaults to 10cm
  77778. */
  77779. impostorSize?: number | {
  77780. width: number;
  77781. height: number;
  77782. depth: number;
  77783. };
  77784. /**
  77785. * Friction definitions
  77786. */
  77787. friction?: number;
  77788. /**
  77789. * Restitution
  77790. */
  77791. restitution?: number;
  77792. };
  77793. /**
  77794. * the xr input to use with this pointer selection
  77795. */
  77796. xrInput: WebXRInput;
  77797. }
  77798. /**
  77799. * Add physics impostor to your webxr controllers,
  77800. * including naive calculation of their linear and angular velocity
  77801. */
  77802. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77803. private readonly _options;
  77804. private _attachController;
  77805. private _controllers;
  77806. private _debugMode;
  77807. private _delta;
  77808. private _headsetImpostor?;
  77809. private _headsetMesh?;
  77810. private _lastTimestamp;
  77811. private _tmpQuaternion;
  77812. private _tmpVector;
  77813. /**
  77814. * The module's name
  77815. */
  77816. static readonly Name: string;
  77817. /**
  77818. * The (Babylon) version of this module.
  77819. * This is an integer representing the implementation version.
  77820. * This number does not correspond to the webxr specs version
  77821. */
  77822. static readonly Version: number;
  77823. /**
  77824. * Construct a new Controller Physics Feature
  77825. * @param _xrSessionManager the corresponding xr session manager
  77826. * @param _options options to create this feature with
  77827. */
  77828. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77829. /**
  77830. * @hidden
  77831. * enable debugging - will show console outputs and the impostor mesh
  77832. */
  77833. _enablePhysicsDebug(): void;
  77834. /**
  77835. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77836. * @param xrController the controller to add
  77837. */
  77838. addController(xrController: WebXRInputSource): void;
  77839. /**
  77840. * attach this feature
  77841. * Will usually be called by the features manager
  77842. *
  77843. * @returns true if successful.
  77844. */
  77845. attach(): boolean;
  77846. /**
  77847. * detach this feature.
  77848. * Will usually be called by the features manager
  77849. *
  77850. * @returns true if successful.
  77851. */
  77852. detach(): boolean;
  77853. /**
  77854. * Get the headset impostor, if enabled
  77855. * @returns the impostor
  77856. */
  77857. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77858. /**
  77859. * Get the physics impostor of a specific controller.
  77860. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77861. * @param controller the controller or the controller id of which to get the impostor
  77862. * @returns the impostor or null
  77863. */
  77864. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77865. /**
  77866. * Update the physics properties provided in the constructor
  77867. * @param newProperties the new properties object
  77868. */
  77869. setPhysicsProperties(newProperties: {
  77870. impostorType?: number;
  77871. impostorSize?: number | {
  77872. width: number;
  77873. height: number;
  77874. depth: number;
  77875. };
  77876. friction?: number;
  77877. restitution?: number;
  77878. }): void;
  77879. protected _onXRFrame(_xrFrame: any): void;
  77880. private _detachController;
  77881. }
  77882. }
  77883. declare module "babylonjs/XR/features/index" {
  77884. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77885. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77886. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77887. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77888. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77889. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77890. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77891. export * from "babylonjs/XR/features/WebXRHitTest";
  77892. }
  77893. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77894. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77896. import { Scene } from "babylonjs/scene";
  77897. /**
  77898. * The motion controller class for all microsoft mixed reality controllers
  77899. */
  77900. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77901. protected readonly _mapping: {
  77902. defaultButton: {
  77903. valueNodeName: string;
  77904. unpressedNodeName: string;
  77905. pressedNodeName: string;
  77906. };
  77907. defaultAxis: {
  77908. valueNodeName: string;
  77909. minNodeName: string;
  77910. maxNodeName: string;
  77911. };
  77912. buttons: {
  77913. "xr-standard-trigger": {
  77914. rootNodeName: string;
  77915. componentProperty: string;
  77916. states: string[];
  77917. };
  77918. "xr-standard-squeeze": {
  77919. rootNodeName: string;
  77920. componentProperty: string;
  77921. states: string[];
  77922. };
  77923. "xr-standard-touchpad": {
  77924. rootNodeName: string;
  77925. labelAnchorNodeName: string;
  77926. touchPointNodeName: string;
  77927. };
  77928. "xr-standard-thumbstick": {
  77929. rootNodeName: string;
  77930. componentProperty: string;
  77931. states: string[];
  77932. };
  77933. };
  77934. axes: {
  77935. "xr-standard-touchpad": {
  77936. "x-axis": {
  77937. rootNodeName: string;
  77938. };
  77939. "y-axis": {
  77940. rootNodeName: string;
  77941. };
  77942. };
  77943. "xr-standard-thumbstick": {
  77944. "x-axis": {
  77945. rootNodeName: string;
  77946. };
  77947. "y-axis": {
  77948. rootNodeName: string;
  77949. };
  77950. };
  77951. };
  77952. };
  77953. /**
  77954. * The base url used to load the left and right controller models
  77955. */
  77956. static MODEL_BASE_URL: string;
  77957. /**
  77958. * The name of the left controller model file
  77959. */
  77960. static MODEL_LEFT_FILENAME: string;
  77961. /**
  77962. * The name of the right controller model file
  77963. */
  77964. static MODEL_RIGHT_FILENAME: string;
  77965. profileId: string;
  77966. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77967. protected _getFilenameAndPath(): {
  77968. filename: string;
  77969. path: string;
  77970. };
  77971. protected _getModelLoadingConstraints(): boolean;
  77972. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77973. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77974. protected _updateModel(): void;
  77975. }
  77976. }
  77977. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77978. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77980. import { Scene } from "babylonjs/scene";
  77981. /**
  77982. * The motion controller class for oculus touch (quest, rift).
  77983. * This class supports legacy mapping as well the standard xr mapping
  77984. */
  77985. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77986. private _forceLegacyControllers;
  77987. private _modelRootNode;
  77988. /**
  77989. * The base url used to load the left and right controller models
  77990. */
  77991. static MODEL_BASE_URL: string;
  77992. /**
  77993. * The name of the left controller model file
  77994. */
  77995. static MODEL_LEFT_FILENAME: string;
  77996. /**
  77997. * The name of the right controller model file
  77998. */
  77999. static MODEL_RIGHT_FILENAME: string;
  78000. /**
  78001. * Base Url for the Quest controller model.
  78002. */
  78003. static QUEST_MODEL_BASE_URL: string;
  78004. profileId: string;
  78005. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78006. protected _getFilenameAndPath(): {
  78007. filename: string;
  78008. path: string;
  78009. };
  78010. protected _getModelLoadingConstraints(): boolean;
  78011. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78012. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78013. protected _updateModel(): void;
  78014. /**
  78015. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78016. * between the touch and touch 2.
  78017. */
  78018. private _isQuest;
  78019. }
  78020. }
  78021. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78022. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78023. import { Scene } from "babylonjs/scene";
  78024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78025. /**
  78026. * The motion controller class for the standard HTC-Vive controllers
  78027. */
  78028. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78029. private _modelRootNode;
  78030. /**
  78031. * The base url used to load the left and right controller models
  78032. */
  78033. static MODEL_BASE_URL: string;
  78034. /**
  78035. * File name for the controller model.
  78036. */
  78037. static MODEL_FILENAME: string;
  78038. profileId: string;
  78039. /**
  78040. * Create a new Vive motion controller object
  78041. * @param scene the scene to use to create this controller
  78042. * @param gamepadObject the corresponding gamepad object
  78043. * @param handedness the handedness of the controller
  78044. */
  78045. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78046. protected _getFilenameAndPath(): {
  78047. filename: string;
  78048. path: string;
  78049. };
  78050. protected _getModelLoadingConstraints(): boolean;
  78051. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78053. protected _updateModel(): void;
  78054. }
  78055. }
  78056. declare module "babylonjs/XR/motionController/index" {
  78057. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78058. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78059. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78060. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78061. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78062. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78063. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78064. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78065. }
  78066. declare module "babylonjs/XR/index" {
  78067. export * from "babylonjs/XR/webXRCamera";
  78068. export * from "babylonjs/XR/webXREnterExitUI";
  78069. export * from "babylonjs/XR/webXRExperienceHelper";
  78070. export * from "babylonjs/XR/webXRInput";
  78071. export * from "babylonjs/XR/webXRInputSource";
  78072. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78073. export * from "babylonjs/XR/webXRTypes";
  78074. export * from "babylonjs/XR/webXRSessionManager";
  78075. export * from "babylonjs/XR/webXRDefaultExperience";
  78076. export * from "babylonjs/XR/webXRFeaturesManager";
  78077. export * from "babylonjs/XR/features/index";
  78078. export * from "babylonjs/XR/motionController/index";
  78079. }
  78080. declare module "babylonjs/index" {
  78081. export * from "babylonjs/abstractScene";
  78082. export * from "babylonjs/Actions/index";
  78083. export * from "babylonjs/Animations/index";
  78084. export * from "babylonjs/assetContainer";
  78085. export * from "babylonjs/Audio/index";
  78086. export * from "babylonjs/Behaviors/index";
  78087. export * from "babylonjs/Bones/index";
  78088. export * from "babylonjs/Cameras/index";
  78089. export * from "babylonjs/Collisions/index";
  78090. export * from "babylonjs/Culling/index";
  78091. export * from "babylonjs/Debug/index";
  78092. export * from "babylonjs/DeviceInput/index";
  78093. export * from "babylonjs/Engines/index";
  78094. export * from "babylonjs/Events/index";
  78095. export * from "babylonjs/Gamepads/index";
  78096. export * from "babylonjs/Gizmos/index";
  78097. export * from "babylonjs/Helpers/index";
  78098. export * from "babylonjs/Instrumentation/index";
  78099. export * from "babylonjs/Layers/index";
  78100. export * from "babylonjs/LensFlares/index";
  78101. export * from "babylonjs/Lights/index";
  78102. export * from "babylonjs/Loading/index";
  78103. export * from "babylonjs/Materials/index";
  78104. export * from "babylonjs/Maths/index";
  78105. export * from "babylonjs/Meshes/index";
  78106. export * from "babylonjs/Morph/index";
  78107. export * from "babylonjs/Navigation/index";
  78108. export * from "babylonjs/node";
  78109. export * from "babylonjs/Offline/index";
  78110. export * from "babylonjs/Particles/index";
  78111. export * from "babylonjs/Physics/index";
  78112. export * from "babylonjs/PostProcesses/index";
  78113. export * from "babylonjs/Probes/index";
  78114. export * from "babylonjs/Rendering/index";
  78115. export * from "babylonjs/scene";
  78116. export * from "babylonjs/sceneComponent";
  78117. export * from "babylonjs/Sprites/index";
  78118. export * from "babylonjs/States/index";
  78119. export * from "babylonjs/Misc/index";
  78120. export * from "babylonjs/XR/index";
  78121. export * from "babylonjs/types";
  78122. }
  78123. declare module "babylonjs/Animations/pathCursor" {
  78124. import { Vector3 } from "babylonjs/Maths/math.vector";
  78125. import { Path2 } from "babylonjs/Maths/math.path";
  78126. /**
  78127. * A cursor which tracks a point on a path
  78128. */
  78129. export class PathCursor {
  78130. private path;
  78131. /**
  78132. * Stores path cursor callbacks for when an onchange event is triggered
  78133. */
  78134. private _onchange;
  78135. /**
  78136. * The value of the path cursor
  78137. */
  78138. value: number;
  78139. /**
  78140. * The animation array of the path cursor
  78141. */
  78142. animations: Animation[];
  78143. /**
  78144. * Initializes the path cursor
  78145. * @param path The path to track
  78146. */
  78147. constructor(path: Path2);
  78148. /**
  78149. * Gets the cursor point on the path
  78150. * @returns A point on the path cursor at the cursor location
  78151. */
  78152. getPoint(): Vector3;
  78153. /**
  78154. * Moves the cursor ahead by the step amount
  78155. * @param step The amount to move the cursor forward
  78156. * @returns This path cursor
  78157. */
  78158. moveAhead(step?: number): PathCursor;
  78159. /**
  78160. * Moves the cursor behind by the step amount
  78161. * @param step The amount to move the cursor back
  78162. * @returns This path cursor
  78163. */
  78164. moveBack(step?: number): PathCursor;
  78165. /**
  78166. * Moves the cursor by the step amount
  78167. * If the step amount is greater than one, an exception is thrown
  78168. * @param step The amount to move the cursor
  78169. * @returns This path cursor
  78170. */
  78171. move(step: number): PathCursor;
  78172. /**
  78173. * Ensures that the value is limited between zero and one
  78174. * @returns This path cursor
  78175. */
  78176. private ensureLimits;
  78177. /**
  78178. * Runs onchange callbacks on change (used by the animation engine)
  78179. * @returns This path cursor
  78180. */
  78181. private raiseOnChange;
  78182. /**
  78183. * Executes a function on change
  78184. * @param f A path cursor onchange callback
  78185. * @returns This path cursor
  78186. */
  78187. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78188. }
  78189. }
  78190. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78191. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78192. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78193. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78194. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78195. }
  78196. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78197. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78198. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78199. }
  78200. declare module "babylonjs/Engines/Processors/index" {
  78201. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78202. export * from "babylonjs/Engines/Processors/Expressions/index";
  78203. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78204. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78205. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78206. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78207. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78208. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78209. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78210. }
  78211. declare module "babylonjs/Legacy/legacy" {
  78212. import * as Babylon from "babylonjs/index";
  78213. export * from "babylonjs/index";
  78214. }
  78215. declare module "babylonjs/Shaders/blur.fragment" {
  78216. /** @hidden */
  78217. export var blurPixelShader: {
  78218. name: string;
  78219. shader: string;
  78220. };
  78221. }
  78222. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78223. /** @hidden */
  78224. export var pointCloudVertexDeclaration: {
  78225. name: string;
  78226. shader: string;
  78227. };
  78228. }
  78229. declare module "babylonjs" {
  78230. export * from "babylonjs/Legacy/legacy";
  78231. }
  78232. declare module BABYLON {
  78233. /** Alias type for value that can be null */
  78234. export type Nullable<T> = T | null;
  78235. /**
  78236. * Alias type for number that are floats
  78237. * @ignorenaming
  78238. */
  78239. export type float = number;
  78240. /**
  78241. * Alias type for number that are doubles.
  78242. * @ignorenaming
  78243. */
  78244. export type double = number;
  78245. /**
  78246. * Alias type for number that are integer
  78247. * @ignorenaming
  78248. */
  78249. export type int = number;
  78250. /** Alias type for number array or Float32Array */
  78251. export type FloatArray = number[] | Float32Array;
  78252. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78253. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78254. /**
  78255. * Alias for types that can be used by a Buffer or VertexBuffer.
  78256. */
  78257. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78258. /**
  78259. * Alias type for primitive types
  78260. * @ignorenaming
  78261. */
  78262. type Primitive = undefined | null | boolean | string | number | Function;
  78263. /**
  78264. * Type modifier to make all the properties of an object Readonly
  78265. */
  78266. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78267. /**
  78268. * Type modifier to make all the properties of an object Readonly recursively
  78269. */
  78270. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78271. /**
  78272. * Type modifier to make object properties readonly.
  78273. */
  78274. export type DeepImmutableObject<T> = {
  78275. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78276. };
  78277. /** @hidden */
  78278. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78279. }
  78280. }
  78281. declare module BABYLON {
  78282. /**
  78283. * A class serves as a medium between the observable and its observers
  78284. */
  78285. export class EventState {
  78286. /**
  78287. * Create a new EventState
  78288. * @param mask defines the mask associated with this state
  78289. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78290. * @param target defines the original target of the state
  78291. * @param currentTarget defines the current target of the state
  78292. */
  78293. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78294. /**
  78295. * Initialize the current event state
  78296. * @param mask defines the mask associated with this state
  78297. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78298. * @param target defines the original target of the state
  78299. * @param currentTarget defines the current target of the state
  78300. * @returns the current event state
  78301. */
  78302. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78303. /**
  78304. * An Observer can set this property to true to prevent subsequent observers of being notified
  78305. */
  78306. skipNextObservers: boolean;
  78307. /**
  78308. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78309. */
  78310. mask: number;
  78311. /**
  78312. * The object that originally notified the event
  78313. */
  78314. target?: any;
  78315. /**
  78316. * The current object in the bubbling phase
  78317. */
  78318. currentTarget?: any;
  78319. /**
  78320. * This will be populated with the return value of the last function that was executed.
  78321. * If it is the first function in the callback chain it will be the event data.
  78322. */
  78323. lastReturnValue?: any;
  78324. }
  78325. /**
  78326. * Represent an Observer registered to a given Observable object.
  78327. */
  78328. export class Observer<T> {
  78329. /**
  78330. * Defines the callback to call when the observer is notified
  78331. */
  78332. callback: (eventData: T, eventState: EventState) => void;
  78333. /**
  78334. * Defines the mask of the observer (used to filter notifications)
  78335. */
  78336. mask: number;
  78337. /**
  78338. * Defines the current scope used to restore the JS context
  78339. */
  78340. scope: any;
  78341. /** @hidden */
  78342. _willBeUnregistered: boolean;
  78343. /**
  78344. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78345. */
  78346. unregisterOnNextCall: boolean;
  78347. /**
  78348. * Creates a new observer
  78349. * @param callback defines the callback to call when the observer is notified
  78350. * @param mask defines the mask of the observer (used to filter notifications)
  78351. * @param scope defines the current scope used to restore the JS context
  78352. */
  78353. constructor(
  78354. /**
  78355. * Defines the callback to call when the observer is notified
  78356. */
  78357. callback: (eventData: T, eventState: EventState) => void,
  78358. /**
  78359. * Defines the mask of the observer (used to filter notifications)
  78360. */
  78361. mask: number,
  78362. /**
  78363. * Defines the current scope used to restore the JS context
  78364. */
  78365. scope?: any);
  78366. }
  78367. /**
  78368. * Represent a list of observers registered to multiple Observables object.
  78369. */
  78370. export class MultiObserver<T> {
  78371. private _observers;
  78372. private _observables;
  78373. /**
  78374. * Release associated resources
  78375. */
  78376. dispose(): void;
  78377. /**
  78378. * Raise a callback when one of the observable will notify
  78379. * @param observables defines a list of observables to watch
  78380. * @param callback defines the callback to call on notification
  78381. * @param mask defines the mask used to filter notifications
  78382. * @param scope defines the current scope used to restore the JS context
  78383. * @returns the new MultiObserver
  78384. */
  78385. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78386. }
  78387. /**
  78388. * The Observable class is a simple implementation of the Observable pattern.
  78389. *
  78390. * 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.
  78391. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78392. * 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).
  78393. * 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.
  78394. */
  78395. export class Observable<T> {
  78396. private _observers;
  78397. private _eventState;
  78398. private _onObserverAdded;
  78399. /**
  78400. * Gets the list of observers
  78401. */
  78402. get observers(): Array<Observer<T>>;
  78403. /**
  78404. * Creates a new observable
  78405. * @param onObserverAdded defines a callback to call when a new observer is added
  78406. */
  78407. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78408. /**
  78409. * Create a new Observer with the specified callback
  78410. * @param callback the callback that will be executed for that Observer
  78411. * @param mask the mask used to filter observers
  78412. * @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.
  78413. * @param scope optional scope for the callback to be called from
  78414. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78415. * @returns the new observer created for the callback
  78416. */
  78417. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78418. /**
  78419. * Create a new Observer with the specified callback and unregisters after the next notification
  78420. * @param callback the callback that will be executed for that Observer
  78421. * @returns the new observer created for the callback
  78422. */
  78423. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78424. /**
  78425. * Remove an Observer from the Observable object
  78426. * @param observer the instance of the Observer to remove
  78427. * @returns false if it doesn't belong to this Observable
  78428. */
  78429. remove(observer: Nullable<Observer<T>>): boolean;
  78430. /**
  78431. * Remove a callback from the Observable object
  78432. * @param callback the callback to remove
  78433. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78434. * @returns false if it doesn't belong to this Observable
  78435. */
  78436. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78437. private _deferUnregister;
  78438. private _remove;
  78439. /**
  78440. * Moves the observable to the top of the observer list making it get called first when notified
  78441. * @param observer the observer to move
  78442. */
  78443. makeObserverTopPriority(observer: Observer<T>): void;
  78444. /**
  78445. * Moves the observable to the bottom of the observer list making it get called last when notified
  78446. * @param observer the observer to move
  78447. */
  78448. makeObserverBottomPriority(observer: Observer<T>): void;
  78449. /**
  78450. * Notify all Observers by calling their respective callback with the given data
  78451. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78452. * @param eventData defines the data to send to all observers
  78453. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78454. * @param target defines the original target of the state
  78455. * @param currentTarget defines the current target of the state
  78456. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78457. */
  78458. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78459. /**
  78460. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78461. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78462. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78463. * and it is crucial that all callbacks will be executed.
  78464. * The order of the callbacks is kept, callbacks are not executed parallel.
  78465. *
  78466. * @param eventData The data to be sent to each callback
  78467. * @param mask is used to filter observers defaults to -1
  78468. * @param target defines the callback target (see EventState)
  78469. * @param currentTarget defines he current object in the bubbling phase
  78470. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78471. */
  78472. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78473. /**
  78474. * Notify a specific observer
  78475. * @param observer defines the observer to notify
  78476. * @param eventData defines the data to be sent to each callback
  78477. * @param mask is used to filter observers defaults to -1
  78478. */
  78479. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78480. /**
  78481. * Gets a boolean indicating if the observable has at least one observer
  78482. * @returns true is the Observable has at least one Observer registered
  78483. */
  78484. hasObservers(): boolean;
  78485. /**
  78486. * Clear the list of observers
  78487. */
  78488. clear(): void;
  78489. /**
  78490. * Clone the current observable
  78491. * @returns a new observable
  78492. */
  78493. clone(): Observable<T>;
  78494. /**
  78495. * Does this observable handles observer registered with a given mask
  78496. * @param mask defines the mask to be tested
  78497. * @return whether or not one observer registered with the given mask is handeled
  78498. **/
  78499. hasSpecificMask(mask?: number): boolean;
  78500. }
  78501. }
  78502. declare module BABYLON {
  78503. /**
  78504. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78505. * Babylon.js
  78506. */
  78507. export class DomManagement {
  78508. /**
  78509. * Checks if the window object exists
  78510. * @returns true if the window object exists
  78511. */
  78512. static IsWindowObjectExist(): boolean;
  78513. /**
  78514. * Checks if the navigator object exists
  78515. * @returns true if the navigator object exists
  78516. */
  78517. static IsNavigatorAvailable(): boolean;
  78518. /**
  78519. * Check if the document object exists
  78520. * @returns true if the document object exists
  78521. */
  78522. static IsDocumentAvailable(): boolean;
  78523. /**
  78524. * Extracts text content from a DOM element hierarchy
  78525. * @param element defines the root element
  78526. * @returns a string
  78527. */
  78528. static GetDOMTextContent(element: HTMLElement): string;
  78529. }
  78530. }
  78531. declare module BABYLON {
  78532. /**
  78533. * Logger used througouht the application to allow configuration of
  78534. * the log level required for the messages.
  78535. */
  78536. export class Logger {
  78537. /**
  78538. * No log
  78539. */
  78540. static readonly NoneLogLevel: number;
  78541. /**
  78542. * Only message logs
  78543. */
  78544. static readonly MessageLogLevel: number;
  78545. /**
  78546. * Only warning logs
  78547. */
  78548. static readonly WarningLogLevel: number;
  78549. /**
  78550. * Only error logs
  78551. */
  78552. static readonly ErrorLogLevel: number;
  78553. /**
  78554. * All logs
  78555. */
  78556. static readonly AllLogLevel: number;
  78557. private static _LogCache;
  78558. /**
  78559. * Gets a value indicating the number of loading errors
  78560. * @ignorenaming
  78561. */
  78562. static errorsCount: number;
  78563. /**
  78564. * Callback called when a new log is added
  78565. */
  78566. static OnNewCacheEntry: (entry: string) => void;
  78567. private static _AddLogEntry;
  78568. private static _FormatMessage;
  78569. private static _LogDisabled;
  78570. private static _LogEnabled;
  78571. private static _WarnDisabled;
  78572. private static _WarnEnabled;
  78573. private static _ErrorDisabled;
  78574. private static _ErrorEnabled;
  78575. /**
  78576. * Log a message to the console
  78577. */
  78578. static Log: (message: string) => void;
  78579. /**
  78580. * Write a warning message to the console
  78581. */
  78582. static Warn: (message: string) => void;
  78583. /**
  78584. * Write an error message to the console
  78585. */
  78586. static Error: (message: string) => void;
  78587. /**
  78588. * Gets current log cache (list of logs)
  78589. */
  78590. static get LogCache(): string;
  78591. /**
  78592. * Clears the log cache
  78593. */
  78594. static ClearLogCache(): void;
  78595. /**
  78596. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78597. */
  78598. static set LogLevels(level: number);
  78599. }
  78600. }
  78601. declare module BABYLON {
  78602. /** @hidden */
  78603. export class _TypeStore {
  78604. /** @hidden */
  78605. static RegisteredTypes: {
  78606. [key: string]: Object;
  78607. };
  78608. /** @hidden */
  78609. static GetClass(fqdn: string): any;
  78610. }
  78611. }
  78612. declare module BABYLON {
  78613. /**
  78614. * Helper to manipulate strings
  78615. */
  78616. export class StringTools {
  78617. /**
  78618. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78619. * @param str Source string
  78620. * @param suffix Suffix to search for in the source string
  78621. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78622. */
  78623. static EndsWith(str: string, suffix: string): boolean;
  78624. /**
  78625. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78626. * @param str Source string
  78627. * @param suffix Suffix to search for in the source string
  78628. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78629. */
  78630. static StartsWith(str: string, suffix: string): boolean;
  78631. /**
  78632. * Decodes a buffer into a string
  78633. * @param buffer The buffer to decode
  78634. * @returns The decoded string
  78635. */
  78636. static Decode(buffer: Uint8Array | Uint16Array): string;
  78637. /**
  78638. * Encode a buffer to a base64 string
  78639. * @param buffer defines the buffer to encode
  78640. * @returns the encoded string
  78641. */
  78642. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78643. /**
  78644. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78645. * @param num the number to convert and pad
  78646. * @param length the expected length of the string
  78647. * @returns the padded string
  78648. */
  78649. static PadNumber(num: number, length: number): string;
  78650. }
  78651. }
  78652. declare module BABYLON {
  78653. /**
  78654. * Class containing a set of static utilities functions for deep copy.
  78655. */
  78656. export class DeepCopier {
  78657. /**
  78658. * Tries to copy an object by duplicating every property
  78659. * @param source defines the source object
  78660. * @param destination defines the target object
  78661. * @param doNotCopyList defines a list of properties to avoid
  78662. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78663. */
  78664. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78665. }
  78666. }
  78667. declare module BABYLON {
  78668. /**
  78669. * Class containing a set of static utilities functions for precision date
  78670. */
  78671. export class PrecisionDate {
  78672. /**
  78673. * Gets either window.performance.now() if supported or Date.now() else
  78674. */
  78675. static get Now(): number;
  78676. }
  78677. }
  78678. declare module BABYLON {
  78679. /** @hidden */
  78680. export class _DevTools {
  78681. static WarnImport(name: string): string;
  78682. }
  78683. }
  78684. declare module BABYLON {
  78685. /**
  78686. * Interface used to define the mechanism to get data from the network
  78687. */
  78688. export interface IWebRequest {
  78689. /**
  78690. * Returns client's response url
  78691. */
  78692. responseURL: string;
  78693. /**
  78694. * Returns client's status
  78695. */
  78696. status: number;
  78697. /**
  78698. * Returns client's status as a text
  78699. */
  78700. statusText: string;
  78701. }
  78702. }
  78703. declare module BABYLON {
  78704. /**
  78705. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78706. */
  78707. export class WebRequest implements IWebRequest {
  78708. private _xhr;
  78709. /**
  78710. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78711. * i.e. when loading files, where the server/service expects an Authorization header
  78712. */
  78713. static CustomRequestHeaders: {
  78714. [key: string]: string;
  78715. };
  78716. /**
  78717. * Add callback functions in this array to update all the requests before they get sent to the network
  78718. */
  78719. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78720. private _injectCustomRequestHeaders;
  78721. /**
  78722. * Gets or sets a function to be called when loading progress changes
  78723. */
  78724. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78725. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78726. /**
  78727. * Returns client's state
  78728. */
  78729. get readyState(): number;
  78730. /**
  78731. * Returns client's status
  78732. */
  78733. get status(): number;
  78734. /**
  78735. * Returns client's status as a text
  78736. */
  78737. get statusText(): string;
  78738. /**
  78739. * Returns client's response
  78740. */
  78741. get response(): any;
  78742. /**
  78743. * Returns client's response url
  78744. */
  78745. get responseURL(): string;
  78746. /**
  78747. * Returns client's response as text
  78748. */
  78749. get responseText(): string;
  78750. /**
  78751. * Gets or sets the expected response type
  78752. */
  78753. get responseType(): XMLHttpRequestResponseType;
  78754. set responseType(value: XMLHttpRequestResponseType);
  78755. /** @hidden */
  78756. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78757. /** @hidden */
  78758. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78759. /**
  78760. * Cancels any network activity
  78761. */
  78762. abort(): void;
  78763. /**
  78764. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78765. * @param body defines an optional request body
  78766. */
  78767. send(body?: Document | BodyInit | null): void;
  78768. /**
  78769. * Sets the request method, request URL
  78770. * @param method defines the method to use (GET, POST, etc..)
  78771. * @param url defines the url to connect with
  78772. */
  78773. open(method: string, url: string): void;
  78774. /**
  78775. * Sets the value of a request header.
  78776. * @param name The name of the header whose value is to be set
  78777. * @param value The value to set as the body of the header
  78778. */
  78779. setRequestHeader(name: string, value: string): void;
  78780. /**
  78781. * Get the string containing the text of a particular header's value.
  78782. * @param name The name of the header
  78783. * @returns The string containing the text of the given header name
  78784. */
  78785. getResponseHeader(name: string): Nullable<string>;
  78786. }
  78787. }
  78788. declare module BABYLON {
  78789. /**
  78790. * File request interface
  78791. */
  78792. export interface IFileRequest {
  78793. /**
  78794. * Raised when the request is complete (success or error).
  78795. */
  78796. onCompleteObservable: Observable<IFileRequest>;
  78797. /**
  78798. * Aborts the request for a file.
  78799. */
  78800. abort: () => void;
  78801. }
  78802. }
  78803. declare module BABYLON {
  78804. /**
  78805. * Define options used to create a render target texture
  78806. */
  78807. export class RenderTargetCreationOptions {
  78808. /**
  78809. * Specifies is mipmaps must be generated
  78810. */
  78811. generateMipMaps?: boolean;
  78812. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78813. generateDepthBuffer?: boolean;
  78814. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78815. generateStencilBuffer?: boolean;
  78816. /** Defines texture type (int by default) */
  78817. type?: number;
  78818. /** Defines sampling mode (trilinear by default) */
  78819. samplingMode?: number;
  78820. /** Defines format (RGBA by default) */
  78821. format?: number;
  78822. }
  78823. }
  78824. declare module BABYLON {
  78825. /** Defines the cross module used constants to avoid circular dependncies */
  78826. export class Constants {
  78827. /** Defines that alpha blending is disabled */
  78828. static readonly ALPHA_DISABLE: number;
  78829. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78830. static readonly ALPHA_ADD: number;
  78831. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78832. static readonly ALPHA_COMBINE: number;
  78833. /** Defines that alpha blending is DEST - SRC * DEST */
  78834. static readonly ALPHA_SUBTRACT: number;
  78835. /** Defines that alpha blending is SRC * DEST */
  78836. static readonly ALPHA_MULTIPLY: number;
  78837. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78838. static readonly ALPHA_MAXIMIZED: number;
  78839. /** Defines that alpha blending is SRC + DEST */
  78840. static readonly ALPHA_ONEONE: number;
  78841. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78842. static readonly ALPHA_PREMULTIPLIED: number;
  78843. /**
  78844. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78845. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78846. */
  78847. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78848. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78849. static readonly ALPHA_INTERPOLATE: number;
  78850. /**
  78851. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78852. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78853. */
  78854. static readonly ALPHA_SCREENMODE: number;
  78855. /**
  78856. * Defines that alpha blending is SRC + DST
  78857. * Alpha will be set to SRC ALPHA + DST ALPHA
  78858. */
  78859. static readonly ALPHA_ONEONE_ONEONE: number;
  78860. /**
  78861. * Defines that alpha blending is SRC * DST ALPHA + DST
  78862. * Alpha will be set to 0
  78863. */
  78864. static readonly ALPHA_ALPHATOCOLOR: number;
  78865. /**
  78866. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78867. */
  78868. static readonly ALPHA_REVERSEONEMINUS: number;
  78869. /**
  78870. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78871. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78872. */
  78873. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78874. /**
  78875. * Defines that alpha blending is SRC + DST
  78876. * Alpha will be set to SRC ALPHA
  78877. */
  78878. static readonly ALPHA_ONEONE_ONEZERO: number;
  78879. /**
  78880. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78881. * Alpha will be set to DST ALPHA
  78882. */
  78883. static readonly ALPHA_EXCLUSION: number;
  78884. /** Defines that alpha blending equation a SUM */
  78885. static readonly ALPHA_EQUATION_ADD: number;
  78886. /** Defines that alpha blending equation a SUBSTRACTION */
  78887. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78888. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78889. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78890. /** Defines that alpha blending equation a MAX operation */
  78891. static readonly ALPHA_EQUATION_MAX: number;
  78892. /** Defines that alpha blending equation a MIN operation */
  78893. static readonly ALPHA_EQUATION_MIN: number;
  78894. /**
  78895. * Defines that alpha blending equation a DARKEN operation:
  78896. * It takes the min of the src and sums the alpha channels.
  78897. */
  78898. static readonly ALPHA_EQUATION_DARKEN: number;
  78899. /** Defines that the ressource is not delayed*/
  78900. static readonly DELAYLOADSTATE_NONE: number;
  78901. /** Defines that the ressource was successfully delay loaded */
  78902. static readonly DELAYLOADSTATE_LOADED: number;
  78903. /** Defines that the ressource is currently delay loading */
  78904. static readonly DELAYLOADSTATE_LOADING: number;
  78905. /** Defines that the ressource is delayed and has not started loading */
  78906. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78907. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78908. static readonly NEVER: number;
  78909. /** 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 */
  78910. static readonly ALWAYS: number;
  78911. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78912. static readonly LESS: number;
  78913. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78914. static readonly EQUAL: number;
  78915. /** 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 */
  78916. static readonly LEQUAL: number;
  78917. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78918. static readonly GREATER: number;
  78919. /** 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 */
  78920. static readonly GEQUAL: number;
  78921. /** 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 */
  78922. static readonly NOTEQUAL: number;
  78923. /** Passed to stencilOperation to specify that stencil value must be kept */
  78924. static readonly KEEP: number;
  78925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78926. static readonly REPLACE: number;
  78927. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78928. static readonly INCR: number;
  78929. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78930. static readonly DECR: number;
  78931. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78932. static readonly INVERT: number;
  78933. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78934. static readonly INCR_WRAP: number;
  78935. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78936. static readonly DECR_WRAP: number;
  78937. /** Texture is not repeating outside of 0..1 UVs */
  78938. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78939. /** Texture is repeating outside of 0..1 UVs */
  78940. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78941. /** Texture is repeating and mirrored */
  78942. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78943. /** ALPHA */
  78944. static readonly TEXTUREFORMAT_ALPHA: number;
  78945. /** LUMINANCE */
  78946. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78947. /** LUMINANCE_ALPHA */
  78948. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78949. /** RGB */
  78950. static readonly TEXTUREFORMAT_RGB: number;
  78951. /** RGBA */
  78952. static readonly TEXTUREFORMAT_RGBA: number;
  78953. /** RED */
  78954. static readonly TEXTUREFORMAT_RED: number;
  78955. /** RED (2nd reference) */
  78956. static readonly TEXTUREFORMAT_R: number;
  78957. /** RG */
  78958. static readonly TEXTUREFORMAT_RG: number;
  78959. /** RED_INTEGER */
  78960. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78961. /** RED_INTEGER (2nd reference) */
  78962. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78963. /** RG_INTEGER */
  78964. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78965. /** RGB_INTEGER */
  78966. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78967. /** RGBA_INTEGER */
  78968. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78969. /** UNSIGNED_BYTE */
  78970. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78971. /** UNSIGNED_BYTE (2nd reference) */
  78972. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78973. /** FLOAT */
  78974. static readonly TEXTURETYPE_FLOAT: number;
  78975. /** HALF_FLOAT */
  78976. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78977. /** BYTE */
  78978. static readonly TEXTURETYPE_BYTE: number;
  78979. /** SHORT */
  78980. static readonly TEXTURETYPE_SHORT: number;
  78981. /** UNSIGNED_SHORT */
  78982. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78983. /** INT */
  78984. static readonly TEXTURETYPE_INT: number;
  78985. /** UNSIGNED_INT */
  78986. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78987. /** UNSIGNED_SHORT_4_4_4_4 */
  78988. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78989. /** UNSIGNED_SHORT_5_5_5_1 */
  78990. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78991. /** UNSIGNED_SHORT_5_6_5 */
  78992. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78993. /** UNSIGNED_INT_2_10_10_10_REV */
  78994. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78995. /** UNSIGNED_INT_24_8 */
  78996. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78997. /** UNSIGNED_INT_10F_11F_11F_REV */
  78998. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78999. /** UNSIGNED_INT_5_9_9_9_REV */
  79000. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79001. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79002. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79003. /** nearest is mag = nearest and min = nearest and no mip */
  79004. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79005. /** mag = nearest and min = nearest and mip = none */
  79006. static readonly TEXTURE_NEAREST_NEAREST: number;
  79007. /** Bilinear is mag = linear and min = linear and no mip */
  79008. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79009. /** mag = linear and min = linear and mip = none */
  79010. static readonly TEXTURE_LINEAR_LINEAR: number;
  79011. /** Trilinear is mag = linear and min = linear and mip = linear */
  79012. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79013. /** Trilinear is mag = linear and min = linear and mip = linear */
  79014. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79015. /** mag = nearest and min = nearest and mip = nearest */
  79016. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79017. /** mag = nearest and min = linear and mip = nearest */
  79018. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79019. /** mag = nearest and min = linear and mip = linear */
  79020. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79021. /** mag = nearest and min = linear and mip = none */
  79022. static readonly TEXTURE_NEAREST_LINEAR: number;
  79023. /** nearest is mag = nearest and min = nearest and mip = linear */
  79024. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79025. /** mag = linear and min = nearest and mip = nearest */
  79026. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79027. /** mag = linear and min = nearest and mip = linear */
  79028. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79029. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79030. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79031. /** mag = linear and min = nearest and mip = none */
  79032. static readonly TEXTURE_LINEAR_NEAREST: number;
  79033. /** Explicit coordinates mode */
  79034. static readonly TEXTURE_EXPLICIT_MODE: number;
  79035. /** Spherical coordinates mode */
  79036. static readonly TEXTURE_SPHERICAL_MODE: number;
  79037. /** Planar coordinates mode */
  79038. static readonly TEXTURE_PLANAR_MODE: number;
  79039. /** Cubic coordinates mode */
  79040. static readonly TEXTURE_CUBIC_MODE: number;
  79041. /** Projection coordinates mode */
  79042. static readonly TEXTURE_PROJECTION_MODE: number;
  79043. /** Skybox coordinates mode */
  79044. static readonly TEXTURE_SKYBOX_MODE: number;
  79045. /** Inverse Cubic coordinates mode */
  79046. static readonly TEXTURE_INVCUBIC_MODE: number;
  79047. /** Equirectangular coordinates mode */
  79048. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79049. /** Equirectangular Fixed coordinates mode */
  79050. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79051. /** Equirectangular Fixed Mirrored coordinates mode */
  79052. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79053. /** Offline (baking) quality for texture filtering */
  79054. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79055. /** High quality for texture filtering */
  79056. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79057. /** Medium quality for texture filtering */
  79058. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79059. /** Low quality for texture filtering */
  79060. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79061. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79062. static readonly SCALEMODE_FLOOR: number;
  79063. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79064. static readonly SCALEMODE_NEAREST: number;
  79065. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79066. static readonly SCALEMODE_CEILING: number;
  79067. /**
  79068. * The dirty texture flag value
  79069. */
  79070. static readonly MATERIAL_TextureDirtyFlag: number;
  79071. /**
  79072. * The dirty light flag value
  79073. */
  79074. static readonly MATERIAL_LightDirtyFlag: number;
  79075. /**
  79076. * The dirty fresnel flag value
  79077. */
  79078. static readonly MATERIAL_FresnelDirtyFlag: number;
  79079. /**
  79080. * The dirty attribute flag value
  79081. */
  79082. static readonly MATERIAL_AttributesDirtyFlag: number;
  79083. /**
  79084. * The dirty misc flag value
  79085. */
  79086. static readonly MATERIAL_MiscDirtyFlag: number;
  79087. /**
  79088. * The all dirty flag value
  79089. */
  79090. static readonly MATERIAL_AllDirtyFlag: number;
  79091. /**
  79092. * Returns the triangle fill mode
  79093. */
  79094. static readonly MATERIAL_TriangleFillMode: number;
  79095. /**
  79096. * Returns the wireframe mode
  79097. */
  79098. static readonly MATERIAL_WireFrameFillMode: number;
  79099. /**
  79100. * Returns the point fill mode
  79101. */
  79102. static readonly MATERIAL_PointFillMode: number;
  79103. /**
  79104. * Returns the point list draw mode
  79105. */
  79106. static readonly MATERIAL_PointListDrawMode: number;
  79107. /**
  79108. * Returns the line list draw mode
  79109. */
  79110. static readonly MATERIAL_LineListDrawMode: number;
  79111. /**
  79112. * Returns the line loop draw mode
  79113. */
  79114. static readonly MATERIAL_LineLoopDrawMode: number;
  79115. /**
  79116. * Returns the line strip draw mode
  79117. */
  79118. static readonly MATERIAL_LineStripDrawMode: number;
  79119. /**
  79120. * Returns the triangle strip draw mode
  79121. */
  79122. static readonly MATERIAL_TriangleStripDrawMode: number;
  79123. /**
  79124. * Returns the triangle fan draw mode
  79125. */
  79126. static readonly MATERIAL_TriangleFanDrawMode: number;
  79127. /**
  79128. * Stores the clock-wise side orientation
  79129. */
  79130. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79131. /**
  79132. * Stores the counter clock-wise side orientation
  79133. */
  79134. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79135. /**
  79136. * Nothing
  79137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79138. */
  79139. static readonly ACTION_NothingTrigger: number;
  79140. /**
  79141. * On pick
  79142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79143. */
  79144. static readonly ACTION_OnPickTrigger: number;
  79145. /**
  79146. * On left pick
  79147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79148. */
  79149. static readonly ACTION_OnLeftPickTrigger: number;
  79150. /**
  79151. * On right pick
  79152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79153. */
  79154. static readonly ACTION_OnRightPickTrigger: number;
  79155. /**
  79156. * On center pick
  79157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79158. */
  79159. static readonly ACTION_OnCenterPickTrigger: number;
  79160. /**
  79161. * On pick down
  79162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79163. */
  79164. static readonly ACTION_OnPickDownTrigger: number;
  79165. /**
  79166. * On double pick
  79167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79168. */
  79169. static readonly ACTION_OnDoublePickTrigger: number;
  79170. /**
  79171. * On pick up
  79172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79173. */
  79174. static readonly ACTION_OnPickUpTrigger: number;
  79175. /**
  79176. * On pick out.
  79177. * This trigger will only be raised if you also declared a OnPickDown
  79178. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79179. */
  79180. static readonly ACTION_OnPickOutTrigger: number;
  79181. /**
  79182. * On long press
  79183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79184. */
  79185. static readonly ACTION_OnLongPressTrigger: number;
  79186. /**
  79187. * On pointer over
  79188. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79189. */
  79190. static readonly ACTION_OnPointerOverTrigger: number;
  79191. /**
  79192. * On pointer out
  79193. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79194. */
  79195. static readonly ACTION_OnPointerOutTrigger: number;
  79196. /**
  79197. * On every frame
  79198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79199. */
  79200. static readonly ACTION_OnEveryFrameTrigger: number;
  79201. /**
  79202. * On intersection enter
  79203. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79204. */
  79205. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79206. /**
  79207. * On intersection exit
  79208. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79209. */
  79210. static readonly ACTION_OnIntersectionExitTrigger: number;
  79211. /**
  79212. * On key down
  79213. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79214. */
  79215. static readonly ACTION_OnKeyDownTrigger: number;
  79216. /**
  79217. * On key up
  79218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79219. */
  79220. static readonly ACTION_OnKeyUpTrigger: number;
  79221. /**
  79222. * Billboard mode will only apply to Y axis
  79223. */
  79224. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79225. /**
  79226. * Billboard mode will apply to all axes
  79227. */
  79228. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79229. /**
  79230. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79231. */
  79232. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79233. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79234. * Test order :
  79235. * Is the bounding sphere outside the frustum ?
  79236. * If not, are the bounding box vertices outside the frustum ?
  79237. * It not, then the cullable object is in the frustum.
  79238. */
  79239. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79240. /** Culling strategy : Bounding Sphere Only.
  79241. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79242. * It's also less accurate than the standard because some not visible objects can still be selected.
  79243. * Test : is the bounding sphere outside the frustum ?
  79244. * If not, then the cullable object is in the frustum.
  79245. */
  79246. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79247. /** Culling strategy : Optimistic Inclusion.
  79248. * This in an inclusion test first, then the standard exclusion test.
  79249. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79250. * 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.
  79251. * Anyway, it's as accurate as the standard strategy.
  79252. * Test :
  79253. * Is the cullable object bounding sphere center in the frustum ?
  79254. * If not, apply the default culling strategy.
  79255. */
  79256. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79257. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79258. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79259. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79260. * 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.
  79261. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79262. * Test :
  79263. * Is the cullable object bounding sphere center in the frustum ?
  79264. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79265. */
  79266. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79267. /**
  79268. * No logging while loading
  79269. */
  79270. static readonly SCENELOADER_NO_LOGGING: number;
  79271. /**
  79272. * Minimal logging while loading
  79273. */
  79274. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79275. /**
  79276. * Summary logging while loading
  79277. */
  79278. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79279. /**
  79280. * Detailled logging while loading
  79281. */
  79282. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79283. }
  79284. }
  79285. declare module BABYLON {
  79286. /**
  79287. * This represents the required contract to create a new type of texture loader.
  79288. */
  79289. export interface IInternalTextureLoader {
  79290. /**
  79291. * Defines wether the loader supports cascade loading the different faces.
  79292. */
  79293. supportCascades: boolean;
  79294. /**
  79295. * This returns if the loader support the current file information.
  79296. * @param extension defines the file extension of the file being loaded
  79297. * @param mimeType defines the optional mime type of the file being loaded
  79298. * @returns true if the loader can load the specified file
  79299. */
  79300. canLoad(extension: string, mimeType?: string): boolean;
  79301. /**
  79302. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79303. * @param data contains the texture data
  79304. * @param texture defines the BabylonJS internal texture
  79305. * @param createPolynomials will be true if polynomials have been requested
  79306. * @param onLoad defines the callback to trigger once the texture is ready
  79307. * @param onError defines the callback to trigger in case of error
  79308. */
  79309. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79310. /**
  79311. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79312. * @param data contains the texture data
  79313. * @param texture defines the BabylonJS internal texture
  79314. * @param callback defines the method to call once ready to upload
  79315. */
  79316. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79317. }
  79318. }
  79319. declare module BABYLON {
  79320. /**
  79321. * Class used to store and describe the pipeline context associated with an effect
  79322. */
  79323. export interface IPipelineContext {
  79324. /**
  79325. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79326. */
  79327. isAsync: boolean;
  79328. /**
  79329. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79330. */
  79331. isReady: boolean;
  79332. /** @hidden */
  79333. _getVertexShaderCode(): string | null;
  79334. /** @hidden */
  79335. _getFragmentShaderCode(): string | null;
  79336. /** @hidden */
  79337. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79338. }
  79339. }
  79340. declare module BABYLON {
  79341. /**
  79342. * Class used to store gfx data (like WebGLBuffer)
  79343. */
  79344. export class DataBuffer {
  79345. /**
  79346. * Gets or sets the number of objects referencing this buffer
  79347. */
  79348. references: number;
  79349. /** Gets or sets the size of the underlying buffer */
  79350. capacity: number;
  79351. /**
  79352. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79353. */
  79354. is32Bits: boolean;
  79355. /**
  79356. * Gets the underlying buffer
  79357. */
  79358. get underlyingResource(): any;
  79359. }
  79360. }
  79361. declare module BABYLON {
  79362. /** @hidden */
  79363. export interface IShaderProcessor {
  79364. attributeProcessor?: (attribute: string) => string;
  79365. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79366. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79367. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79368. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79369. lineProcessor?: (line: string, isFragment: boolean) => string;
  79370. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79371. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79372. }
  79373. }
  79374. declare module BABYLON {
  79375. /** @hidden */
  79376. export interface ProcessingOptions {
  79377. defines: string[];
  79378. indexParameters: any;
  79379. isFragment: boolean;
  79380. shouldUseHighPrecisionShader: boolean;
  79381. supportsUniformBuffers: boolean;
  79382. shadersRepository: string;
  79383. includesShadersStore: {
  79384. [key: string]: string;
  79385. };
  79386. processor?: IShaderProcessor;
  79387. version: string;
  79388. platformName: string;
  79389. lookForClosingBracketForUniformBuffer?: boolean;
  79390. }
  79391. }
  79392. declare module BABYLON {
  79393. /** @hidden */
  79394. export class ShaderCodeNode {
  79395. line: string;
  79396. children: ShaderCodeNode[];
  79397. additionalDefineKey?: string;
  79398. additionalDefineValue?: string;
  79399. isValid(preprocessors: {
  79400. [key: string]: string;
  79401. }): boolean;
  79402. process(preprocessors: {
  79403. [key: string]: string;
  79404. }, options: ProcessingOptions): string;
  79405. }
  79406. }
  79407. declare module BABYLON {
  79408. /** @hidden */
  79409. export class ShaderCodeCursor {
  79410. private _lines;
  79411. lineIndex: number;
  79412. get currentLine(): string;
  79413. get canRead(): boolean;
  79414. set lines(value: string[]);
  79415. }
  79416. }
  79417. declare module BABYLON {
  79418. /** @hidden */
  79419. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79420. process(preprocessors: {
  79421. [key: string]: string;
  79422. }, options: ProcessingOptions): string;
  79423. }
  79424. }
  79425. declare module BABYLON {
  79426. /** @hidden */
  79427. export class ShaderDefineExpression {
  79428. isTrue(preprocessors: {
  79429. [key: string]: string;
  79430. }): boolean;
  79431. private static _OperatorPriority;
  79432. private static _Stack;
  79433. static postfixToInfix(postfix: string[]): string;
  79434. static infixToPostfix(infix: string): string[];
  79435. }
  79436. }
  79437. declare module BABYLON {
  79438. /** @hidden */
  79439. export class ShaderCodeTestNode extends ShaderCodeNode {
  79440. testExpression: ShaderDefineExpression;
  79441. isValid(preprocessors: {
  79442. [key: string]: string;
  79443. }): boolean;
  79444. }
  79445. }
  79446. declare module BABYLON {
  79447. /** @hidden */
  79448. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79449. define: string;
  79450. not: boolean;
  79451. constructor(define: string, not?: boolean);
  79452. isTrue(preprocessors: {
  79453. [key: string]: string;
  79454. }): boolean;
  79455. }
  79456. }
  79457. declare module BABYLON {
  79458. /** @hidden */
  79459. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79460. leftOperand: ShaderDefineExpression;
  79461. rightOperand: ShaderDefineExpression;
  79462. isTrue(preprocessors: {
  79463. [key: string]: string;
  79464. }): boolean;
  79465. }
  79466. }
  79467. declare module BABYLON {
  79468. /** @hidden */
  79469. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79470. leftOperand: ShaderDefineExpression;
  79471. rightOperand: ShaderDefineExpression;
  79472. isTrue(preprocessors: {
  79473. [key: string]: string;
  79474. }): boolean;
  79475. }
  79476. }
  79477. declare module BABYLON {
  79478. /** @hidden */
  79479. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79480. define: string;
  79481. operand: string;
  79482. testValue: string;
  79483. constructor(define: string, operand: string, testValue: string);
  79484. isTrue(preprocessors: {
  79485. [key: string]: string;
  79486. }): boolean;
  79487. }
  79488. }
  79489. declare module BABYLON {
  79490. /**
  79491. * Class used to enable access to offline support
  79492. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79493. */
  79494. export interface IOfflineProvider {
  79495. /**
  79496. * Gets a boolean indicating if scene must be saved in the database
  79497. */
  79498. enableSceneOffline: boolean;
  79499. /**
  79500. * Gets a boolean indicating if textures must be saved in the database
  79501. */
  79502. enableTexturesOffline: boolean;
  79503. /**
  79504. * Open the offline support and make it available
  79505. * @param successCallback defines the callback to call on success
  79506. * @param errorCallback defines the callback to call on error
  79507. */
  79508. open(successCallback: () => void, errorCallback: () => void): void;
  79509. /**
  79510. * Loads an image from the offline support
  79511. * @param url defines the url to load from
  79512. * @param image defines the target DOM image
  79513. */
  79514. loadImage(url: string, image: HTMLImageElement): void;
  79515. /**
  79516. * Loads a file from offline support
  79517. * @param url defines the URL to load from
  79518. * @param sceneLoaded defines a callback to call on success
  79519. * @param progressCallBack defines a callback to call when progress changed
  79520. * @param errorCallback defines a callback to call on error
  79521. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79522. */
  79523. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79524. }
  79525. }
  79526. declare module BABYLON {
  79527. /**
  79528. * Class used to help managing file picking and drag'n'drop
  79529. * File Storage
  79530. */
  79531. export class FilesInputStore {
  79532. /**
  79533. * List of files ready to be loaded
  79534. */
  79535. static FilesToLoad: {
  79536. [key: string]: File;
  79537. };
  79538. }
  79539. }
  79540. declare module BABYLON {
  79541. /**
  79542. * Class used to define a retry strategy when error happens while loading assets
  79543. */
  79544. export class RetryStrategy {
  79545. /**
  79546. * Function used to defines an exponential back off strategy
  79547. * @param maxRetries defines the maximum number of retries (3 by default)
  79548. * @param baseInterval defines the interval between retries
  79549. * @returns the strategy function to use
  79550. */
  79551. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79552. }
  79553. }
  79554. declare module BABYLON {
  79555. /**
  79556. * @ignore
  79557. * Application error to support additional information when loading a file
  79558. */
  79559. export abstract class BaseError extends Error {
  79560. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79561. }
  79562. }
  79563. declare module BABYLON {
  79564. /** @ignore */
  79565. export class LoadFileError extends BaseError {
  79566. request?: WebRequest;
  79567. file?: File;
  79568. /**
  79569. * Creates a new LoadFileError
  79570. * @param message defines the message of the error
  79571. * @param request defines the optional web request
  79572. * @param file defines the optional file
  79573. */
  79574. constructor(message: string, object?: WebRequest | File);
  79575. }
  79576. /** @ignore */
  79577. export class RequestFileError extends BaseError {
  79578. request: WebRequest;
  79579. /**
  79580. * Creates a new LoadFileError
  79581. * @param message defines the message of the error
  79582. * @param request defines the optional web request
  79583. */
  79584. constructor(message: string, request: WebRequest);
  79585. }
  79586. /** @ignore */
  79587. export class ReadFileError extends BaseError {
  79588. file: File;
  79589. /**
  79590. * Creates a new ReadFileError
  79591. * @param message defines the message of the error
  79592. * @param file defines the optional file
  79593. */
  79594. constructor(message: string, file: File);
  79595. }
  79596. /**
  79597. * @hidden
  79598. */
  79599. export class FileTools {
  79600. /**
  79601. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79602. */
  79603. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79604. /**
  79605. * Gets or sets the base URL to use to load assets
  79606. */
  79607. static BaseUrl: string;
  79608. /**
  79609. * Default behaviour for cors in the application.
  79610. * It can be a string if the expected behavior is identical in the entire app.
  79611. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79612. */
  79613. static CorsBehavior: string | ((url: string | string[]) => string);
  79614. /**
  79615. * Gets or sets a function used to pre-process url before using them to load assets
  79616. */
  79617. static PreprocessUrl: (url: string) => string;
  79618. /**
  79619. * Removes unwanted characters from an url
  79620. * @param url defines the url to clean
  79621. * @returns the cleaned url
  79622. */
  79623. private static _CleanUrl;
  79624. /**
  79625. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79626. * @param url define the url we are trying
  79627. * @param element define the dom element where to configure the cors policy
  79628. */
  79629. static SetCorsBehavior(url: string | string[], element: {
  79630. crossOrigin: string | null;
  79631. }): void;
  79632. /**
  79633. * Loads an image as an HTMLImageElement.
  79634. * @param input url string, ArrayBuffer, or Blob to load
  79635. * @param onLoad callback called when the image successfully loads
  79636. * @param onError callback called when the image fails to load
  79637. * @param offlineProvider offline provider for caching
  79638. * @param mimeType optional mime type
  79639. * @returns the HTMLImageElement of the loaded image
  79640. */
  79641. 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>;
  79642. /**
  79643. * Reads a file from a File object
  79644. * @param file defines the file to load
  79645. * @param onSuccess defines the callback to call when data is loaded
  79646. * @param onProgress defines the callback to call during loading process
  79647. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79648. * @param onError defines the callback to call when an error occurs
  79649. * @returns a file request object
  79650. */
  79651. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79652. /**
  79653. * Loads a file from a url
  79654. * @param url url to load
  79655. * @param onSuccess callback called when the file successfully loads
  79656. * @param onProgress callback called while file is loading (if the server supports this mode)
  79657. * @param offlineProvider defines the offline provider for caching
  79658. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79659. * @param onError callback called when the file fails to load
  79660. * @returns a file request object
  79661. */
  79662. 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;
  79663. /**
  79664. * Loads a file
  79665. * @param url url to load
  79666. * @param onSuccess callback called when the file successfully loads
  79667. * @param onProgress callback called while file is loading (if the server supports this mode)
  79668. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79669. * @param onError callback called when the file fails to load
  79670. * @param onOpened callback called when the web request is opened
  79671. * @returns a file request object
  79672. */
  79673. 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;
  79674. /**
  79675. * Checks if the loaded document was accessed via `file:`-Protocol.
  79676. * @returns boolean
  79677. */
  79678. static IsFileURL(): boolean;
  79679. }
  79680. }
  79681. declare module BABYLON {
  79682. /** @hidden */
  79683. export class ShaderProcessor {
  79684. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79685. private static _ProcessPrecision;
  79686. private static _ExtractOperation;
  79687. private static _BuildSubExpression;
  79688. private static _BuildExpression;
  79689. private static _MoveCursorWithinIf;
  79690. private static _MoveCursor;
  79691. private static _EvaluatePreProcessors;
  79692. private static _PreparePreProcessors;
  79693. private static _ProcessShaderConversion;
  79694. private static _ProcessIncludes;
  79695. /**
  79696. * Loads a file from a url
  79697. * @param url url to load
  79698. * @param onSuccess callback called when the file successfully loads
  79699. * @param onProgress callback called while file is loading (if the server supports this mode)
  79700. * @param offlineProvider defines the offline provider for caching
  79701. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79702. * @param onError callback called when the file fails to load
  79703. * @returns a file request object
  79704. * @hidden
  79705. */
  79706. 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;
  79707. }
  79708. }
  79709. declare module BABYLON {
  79710. /**
  79711. * @hidden
  79712. */
  79713. export interface IColor4Like {
  79714. r: float;
  79715. g: float;
  79716. b: float;
  79717. a: float;
  79718. }
  79719. /**
  79720. * @hidden
  79721. */
  79722. export interface IColor3Like {
  79723. r: float;
  79724. g: float;
  79725. b: float;
  79726. }
  79727. /**
  79728. * @hidden
  79729. */
  79730. export interface IVector4Like {
  79731. x: float;
  79732. y: float;
  79733. z: float;
  79734. w: float;
  79735. }
  79736. /**
  79737. * @hidden
  79738. */
  79739. export interface IVector3Like {
  79740. x: float;
  79741. y: float;
  79742. z: float;
  79743. }
  79744. /**
  79745. * @hidden
  79746. */
  79747. export interface IVector2Like {
  79748. x: float;
  79749. y: float;
  79750. }
  79751. /**
  79752. * @hidden
  79753. */
  79754. export interface IMatrixLike {
  79755. toArray(): DeepImmutable<Float32Array>;
  79756. updateFlag: int;
  79757. }
  79758. /**
  79759. * @hidden
  79760. */
  79761. export interface IViewportLike {
  79762. x: float;
  79763. y: float;
  79764. width: float;
  79765. height: float;
  79766. }
  79767. /**
  79768. * @hidden
  79769. */
  79770. export interface IPlaneLike {
  79771. normal: IVector3Like;
  79772. d: float;
  79773. normalize(): void;
  79774. }
  79775. }
  79776. declare module BABYLON {
  79777. /**
  79778. * Interface used to define common properties for effect fallbacks
  79779. */
  79780. export interface IEffectFallbacks {
  79781. /**
  79782. * Removes the defines that should be removed when falling back.
  79783. * @param currentDefines defines the current define statements for the shader.
  79784. * @param effect defines the current effect we try to compile
  79785. * @returns The resulting defines with defines of the current rank removed.
  79786. */
  79787. reduce(currentDefines: string, effect: Effect): string;
  79788. /**
  79789. * Removes the fallback from the bound mesh.
  79790. */
  79791. unBindMesh(): void;
  79792. /**
  79793. * Checks to see if more fallbacks are still availible.
  79794. */
  79795. hasMoreFallbacks: boolean;
  79796. }
  79797. }
  79798. declare module BABYLON {
  79799. /**
  79800. * Class used to evalaute queries containing `and` and `or` operators
  79801. */
  79802. export class AndOrNotEvaluator {
  79803. /**
  79804. * Evaluate a query
  79805. * @param query defines the query to evaluate
  79806. * @param evaluateCallback defines the callback used to filter result
  79807. * @returns true if the query matches
  79808. */
  79809. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79810. private static _HandleParenthesisContent;
  79811. private static _SimplifyNegation;
  79812. }
  79813. }
  79814. declare module BABYLON {
  79815. /**
  79816. * Class used to store custom tags
  79817. */
  79818. export class Tags {
  79819. /**
  79820. * Adds support for tags on the given object
  79821. * @param obj defines the object to use
  79822. */
  79823. static EnableFor(obj: any): void;
  79824. /**
  79825. * Removes tags support
  79826. * @param obj defines the object to use
  79827. */
  79828. static DisableFor(obj: any): void;
  79829. /**
  79830. * Gets a boolean indicating if the given object has tags
  79831. * @param obj defines the object to use
  79832. * @returns a boolean
  79833. */
  79834. static HasTags(obj: any): boolean;
  79835. /**
  79836. * Gets the tags available on a given object
  79837. * @param obj defines the object to use
  79838. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79839. * @returns the tags
  79840. */
  79841. static GetTags(obj: any, asString?: boolean): any;
  79842. /**
  79843. * Adds tags to an object
  79844. * @param obj defines the object to use
  79845. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79846. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79847. */
  79848. static AddTagsTo(obj: any, tagsString: string): void;
  79849. /**
  79850. * @hidden
  79851. */
  79852. static _AddTagTo(obj: any, tag: string): void;
  79853. /**
  79854. * Removes specific tags from a specific object
  79855. * @param obj defines the object to use
  79856. * @param tagsString defines the tags to remove
  79857. */
  79858. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79859. /**
  79860. * @hidden
  79861. */
  79862. static _RemoveTagFrom(obj: any, tag: string): void;
  79863. /**
  79864. * Defines if tags hosted on an object match a given query
  79865. * @param obj defines the object to use
  79866. * @param tagsQuery defines the tag query
  79867. * @returns a boolean
  79868. */
  79869. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79870. }
  79871. }
  79872. declare module BABYLON {
  79873. /**
  79874. * Scalar computation library
  79875. */
  79876. export class Scalar {
  79877. /**
  79878. * Two pi constants convenient for computation.
  79879. */
  79880. static TwoPi: number;
  79881. /**
  79882. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79883. * @param a number
  79884. * @param b number
  79885. * @param epsilon (default = 1.401298E-45)
  79886. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79887. */
  79888. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79889. /**
  79890. * Returns a string : the upper case translation of the number i to hexadecimal.
  79891. * @param i number
  79892. * @returns the upper case translation of the number i to hexadecimal.
  79893. */
  79894. static ToHex(i: number): string;
  79895. /**
  79896. * Returns -1 if value is negative and +1 is value is positive.
  79897. * @param value the value
  79898. * @returns the value itself if it's equal to zero.
  79899. */
  79900. static Sign(value: number): number;
  79901. /**
  79902. * Returns the value itself if it's between min and max.
  79903. * Returns min if the value is lower than min.
  79904. * Returns max if the value is greater than max.
  79905. * @param value the value to clmap
  79906. * @param min the min value to clamp to (default: 0)
  79907. * @param max the max value to clamp to (default: 1)
  79908. * @returns the clamped value
  79909. */
  79910. static Clamp(value: number, min?: number, max?: number): number;
  79911. /**
  79912. * the log2 of value.
  79913. * @param value the value to compute log2 of
  79914. * @returns the log2 of value.
  79915. */
  79916. static Log2(value: number): number;
  79917. /**
  79918. * Loops the value, so that it is never larger than length and never smaller than 0.
  79919. *
  79920. * This is similar to the modulo operator but it works with floating point numbers.
  79921. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79922. * With t = 5 and length = 2.5, the result would be 0.0.
  79923. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79924. * @param value the value
  79925. * @param length the length
  79926. * @returns the looped value
  79927. */
  79928. static Repeat(value: number, length: number): number;
  79929. /**
  79930. * Normalize the value between 0.0 and 1.0 using min and max values
  79931. * @param value value to normalize
  79932. * @param min max to normalize between
  79933. * @param max min to normalize between
  79934. * @returns the normalized value
  79935. */
  79936. static Normalize(value: number, min: number, max: number): number;
  79937. /**
  79938. * Denormalize the value from 0.0 and 1.0 using min and max values
  79939. * @param normalized value to denormalize
  79940. * @param min max to denormalize between
  79941. * @param max min to denormalize between
  79942. * @returns the denormalized value
  79943. */
  79944. static Denormalize(normalized: number, min: number, max: number): number;
  79945. /**
  79946. * Calculates the shortest difference between two given angles given in degrees.
  79947. * @param current current angle in degrees
  79948. * @param target target angle in degrees
  79949. * @returns the delta
  79950. */
  79951. static DeltaAngle(current: number, target: number): number;
  79952. /**
  79953. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79954. * @param tx value
  79955. * @param length length
  79956. * @returns The returned value will move back and forth between 0 and length
  79957. */
  79958. static PingPong(tx: number, length: number): number;
  79959. /**
  79960. * Interpolates between min and max with smoothing at the limits.
  79961. *
  79962. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79963. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79964. * @param from from
  79965. * @param to to
  79966. * @param tx value
  79967. * @returns the smooth stepped value
  79968. */
  79969. static SmoothStep(from: number, to: number, tx: number): number;
  79970. /**
  79971. * Moves a value current towards target.
  79972. *
  79973. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79974. * Negative values of maxDelta pushes the value away from target.
  79975. * @param current current value
  79976. * @param target target value
  79977. * @param maxDelta max distance to move
  79978. * @returns resulting value
  79979. */
  79980. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79981. /**
  79982. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79983. *
  79984. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79985. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79986. * @param current current value
  79987. * @param target target value
  79988. * @param maxDelta max distance to move
  79989. * @returns resulting angle
  79990. */
  79991. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79992. /**
  79993. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79994. * @param start start value
  79995. * @param end target value
  79996. * @param amount amount to lerp between
  79997. * @returns the lerped value
  79998. */
  79999. static Lerp(start: number, end: number, amount: number): number;
  80000. /**
  80001. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80002. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80003. * @param start start value
  80004. * @param end target value
  80005. * @param amount amount to lerp between
  80006. * @returns the lerped value
  80007. */
  80008. static LerpAngle(start: number, end: number, amount: number): number;
  80009. /**
  80010. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80011. * @param a start value
  80012. * @param b target value
  80013. * @param value value between a and b
  80014. * @returns the inverseLerp value
  80015. */
  80016. static InverseLerp(a: number, b: number, value: number): number;
  80017. /**
  80018. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80019. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80020. * @param value1 spline value
  80021. * @param tangent1 spline value
  80022. * @param value2 spline value
  80023. * @param tangent2 spline value
  80024. * @param amount input value
  80025. * @returns hermite result
  80026. */
  80027. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80028. /**
  80029. * Returns a random float number between and min and max values
  80030. * @param min min value of random
  80031. * @param max max value of random
  80032. * @returns random value
  80033. */
  80034. static RandomRange(min: number, max: number): number;
  80035. /**
  80036. * This function returns percentage of a number in a given range.
  80037. *
  80038. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80039. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80040. * @param number to convert to percentage
  80041. * @param min min range
  80042. * @param max max range
  80043. * @returns the percentage
  80044. */
  80045. static RangeToPercent(number: number, min: number, max: number): number;
  80046. /**
  80047. * This function returns number that corresponds to the percentage in a given range.
  80048. *
  80049. * PercentToRange(0.34,0,100) will return 34.
  80050. * @param percent to convert to number
  80051. * @param min min range
  80052. * @param max max range
  80053. * @returns the number
  80054. */
  80055. static PercentToRange(percent: number, min: number, max: number): number;
  80056. /**
  80057. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80058. * @param angle The angle to normalize in radian.
  80059. * @return The converted angle.
  80060. */
  80061. static NormalizeRadians(angle: number): number;
  80062. }
  80063. }
  80064. declare module BABYLON {
  80065. /**
  80066. * Constant used to convert a value to gamma space
  80067. * @ignorenaming
  80068. */
  80069. export const ToGammaSpace: number;
  80070. /**
  80071. * Constant used to convert a value to linear space
  80072. * @ignorenaming
  80073. */
  80074. export const ToLinearSpace = 2.2;
  80075. /**
  80076. * Constant used to define the minimal number value in Babylon.js
  80077. * @ignorenaming
  80078. */
  80079. let Epsilon: number;
  80080. }
  80081. declare module BABYLON {
  80082. /**
  80083. * Class used to represent a viewport on screen
  80084. */
  80085. export class Viewport {
  80086. /** viewport left coordinate */
  80087. x: number;
  80088. /** viewport top coordinate */
  80089. y: number;
  80090. /**viewport width */
  80091. width: number;
  80092. /** viewport height */
  80093. height: number;
  80094. /**
  80095. * Creates a Viewport object located at (x, y) and sized (width, height)
  80096. * @param x defines viewport left coordinate
  80097. * @param y defines viewport top coordinate
  80098. * @param width defines the viewport width
  80099. * @param height defines the viewport height
  80100. */
  80101. constructor(
  80102. /** viewport left coordinate */
  80103. x: number,
  80104. /** viewport top coordinate */
  80105. y: number,
  80106. /**viewport width */
  80107. width: number,
  80108. /** viewport height */
  80109. height: number);
  80110. /**
  80111. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80112. * @param renderWidth defines the rendering width
  80113. * @param renderHeight defines the rendering height
  80114. * @returns a new Viewport
  80115. */
  80116. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80117. /**
  80118. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80119. * @param renderWidth defines the rendering width
  80120. * @param renderHeight defines the rendering height
  80121. * @param ref defines the target viewport
  80122. * @returns the current viewport
  80123. */
  80124. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80125. /**
  80126. * Returns a new Viewport copied from the current one
  80127. * @returns a new Viewport
  80128. */
  80129. clone(): Viewport;
  80130. }
  80131. }
  80132. declare module BABYLON {
  80133. /**
  80134. * Class containing a set of static utilities functions for arrays.
  80135. */
  80136. export class ArrayTools {
  80137. /**
  80138. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80139. * @param size the number of element to construct and put in the array
  80140. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80141. * @returns a new array filled with new objects
  80142. */
  80143. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80144. }
  80145. }
  80146. declare module BABYLON {
  80147. /**
  80148. * Represents a plane by the equation ax + by + cz + d = 0
  80149. */
  80150. export class Plane {
  80151. private static _TmpMatrix;
  80152. /**
  80153. * Normal of the plane (a,b,c)
  80154. */
  80155. normal: Vector3;
  80156. /**
  80157. * d component of the plane
  80158. */
  80159. d: number;
  80160. /**
  80161. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80162. * @param a a component of the plane
  80163. * @param b b component of the plane
  80164. * @param c c component of the plane
  80165. * @param d d component of the plane
  80166. */
  80167. constructor(a: number, b: number, c: number, d: number);
  80168. /**
  80169. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80170. */
  80171. asArray(): number[];
  80172. /**
  80173. * @returns a new plane copied from the current Plane.
  80174. */
  80175. clone(): Plane;
  80176. /**
  80177. * @returns the string "Plane".
  80178. */
  80179. getClassName(): string;
  80180. /**
  80181. * @returns the Plane hash code.
  80182. */
  80183. getHashCode(): number;
  80184. /**
  80185. * Normalize the current Plane in place.
  80186. * @returns the updated Plane.
  80187. */
  80188. normalize(): Plane;
  80189. /**
  80190. * Applies a transformation the plane and returns the result
  80191. * @param transformation the transformation matrix to be applied to the plane
  80192. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80193. */
  80194. transform(transformation: DeepImmutable<Matrix>): Plane;
  80195. /**
  80196. * Compute the dot product between the point and the plane normal
  80197. * @param point point to calculate the dot product with
  80198. * @returns the dot product (float) of the point coordinates and the plane normal.
  80199. */
  80200. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80201. /**
  80202. * Updates the current Plane from the plane defined by the three given points.
  80203. * @param point1 one of the points used to contruct the plane
  80204. * @param point2 one of the points used to contruct the plane
  80205. * @param point3 one of the points used to contruct the plane
  80206. * @returns the updated Plane.
  80207. */
  80208. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80209. /**
  80210. * Checks if the plane is facing a given direction
  80211. * @param direction the direction to check if the plane is facing
  80212. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80213. * @returns True is the vector "direction" is the same side than the plane normal.
  80214. */
  80215. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80216. /**
  80217. * Calculates the distance to a point
  80218. * @param point point to calculate distance to
  80219. * @returns the signed distance (float) from the given point to the Plane.
  80220. */
  80221. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80222. /**
  80223. * Creates a plane from an array
  80224. * @param array the array to create a plane from
  80225. * @returns a new Plane from the given array.
  80226. */
  80227. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80228. /**
  80229. * Creates a plane from three points
  80230. * @param point1 point used to create the plane
  80231. * @param point2 point used to create the plane
  80232. * @param point3 point used to create the plane
  80233. * @returns a new Plane defined by the three given points.
  80234. */
  80235. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80236. /**
  80237. * Creates a plane from an origin point and a normal
  80238. * @param origin origin of the plane to be constructed
  80239. * @param normal normal of the plane to be constructed
  80240. * @returns a new Plane the normal vector to this plane at the given origin point.
  80241. * Note : the vector "normal" is updated because normalized.
  80242. */
  80243. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80244. /**
  80245. * Calculates the distance from a plane and a point
  80246. * @param origin origin of the plane to be constructed
  80247. * @param normal normal of the plane to be constructed
  80248. * @param point point to calculate distance to
  80249. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80250. */
  80251. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80252. }
  80253. }
  80254. declare module BABYLON {
  80255. /**
  80256. * Class representing a vector containing 2 coordinates
  80257. */
  80258. export class Vector2 {
  80259. /** defines the first coordinate */
  80260. x: number;
  80261. /** defines the second coordinate */
  80262. y: number;
  80263. /**
  80264. * Creates a new Vector2 from the given x and y coordinates
  80265. * @param x defines the first coordinate
  80266. * @param y defines the second coordinate
  80267. */
  80268. constructor(
  80269. /** defines the first coordinate */
  80270. x?: number,
  80271. /** defines the second coordinate */
  80272. y?: number);
  80273. /**
  80274. * Gets a string with the Vector2 coordinates
  80275. * @returns a string with the Vector2 coordinates
  80276. */
  80277. toString(): string;
  80278. /**
  80279. * Gets class name
  80280. * @returns the string "Vector2"
  80281. */
  80282. getClassName(): string;
  80283. /**
  80284. * Gets current vector hash code
  80285. * @returns the Vector2 hash code as a number
  80286. */
  80287. getHashCode(): number;
  80288. /**
  80289. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80290. * @param array defines the source array
  80291. * @param index defines the offset in source array
  80292. * @returns the current Vector2
  80293. */
  80294. toArray(array: FloatArray, index?: number): Vector2;
  80295. /**
  80296. * Copy the current vector to an array
  80297. * @returns a new array with 2 elements: the Vector2 coordinates.
  80298. */
  80299. asArray(): number[];
  80300. /**
  80301. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80302. * @param source defines the source Vector2
  80303. * @returns the current updated Vector2
  80304. */
  80305. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80306. /**
  80307. * Sets the Vector2 coordinates with the given floats
  80308. * @param x defines the first coordinate
  80309. * @param y defines the second coordinate
  80310. * @returns the current updated Vector2
  80311. */
  80312. copyFromFloats(x: number, y: number): Vector2;
  80313. /**
  80314. * Sets the Vector2 coordinates with the given floats
  80315. * @param x defines the first coordinate
  80316. * @param y defines the second coordinate
  80317. * @returns the current updated Vector2
  80318. */
  80319. set(x: number, y: number): Vector2;
  80320. /**
  80321. * Add another vector with the current one
  80322. * @param otherVector defines the other vector
  80323. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80324. */
  80325. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80326. /**
  80327. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80328. * @param otherVector defines the other vector
  80329. * @param result defines the target vector
  80330. * @returns the unmodified current Vector2
  80331. */
  80332. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80333. /**
  80334. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80335. * @param otherVector defines the other vector
  80336. * @returns the current updated Vector2
  80337. */
  80338. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80339. /**
  80340. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80341. * @param otherVector defines the other vector
  80342. * @returns a new Vector2
  80343. */
  80344. addVector3(otherVector: Vector3): Vector2;
  80345. /**
  80346. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80347. * @param otherVector defines the other vector
  80348. * @returns a new Vector2
  80349. */
  80350. subtract(otherVector: Vector2): Vector2;
  80351. /**
  80352. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80353. * @param otherVector defines the other vector
  80354. * @param result defines the target vector
  80355. * @returns the unmodified current Vector2
  80356. */
  80357. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80358. /**
  80359. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80360. * @param otherVector defines the other vector
  80361. * @returns the current updated Vector2
  80362. */
  80363. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80364. /**
  80365. * Multiplies in place the current Vector2 coordinates by the given ones
  80366. * @param otherVector defines the other vector
  80367. * @returns the current updated Vector2
  80368. */
  80369. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80370. /**
  80371. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80372. * @param otherVector defines the other vector
  80373. * @returns a new Vector2
  80374. */
  80375. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80376. /**
  80377. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80378. * @param otherVector defines the other vector
  80379. * @param result defines the target vector
  80380. * @returns the unmodified current Vector2
  80381. */
  80382. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80383. /**
  80384. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80385. * @param x defines the first coordinate
  80386. * @param y defines the second coordinate
  80387. * @returns a new Vector2
  80388. */
  80389. multiplyByFloats(x: number, y: number): Vector2;
  80390. /**
  80391. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80392. * @param otherVector defines the other vector
  80393. * @returns a new Vector2
  80394. */
  80395. divide(otherVector: Vector2): Vector2;
  80396. /**
  80397. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80398. * @param otherVector defines the other vector
  80399. * @param result defines the target vector
  80400. * @returns the unmodified current Vector2
  80401. */
  80402. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80403. /**
  80404. * Divides the current Vector2 coordinates by the given ones
  80405. * @param otherVector defines the other vector
  80406. * @returns the current updated Vector2
  80407. */
  80408. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80409. /**
  80410. * Gets a new Vector2 with current Vector2 negated coordinates
  80411. * @returns a new Vector2
  80412. */
  80413. negate(): Vector2;
  80414. /**
  80415. * Negate this vector in place
  80416. * @returns this
  80417. */
  80418. negateInPlace(): Vector2;
  80419. /**
  80420. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80421. * @param result defines the Vector3 object where to store the result
  80422. * @returns the current Vector2
  80423. */
  80424. negateToRef(result: Vector2): Vector2;
  80425. /**
  80426. * Multiply the Vector2 coordinates by scale
  80427. * @param scale defines the scaling factor
  80428. * @returns the current updated Vector2
  80429. */
  80430. scaleInPlace(scale: number): Vector2;
  80431. /**
  80432. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80433. * @param scale defines the scaling factor
  80434. * @returns a new Vector2
  80435. */
  80436. scale(scale: number): Vector2;
  80437. /**
  80438. * Scale the current Vector2 values by a factor to a given Vector2
  80439. * @param scale defines the scale factor
  80440. * @param result defines the Vector2 object where to store the result
  80441. * @returns the unmodified current Vector2
  80442. */
  80443. scaleToRef(scale: number, result: Vector2): Vector2;
  80444. /**
  80445. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80446. * @param scale defines the scale factor
  80447. * @param result defines the Vector2 object where to store the result
  80448. * @returns the unmodified current Vector2
  80449. */
  80450. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80451. /**
  80452. * Gets a boolean if two vectors are equals
  80453. * @param otherVector defines the other vector
  80454. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80455. */
  80456. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80457. /**
  80458. * Gets a boolean if two vectors are equals (using an epsilon value)
  80459. * @param otherVector defines the other vector
  80460. * @param epsilon defines the minimal distance to consider equality
  80461. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80462. */
  80463. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80464. /**
  80465. * Gets a new Vector2 from current Vector2 floored values
  80466. * @returns a new Vector2
  80467. */
  80468. floor(): Vector2;
  80469. /**
  80470. * Gets a new Vector2 from current Vector2 floored values
  80471. * @returns a new Vector2
  80472. */
  80473. fract(): Vector2;
  80474. /**
  80475. * Gets the length of the vector
  80476. * @returns the vector length (float)
  80477. */
  80478. length(): number;
  80479. /**
  80480. * Gets the vector squared length
  80481. * @returns the vector squared length (float)
  80482. */
  80483. lengthSquared(): number;
  80484. /**
  80485. * Normalize the vector
  80486. * @returns the current updated Vector2
  80487. */
  80488. normalize(): Vector2;
  80489. /**
  80490. * Gets a new Vector2 copied from the Vector2
  80491. * @returns a new Vector2
  80492. */
  80493. clone(): Vector2;
  80494. /**
  80495. * Gets a new Vector2(0, 0)
  80496. * @returns a new Vector2
  80497. */
  80498. static Zero(): Vector2;
  80499. /**
  80500. * Gets a new Vector2(1, 1)
  80501. * @returns a new Vector2
  80502. */
  80503. static One(): Vector2;
  80504. /**
  80505. * Gets a new Vector2 set from the given index element of the given array
  80506. * @param array defines the data source
  80507. * @param offset defines the offset in the data source
  80508. * @returns a new Vector2
  80509. */
  80510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80511. /**
  80512. * Sets "result" from the given index element of the given array
  80513. * @param array defines the data source
  80514. * @param offset defines the offset in the data source
  80515. * @param result defines the target vector
  80516. */
  80517. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80518. /**
  80519. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80520. * @param value1 defines 1st point of control
  80521. * @param value2 defines 2nd point of control
  80522. * @param value3 defines 3rd point of control
  80523. * @param value4 defines 4th point of control
  80524. * @param amount defines the interpolation factor
  80525. * @returns a new Vector2
  80526. */
  80527. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80528. /**
  80529. * 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".
  80530. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80531. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80532. * @param value defines the value to clamp
  80533. * @param min defines the lower limit
  80534. * @param max defines the upper limit
  80535. * @returns a new Vector2
  80536. */
  80537. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80538. /**
  80539. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80540. * @param value1 defines the 1st control point
  80541. * @param tangent1 defines the outgoing tangent
  80542. * @param value2 defines the 2nd control point
  80543. * @param tangent2 defines the incoming tangent
  80544. * @param amount defines the interpolation factor
  80545. * @returns a new Vector2
  80546. */
  80547. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80548. /**
  80549. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80550. * @param start defines the start vector
  80551. * @param end defines the end vector
  80552. * @param amount defines the interpolation factor
  80553. * @returns a new Vector2
  80554. */
  80555. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80556. /**
  80557. * Gets the dot product of the vector "left" and the vector "right"
  80558. * @param left defines first vector
  80559. * @param right defines second vector
  80560. * @returns the dot product (float)
  80561. */
  80562. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80563. /**
  80564. * Returns a new Vector2 equal to the normalized given vector
  80565. * @param vector defines the vector to normalize
  80566. * @returns a new Vector2
  80567. */
  80568. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80569. /**
  80570. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80571. * @param left defines 1st vector
  80572. * @param right defines 2nd vector
  80573. * @returns a new Vector2
  80574. */
  80575. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80576. /**
  80577. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80578. * @param left defines 1st vector
  80579. * @param right defines 2nd vector
  80580. * @returns a new Vector2
  80581. */
  80582. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80583. /**
  80584. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80585. * @param vector defines the vector to transform
  80586. * @param transformation defines the matrix to apply
  80587. * @returns a new Vector2
  80588. */
  80589. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80590. /**
  80591. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80592. * @param vector defines the vector to transform
  80593. * @param transformation defines the matrix to apply
  80594. * @param result defines the target vector
  80595. */
  80596. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80597. /**
  80598. * Determines if a given vector is included in a triangle
  80599. * @param p defines the vector to test
  80600. * @param p0 defines 1st triangle point
  80601. * @param p1 defines 2nd triangle point
  80602. * @param p2 defines 3rd triangle point
  80603. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80604. */
  80605. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80606. /**
  80607. * Gets the distance between the vectors "value1" and "value2"
  80608. * @param value1 defines first vector
  80609. * @param value2 defines second vector
  80610. * @returns the distance between vectors
  80611. */
  80612. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80613. /**
  80614. * Returns the squared distance between the vectors "value1" and "value2"
  80615. * @param value1 defines first vector
  80616. * @param value2 defines second vector
  80617. * @returns the squared distance between vectors
  80618. */
  80619. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80620. /**
  80621. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80622. * @param value1 defines first vector
  80623. * @param value2 defines second vector
  80624. * @returns a new Vector2
  80625. */
  80626. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80627. /**
  80628. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80629. * @param p defines the middle point
  80630. * @param segA defines one point of the segment
  80631. * @param segB defines the other point of the segment
  80632. * @returns the shortest distance
  80633. */
  80634. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80635. }
  80636. /**
  80637. * Class used to store (x,y,z) vector representation
  80638. * A Vector3 is the main object used in 3D geometry
  80639. * It can represent etiher the coordinates of a point the space, either a direction
  80640. * Reminder: js uses a left handed forward facing system
  80641. */
  80642. export class Vector3 {
  80643. private static _UpReadOnly;
  80644. private static _ZeroReadOnly;
  80645. /** @hidden */
  80646. _x: number;
  80647. /** @hidden */
  80648. _y: number;
  80649. /** @hidden */
  80650. _z: number;
  80651. /** @hidden */
  80652. _isDirty: boolean;
  80653. /** Gets or sets the x coordinate */
  80654. get x(): number;
  80655. set x(value: number);
  80656. /** Gets or sets the y coordinate */
  80657. get y(): number;
  80658. set y(value: number);
  80659. /** Gets or sets the z coordinate */
  80660. get z(): number;
  80661. set z(value: number);
  80662. /**
  80663. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80664. * @param x defines the first coordinates (on X axis)
  80665. * @param y defines the second coordinates (on Y axis)
  80666. * @param z defines the third coordinates (on Z axis)
  80667. */
  80668. constructor(x?: number, y?: number, z?: number);
  80669. /**
  80670. * Creates a string representation of the Vector3
  80671. * @returns a string with the Vector3 coordinates.
  80672. */
  80673. toString(): string;
  80674. /**
  80675. * Gets the class name
  80676. * @returns the string "Vector3"
  80677. */
  80678. getClassName(): string;
  80679. /**
  80680. * Creates the Vector3 hash code
  80681. * @returns a number which tends to be unique between Vector3 instances
  80682. */
  80683. getHashCode(): number;
  80684. /**
  80685. * Creates an array containing three elements : the coordinates of the Vector3
  80686. * @returns a new array of numbers
  80687. */
  80688. asArray(): number[];
  80689. /**
  80690. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80691. * @param array defines the destination array
  80692. * @param index defines the offset in the destination array
  80693. * @returns the current Vector3
  80694. */
  80695. toArray(array: FloatArray, index?: number): Vector3;
  80696. /**
  80697. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80698. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80699. */
  80700. toQuaternion(): Quaternion;
  80701. /**
  80702. * Adds the given vector to the current Vector3
  80703. * @param otherVector defines the second operand
  80704. * @returns the current updated Vector3
  80705. */
  80706. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80707. /**
  80708. * Adds the given coordinates to the current Vector3
  80709. * @param x defines the x coordinate of the operand
  80710. * @param y defines the y coordinate of the operand
  80711. * @param z defines the z coordinate of the operand
  80712. * @returns the current updated Vector3
  80713. */
  80714. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80715. /**
  80716. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80717. * @param otherVector defines the second operand
  80718. * @returns the resulting Vector3
  80719. */
  80720. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80721. /**
  80722. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80723. * @param otherVector defines the second operand
  80724. * @param result defines the Vector3 object where to store the result
  80725. * @returns the current Vector3
  80726. */
  80727. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80728. /**
  80729. * Subtract the given vector from the current Vector3
  80730. * @param otherVector defines the second operand
  80731. * @returns the current updated Vector3
  80732. */
  80733. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80734. /**
  80735. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80736. * @param otherVector defines the second operand
  80737. * @returns the resulting Vector3
  80738. */
  80739. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80740. /**
  80741. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80742. * @param otherVector defines the second operand
  80743. * @param result defines the Vector3 object where to store the result
  80744. * @returns the current Vector3
  80745. */
  80746. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80747. /**
  80748. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80749. * @param x defines the x coordinate of the operand
  80750. * @param y defines the y coordinate of the operand
  80751. * @param z defines the z coordinate of the operand
  80752. * @returns the resulting Vector3
  80753. */
  80754. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80755. /**
  80756. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80757. * @param x defines the x coordinate of the operand
  80758. * @param y defines the y coordinate of the operand
  80759. * @param z defines the z coordinate of the operand
  80760. * @param result defines the Vector3 object where to store the result
  80761. * @returns the current Vector3
  80762. */
  80763. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80764. /**
  80765. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80766. * @returns a new Vector3
  80767. */
  80768. negate(): Vector3;
  80769. /**
  80770. * Negate this vector in place
  80771. * @returns this
  80772. */
  80773. negateInPlace(): Vector3;
  80774. /**
  80775. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80776. * @param result defines the Vector3 object where to store the result
  80777. * @returns the current Vector3
  80778. */
  80779. negateToRef(result: Vector3): Vector3;
  80780. /**
  80781. * Multiplies the Vector3 coordinates by the float "scale"
  80782. * @param scale defines the multiplier factor
  80783. * @returns the current updated Vector3
  80784. */
  80785. scaleInPlace(scale: number): Vector3;
  80786. /**
  80787. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80788. * @param scale defines the multiplier factor
  80789. * @returns a new Vector3
  80790. */
  80791. scale(scale: number): Vector3;
  80792. /**
  80793. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80794. * @param scale defines the multiplier factor
  80795. * @param result defines the Vector3 object where to store the result
  80796. * @returns the current Vector3
  80797. */
  80798. scaleToRef(scale: number, result: Vector3): Vector3;
  80799. /**
  80800. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80801. * @param scale defines the scale factor
  80802. * @param result defines the Vector3 object where to store the result
  80803. * @returns the unmodified current Vector3
  80804. */
  80805. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80806. /**
  80807. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80808. * @param origin defines the origin of the projection ray
  80809. * @param plane defines the plane to project to
  80810. * @returns the projected vector3
  80811. */
  80812. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80813. /**
  80814. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80815. * @param origin defines the origin of the projection ray
  80816. * @param plane defines the plane to project to
  80817. * @param result defines the Vector3 where to store the result
  80818. */
  80819. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80820. /**
  80821. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80822. * @param otherVector defines the second operand
  80823. * @returns true if both vectors are equals
  80824. */
  80825. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80826. /**
  80827. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80828. * @param otherVector defines the second operand
  80829. * @param epsilon defines the minimal distance to define values as equals
  80830. * @returns true if both vectors are distant less than epsilon
  80831. */
  80832. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80833. /**
  80834. * Returns true if the current Vector3 coordinates equals the given floats
  80835. * @param x defines the x coordinate of the operand
  80836. * @param y defines the y coordinate of the operand
  80837. * @param z defines the z coordinate of the operand
  80838. * @returns true if both vectors are equals
  80839. */
  80840. equalsToFloats(x: number, y: number, z: number): boolean;
  80841. /**
  80842. * Multiplies the current Vector3 coordinates by the given ones
  80843. * @param otherVector defines the second operand
  80844. * @returns the current updated Vector3
  80845. */
  80846. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80847. /**
  80848. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80849. * @param otherVector defines the second operand
  80850. * @returns the new Vector3
  80851. */
  80852. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80853. /**
  80854. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80855. * @param otherVector defines the second operand
  80856. * @param result defines the Vector3 object where to store the result
  80857. * @returns the current Vector3
  80858. */
  80859. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80860. /**
  80861. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80862. * @param x defines the x coordinate of the operand
  80863. * @param y defines the y coordinate of the operand
  80864. * @param z defines the z coordinate of the operand
  80865. * @returns the new Vector3
  80866. */
  80867. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80868. /**
  80869. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80870. * @param otherVector defines the second operand
  80871. * @returns the new Vector3
  80872. */
  80873. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80874. /**
  80875. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80876. * @param otherVector defines the second operand
  80877. * @param result defines the Vector3 object where to store the result
  80878. * @returns the current Vector3
  80879. */
  80880. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80881. /**
  80882. * Divides the current Vector3 coordinates by the given ones.
  80883. * @param otherVector defines the second operand
  80884. * @returns the current updated Vector3
  80885. */
  80886. divideInPlace(otherVector: Vector3): Vector3;
  80887. /**
  80888. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80889. * @param other defines the second operand
  80890. * @returns the current updated Vector3
  80891. */
  80892. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80893. /**
  80894. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80895. * @param other defines the second operand
  80896. * @returns the current updated Vector3
  80897. */
  80898. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80899. /**
  80900. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80901. * @param x defines the x coordinate of the operand
  80902. * @param y defines the y coordinate of the operand
  80903. * @param z defines the z coordinate of the operand
  80904. * @returns the current updated Vector3
  80905. */
  80906. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80907. /**
  80908. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80909. * @param x defines the x coordinate of the operand
  80910. * @param y defines the y coordinate of the operand
  80911. * @param z defines the z coordinate of the operand
  80912. * @returns the current updated Vector3
  80913. */
  80914. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80915. /**
  80916. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80917. * Check if is non uniform within a certain amount of decimal places to account for this
  80918. * @param epsilon the amount the values can differ
  80919. * @returns if the the vector is non uniform to a certain number of decimal places
  80920. */
  80921. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80922. /**
  80923. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80924. */
  80925. get isNonUniform(): boolean;
  80926. /**
  80927. * Gets a new Vector3 from current Vector3 floored values
  80928. * @returns a new Vector3
  80929. */
  80930. floor(): Vector3;
  80931. /**
  80932. * Gets a new Vector3 from current Vector3 floored values
  80933. * @returns a new Vector3
  80934. */
  80935. fract(): Vector3;
  80936. /**
  80937. * Gets the length of the Vector3
  80938. * @returns the length of the Vector3
  80939. */
  80940. length(): number;
  80941. /**
  80942. * Gets the squared length of the Vector3
  80943. * @returns squared length of the Vector3
  80944. */
  80945. lengthSquared(): number;
  80946. /**
  80947. * Normalize the current Vector3.
  80948. * Please note that this is an in place operation.
  80949. * @returns the current updated Vector3
  80950. */
  80951. normalize(): Vector3;
  80952. /**
  80953. * Reorders the x y z properties of the vector in place
  80954. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80955. * @returns the current updated vector
  80956. */
  80957. reorderInPlace(order: string): this;
  80958. /**
  80959. * Rotates the vector around 0,0,0 by a quaternion
  80960. * @param quaternion the rotation quaternion
  80961. * @param result vector to store the result
  80962. * @returns the resulting vector
  80963. */
  80964. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80965. /**
  80966. * Rotates a vector around a given point
  80967. * @param quaternion the rotation quaternion
  80968. * @param point the point to rotate around
  80969. * @param result vector to store the result
  80970. * @returns the resulting vector
  80971. */
  80972. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80973. /**
  80974. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80975. * The cross product is then orthogonal to both current and "other"
  80976. * @param other defines the right operand
  80977. * @returns the cross product
  80978. */
  80979. cross(other: Vector3): Vector3;
  80980. /**
  80981. * Normalize the current Vector3 with the given input length.
  80982. * Please note that this is an in place operation.
  80983. * @param len the length of the vector
  80984. * @returns the current updated Vector3
  80985. */
  80986. normalizeFromLength(len: number): Vector3;
  80987. /**
  80988. * Normalize the current Vector3 to a new vector
  80989. * @returns the new Vector3
  80990. */
  80991. normalizeToNew(): Vector3;
  80992. /**
  80993. * Normalize the current Vector3 to the reference
  80994. * @param reference define the Vector3 to update
  80995. * @returns the updated Vector3
  80996. */
  80997. normalizeToRef(reference: Vector3): Vector3;
  80998. /**
  80999. * Creates a new Vector3 copied from the current Vector3
  81000. * @returns the new Vector3
  81001. */
  81002. clone(): Vector3;
  81003. /**
  81004. * Copies the given vector coordinates to the current Vector3 ones
  81005. * @param source defines the source Vector3
  81006. * @returns the current updated Vector3
  81007. */
  81008. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81009. /**
  81010. * Copies the given floats to the current Vector3 coordinates
  81011. * @param x defines the x coordinate of the operand
  81012. * @param y defines the y coordinate of the operand
  81013. * @param z defines the z coordinate of the operand
  81014. * @returns the current updated Vector3
  81015. */
  81016. copyFromFloats(x: number, y: number, z: number): Vector3;
  81017. /**
  81018. * Copies the given floats to the current Vector3 coordinates
  81019. * @param x defines the x coordinate of the operand
  81020. * @param y defines the y coordinate of the operand
  81021. * @param z defines the z coordinate of the operand
  81022. * @returns the current updated Vector3
  81023. */
  81024. set(x: number, y: number, z: number): Vector3;
  81025. /**
  81026. * Copies the given float to the current Vector3 coordinates
  81027. * @param v defines the x, y and z coordinates of the operand
  81028. * @returns the current updated Vector3
  81029. */
  81030. setAll(v: number): Vector3;
  81031. /**
  81032. * Get the clip factor between two vectors
  81033. * @param vector0 defines the first operand
  81034. * @param vector1 defines the second operand
  81035. * @param axis defines the axis to use
  81036. * @param size defines the size along the axis
  81037. * @returns the clip factor
  81038. */
  81039. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81040. /**
  81041. * Get angle between two vectors
  81042. * @param vector0 angle between vector0 and vector1
  81043. * @param vector1 angle between vector0 and vector1
  81044. * @param normal direction of the normal
  81045. * @return the angle between vector0 and vector1
  81046. */
  81047. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81048. /**
  81049. * Returns a new Vector3 set from the index "offset" of the given array
  81050. * @param array defines the source array
  81051. * @param offset defines the offset in the source array
  81052. * @returns the new Vector3
  81053. */
  81054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81055. /**
  81056. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81057. * @param array defines the source array
  81058. * @param offset defines the offset in the source array
  81059. * @returns the new Vector3
  81060. * @deprecated Please use FromArray instead.
  81061. */
  81062. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81063. /**
  81064. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81065. * @param array defines the source array
  81066. * @param offset defines the offset in the source array
  81067. * @param result defines the Vector3 where to store the result
  81068. */
  81069. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81070. /**
  81071. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81072. * @param array defines the source array
  81073. * @param offset defines the offset in the source array
  81074. * @param result defines the Vector3 where to store the result
  81075. * @deprecated Please use FromArrayToRef instead.
  81076. */
  81077. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81078. /**
  81079. * Sets the given vector "result" with the given floats.
  81080. * @param x defines the x coordinate of the source
  81081. * @param y defines the y coordinate of the source
  81082. * @param z defines the z coordinate of the source
  81083. * @param result defines the Vector3 where to store the result
  81084. */
  81085. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81086. /**
  81087. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81088. * @returns a new empty Vector3
  81089. */
  81090. static Zero(): Vector3;
  81091. /**
  81092. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81093. * @returns a new unit Vector3
  81094. */
  81095. static One(): Vector3;
  81096. /**
  81097. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81098. * @returns a new up Vector3
  81099. */
  81100. static Up(): Vector3;
  81101. /**
  81102. * Gets a up Vector3 that must not be updated
  81103. */
  81104. static get UpReadOnly(): DeepImmutable<Vector3>;
  81105. /**
  81106. * Gets a zero Vector3 that must not be updated
  81107. */
  81108. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81109. /**
  81110. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81111. * @returns a new down Vector3
  81112. */
  81113. static Down(): Vector3;
  81114. /**
  81115. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81116. * @param rightHandedSystem is the scene right-handed (negative z)
  81117. * @returns a new forward Vector3
  81118. */
  81119. static Forward(rightHandedSystem?: boolean): Vector3;
  81120. /**
  81121. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81122. * @param rightHandedSystem is the scene right-handed (negative-z)
  81123. * @returns a new forward Vector3
  81124. */
  81125. static Backward(rightHandedSystem?: boolean): Vector3;
  81126. /**
  81127. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81128. * @returns a new right Vector3
  81129. */
  81130. static Right(): Vector3;
  81131. /**
  81132. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81133. * @returns a new left Vector3
  81134. */
  81135. static Left(): Vector3;
  81136. /**
  81137. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81138. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81139. * @param vector defines the Vector3 to transform
  81140. * @param transformation defines the transformation matrix
  81141. * @returns the transformed Vector3
  81142. */
  81143. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81144. /**
  81145. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81146. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81147. * @param vector defines the Vector3 to transform
  81148. * @param transformation defines the transformation matrix
  81149. * @param result defines the Vector3 where to store the result
  81150. */
  81151. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81152. /**
  81153. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81154. * This method computes tranformed coordinates only, not transformed direction vectors
  81155. * @param x define the x coordinate of the source vector
  81156. * @param y define the y coordinate of the source vector
  81157. * @param z define the z coordinate of the source vector
  81158. * @param transformation defines the transformation matrix
  81159. * @param result defines the Vector3 where to store the result
  81160. */
  81161. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81162. /**
  81163. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81164. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81165. * @param vector defines the Vector3 to transform
  81166. * @param transformation defines the transformation matrix
  81167. * @returns the new Vector3
  81168. */
  81169. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81170. /**
  81171. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81172. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81173. * @param vector defines the Vector3 to transform
  81174. * @param transformation defines the transformation matrix
  81175. * @param result defines the Vector3 where to store the result
  81176. */
  81177. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81178. /**
  81179. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81180. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81181. * @param x define the x coordinate of the source vector
  81182. * @param y define the y coordinate of the source vector
  81183. * @param z define the z coordinate of the source vector
  81184. * @param transformation defines the transformation matrix
  81185. * @param result defines the Vector3 where to store the result
  81186. */
  81187. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81188. /**
  81189. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81190. * @param value1 defines the first control point
  81191. * @param value2 defines the second control point
  81192. * @param value3 defines the third control point
  81193. * @param value4 defines the fourth control point
  81194. * @param amount defines the amount on the spline to use
  81195. * @returns the new Vector3
  81196. */
  81197. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81198. /**
  81199. * 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"
  81200. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81201. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81202. * @param value defines the current value
  81203. * @param min defines the lower range value
  81204. * @param max defines the upper range value
  81205. * @returns the new Vector3
  81206. */
  81207. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81208. /**
  81209. * 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"
  81210. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81211. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81212. * @param value defines the current value
  81213. * @param min defines the lower range value
  81214. * @param max defines the upper range value
  81215. * @param result defines the Vector3 where to store the result
  81216. */
  81217. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81218. /**
  81219. * Checks if a given vector is inside a specific range
  81220. * @param v defines the vector to test
  81221. * @param min defines the minimum range
  81222. * @param max defines the maximum range
  81223. */
  81224. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81225. /**
  81226. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81227. * @param value1 defines the first control point
  81228. * @param tangent1 defines the first tangent vector
  81229. * @param value2 defines the second control point
  81230. * @param tangent2 defines the second tangent vector
  81231. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81232. * @returns the new Vector3
  81233. */
  81234. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81235. /**
  81236. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81237. * @param start defines the start value
  81238. * @param end defines the end value
  81239. * @param amount max defines amount between both (between 0 and 1)
  81240. * @returns the new Vector3
  81241. */
  81242. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81243. /**
  81244. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81245. * @param start defines the start value
  81246. * @param end defines the end value
  81247. * @param amount max defines amount between both (between 0 and 1)
  81248. * @param result defines the Vector3 where to store the result
  81249. */
  81250. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81251. /**
  81252. * Returns the dot product (float) between the vectors "left" and "right"
  81253. * @param left defines the left operand
  81254. * @param right defines the right operand
  81255. * @returns the dot product
  81256. */
  81257. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81258. /**
  81259. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81260. * The cross product is then orthogonal to both "left" and "right"
  81261. * @param left defines the left operand
  81262. * @param right defines the right operand
  81263. * @returns the cross product
  81264. */
  81265. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81266. /**
  81267. * Sets the given vector "result" with the cross product of "left" and "right"
  81268. * The cross product is then orthogonal to both "left" and "right"
  81269. * @param left defines the left operand
  81270. * @param right defines the right operand
  81271. * @param result defines the Vector3 where to store the result
  81272. */
  81273. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81274. /**
  81275. * Returns a new Vector3 as the normalization of the given vector
  81276. * @param vector defines the Vector3 to normalize
  81277. * @returns the new Vector3
  81278. */
  81279. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81280. /**
  81281. * Sets the given vector "result" with the normalization of the given first vector
  81282. * @param vector defines the Vector3 to normalize
  81283. * @param result defines the Vector3 where to store the result
  81284. */
  81285. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81286. /**
  81287. * Project a Vector3 onto screen space
  81288. * @param vector defines the Vector3 to project
  81289. * @param world defines the world matrix to use
  81290. * @param transform defines the transform (view x projection) matrix to use
  81291. * @param viewport defines the screen viewport to use
  81292. * @returns the new Vector3
  81293. */
  81294. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81295. /** @hidden */
  81296. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81297. /**
  81298. * Unproject from screen space to object space
  81299. * @param source defines the screen space Vector3 to use
  81300. * @param viewportWidth defines the current width of the viewport
  81301. * @param viewportHeight defines the current height of the viewport
  81302. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81303. * @param transform defines the transform (view x projection) matrix to use
  81304. * @returns the new Vector3
  81305. */
  81306. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81307. /**
  81308. * Unproject from screen space to object space
  81309. * @param source defines the screen space Vector3 to use
  81310. * @param viewportWidth defines the current width of the viewport
  81311. * @param viewportHeight defines the current height of the viewport
  81312. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81313. * @param view defines the view matrix to use
  81314. * @param projection defines the projection matrix to use
  81315. * @returns the new Vector3
  81316. */
  81317. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81318. /**
  81319. * Unproject from screen space to object space
  81320. * @param source defines the screen space Vector3 to use
  81321. * @param viewportWidth defines the current width of the viewport
  81322. * @param viewportHeight defines the current height of the viewport
  81323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81324. * @param view defines the view matrix to use
  81325. * @param projection defines the projection matrix to use
  81326. * @param result defines the Vector3 where to store the result
  81327. */
  81328. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81329. /**
  81330. * Unproject from screen space to object space
  81331. * @param sourceX defines the screen space x coordinate to use
  81332. * @param sourceY defines the screen space y coordinate to use
  81333. * @param sourceZ defines the screen space z coordinate to use
  81334. * @param viewportWidth defines the current width of the viewport
  81335. * @param viewportHeight defines the current height of the viewport
  81336. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81337. * @param view defines the view matrix to use
  81338. * @param projection defines the projection matrix to use
  81339. * @param result defines the Vector3 where to store the result
  81340. */
  81341. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81342. /**
  81343. * Gets the minimal coordinate values between two Vector3
  81344. * @param left defines the first operand
  81345. * @param right defines the second operand
  81346. * @returns the new Vector3
  81347. */
  81348. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81349. /**
  81350. * Gets the maximal coordinate values between two Vector3
  81351. * @param left defines the first operand
  81352. * @param right defines the second operand
  81353. * @returns the new Vector3
  81354. */
  81355. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81356. /**
  81357. * Returns the distance between the vectors "value1" and "value2"
  81358. * @param value1 defines the first operand
  81359. * @param value2 defines the second operand
  81360. * @returns the distance
  81361. */
  81362. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81363. /**
  81364. * Returns the squared distance between the vectors "value1" and "value2"
  81365. * @param value1 defines the first operand
  81366. * @param value2 defines the second operand
  81367. * @returns the squared distance
  81368. */
  81369. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81370. /**
  81371. * Returns a new Vector3 located at the center between "value1" and "value2"
  81372. * @param value1 defines the first operand
  81373. * @param value2 defines the second operand
  81374. * @returns the new Vector3
  81375. */
  81376. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81377. /**
  81378. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81379. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81380. * to something in order to rotate it from its local system to the given target system
  81381. * Note: axis1, axis2 and axis3 are normalized during this operation
  81382. * @param axis1 defines the first axis
  81383. * @param axis2 defines the second axis
  81384. * @param axis3 defines the third axis
  81385. * @returns a new Vector3
  81386. */
  81387. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81388. /**
  81389. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81390. * @param axis1 defines the first axis
  81391. * @param axis2 defines the second axis
  81392. * @param axis3 defines the third axis
  81393. * @param ref defines the Vector3 where to store the result
  81394. */
  81395. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81396. }
  81397. /**
  81398. * Vector4 class created for EulerAngle class conversion to Quaternion
  81399. */
  81400. export class Vector4 {
  81401. /** x value of the vector */
  81402. x: number;
  81403. /** y value of the vector */
  81404. y: number;
  81405. /** z value of the vector */
  81406. z: number;
  81407. /** w value of the vector */
  81408. w: number;
  81409. /**
  81410. * Creates a Vector4 object from the given floats.
  81411. * @param x x value of the vector
  81412. * @param y y value of the vector
  81413. * @param z z value of the vector
  81414. * @param w w value of the vector
  81415. */
  81416. constructor(
  81417. /** x value of the vector */
  81418. x: number,
  81419. /** y value of the vector */
  81420. y: number,
  81421. /** z value of the vector */
  81422. z: number,
  81423. /** w value of the vector */
  81424. w: number);
  81425. /**
  81426. * Returns the string with the Vector4 coordinates.
  81427. * @returns a string containing all the vector values
  81428. */
  81429. toString(): string;
  81430. /**
  81431. * Returns the string "Vector4".
  81432. * @returns "Vector4"
  81433. */
  81434. getClassName(): string;
  81435. /**
  81436. * Returns the Vector4 hash code.
  81437. * @returns a unique hash code
  81438. */
  81439. getHashCode(): number;
  81440. /**
  81441. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81442. * @returns the resulting array
  81443. */
  81444. asArray(): number[];
  81445. /**
  81446. * Populates the given array from the given index with the Vector4 coordinates.
  81447. * @param array array to populate
  81448. * @param index index of the array to start at (default: 0)
  81449. * @returns the Vector4.
  81450. */
  81451. toArray(array: FloatArray, index?: number): Vector4;
  81452. /**
  81453. * Adds the given vector to the current Vector4.
  81454. * @param otherVector the vector to add
  81455. * @returns the updated Vector4.
  81456. */
  81457. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81458. /**
  81459. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81460. * @param otherVector the vector to add
  81461. * @returns the resulting vector
  81462. */
  81463. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81464. /**
  81465. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81466. * @param otherVector the vector to add
  81467. * @param result the vector to store the result
  81468. * @returns the current Vector4.
  81469. */
  81470. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81471. /**
  81472. * Subtract in place the given vector from the current Vector4.
  81473. * @param otherVector the vector to subtract
  81474. * @returns the updated Vector4.
  81475. */
  81476. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81477. /**
  81478. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81479. * @param otherVector the vector to add
  81480. * @returns the new vector with the result
  81481. */
  81482. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81483. /**
  81484. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81485. * @param otherVector the vector to subtract
  81486. * @param result the vector to store the result
  81487. * @returns the current Vector4.
  81488. */
  81489. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81490. /**
  81491. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81492. */
  81493. /**
  81494. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81495. * @param x value to subtract
  81496. * @param y value to subtract
  81497. * @param z value to subtract
  81498. * @param w value to subtract
  81499. * @returns new vector containing the result
  81500. */
  81501. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81502. /**
  81503. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81504. * @param x value to subtract
  81505. * @param y value to subtract
  81506. * @param z value to subtract
  81507. * @param w value to subtract
  81508. * @param result the vector to store the result in
  81509. * @returns the current Vector4.
  81510. */
  81511. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81512. /**
  81513. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81514. * @returns a new vector with the negated values
  81515. */
  81516. negate(): Vector4;
  81517. /**
  81518. * Negate this vector in place
  81519. * @returns this
  81520. */
  81521. negateInPlace(): Vector4;
  81522. /**
  81523. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81524. * @param result defines the Vector3 object where to store the result
  81525. * @returns the current Vector4
  81526. */
  81527. negateToRef(result: Vector4): Vector4;
  81528. /**
  81529. * Multiplies the current Vector4 coordinates by scale (float).
  81530. * @param scale the number to scale with
  81531. * @returns the updated Vector4.
  81532. */
  81533. scaleInPlace(scale: number): Vector4;
  81534. /**
  81535. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81536. * @param scale the number to scale with
  81537. * @returns a new vector with the result
  81538. */
  81539. scale(scale: number): Vector4;
  81540. /**
  81541. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81542. * @param scale the number to scale with
  81543. * @param result a vector to store the result in
  81544. * @returns the current Vector4.
  81545. */
  81546. scaleToRef(scale: number, result: Vector4): Vector4;
  81547. /**
  81548. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81549. * @param scale defines the scale factor
  81550. * @param result defines the Vector4 object where to store the result
  81551. * @returns the unmodified current Vector4
  81552. */
  81553. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81554. /**
  81555. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81556. * @param otherVector the vector to compare against
  81557. * @returns true if they are equal
  81558. */
  81559. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81560. /**
  81561. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81562. * @param otherVector vector to compare against
  81563. * @param epsilon (Default: very small number)
  81564. * @returns true if they are equal
  81565. */
  81566. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81567. /**
  81568. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81569. * @param x x value to compare against
  81570. * @param y y value to compare against
  81571. * @param z z value to compare against
  81572. * @param w w value to compare against
  81573. * @returns true if equal
  81574. */
  81575. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81576. /**
  81577. * Multiplies in place the current Vector4 by the given one.
  81578. * @param otherVector vector to multiple with
  81579. * @returns the updated Vector4.
  81580. */
  81581. multiplyInPlace(otherVector: Vector4): Vector4;
  81582. /**
  81583. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81584. * @param otherVector vector to multiple with
  81585. * @returns resulting new vector
  81586. */
  81587. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81588. /**
  81589. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81590. * @param otherVector vector to multiple with
  81591. * @param result vector to store the result
  81592. * @returns the current Vector4.
  81593. */
  81594. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81595. /**
  81596. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81597. * @param x x value multiply with
  81598. * @param y y value multiply with
  81599. * @param z z value multiply with
  81600. * @param w w value multiply with
  81601. * @returns resulting new vector
  81602. */
  81603. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81604. /**
  81605. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81606. * @param otherVector vector to devide with
  81607. * @returns resulting new vector
  81608. */
  81609. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81610. /**
  81611. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81612. * @param otherVector vector to devide with
  81613. * @param result vector to store the result
  81614. * @returns the current Vector4.
  81615. */
  81616. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81617. /**
  81618. * Divides the current Vector3 coordinates by the given ones.
  81619. * @param otherVector vector to devide with
  81620. * @returns the updated Vector3.
  81621. */
  81622. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81623. /**
  81624. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81625. * @param other defines the second operand
  81626. * @returns the current updated Vector4
  81627. */
  81628. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81629. /**
  81630. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81631. * @param other defines the second operand
  81632. * @returns the current updated Vector4
  81633. */
  81634. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81635. /**
  81636. * Gets a new Vector4 from current Vector4 floored values
  81637. * @returns a new Vector4
  81638. */
  81639. floor(): Vector4;
  81640. /**
  81641. * Gets a new Vector4 from current Vector3 floored values
  81642. * @returns a new Vector4
  81643. */
  81644. fract(): Vector4;
  81645. /**
  81646. * Returns the Vector4 length (float).
  81647. * @returns the length
  81648. */
  81649. length(): number;
  81650. /**
  81651. * Returns the Vector4 squared length (float).
  81652. * @returns the length squared
  81653. */
  81654. lengthSquared(): number;
  81655. /**
  81656. * Normalizes in place the Vector4.
  81657. * @returns the updated Vector4.
  81658. */
  81659. normalize(): Vector4;
  81660. /**
  81661. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81662. * @returns this converted to a new vector3
  81663. */
  81664. toVector3(): Vector3;
  81665. /**
  81666. * Returns a new Vector4 copied from the current one.
  81667. * @returns the new cloned vector
  81668. */
  81669. clone(): Vector4;
  81670. /**
  81671. * Updates the current Vector4 with the given one coordinates.
  81672. * @param source the source vector to copy from
  81673. * @returns the updated Vector4.
  81674. */
  81675. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81676. /**
  81677. * Updates the current Vector4 coordinates with the given floats.
  81678. * @param x float to copy from
  81679. * @param y float to copy from
  81680. * @param z float to copy from
  81681. * @param w float to copy from
  81682. * @returns the updated Vector4.
  81683. */
  81684. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81685. /**
  81686. * Updates the current Vector4 coordinates with the given floats.
  81687. * @param x float to set from
  81688. * @param y float to set from
  81689. * @param z float to set from
  81690. * @param w float to set from
  81691. * @returns the updated Vector4.
  81692. */
  81693. set(x: number, y: number, z: number, w: number): Vector4;
  81694. /**
  81695. * Copies the given float to the current Vector3 coordinates
  81696. * @param v defines the x, y, z and w coordinates of the operand
  81697. * @returns the current updated Vector3
  81698. */
  81699. setAll(v: number): Vector4;
  81700. /**
  81701. * Returns a new Vector4 set from the starting index of the given array.
  81702. * @param array the array to pull values from
  81703. * @param offset the offset into the array to start at
  81704. * @returns the new vector
  81705. */
  81706. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81707. /**
  81708. * Updates the given vector "result" from the starting index of the given array.
  81709. * @param array the array to pull values from
  81710. * @param offset the offset into the array to start at
  81711. * @param result the vector to store the result in
  81712. */
  81713. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81714. /**
  81715. * Updates the given vector "result" from the starting index of the given Float32Array.
  81716. * @param array the array to pull values from
  81717. * @param offset the offset into the array to start at
  81718. * @param result the vector to store the result in
  81719. */
  81720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81721. /**
  81722. * Updates the given vector "result" coordinates from the given floats.
  81723. * @param x float to set from
  81724. * @param y float to set from
  81725. * @param z float to set from
  81726. * @param w float to set from
  81727. * @param result the vector to the floats in
  81728. */
  81729. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81730. /**
  81731. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81732. * @returns the new vector
  81733. */
  81734. static Zero(): Vector4;
  81735. /**
  81736. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81737. * @returns the new vector
  81738. */
  81739. static One(): Vector4;
  81740. /**
  81741. * Returns a new normalized Vector4 from the given one.
  81742. * @param vector the vector to normalize
  81743. * @returns the vector
  81744. */
  81745. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81746. /**
  81747. * Updates the given vector "result" from the normalization of the given one.
  81748. * @param vector the vector to normalize
  81749. * @param result the vector to store the result in
  81750. */
  81751. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81752. /**
  81753. * Returns a vector with the minimum values from the left and right vectors
  81754. * @param left left vector to minimize
  81755. * @param right right vector to minimize
  81756. * @returns a new vector with the minimum of the left and right vector values
  81757. */
  81758. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81759. /**
  81760. * Returns a vector with the maximum values from the left and right vectors
  81761. * @param left left vector to maximize
  81762. * @param right right vector to maximize
  81763. * @returns a new vector with the maximum of the left and right vector values
  81764. */
  81765. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81766. /**
  81767. * Returns the distance (float) between the vectors "value1" and "value2".
  81768. * @param value1 value to calulate the distance between
  81769. * @param value2 value to calulate the distance between
  81770. * @return the distance between the two vectors
  81771. */
  81772. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81773. /**
  81774. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81775. * @param value1 value to calulate the distance between
  81776. * @param value2 value to calulate the distance between
  81777. * @return the distance between the two vectors squared
  81778. */
  81779. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81780. /**
  81781. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81782. * @param value1 value to calulate the center between
  81783. * @param value2 value to calulate the center between
  81784. * @return the center between the two vectors
  81785. */
  81786. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81787. /**
  81788. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81789. * This methods computes transformed normalized direction vectors only.
  81790. * @param vector the vector to transform
  81791. * @param transformation the transformation matrix to apply
  81792. * @returns the new vector
  81793. */
  81794. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81795. /**
  81796. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81797. * This methods computes transformed normalized direction vectors only.
  81798. * @param vector the vector to transform
  81799. * @param transformation the transformation matrix to apply
  81800. * @param result the vector to store the result in
  81801. */
  81802. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81803. /**
  81804. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81805. * This methods computes transformed normalized direction vectors only.
  81806. * @param x value to transform
  81807. * @param y value to transform
  81808. * @param z value to transform
  81809. * @param w value to transform
  81810. * @param transformation the transformation matrix to apply
  81811. * @param result the vector to store the results in
  81812. */
  81813. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81814. /**
  81815. * Creates a new Vector4 from a Vector3
  81816. * @param source defines the source data
  81817. * @param w defines the 4th component (default is 0)
  81818. * @returns a new Vector4
  81819. */
  81820. static FromVector3(source: Vector3, w?: number): Vector4;
  81821. }
  81822. /**
  81823. * Class used to store quaternion data
  81824. * @see https://en.wikipedia.org/wiki/Quaternion
  81825. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81826. */
  81827. export class Quaternion {
  81828. /** @hidden */
  81829. _x: number;
  81830. /** @hidden */
  81831. _y: number;
  81832. /** @hidden */
  81833. _z: number;
  81834. /** @hidden */
  81835. _w: number;
  81836. /** @hidden */
  81837. _isDirty: boolean;
  81838. /** Gets or sets the x coordinate */
  81839. get x(): number;
  81840. set x(value: number);
  81841. /** Gets or sets the y coordinate */
  81842. get y(): number;
  81843. set y(value: number);
  81844. /** Gets or sets the z coordinate */
  81845. get z(): number;
  81846. set z(value: number);
  81847. /** Gets or sets the w coordinate */
  81848. get w(): number;
  81849. set w(value: number);
  81850. /**
  81851. * Creates a new Quaternion from the given floats
  81852. * @param x defines the first component (0 by default)
  81853. * @param y defines the second component (0 by default)
  81854. * @param z defines the third component (0 by default)
  81855. * @param w defines the fourth component (1.0 by default)
  81856. */
  81857. constructor(x?: number, y?: number, z?: number, w?: number);
  81858. /**
  81859. * Gets a string representation for the current quaternion
  81860. * @returns a string with the Quaternion coordinates
  81861. */
  81862. toString(): string;
  81863. /**
  81864. * Gets the class name of the quaternion
  81865. * @returns the string "Quaternion"
  81866. */
  81867. getClassName(): string;
  81868. /**
  81869. * Gets a hash code for this quaternion
  81870. * @returns the quaternion hash code
  81871. */
  81872. getHashCode(): number;
  81873. /**
  81874. * Copy the quaternion to an array
  81875. * @returns a new array populated with 4 elements from the quaternion coordinates
  81876. */
  81877. asArray(): number[];
  81878. /**
  81879. * Check if two quaternions are equals
  81880. * @param otherQuaternion defines the second operand
  81881. * @return true if the current quaternion and the given one coordinates are strictly equals
  81882. */
  81883. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81884. /**
  81885. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81886. * @param otherQuaternion defines the other quaternion
  81887. * @param epsilon defines the minimal distance to consider equality
  81888. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81889. */
  81890. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81891. /**
  81892. * Clone the current quaternion
  81893. * @returns a new quaternion copied from the current one
  81894. */
  81895. clone(): Quaternion;
  81896. /**
  81897. * Copy a quaternion to the current one
  81898. * @param other defines the other quaternion
  81899. * @returns the updated current quaternion
  81900. */
  81901. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81902. /**
  81903. * Updates the current quaternion with the given float coordinates
  81904. * @param x defines the x coordinate
  81905. * @param y defines the y coordinate
  81906. * @param z defines the z coordinate
  81907. * @param w defines the w coordinate
  81908. * @returns the updated current quaternion
  81909. */
  81910. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81911. /**
  81912. * Updates the current quaternion from the given float coordinates
  81913. * @param x defines the x coordinate
  81914. * @param y defines the y coordinate
  81915. * @param z defines the z coordinate
  81916. * @param w defines the w coordinate
  81917. * @returns the updated current quaternion
  81918. */
  81919. set(x: number, y: number, z: number, w: number): Quaternion;
  81920. /**
  81921. * Adds two quaternions
  81922. * @param other defines the second operand
  81923. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81924. */
  81925. add(other: DeepImmutable<Quaternion>): Quaternion;
  81926. /**
  81927. * Add a quaternion to the current one
  81928. * @param other defines the quaternion to add
  81929. * @returns the current quaternion
  81930. */
  81931. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81932. /**
  81933. * Subtract two quaternions
  81934. * @param other defines the second operand
  81935. * @returns a new quaternion as the subtraction result of the given one from the current one
  81936. */
  81937. subtract(other: Quaternion): Quaternion;
  81938. /**
  81939. * Multiplies the current quaternion by a scale factor
  81940. * @param value defines the scale factor
  81941. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81942. */
  81943. scale(value: number): Quaternion;
  81944. /**
  81945. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81946. * @param scale defines the scale factor
  81947. * @param result defines the Quaternion object where to store the result
  81948. * @returns the unmodified current quaternion
  81949. */
  81950. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81951. /**
  81952. * Multiplies in place the current quaternion by a scale factor
  81953. * @param value defines the scale factor
  81954. * @returns the current modified quaternion
  81955. */
  81956. scaleInPlace(value: number): Quaternion;
  81957. /**
  81958. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81959. * @param scale defines the scale factor
  81960. * @param result defines the Quaternion object where to store the result
  81961. * @returns the unmodified current quaternion
  81962. */
  81963. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81964. /**
  81965. * Multiplies two quaternions
  81966. * @param q1 defines the second operand
  81967. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81968. */
  81969. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81970. /**
  81971. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81972. * @param q1 defines the second operand
  81973. * @param result defines the target quaternion
  81974. * @returns the current quaternion
  81975. */
  81976. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81977. /**
  81978. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81979. * @param q1 defines the second operand
  81980. * @returns the currentupdated quaternion
  81981. */
  81982. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81983. /**
  81984. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81985. * @param ref defines the target quaternion
  81986. * @returns the current quaternion
  81987. */
  81988. conjugateToRef(ref: Quaternion): Quaternion;
  81989. /**
  81990. * Conjugates in place (1-q) the current quaternion
  81991. * @returns the current updated quaternion
  81992. */
  81993. conjugateInPlace(): Quaternion;
  81994. /**
  81995. * Conjugates in place (1-q) the current quaternion
  81996. * @returns a new quaternion
  81997. */
  81998. conjugate(): Quaternion;
  81999. /**
  82000. * Gets length of current quaternion
  82001. * @returns the quaternion length (float)
  82002. */
  82003. length(): number;
  82004. /**
  82005. * Normalize in place the current quaternion
  82006. * @returns the current updated quaternion
  82007. */
  82008. normalize(): Quaternion;
  82009. /**
  82010. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82011. * @param order is a reserved parameter and is ignore for now
  82012. * @returns a new Vector3 containing the Euler angles
  82013. */
  82014. toEulerAngles(order?: string): Vector3;
  82015. /**
  82016. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82017. * @param result defines the vector which will be filled with the Euler angles
  82018. * @param order is a reserved parameter and is ignore for now
  82019. * @returns the current unchanged quaternion
  82020. */
  82021. toEulerAnglesToRef(result: Vector3): Quaternion;
  82022. /**
  82023. * Updates the given rotation matrix with the current quaternion values
  82024. * @param result defines the target matrix
  82025. * @returns the current unchanged quaternion
  82026. */
  82027. toRotationMatrix(result: Matrix): Quaternion;
  82028. /**
  82029. * Updates the current quaternion from the given rotation matrix values
  82030. * @param matrix defines the source matrix
  82031. * @returns the current updated quaternion
  82032. */
  82033. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82034. /**
  82035. * Creates a new quaternion from a rotation matrix
  82036. * @param matrix defines the source matrix
  82037. * @returns a new quaternion created from the given rotation matrix values
  82038. */
  82039. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82040. /**
  82041. * Updates the given quaternion with the given rotation matrix values
  82042. * @param matrix defines the source matrix
  82043. * @param result defines the target quaternion
  82044. */
  82045. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82046. /**
  82047. * Returns the dot product (float) between the quaternions "left" and "right"
  82048. * @param left defines the left operand
  82049. * @param right defines the right operand
  82050. * @returns the dot product
  82051. */
  82052. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82053. /**
  82054. * Checks if the two quaternions are close to each other
  82055. * @param quat0 defines the first quaternion to check
  82056. * @param quat1 defines the second quaternion to check
  82057. * @returns true if the two quaternions are close to each other
  82058. */
  82059. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82060. /**
  82061. * Creates an empty quaternion
  82062. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82063. */
  82064. static Zero(): Quaternion;
  82065. /**
  82066. * Inverse a given quaternion
  82067. * @param q defines the source quaternion
  82068. * @returns a new quaternion as the inverted current quaternion
  82069. */
  82070. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82071. /**
  82072. * Inverse a given quaternion
  82073. * @param q defines the source quaternion
  82074. * @param result the quaternion the result will be stored in
  82075. * @returns the result quaternion
  82076. */
  82077. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82078. /**
  82079. * Creates an identity quaternion
  82080. * @returns the identity quaternion
  82081. */
  82082. static Identity(): Quaternion;
  82083. /**
  82084. * Gets a boolean indicating if the given quaternion is identity
  82085. * @param quaternion defines the quaternion to check
  82086. * @returns true if the quaternion is identity
  82087. */
  82088. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82089. /**
  82090. * Creates a quaternion from a rotation around an axis
  82091. * @param axis defines the axis to use
  82092. * @param angle defines the angle to use
  82093. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82094. */
  82095. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82096. /**
  82097. * Creates a rotation around an axis and stores it into the given quaternion
  82098. * @param axis defines the axis to use
  82099. * @param angle defines the angle to use
  82100. * @param result defines the target quaternion
  82101. * @returns the target quaternion
  82102. */
  82103. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82104. /**
  82105. * Creates a new quaternion from data stored into an array
  82106. * @param array defines the data source
  82107. * @param offset defines the offset in the source array where the data starts
  82108. * @returns a new quaternion
  82109. */
  82110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82111. /**
  82112. * Updates the given quaternion "result" from the starting index of the given array.
  82113. * @param array the array to pull values from
  82114. * @param offset the offset into the array to start at
  82115. * @param result the quaternion to store the result in
  82116. */
  82117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82118. /**
  82119. * Create a quaternion from Euler rotation angles
  82120. * @param x Pitch
  82121. * @param y Yaw
  82122. * @param z Roll
  82123. * @returns the new Quaternion
  82124. */
  82125. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82126. /**
  82127. * Updates a quaternion from Euler rotation angles
  82128. * @param x Pitch
  82129. * @param y Yaw
  82130. * @param z Roll
  82131. * @param result the quaternion to store the result
  82132. * @returns the updated quaternion
  82133. */
  82134. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82135. /**
  82136. * Create a quaternion from Euler rotation vector
  82137. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82138. * @returns the new Quaternion
  82139. */
  82140. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82141. /**
  82142. * Updates a quaternion from Euler rotation vector
  82143. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82144. * @param result the quaternion to store the result
  82145. * @returns the updated quaternion
  82146. */
  82147. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82148. /**
  82149. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82150. * @param yaw defines the rotation around Y axis
  82151. * @param pitch defines the rotation around X axis
  82152. * @param roll defines the rotation around Z axis
  82153. * @returns the new quaternion
  82154. */
  82155. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82156. /**
  82157. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82158. * @param yaw defines the rotation around Y axis
  82159. * @param pitch defines the rotation around X axis
  82160. * @param roll defines the rotation around Z axis
  82161. * @param result defines the target quaternion
  82162. */
  82163. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82164. /**
  82165. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82166. * @param alpha defines the rotation around first axis
  82167. * @param beta defines the rotation around second axis
  82168. * @param gamma defines the rotation around third axis
  82169. * @returns the new quaternion
  82170. */
  82171. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82172. /**
  82173. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82174. * @param alpha defines the rotation around first axis
  82175. * @param beta defines the rotation around second axis
  82176. * @param gamma defines the rotation around third axis
  82177. * @param result defines the target quaternion
  82178. */
  82179. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82180. /**
  82181. * 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)
  82182. * @param axis1 defines the first axis
  82183. * @param axis2 defines the second axis
  82184. * @param axis3 defines the third axis
  82185. * @returns the new quaternion
  82186. */
  82187. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82188. /**
  82189. * 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
  82190. * @param axis1 defines the first axis
  82191. * @param axis2 defines the second axis
  82192. * @param axis3 defines the third axis
  82193. * @param ref defines the target quaternion
  82194. */
  82195. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82196. /**
  82197. * Interpolates between two quaternions
  82198. * @param left defines first quaternion
  82199. * @param right defines second quaternion
  82200. * @param amount defines the gradient to use
  82201. * @returns the new interpolated quaternion
  82202. */
  82203. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82204. /**
  82205. * Interpolates between two quaternions and stores it into a target quaternion
  82206. * @param left defines first quaternion
  82207. * @param right defines second quaternion
  82208. * @param amount defines the gradient to use
  82209. * @param result defines the target quaternion
  82210. */
  82211. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82212. /**
  82213. * Interpolate between two quaternions using Hermite interpolation
  82214. * @param value1 defines first quaternion
  82215. * @param tangent1 defines the incoming tangent
  82216. * @param value2 defines second quaternion
  82217. * @param tangent2 defines the outgoing tangent
  82218. * @param amount defines the target quaternion
  82219. * @returns the new interpolated quaternion
  82220. */
  82221. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82222. }
  82223. /**
  82224. * Class used to store matrix data (4x4)
  82225. */
  82226. export class Matrix {
  82227. private static _updateFlagSeed;
  82228. private static _identityReadOnly;
  82229. private _isIdentity;
  82230. private _isIdentityDirty;
  82231. private _isIdentity3x2;
  82232. private _isIdentity3x2Dirty;
  82233. /**
  82234. * Gets the update flag of the matrix which is an unique number for the matrix.
  82235. * It will be incremented every time the matrix data change.
  82236. * You can use it to speed the comparison between two versions of the same matrix.
  82237. */
  82238. updateFlag: number;
  82239. private readonly _m;
  82240. /**
  82241. * Gets the internal data of the matrix
  82242. */
  82243. get m(): DeepImmutable<Float32Array>;
  82244. /** @hidden */
  82245. _markAsUpdated(): void;
  82246. /** @hidden */
  82247. private _updateIdentityStatus;
  82248. /**
  82249. * Creates an empty matrix (filled with zeros)
  82250. */
  82251. constructor();
  82252. /**
  82253. * Check if the current matrix is identity
  82254. * @returns true is the matrix is the identity matrix
  82255. */
  82256. isIdentity(): boolean;
  82257. /**
  82258. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82259. * @returns true is the matrix is the identity matrix
  82260. */
  82261. isIdentityAs3x2(): boolean;
  82262. /**
  82263. * Gets the determinant of the matrix
  82264. * @returns the matrix determinant
  82265. */
  82266. determinant(): number;
  82267. /**
  82268. * Returns the matrix as a Float32Array
  82269. * @returns the matrix underlying array
  82270. */
  82271. toArray(): DeepImmutable<Float32Array>;
  82272. /**
  82273. * Returns the matrix as a Float32Array
  82274. * @returns the matrix underlying array.
  82275. */
  82276. asArray(): DeepImmutable<Float32Array>;
  82277. /**
  82278. * Inverts the current matrix in place
  82279. * @returns the current inverted matrix
  82280. */
  82281. invert(): Matrix;
  82282. /**
  82283. * Sets all the matrix elements to zero
  82284. * @returns the current matrix
  82285. */
  82286. reset(): Matrix;
  82287. /**
  82288. * Adds the current matrix with a second one
  82289. * @param other defines the matrix to add
  82290. * @returns a new matrix as the addition of the current matrix and the given one
  82291. */
  82292. add(other: DeepImmutable<Matrix>): Matrix;
  82293. /**
  82294. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82295. * @param other defines the matrix to add
  82296. * @param result defines the target matrix
  82297. * @returns the current matrix
  82298. */
  82299. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82300. /**
  82301. * Adds in place the given matrix to the current matrix
  82302. * @param other defines the second operand
  82303. * @returns the current updated matrix
  82304. */
  82305. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82306. /**
  82307. * Sets the given matrix to the current inverted Matrix
  82308. * @param other defines the target matrix
  82309. * @returns the unmodified current matrix
  82310. */
  82311. invertToRef(other: Matrix): Matrix;
  82312. /**
  82313. * add a value at the specified position in the current Matrix
  82314. * @param index the index of the value within the matrix. between 0 and 15.
  82315. * @param value the value to be added
  82316. * @returns the current updated matrix
  82317. */
  82318. addAtIndex(index: number, value: number): Matrix;
  82319. /**
  82320. * mutiply the specified position in the current Matrix by a value
  82321. * @param index the index of the value within the matrix. between 0 and 15.
  82322. * @param value the value to be added
  82323. * @returns the current updated matrix
  82324. */
  82325. multiplyAtIndex(index: number, value: number): Matrix;
  82326. /**
  82327. * Inserts the translation vector (using 3 floats) in the current matrix
  82328. * @param x defines the 1st component of the translation
  82329. * @param y defines the 2nd component of the translation
  82330. * @param z defines the 3rd component of the translation
  82331. * @returns the current updated matrix
  82332. */
  82333. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82334. /**
  82335. * Adds the translation vector (using 3 floats) in the current matrix
  82336. * @param x defines the 1st component of the translation
  82337. * @param y defines the 2nd component of the translation
  82338. * @param z defines the 3rd component of the translation
  82339. * @returns the current updated matrix
  82340. */
  82341. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82342. /**
  82343. * Inserts the translation vector in the current matrix
  82344. * @param vector3 defines the translation to insert
  82345. * @returns the current updated matrix
  82346. */
  82347. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82348. /**
  82349. * Gets the translation value of the current matrix
  82350. * @returns a new Vector3 as the extracted translation from the matrix
  82351. */
  82352. getTranslation(): Vector3;
  82353. /**
  82354. * Fill a Vector3 with the extracted translation from the matrix
  82355. * @param result defines the Vector3 where to store the translation
  82356. * @returns the current matrix
  82357. */
  82358. getTranslationToRef(result: Vector3): Matrix;
  82359. /**
  82360. * Remove rotation and scaling part from the matrix
  82361. * @returns the updated matrix
  82362. */
  82363. removeRotationAndScaling(): Matrix;
  82364. /**
  82365. * Multiply two matrices
  82366. * @param other defines the second operand
  82367. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82368. */
  82369. multiply(other: DeepImmutable<Matrix>): Matrix;
  82370. /**
  82371. * Copy the current matrix from the given one
  82372. * @param other defines the source matrix
  82373. * @returns the current updated matrix
  82374. */
  82375. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82376. /**
  82377. * Populates the given array from the starting index with the current matrix values
  82378. * @param array defines the target array
  82379. * @param offset defines the offset in the target array where to start storing values
  82380. * @returns the current matrix
  82381. */
  82382. copyToArray(array: Float32Array, offset?: number): Matrix;
  82383. /**
  82384. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82385. * @param other defines the second operand
  82386. * @param result defines the matrix where to store the multiplication
  82387. * @returns the current matrix
  82388. */
  82389. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82390. /**
  82391. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82392. * @param other defines the second operand
  82393. * @param result defines the array where to store the multiplication
  82394. * @param offset defines the offset in the target array where to start storing values
  82395. * @returns the current matrix
  82396. */
  82397. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82398. /**
  82399. * Check equality between this matrix and a second one
  82400. * @param value defines the second matrix to compare
  82401. * @returns true is the current matrix and the given one values are strictly equal
  82402. */
  82403. equals(value: DeepImmutable<Matrix>): boolean;
  82404. /**
  82405. * Clone the current matrix
  82406. * @returns a new matrix from the current matrix
  82407. */
  82408. clone(): Matrix;
  82409. /**
  82410. * Returns the name of the current matrix class
  82411. * @returns the string "Matrix"
  82412. */
  82413. getClassName(): string;
  82414. /**
  82415. * Gets the hash code of the current matrix
  82416. * @returns the hash code
  82417. */
  82418. getHashCode(): number;
  82419. /**
  82420. * Decomposes the current Matrix into a translation, rotation and scaling components
  82421. * @param scale defines the scale vector3 given as a reference to update
  82422. * @param rotation defines the rotation quaternion given as a reference to update
  82423. * @param translation defines the translation vector3 given as a reference to update
  82424. * @returns true if operation was successful
  82425. */
  82426. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82427. /**
  82428. * Gets specific row of the matrix
  82429. * @param index defines the number of the row to get
  82430. * @returns the index-th row of the current matrix as a new Vector4
  82431. */
  82432. getRow(index: number): Nullable<Vector4>;
  82433. /**
  82434. * Sets the index-th row of the current matrix to the vector4 values
  82435. * @param index defines the number of the row to set
  82436. * @param row defines the target vector4
  82437. * @returns the updated current matrix
  82438. */
  82439. setRow(index: number, row: Vector4): Matrix;
  82440. /**
  82441. * Compute the transpose of the matrix
  82442. * @returns the new transposed matrix
  82443. */
  82444. transpose(): Matrix;
  82445. /**
  82446. * Compute the transpose of the matrix and store it in a given matrix
  82447. * @param result defines the target matrix
  82448. * @returns the current matrix
  82449. */
  82450. transposeToRef(result: Matrix): Matrix;
  82451. /**
  82452. * Sets the index-th row of the current matrix with the given 4 x float values
  82453. * @param index defines the row index
  82454. * @param x defines the x component to set
  82455. * @param y defines the y component to set
  82456. * @param z defines the z component to set
  82457. * @param w defines the w component to set
  82458. * @returns the updated current matrix
  82459. */
  82460. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82461. /**
  82462. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82463. * @param scale defines the scale factor
  82464. * @returns a new matrix
  82465. */
  82466. scale(scale: number): Matrix;
  82467. /**
  82468. * Scale the current matrix values by a factor to a given result matrix
  82469. * @param scale defines the scale factor
  82470. * @param result defines the matrix to store the result
  82471. * @returns the current matrix
  82472. */
  82473. scaleToRef(scale: number, result: Matrix): Matrix;
  82474. /**
  82475. * Scale the current matrix values by a factor and add the result to a given matrix
  82476. * @param scale defines the scale factor
  82477. * @param result defines the Matrix to store the result
  82478. * @returns the current matrix
  82479. */
  82480. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82481. /**
  82482. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82483. * @param ref matrix to store the result
  82484. */
  82485. toNormalMatrix(ref: Matrix): void;
  82486. /**
  82487. * Gets only rotation part of the current matrix
  82488. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82489. */
  82490. getRotationMatrix(): Matrix;
  82491. /**
  82492. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82493. * @param result defines the target matrix to store data to
  82494. * @returns the current matrix
  82495. */
  82496. getRotationMatrixToRef(result: Matrix): Matrix;
  82497. /**
  82498. * Toggles model matrix from being right handed to left handed in place and vice versa
  82499. */
  82500. toggleModelMatrixHandInPlace(): void;
  82501. /**
  82502. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82503. */
  82504. toggleProjectionMatrixHandInPlace(): void;
  82505. /**
  82506. * Creates a matrix from an array
  82507. * @param array defines the source array
  82508. * @param offset defines an offset in the source array
  82509. * @returns a new Matrix set from the starting index of the given array
  82510. */
  82511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82512. /**
  82513. * Copy the content of an array into a given matrix
  82514. * @param array defines the source array
  82515. * @param offset defines an offset in the source array
  82516. * @param result defines the target matrix
  82517. */
  82518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82519. /**
  82520. * Stores an array into a matrix after having multiplied each component by a given factor
  82521. * @param array defines the source array
  82522. * @param offset defines the offset in the source array
  82523. * @param scale defines the scaling factor
  82524. * @param result defines the target matrix
  82525. */
  82526. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82527. /**
  82528. * Gets an identity matrix that must not be updated
  82529. */
  82530. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82531. /**
  82532. * Stores a list of values (16) inside a given matrix
  82533. * @param initialM11 defines 1st value of 1st row
  82534. * @param initialM12 defines 2nd value of 1st row
  82535. * @param initialM13 defines 3rd value of 1st row
  82536. * @param initialM14 defines 4th value of 1st row
  82537. * @param initialM21 defines 1st value of 2nd row
  82538. * @param initialM22 defines 2nd value of 2nd row
  82539. * @param initialM23 defines 3rd value of 2nd row
  82540. * @param initialM24 defines 4th value of 2nd row
  82541. * @param initialM31 defines 1st value of 3rd row
  82542. * @param initialM32 defines 2nd value of 3rd row
  82543. * @param initialM33 defines 3rd value of 3rd row
  82544. * @param initialM34 defines 4th value of 3rd row
  82545. * @param initialM41 defines 1st value of 4th row
  82546. * @param initialM42 defines 2nd value of 4th row
  82547. * @param initialM43 defines 3rd value of 4th row
  82548. * @param initialM44 defines 4th value of 4th row
  82549. * @param result defines the target matrix
  82550. */
  82551. 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;
  82552. /**
  82553. * Creates new matrix from a list of values (16)
  82554. * @param initialM11 defines 1st value of 1st row
  82555. * @param initialM12 defines 2nd value of 1st row
  82556. * @param initialM13 defines 3rd value of 1st row
  82557. * @param initialM14 defines 4th value of 1st row
  82558. * @param initialM21 defines 1st value of 2nd row
  82559. * @param initialM22 defines 2nd value of 2nd row
  82560. * @param initialM23 defines 3rd value of 2nd row
  82561. * @param initialM24 defines 4th value of 2nd row
  82562. * @param initialM31 defines 1st value of 3rd row
  82563. * @param initialM32 defines 2nd value of 3rd row
  82564. * @param initialM33 defines 3rd value of 3rd row
  82565. * @param initialM34 defines 4th value of 3rd row
  82566. * @param initialM41 defines 1st value of 4th row
  82567. * @param initialM42 defines 2nd value of 4th row
  82568. * @param initialM43 defines 3rd value of 4th row
  82569. * @param initialM44 defines 4th value of 4th row
  82570. * @returns the new matrix
  82571. */
  82572. 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;
  82573. /**
  82574. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82575. * @param scale defines the scale vector3
  82576. * @param rotation defines the rotation quaternion
  82577. * @param translation defines the translation vector3
  82578. * @returns a new matrix
  82579. */
  82580. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82581. /**
  82582. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82583. * @param scale defines the scale vector3
  82584. * @param rotation defines the rotation quaternion
  82585. * @param translation defines the translation vector3
  82586. * @param result defines the target matrix
  82587. */
  82588. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82589. /**
  82590. * Creates a new identity matrix
  82591. * @returns a new identity matrix
  82592. */
  82593. static Identity(): Matrix;
  82594. /**
  82595. * Creates a new identity matrix and stores the result in a given matrix
  82596. * @param result defines the target matrix
  82597. */
  82598. static IdentityToRef(result: Matrix): void;
  82599. /**
  82600. * Creates a new zero matrix
  82601. * @returns a new zero matrix
  82602. */
  82603. static Zero(): Matrix;
  82604. /**
  82605. * Creates a new rotation matrix for "angle" radians around the X axis
  82606. * @param angle defines the angle (in radians) to use
  82607. * @return the new matrix
  82608. */
  82609. static RotationX(angle: number): Matrix;
  82610. /**
  82611. * Creates a new matrix as the invert of a given matrix
  82612. * @param source defines the source matrix
  82613. * @returns the new matrix
  82614. */
  82615. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82616. /**
  82617. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82618. * @param angle defines the angle (in radians) to use
  82619. * @param result defines the target matrix
  82620. */
  82621. static RotationXToRef(angle: number, result: Matrix): void;
  82622. /**
  82623. * Creates a new rotation matrix for "angle" radians around the Y axis
  82624. * @param angle defines the angle (in radians) to use
  82625. * @return the new matrix
  82626. */
  82627. static RotationY(angle: number): Matrix;
  82628. /**
  82629. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82630. * @param angle defines the angle (in radians) to use
  82631. * @param result defines the target matrix
  82632. */
  82633. static RotationYToRef(angle: number, result: Matrix): void;
  82634. /**
  82635. * Creates a new rotation matrix for "angle" radians around the Z axis
  82636. * @param angle defines the angle (in radians) to use
  82637. * @return the new matrix
  82638. */
  82639. static RotationZ(angle: number): Matrix;
  82640. /**
  82641. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82642. * @param angle defines the angle (in radians) to use
  82643. * @param result defines the target matrix
  82644. */
  82645. static RotationZToRef(angle: number, result: Matrix): void;
  82646. /**
  82647. * Creates a new rotation matrix for "angle" radians around the given axis
  82648. * @param axis defines the axis to use
  82649. * @param angle defines the angle (in radians) to use
  82650. * @return the new matrix
  82651. */
  82652. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82653. /**
  82654. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82655. * @param axis defines the axis to use
  82656. * @param angle defines the angle (in radians) to use
  82657. * @param result defines the target matrix
  82658. */
  82659. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82660. /**
  82661. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82662. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82663. * @param from defines the vector to align
  82664. * @param to defines the vector to align to
  82665. * @param result defines the target matrix
  82666. */
  82667. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82668. /**
  82669. * Creates a rotation matrix
  82670. * @param yaw defines the yaw angle in radians (Y axis)
  82671. * @param pitch defines the pitch angle in radians (X axis)
  82672. * @param roll defines the roll angle in radians (X axis)
  82673. * @returns the new rotation matrix
  82674. */
  82675. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82676. /**
  82677. * Creates a rotation matrix and stores it in a given matrix
  82678. * @param yaw defines the yaw angle in radians (Y axis)
  82679. * @param pitch defines the pitch angle in radians (X axis)
  82680. * @param roll defines the roll angle in radians (X axis)
  82681. * @param result defines the target matrix
  82682. */
  82683. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82684. /**
  82685. * Creates a scaling matrix
  82686. * @param x defines the scale factor on X axis
  82687. * @param y defines the scale factor on Y axis
  82688. * @param z defines the scale factor on Z axis
  82689. * @returns the new matrix
  82690. */
  82691. static Scaling(x: number, y: number, z: number): Matrix;
  82692. /**
  82693. * Creates a scaling matrix and stores it in a given matrix
  82694. * @param x defines the scale factor on X axis
  82695. * @param y defines the scale factor on Y axis
  82696. * @param z defines the scale factor on Z axis
  82697. * @param result defines the target matrix
  82698. */
  82699. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82700. /**
  82701. * Creates a translation matrix
  82702. * @param x defines the translation on X axis
  82703. * @param y defines the translation on Y axis
  82704. * @param z defines the translationon Z axis
  82705. * @returns the new matrix
  82706. */
  82707. static Translation(x: number, y: number, z: number): Matrix;
  82708. /**
  82709. * Creates a translation matrix and stores it in a given matrix
  82710. * @param x defines the translation on X axis
  82711. * @param y defines the translation on Y axis
  82712. * @param z defines the translationon Z axis
  82713. * @param result defines the target matrix
  82714. */
  82715. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82716. /**
  82717. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82718. * @param startValue defines the start value
  82719. * @param endValue defines the end value
  82720. * @param gradient defines the gradient factor
  82721. * @returns the new matrix
  82722. */
  82723. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82724. /**
  82725. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82726. * @param startValue defines the start value
  82727. * @param endValue defines the end value
  82728. * @param gradient defines the gradient factor
  82729. * @param result defines the Matrix object where to store data
  82730. */
  82731. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82732. /**
  82733. * Builds a new matrix whose values are computed by:
  82734. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82735. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82736. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82737. * @param startValue defines the first matrix
  82738. * @param endValue defines the second matrix
  82739. * @param gradient defines the gradient between the two matrices
  82740. * @returns the new matrix
  82741. */
  82742. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82743. /**
  82744. * Update a matrix to values which are computed by:
  82745. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82746. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82747. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82748. * @param startValue defines the first matrix
  82749. * @param endValue defines the second matrix
  82750. * @param gradient defines the gradient between the two matrices
  82751. * @param result defines the target matrix
  82752. */
  82753. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82754. /**
  82755. * 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"
  82756. * This function works in left handed mode
  82757. * @param eye defines the final position of the entity
  82758. * @param target defines where the entity should look at
  82759. * @param up defines the up vector for the entity
  82760. * @returns the new matrix
  82761. */
  82762. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82763. /**
  82764. * 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".
  82765. * This function works in left handed mode
  82766. * @param eye defines the final position of the entity
  82767. * @param target defines where the entity should look at
  82768. * @param up defines the up vector for the entity
  82769. * @param result defines the target matrix
  82770. */
  82771. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82772. /**
  82773. * 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"
  82774. * This function works in right handed mode
  82775. * @param eye defines the final position of the entity
  82776. * @param target defines where the entity should look at
  82777. * @param up defines the up vector for the entity
  82778. * @returns the new matrix
  82779. */
  82780. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82781. /**
  82782. * 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".
  82783. * This function works in right handed mode
  82784. * @param eye defines the final position of the entity
  82785. * @param target defines where the entity should look at
  82786. * @param up defines the up vector for the entity
  82787. * @param result defines the target matrix
  82788. */
  82789. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82790. /**
  82791. * Create a left-handed orthographic projection matrix
  82792. * @param width defines the viewport width
  82793. * @param height defines the viewport height
  82794. * @param znear defines the near clip plane
  82795. * @param zfar defines the far clip plane
  82796. * @returns a new matrix as a left-handed orthographic projection matrix
  82797. */
  82798. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82799. /**
  82800. * Store a left-handed orthographic projection to a given matrix
  82801. * @param width defines the viewport width
  82802. * @param height defines the viewport height
  82803. * @param znear defines the near clip plane
  82804. * @param zfar defines the far clip plane
  82805. * @param result defines the target matrix
  82806. */
  82807. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82808. /**
  82809. * Create a left-handed orthographic projection matrix
  82810. * @param left defines the viewport left coordinate
  82811. * @param right defines the viewport right coordinate
  82812. * @param bottom defines the viewport bottom coordinate
  82813. * @param top defines the viewport top coordinate
  82814. * @param znear defines the near clip plane
  82815. * @param zfar defines the far clip plane
  82816. * @returns a new matrix as a left-handed orthographic projection matrix
  82817. */
  82818. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82819. /**
  82820. * Stores a left-handed orthographic projection into a given matrix
  82821. * @param left defines the viewport left coordinate
  82822. * @param right defines the viewport right coordinate
  82823. * @param bottom defines the viewport bottom coordinate
  82824. * @param top defines the viewport top coordinate
  82825. * @param znear defines the near clip plane
  82826. * @param zfar defines the far clip plane
  82827. * @param result defines the target matrix
  82828. */
  82829. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82830. /**
  82831. * Creates a right-handed orthographic projection matrix
  82832. * @param left defines the viewport left coordinate
  82833. * @param right defines the viewport right coordinate
  82834. * @param bottom defines the viewport bottom coordinate
  82835. * @param top defines the viewport top coordinate
  82836. * @param znear defines the near clip plane
  82837. * @param zfar defines the far clip plane
  82838. * @returns a new matrix as a right-handed orthographic projection matrix
  82839. */
  82840. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82841. /**
  82842. * Stores a right-handed orthographic projection into a given matrix
  82843. * @param left defines the viewport left coordinate
  82844. * @param right defines the viewport right coordinate
  82845. * @param bottom defines the viewport bottom coordinate
  82846. * @param top defines the viewport top coordinate
  82847. * @param znear defines the near clip plane
  82848. * @param zfar defines the far clip plane
  82849. * @param result defines the target matrix
  82850. */
  82851. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82852. /**
  82853. * Creates a left-handed perspective projection matrix
  82854. * @param width defines the viewport width
  82855. * @param height defines the viewport height
  82856. * @param znear defines the near clip plane
  82857. * @param zfar defines the far clip plane
  82858. * @returns a new matrix as a left-handed perspective projection matrix
  82859. */
  82860. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82861. /**
  82862. * Creates a left-handed perspective projection matrix
  82863. * @param fov defines the horizontal field of view
  82864. * @param aspect defines the aspect ratio
  82865. * @param znear defines the near clip plane
  82866. * @param zfar defines the far clip plane
  82867. * @returns a new matrix as a left-handed perspective projection matrix
  82868. */
  82869. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82870. /**
  82871. * Stores a left-handed perspective projection into a given matrix
  82872. * @param fov defines the horizontal field of view
  82873. * @param aspect defines the aspect ratio
  82874. * @param znear defines the near clip plane
  82875. * @param zfar defines the far clip plane
  82876. * @param result defines the target matrix
  82877. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82878. */
  82879. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82880. /**
  82881. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82882. * @param fov defines the horizontal field of view
  82883. * @param aspect defines the aspect ratio
  82884. * @param znear defines the near clip plane
  82885. * @param zfar not used as infinity is used as far clip
  82886. * @param result defines the target matrix
  82887. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82888. */
  82889. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82890. /**
  82891. * Creates a right-handed perspective projection matrix
  82892. * @param fov defines the horizontal field of view
  82893. * @param aspect defines the aspect ratio
  82894. * @param znear defines the near clip plane
  82895. * @param zfar defines the far clip plane
  82896. * @returns a new matrix as a right-handed perspective projection matrix
  82897. */
  82898. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82899. /**
  82900. * Stores a right-handed perspective projection into a given matrix
  82901. * @param fov defines the horizontal field of view
  82902. * @param aspect defines the aspect ratio
  82903. * @param znear defines the near clip plane
  82904. * @param zfar defines the far clip plane
  82905. * @param result defines the target matrix
  82906. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82907. */
  82908. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82909. /**
  82910. * Stores a right-handed perspective projection into a given matrix
  82911. * @param fov defines the horizontal field of view
  82912. * @param aspect defines the aspect ratio
  82913. * @param znear defines the near clip plane
  82914. * @param zfar not used as infinity is used as far clip
  82915. * @param result defines the target matrix
  82916. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82917. */
  82918. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82919. /**
  82920. * Stores a perspective projection for WebVR info a given matrix
  82921. * @param fov defines the field of view
  82922. * @param znear defines the near clip plane
  82923. * @param zfar defines the far clip plane
  82924. * @param result defines the target matrix
  82925. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82926. */
  82927. static PerspectiveFovWebVRToRef(fov: {
  82928. upDegrees: number;
  82929. downDegrees: number;
  82930. leftDegrees: number;
  82931. rightDegrees: number;
  82932. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82933. /**
  82934. * Computes a complete transformation matrix
  82935. * @param viewport defines the viewport to use
  82936. * @param world defines the world matrix
  82937. * @param view defines the view matrix
  82938. * @param projection defines the projection matrix
  82939. * @param zmin defines the near clip plane
  82940. * @param zmax defines the far clip plane
  82941. * @returns the transformation matrix
  82942. */
  82943. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82944. /**
  82945. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82946. * @param matrix defines the matrix to use
  82947. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82948. */
  82949. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82950. /**
  82951. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82952. * @param matrix defines the matrix to use
  82953. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82954. */
  82955. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82956. /**
  82957. * Compute the transpose of a given matrix
  82958. * @param matrix defines the matrix to transpose
  82959. * @returns the new matrix
  82960. */
  82961. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82962. /**
  82963. * Compute the transpose of a matrix and store it in a target matrix
  82964. * @param matrix defines the matrix to transpose
  82965. * @param result defines the target matrix
  82966. */
  82967. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82968. /**
  82969. * Computes a reflection matrix from a plane
  82970. * @param plane defines the reflection plane
  82971. * @returns a new matrix
  82972. */
  82973. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82974. /**
  82975. * Computes a reflection matrix from a plane
  82976. * @param plane defines the reflection plane
  82977. * @param result defines the target matrix
  82978. */
  82979. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82980. /**
  82981. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82982. * @param xaxis defines the value of the 1st axis
  82983. * @param yaxis defines the value of the 2nd axis
  82984. * @param zaxis defines the value of the 3rd axis
  82985. * @param result defines the target matrix
  82986. */
  82987. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82988. /**
  82989. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82990. * @param quat defines the quaternion to use
  82991. * @param result defines the target matrix
  82992. */
  82993. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82994. }
  82995. /**
  82996. * @hidden
  82997. */
  82998. export class TmpVectors {
  82999. static Vector2: Vector2[];
  83000. static Vector3: Vector3[];
  83001. static Vector4: Vector4[];
  83002. static Quaternion: Quaternion[];
  83003. static Matrix: Matrix[];
  83004. }
  83005. }
  83006. declare module BABYLON {
  83007. /**
  83008. * Defines potential orientation for back face culling
  83009. */
  83010. export enum Orientation {
  83011. /**
  83012. * Clockwise
  83013. */
  83014. CW = 0,
  83015. /** Counter clockwise */
  83016. CCW = 1
  83017. }
  83018. /** Class used to represent a Bezier curve */
  83019. export class BezierCurve {
  83020. /**
  83021. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83022. * @param t defines the time
  83023. * @param x1 defines the left coordinate on X axis
  83024. * @param y1 defines the left coordinate on Y axis
  83025. * @param x2 defines the right coordinate on X axis
  83026. * @param y2 defines the right coordinate on Y axis
  83027. * @returns the interpolated value
  83028. */
  83029. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83030. }
  83031. /**
  83032. * Defines angle representation
  83033. */
  83034. export class Angle {
  83035. private _radians;
  83036. /**
  83037. * Creates an Angle object of "radians" radians (float).
  83038. * @param radians the angle in radians
  83039. */
  83040. constructor(radians: number);
  83041. /**
  83042. * Get value in degrees
  83043. * @returns the Angle value in degrees (float)
  83044. */
  83045. degrees(): number;
  83046. /**
  83047. * Get value in radians
  83048. * @returns the Angle value in radians (float)
  83049. */
  83050. radians(): number;
  83051. /**
  83052. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  83053. * @param a defines first vector
  83054. * @param b defines second vector
  83055. * @returns a new Angle
  83056. */
  83057. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83058. /**
  83059. * Gets a new Angle object from the given float in radians
  83060. * @param radians defines the angle value in radians
  83061. * @returns a new Angle
  83062. */
  83063. static FromRadians(radians: number): Angle;
  83064. /**
  83065. * Gets a new Angle object from the given float in degrees
  83066. * @param degrees defines the angle value in degrees
  83067. * @returns a new Angle
  83068. */
  83069. static FromDegrees(degrees: number): Angle;
  83070. }
  83071. /**
  83072. * This represents an arc in a 2d space.
  83073. */
  83074. export class Arc2 {
  83075. /** Defines the start point of the arc */
  83076. startPoint: Vector2;
  83077. /** Defines the mid point of the arc */
  83078. midPoint: Vector2;
  83079. /** Defines the end point of the arc */
  83080. endPoint: Vector2;
  83081. /**
  83082. * Defines the center point of the arc.
  83083. */
  83084. centerPoint: Vector2;
  83085. /**
  83086. * Defines the radius of the arc.
  83087. */
  83088. radius: number;
  83089. /**
  83090. * Defines the angle of the arc (from mid point to end point).
  83091. */
  83092. angle: Angle;
  83093. /**
  83094. * Defines the start angle of the arc (from start point to middle point).
  83095. */
  83096. startAngle: Angle;
  83097. /**
  83098. * Defines the orientation of the arc (clock wise/counter clock wise).
  83099. */
  83100. orientation: Orientation;
  83101. /**
  83102. * Creates an Arc object from the three given points : start, middle and end.
  83103. * @param startPoint Defines the start point of the arc
  83104. * @param midPoint Defines the midlle point of the arc
  83105. * @param endPoint Defines the end point of the arc
  83106. */
  83107. constructor(
  83108. /** Defines the start point of the arc */
  83109. startPoint: Vector2,
  83110. /** Defines the mid point of the arc */
  83111. midPoint: Vector2,
  83112. /** Defines the end point of the arc */
  83113. endPoint: Vector2);
  83114. }
  83115. /**
  83116. * Represents a 2D path made up of multiple 2D points
  83117. */
  83118. export class Path2 {
  83119. private _points;
  83120. private _length;
  83121. /**
  83122. * If the path start and end point are the same
  83123. */
  83124. closed: boolean;
  83125. /**
  83126. * Creates a Path2 object from the starting 2D coordinates x and y.
  83127. * @param x the starting points x value
  83128. * @param y the starting points y value
  83129. */
  83130. constructor(x: number, y: number);
  83131. /**
  83132. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83133. * @param x the added points x value
  83134. * @param y the added points y value
  83135. * @returns the updated Path2.
  83136. */
  83137. addLineTo(x: number, y: number): Path2;
  83138. /**
  83139. * 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.
  83140. * @param midX middle point x value
  83141. * @param midY middle point y value
  83142. * @param endX end point x value
  83143. * @param endY end point y value
  83144. * @param numberOfSegments (default: 36)
  83145. * @returns the updated Path2.
  83146. */
  83147. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83148. /**
  83149. * Closes the Path2.
  83150. * @returns the Path2.
  83151. */
  83152. close(): Path2;
  83153. /**
  83154. * Gets the sum of the distance between each sequential point in the path
  83155. * @returns the Path2 total length (float).
  83156. */
  83157. length(): number;
  83158. /**
  83159. * Gets the points which construct the path
  83160. * @returns the Path2 internal array of points.
  83161. */
  83162. getPoints(): Vector2[];
  83163. /**
  83164. * Retreives the point at the distance aways from the starting point
  83165. * @param normalizedLengthPosition the length along the path to retreive the point from
  83166. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83167. */
  83168. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83169. /**
  83170. * Creates a new path starting from an x and y position
  83171. * @param x starting x value
  83172. * @param y starting y value
  83173. * @returns a new Path2 starting at the coordinates (x, y).
  83174. */
  83175. static StartingAt(x: number, y: number): Path2;
  83176. }
  83177. /**
  83178. * Represents a 3D path made up of multiple 3D points
  83179. */
  83180. export class Path3D {
  83181. /**
  83182. * an array of Vector3, the curve axis of the Path3D
  83183. */
  83184. path: Vector3[];
  83185. private _curve;
  83186. private _distances;
  83187. private _tangents;
  83188. private _normals;
  83189. private _binormals;
  83190. private _raw;
  83191. private _alignTangentsWithPath;
  83192. private readonly _pointAtData;
  83193. /**
  83194. * new Path3D(path, normal, raw)
  83195. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83196. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83197. * @param path an array of Vector3, the curve axis of the Path3D
  83198. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83199. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83200. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83201. */
  83202. constructor(
  83203. /**
  83204. * an array of Vector3, the curve axis of the Path3D
  83205. */
  83206. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83207. /**
  83208. * Returns the Path3D array of successive Vector3 designing its curve.
  83209. * @returns the Path3D array of successive Vector3 designing its curve.
  83210. */
  83211. getCurve(): Vector3[];
  83212. /**
  83213. * Returns the Path3D array of successive Vector3 designing its curve.
  83214. * @returns the Path3D array of successive Vector3 designing its curve.
  83215. */
  83216. getPoints(): Vector3[];
  83217. /**
  83218. * @returns the computed length (float) of the path.
  83219. */
  83220. length(): number;
  83221. /**
  83222. * Returns an array populated with tangent vectors on each Path3D curve point.
  83223. * @returns an array populated with tangent vectors on each Path3D curve point.
  83224. */
  83225. getTangents(): Vector3[];
  83226. /**
  83227. * Returns an array populated with normal vectors on each Path3D curve point.
  83228. * @returns an array populated with normal vectors on each Path3D curve point.
  83229. */
  83230. getNormals(): Vector3[];
  83231. /**
  83232. * Returns an array populated with binormal vectors on each Path3D curve point.
  83233. * @returns an array populated with binormal vectors on each Path3D curve point.
  83234. */
  83235. getBinormals(): Vector3[];
  83236. /**
  83237. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83238. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83239. */
  83240. getDistances(): number[];
  83241. /**
  83242. * Returns an interpolated point along this path
  83243. * @param position the position of the point along this path, from 0.0 to 1.0
  83244. * @returns a new Vector3 as the point
  83245. */
  83246. getPointAt(position: number): Vector3;
  83247. /**
  83248. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83249. * @param position the position of the point along this path, from 0.0 to 1.0
  83250. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83251. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83252. */
  83253. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83254. /**
  83255. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83256. * @param position the position of the point along this path, from 0.0 to 1.0
  83257. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83258. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83259. */
  83260. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83261. /**
  83262. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83263. * @param position the position of the point along this path, from 0.0 to 1.0
  83264. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83265. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83266. */
  83267. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83268. /**
  83269. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83270. * @param position the position of the point along this path, from 0.0 to 1.0
  83271. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83272. */
  83273. getDistanceAt(position: number): number;
  83274. /**
  83275. * Returns the array index of the previous point of an interpolated point along this path
  83276. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83277. * @returns the array index
  83278. */
  83279. getPreviousPointIndexAt(position: number): number;
  83280. /**
  83281. * 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)
  83282. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83283. * @returns the sub position
  83284. */
  83285. getSubPositionAt(position: number): number;
  83286. /**
  83287. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83288. * @param target the vector of which to get the closest position to
  83289. * @returns the position of the closest virtual point on this path to the target vector
  83290. */
  83291. getClosestPositionTo(target: Vector3): number;
  83292. /**
  83293. * Returns a sub path (slice) of this path
  83294. * @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
  83295. * @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
  83296. * @returns a sub path (slice) of this path
  83297. */
  83298. slice(start?: number, end?: number): Path3D;
  83299. /**
  83300. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83301. * @param path path which all values are copied into the curves points
  83302. * @param firstNormal which should be projected onto the curve
  83303. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83304. * @returns the same object updated.
  83305. */
  83306. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83307. private _compute;
  83308. private _getFirstNonNullVector;
  83309. private _getLastNonNullVector;
  83310. private _normalVector;
  83311. /**
  83312. * Updates the point at data for an interpolated point along this curve
  83313. * @param position the position of the point along this curve, from 0.0 to 1.0
  83314. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83315. * @returns the (updated) point at data
  83316. */
  83317. private _updatePointAtData;
  83318. /**
  83319. * Updates the point at data from the specified parameters
  83320. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83321. * @param point the interpolated point
  83322. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83323. */
  83324. private _setPointAtData;
  83325. /**
  83326. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83327. */
  83328. private _updateInterpolationMatrix;
  83329. }
  83330. /**
  83331. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83332. * A Curve3 is designed from a series of successive Vector3.
  83333. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83334. */
  83335. export class Curve3 {
  83336. private _points;
  83337. private _length;
  83338. /**
  83339. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83340. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83341. * @param v1 (Vector3) the control point
  83342. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83343. * @param nbPoints (integer) the wanted number of points in the curve
  83344. * @returns the created Curve3
  83345. */
  83346. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83347. /**
  83348. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83349. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83350. * @param v1 (Vector3) the first control point
  83351. * @param v2 (Vector3) the second control point
  83352. * @param v3 (Vector3) the end point of the Cubic Bezier
  83353. * @param nbPoints (integer) the wanted number of points in the curve
  83354. * @returns the created Curve3
  83355. */
  83356. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83357. /**
  83358. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83359. * @param p1 (Vector3) the origin point of the Hermite Spline
  83360. * @param t1 (Vector3) the tangent vector at the origin point
  83361. * @param p2 (Vector3) the end point of the Hermite Spline
  83362. * @param t2 (Vector3) the tangent vector at the end point
  83363. * @param nbPoints (integer) the wanted number of points in the curve
  83364. * @returns the created Curve3
  83365. */
  83366. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83367. /**
  83368. * Returns a Curve3 object along a CatmullRom Spline curve :
  83369. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83370. * @param nbPoints (integer) the wanted number of points between each curve control points
  83371. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83372. * @returns the created Curve3
  83373. */
  83374. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83375. /**
  83376. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83377. * A Curve3 is designed from a series of successive Vector3.
  83378. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83379. * @param points points which make up the curve
  83380. */
  83381. constructor(points: Vector3[]);
  83382. /**
  83383. * @returns the Curve3 stored array of successive Vector3
  83384. */
  83385. getPoints(): Vector3[];
  83386. /**
  83387. * @returns the computed length (float) of the curve.
  83388. */
  83389. length(): number;
  83390. /**
  83391. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83392. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83393. * curveA and curveB keep unchanged.
  83394. * @param curve the curve to continue from this curve
  83395. * @returns the newly constructed curve
  83396. */
  83397. continue(curve: DeepImmutable<Curve3>): Curve3;
  83398. private _computeLength;
  83399. }
  83400. }
  83401. declare module BABYLON {
  83402. /**
  83403. * This represents the main contract an easing function should follow.
  83404. * Easing functions are used throughout the animation system.
  83405. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83406. */
  83407. export interface IEasingFunction {
  83408. /**
  83409. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83410. * of the easing function.
  83411. * The link below provides some of the most common examples of easing functions.
  83412. * @see https://easings.net/
  83413. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83414. * @returns the corresponding value on the curve defined by the easing function
  83415. */
  83416. ease(gradient: number): number;
  83417. }
  83418. /**
  83419. * Base class used for every default easing function.
  83420. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83421. */
  83422. export class EasingFunction implements IEasingFunction {
  83423. /**
  83424. * Interpolation follows the mathematical formula associated with the easing function.
  83425. */
  83426. static readonly EASINGMODE_EASEIN: number;
  83427. /**
  83428. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83429. */
  83430. static readonly EASINGMODE_EASEOUT: number;
  83431. /**
  83432. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83433. */
  83434. static readonly EASINGMODE_EASEINOUT: number;
  83435. private _easingMode;
  83436. /**
  83437. * Sets the easing mode of the current function.
  83438. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83439. */
  83440. setEasingMode(easingMode: number): void;
  83441. /**
  83442. * Gets the current easing mode.
  83443. * @returns the easing mode
  83444. */
  83445. getEasingMode(): number;
  83446. /**
  83447. * @hidden
  83448. */
  83449. easeInCore(gradient: number): number;
  83450. /**
  83451. * Given an input gradient between 0 and 1, this returns the corresponding value
  83452. * of the easing function.
  83453. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83454. * @returns the corresponding value on the curve defined by the easing function
  83455. */
  83456. ease(gradient: number): number;
  83457. }
  83458. /**
  83459. * Easing function with a circle shape (see link below).
  83460. * @see https://easings.net/#easeInCirc
  83461. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83462. */
  83463. export class CircleEase extends EasingFunction implements IEasingFunction {
  83464. /** @hidden */
  83465. easeInCore(gradient: number): number;
  83466. }
  83467. /**
  83468. * Easing function with a ease back shape (see link below).
  83469. * @see https://easings.net/#easeInBack
  83470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83471. */
  83472. export class BackEase extends EasingFunction implements IEasingFunction {
  83473. /** Defines the amplitude of the function */
  83474. amplitude: number;
  83475. /**
  83476. * Instantiates a back ease easing
  83477. * @see https://easings.net/#easeInBack
  83478. * @param amplitude Defines the amplitude of the function
  83479. */
  83480. constructor(
  83481. /** Defines the amplitude of the function */
  83482. amplitude?: number);
  83483. /** @hidden */
  83484. easeInCore(gradient: number): number;
  83485. }
  83486. /**
  83487. * Easing function with a bouncing shape (see link below).
  83488. * @see https://easings.net/#easeInBounce
  83489. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83490. */
  83491. export class BounceEase extends EasingFunction implements IEasingFunction {
  83492. /** Defines the number of bounces */
  83493. bounces: number;
  83494. /** Defines the amplitude of the bounce */
  83495. bounciness: number;
  83496. /**
  83497. * Instantiates a bounce easing
  83498. * @see https://easings.net/#easeInBounce
  83499. * @param bounces Defines the number of bounces
  83500. * @param bounciness Defines the amplitude of the bounce
  83501. */
  83502. constructor(
  83503. /** Defines the number of bounces */
  83504. bounces?: number,
  83505. /** Defines the amplitude of the bounce */
  83506. bounciness?: number);
  83507. /** @hidden */
  83508. easeInCore(gradient: number): number;
  83509. }
  83510. /**
  83511. * Easing function with a power of 3 shape (see link below).
  83512. * @see https://easings.net/#easeInCubic
  83513. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83514. */
  83515. export class CubicEase extends EasingFunction implements IEasingFunction {
  83516. /** @hidden */
  83517. easeInCore(gradient: number): number;
  83518. }
  83519. /**
  83520. * Easing function with an elastic shape (see link below).
  83521. * @see https://easings.net/#easeInElastic
  83522. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83523. */
  83524. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83525. /** Defines the number of oscillations*/
  83526. oscillations: number;
  83527. /** Defines the amplitude of the oscillations*/
  83528. springiness: number;
  83529. /**
  83530. * Instantiates an elastic easing function
  83531. * @see https://easings.net/#easeInElastic
  83532. * @param oscillations Defines the number of oscillations
  83533. * @param springiness Defines the amplitude of the oscillations
  83534. */
  83535. constructor(
  83536. /** Defines the number of oscillations*/
  83537. oscillations?: number,
  83538. /** Defines the amplitude of the oscillations*/
  83539. springiness?: number);
  83540. /** @hidden */
  83541. easeInCore(gradient: number): number;
  83542. }
  83543. /**
  83544. * Easing function with an exponential shape (see link below).
  83545. * @see https://easings.net/#easeInExpo
  83546. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83547. */
  83548. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83549. /** Defines the exponent of the function */
  83550. exponent: number;
  83551. /**
  83552. * Instantiates an exponential easing function
  83553. * @see https://easings.net/#easeInExpo
  83554. * @param exponent Defines the exponent of the function
  83555. */
  83556. constructor(
  83557. /** Defines the exponent of the function */
  83558. exponent?: number);
  83559. /** @hidden */
  83560. easeInCore(gradient: number): number;
  83561. }
  83562. /**
  83563. * Easing function with a power shape (see link below).
  83564. * @see https://easings.net/#easeInQuad
  83565. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83566. */
  83567. export class PowerEase extends EasingFunction implements IEasingFunction {
  83568. /** Defines the power of the function */
  83569. power: number;
  83570. /**
  83571. * Instantiates an power base easing function
  83572. * @see https://easings.net/#easeInQuad
  83573. * @param power Defines the power of the function
  83574. */
  83575. constructor(
  83576. /** Defines the power of the function */
  83577. power?: number);
  83578. /** @hidden */
  83579. easeInCore(gradient: number): number;
  83580. }
  83581. /**
  83582. * Easing function with a power of 2 shape (see link below).
  83583. * @see https://easings.net/#easeInQuad
  83584. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83585. */
  83586. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83587. /** @hidden */
  83588. easeInCore(gradient: number): number;
  83589. }
  83590. /**
  83591. * Easing function with a power of 4 shape (see link below).
  83592. * @see https://easings.net/#easeInQuart
  83593. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83594. */
  83595. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83596. /** @hidden */
  83597. easeInCore(gradient: number): number;
  83598. }
  83599. /**
  83600. * Easing function with a power of 5 shape (see link below).
  83601. * @see https://easings.net/#easeInQuint
  83602. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83603. */
  83604. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83605. /** @hidden */
  83606. easeInCore(gradient: number): number;
  83607. }
  83608. /**
  83609. * Easing function with a sin shape (see link below).
  83610. * @see https://easings.net/#easeInSine
  83611. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83612. */
  83613. export class SineEase extends EasingFunction implements IEasingFunction {
  83614. /** @hidden */
  83615. easeInCore(gradient: number): number;
  83616. }
  83617. /**
  83618. * Easing function with a bezier shape (see link below).
  83619. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83620. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83621. */
  83622. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83623. /** Defines the x component of the start tangent in the bezier curve */
  83624. x1: number;
  83625. /** Defines the y component of the start tangent in the bezier curve */
  83626. y1: number;
  83627. /** Defines the x component of the end tangent in the bezier curve */
  83628. x2: number;
  83629. /** Defines the y component of the end tangent in the bezier curve */
  83630. y2: number;
  83631. /**
  83632. * Instantiates a bezier function
  83633. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83634. * @param x1 Defines the x component of the start tangent in the bezier curve
  83635. * @param y1 Defines the y component of the start tangent in the bezier curve
  83636. * @param x2 Defines the x component of the end tangent in the bezier curve
  83637. * @param y2 Defines the y component of the end tangent in the bezier curve
  83638. */
  83639. constructor(
  83640. /** Defines the x component of the start tangent in the bezier curve */
  83641. x1?: number,
  83642. /** Defines the y component of the start tangent in the bezier curve */
  83643. y1?: number,
  83644. /** Defines the x component of the end tangent in the bezier curve */
  83645. x2?: number,
  83646. /** Defines the y component of the end tangent in the bezier curve */
  83647. y2?: number);
  83648. /** @hidden */
  83649. easeInCore(gradient: number): number;
  83650. }
  83651. }
  83652. declare module BABYLON {
  83653. /**
  83654. * Class used to hold a RBG color
  83655. */
  83656. export class Color3 {
  83657. /**
  83658. * Defines the red component (between 0 and 1, default is 0)
  83659. */
  83660. r: number;
  83661. /**
  83662. * Defines the green component (between 0 and 1, default is 0)
  83663. */
  83664. g: number;
  83665. /**
  83666. * Defines the blue component (between 0 and 1, default is 0)
  83667. */
  83668. b: number;
  83669. /**
  83670. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83671. * @param r defines the red component (between 0 and 1, default is 0)
  83672. * @param g defines the green component (between 0 and 1, default is 0)
  83673. * @param b defines the blue component (between 0 and 1, default is 0)
  83674. */
  83675. constructor(
  83676. /**
  83677. * Defines the red component (between 0 and 1, default is 0)
  83678. */
  83679. r?: number,
  83680. /**
  83681. * Defines the green component (between 0 and 1, default is 0)
  83682. */
  83683. g?: number,
  83684. /**
  83685. * Defines the blue component (between 0 and 1, default is 0)
  83686. */
  83687. b?: number);
  83688. /**
  83689. * Creates a string with the Color3 current values
  83690. * @returns the string representation of the Color3 object
  83691. */
  83692. toString(): string;
  83693. /**
  83694. * Returns the string "Color3"
  83695. * @returns "Color3"
  83696. */
  83697. getClassName(): string;
  83698. /**
  83699. * Compute the Color3 hash code
  83700. * @returns an unique number that can be used to hash Color3 objects
  83701. */
  83702. getHashCode(): number;
  83703. /**
  83704. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83705. * @param array defines the array where to store the r,g,b components
  83706. * @param index defines an optional index in the target array to define where to start storing values
  83707. * @returns the current Color3 object
  83708. */
  83709. toArray(array: FloatArray, index?: number): Color3;
  83710. /**
  83711. * Returns a new Color4 object from the current Color3 and the given alpha
  83712. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83713. * @returns a new Color4 object
  83714. */
  83715. toColor4(alpha?: number): Color4;
  83716. /**
  83717. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83718. * @returns the new array
  83719. */
  83720. asArray(): number[];
  83721. /**
  83722. * Returns the luminance value
  83723. * @returns a float value
  83724. */
  83725. toLuminance(): number;
  83726. /**
  83727. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83728. * @param otherColor defines the second operand
  83729. * @returns the new Color3 object
  83730. */
  83731. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83732. /**
  83733. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83734. * @param otherColor defines the second operand
  83735. * @param result defines the Color3 object where to store the result
  83736. * @returns the current Color3
  83737. */
  83738. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83739. /**
  83740. * Determines equality between Color3 objects
  83741. * @param otherColor defines the second operand
  83742. * @returns true if the rgb values are equal to the given ones
  83743. */
  83744. equals(otherColor: DeepImmutable<Color3>): boolean;
  83745. /**
  83746. * Determines equality between the current Color3 object and a set of r,b,g values
  83747. * @param r defines the red component to check
  83748. * @param g defines the green component to check
  83749. * @param b defines the blue component to check
  83750. * @returns true if the rgb values are equal to the given ones
  83751. */
  83752. equalsFloats(r: number, g: number, b: number): boolean;
  83753. /**
  83754. * Multiplies in place each rgb value by scale
  83755. * @param scale defines the scaling factor
  83756. * @returns the updated Color3
  83757. */
  83758. scale(scale: number): Color3;
  83759. /**
  83760. * Multiplies the rgb values by scale and stores the result into "result"
  83761. * @param scale defines the scaling factor
  83762. * @param result defines the Color3 object where to store the result
  83763. * @returns the unmodified current Color3
  83764. */
  83765. scaleToRef(scale: number, result: Color3): Color3;
  83766. /**
  83767. * Scale the current Color3 values by a factor and add the result to a given Color3
  83768. * @param scale defines the scale factor
  83769. * @param result defines color to store the result into
  83770. * @returns the unmodified current Color3
  83771. */
  83772. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83773. /**
  83774. * Clamps the rgb values by the min and max values and stores the result into "result"
  83775. * @param min defines minimum clamping value (default is 0)
  83776. * @param max defines maximum clamping value (default is 1)
  83777. * @param result defines color to store the result into
  83778. * @returns the original Color3
  83779. */
  83780. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83781. /**
  83782. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83783. * @param otherColor defines the second operand
  83784. * @returns the new Color3
  83785. */
  83786. add(otherColor: DeepImmutable<Color3>): Color3;
  83787. /**
  83788. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83789. * @param otherColor defines the second operand
  83790. * @param result defines Color3 object to store the result into
  83791. * @returns the unmodified current Color3
  83792. */
  83793. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83794. /**
  83795. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83796. * @param otherColor defines the second operand
  83797. * @returns the new Color3
  83798. */
  83799. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83800. /**
  83801. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83802. * @param otherColor defines the second operand
  83803. * @param result defines Color3 object to store the result into
  83804. * @returns the unmodified current Color3
  83805. */
  83806. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83807. /**
  83808. * Copy the current object
  83809. * @returns a new Color3 copied the current one
  83810. */
  83811. clone(): Color3;
  83812. /**
  83813. * Copies the rgb values from the source in the current Color3
  83814. * @param source defines the source Color3 object
  83815. * @returns the updated Color3 object
  83816. */
  83817. copyFrom(source: DeepImmutable<Color3>): Color3;
  83818. /**
  83819. * Updates the Color3 rgb values from the given floats
  83820. * @param r defines the red component to read from
  83821. * @param g defines the green component to read from
  83822. * @param b defines the blue component to read from
  83823. * @returns the current Color3 object
  83824. */
  83825. copyFromFloats(r: number, g: number, b: number): Color3;
  83826. /**
  83827. * Updates the Color3 rgb values from the given floats
  83828. * @param r defines the red component to read from
  83829. * @param g defines the green component to read from
  83830. * @param b defines the blue component to read from
  83831. * @returns the current Color3 object
  83832. */
  83833. set(r: number, g: number, b: number): Color3;
  83834. /**
  83835. * Compute the Color3 hexadecimal code as a string
  83836. * @returns a string containing the hexadecimal representation of the Color3 object
  83837. */
  83838. toHexString(): string;
  83839. /**
  83840. * Computes a new Color3 converted from the current one to linear space
  83841. * @returns a new Color3 object
  83842. */
  83843. toLinearSpace(): Color3;
  83844. /**
  83845. * Converts current color in rgb space to HSV values
  83846. * @returns a new color3 representing the HSV values
  83847. */
  83848. toHSV(): Color3;
  83849. /**
  83850. * Converts current color in rgb space to HSV values
  83851. * @param result defines the Color3 where to store the HSV values
  83852. */
  83853. toHSVToRef(result: Color3): void;
  83854. /**
  83855. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83856. * @param convertedColor defines the Color3 object where to store the linear space version
  83857. * @returns the unmodified Color3
  83858. */
  83859. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83860. /**
  83861. * Computes a new Color3 converted from the current one to gamma space
  83862. * @returns a new Color3 object
  83863. */
  83864. toGammaSpace(): Color3;
  83865. /**
  83866. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83867. * @param convertedColor defines the Color3 object where to store the gamma space version
  83868. * @returns the unmodified Color3
  83869. */
  83870. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83871. private static _BlackReadOnly;
  83872. /**
  83873. * Convert Hue, saturation and value to a Color3 (RGB)
  83874. * @param hue defines the hue
  83875. * @param saturation defines the saturation
  83876. * @param value defines the value
  83877. * @param result defines the Color3 where to store the RGB values
  83878. */
  83879. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83880. /**
  83881. * Creates a new Color3 from the string containing valid hexadecimal values
  83882. * @param hex defines a string containing valid hexadecimal values
  83883. * @returns a new Color3 object
  83884. */
  83885. static FromHexString(hex: string): Color3;
  83886. /**
  83887. * Creates a new Color3 from the starting index of the given array
  83888. * @param array defines the source array
  83889. * @param offset defines an offset in the source array
  83890. * @returns a new Color3 object
  83891. */
  83892. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83893. /**
  83894. * Creates a new Color3 from integer values (< 256)
  83895. * @param r defines the red component to read from (value between 0 and 255)
  83896. * @param g defines the green component to read from (value between 0 and 255)
  83897. * @param b defines the blue component to read from (value between 0 and 255)
  83898. * @returns a new Color3 object
  83899. */
  83900. static FromInts(r: number, g: number, b: number): Color3;
  83901. /**
  83902. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83903. * @param start defines the start Color3 value
  83904. * @param end defines the end Color3 value
  83905. * @param amount defines the gradient value between start and end
  83906. * @returns a new Color3 object
  83907. */
  83908. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83909. /**
  83910. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83911. * @param left defines the start value
  83912. * @param right defines the end value
  83913. * @param amount defines the gradient factor
  83914. * @param result defines the Color3 object where to store the result
  83915. */
  83916. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83917. /**
  83918. * Returns a Color3 value containing a red color
  83919. * @returns a new Color3 object
  83920. */
  83921. static Red(): Color3;
  83922. /**
  83923. * Returns a Color3 value containing a green color
  83924. * @returns a new Color3 object
  83925. */
  83926. static Green(): Color3;
  83927. /**
  83928. * Returns a Color3 value containing a blue color
  83929. * @returns a new Color3 object
  83930. */
  83931. static Blue(): Color3;
  83932. /**
  83933. * Returns a Color3 value containing a black color
  83934. * @returns a new Color3 object
  83935. */
  83936. static Black(): Color3;
  83937. /**
  83938. * Gets a Color3 value containing a black color that must not be updated
  83939. */
  83940. static get BlackReadOnly(): DeepImmutable<Color3>;
  83941. /**
  83942. * Returns a Color3 value containing a white color
  83943. * @returns a new Color3 object
  83944. */
  83945. static White(): Color3;
  83946. /**
  83947. * Returns a Color3 value containing a purple color
  83948. * @returns a new Color3 object
  83949. */
  83950. static Purple(): Color3;
  83951. /**
  83952. * Returns a Color3 value containing a magenta color
  83953. * @returns a new Color3 object
  83954. */
  83955. static Magenta(): Color3;
  83956. /**
  83957. * Returns a Color3 value containing a yellow color
  83958. * @returns a new Color3 object
  83959. */
  83960. static Yellow(): Color3;
  83961. /**
  83962. * Returns a Color3 value containing a gray color
  83963. * @returns a new Color3 object
  83964. */
  83965. static Gray(): Color3;
  83966. /**
  83967. * Returns a Color3 value containing a teal color
  83968. * @returns a new Color3 object
  83969. */
  83970. static Teal(): Color3;
  83971. /**
  83972. * Returns a Color3 value containing a random color
  83973. * @returns a new Color3 object
  83974. */
  83975. static Random(): Color3;
  83976. }
  83977. /**
  83978. * Class used to hold a RBGA color
  83979. */
  83980. export class Color4 {
  83981. /**
  83982. * Defines the red component (between 0 and 1, default is 0)
  83983. */
  83984. r: number;
  83985. /**
  83986. * Defines the green component (between 0 and 1, default is 0)
  83987. */
  83988. g: number;
  83989. /**
  83990. * Defines the blue component (between 0 and 1, default is 0)
  83991. */
  83992. b: number;
  83993. /**
  83994. * Defines the alpha component (between 0 and 1, default is 1)
  83995. */
  83996. a: number;
  83997. /**
  83998. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83999. * @param r defines the red component (between 0 and 1, default is 0)
  84000. * @param g defines the green component (between 0 and 1, default is 0)
  84001. * @param b defines the blue component (between 0 and 1, default is 0)
  84002. * @param a defines the alpha component (between 0 and 1, default is 1)
  84003. */
  84004. constructor(
  84005. /**
  84006. * Defines the red component (between 0 and 1, default is 0)
  84007. */
  84008. r?: number,
  84009. /**
  84010. * Defines the green component (between 0 and 1, default is 0)
  84011. */
  84012. g?: number,
  84013. /**
  84014. * Defines the blue component (between 0 and 1, default is 0)
  84015. */
  84016. b?: number,
  84017. /**
  84018. * Defines the alpha component (between 0 and 1, default is 1)
  84019. */
  84020. a?: number);
  84021. /**
  84022. * Adds in place the given Color4 values to the current Color4 object
  84023. * @param right defines the second operand
  84024. * @returns the current updated Color4 object
  84025. */
  84026. addInPlace(right: DeepImmutable<Color4>): Color4;
  84027. /**
  84028. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84029. * @returns the new array
  84030. */
  84031. asArray(): number[];
  84032. /**
  84033. * Stores from the starting index in the given array the Color4 successive values
  84034. * @param array defines the array where to store the r,g,b components
  84035. * @param index defines an optional index in the target array to define where to start storing values
  84036. * @returns the current Color4 object
  84037. */
  84038. toArray(array: number[], index?: number): Color4;
  84039. /**
  84040. * Determines equality between Color4 objects
  84041. * @param otherColor defines the second operand
  84042. * @returns true if the rgba values are equal to the given ones
  84043. */
  84044. equals(otherColor: DeepImmutable<Color4>): boolean;
  84045. /**
  84046. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84047. * @param right defines the second operand
  84048. * @returns a new Color4 object
  84049. */
  84050. add(right: DeepImmutable<Color4>): Color4;
  84051. /**
  84052. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84053. * @param right defines the second operand
  84054. * @returns a new Color4 object
  84055. */
  84056. subtract(right: DeepImmutable<Color4>): Color4;
  84057. /**
  84058. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84059. * @param right defines the second operand
  84060. * @param result defines the Color4 object where to store the result
  84061. * @returns the current Color4 object
  84062. */
  84063. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84064. /**
  84065. * Creates a new Color4 with the current Color4 values multiplied by scale
  84066. * @param scale defines the scaling factor to apply
  84067. * @returns a new Color4 object
  84068. */
  84069. scale(scale: number): Color4;
  84070. /**
  84071. * Multiplies the current Color4 values by scale and stores the result in "result"
  84072. * @param scale defines the scaling factor to apply
  84073. * @param result defines the Color4 object where to store the result
  84074. * @returns the current unmodified Color4
  84075. */
  84076. scaleToRef(scale: number, result: Color4): Color4;
  84077. /**
  84078. * Scale the current Color4 values by a factor and add the result to a given Color4
  84079. * @param scale defines the scale factor
  84080. * @param result defines the Color4 object where to store the result
  84081. * @returns the unmodified current Color4
  84082. */
  84083. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84084. /**
  84085. * Clamps the rgb values by the min and max values and stores the result into "result"
  84086. * @param min defines minimum clamping value (default is 0)
  84087. * @param max defines maximum clamping value (default is 1)
  84088. * @param result defines color to store the result into.
  84089. * @returns the cuurent Color4
  84090. */
  84091. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84092. /**
  84093. * Multipy an Color4 value by another and return a new Color4 object
  84094. * @param color defines the Color4 value to multiply by
  84095. * @returns a new Color4 object
  84096. */
  84097. multiply(color: Color4): Color4;
  84098. /**
  84099. * Multipy a Color4 value by another and push the result in a reference value
  84100. * @param color defines the Color4 value to multiply by
  84101. * @param result defines the Color4 to fill the result in
  84102. * @returns the result Color4
  84103. */
  84104. multiplyToRef(color: Color4, result: Color4): Color4;
  84105. /**
  84106. * Creates a string with the Color4 current values
  84107. * @returns the string representation of the Color4 object
  84108. */
  84109. toString(): string;
  84110. /**
  84111. * Returns the string "Color4"
  84112. * @returns "Color4"
  84113. */
  84114. getClassName(): string;
  84115. /**
  84116. * Compute the Color4 hash code
  84117. * @returns an unique number that can be used to hash Color4 objects
  84118. */
  84119. getHashCode(): number;
  84120. /**
  84121. * Creates a new Color4 copied from the current one
  84122. * @returns a new Color4 object
  84123. */
  84124. clone(): Color4;
  84125. /**
  84126. * Copies the given Color4 values into the current one
  84127. * @param source defines the source Color4 object
  84128. * @returns the current updated Color4 object
  84129. */
  84130. copyFrom(source: Color4): Color4;
  84131. /**
  84132. * Copies the given float values into the current one
  84133. * @param r defines the red component to read from
  84134. * @param g defines the green component to read from
  84135. * @param b defines the blue component to read from
  84136. * @param a defines the alpha component to read from
  84137. * @returns the current updated Color4 object
  84138. */
  84139. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84140. /**
  84141. * Copies the given float values into the current one
  84142. * @param r defines the red component to read from
  84143. * @param g defines the green component to read from
  84144. * @param b defines the blue component to read from
  84145. * @param a defines the alpha component to read from
  84146. * @returns the current updated Color4 object
  84147. */
  84148. set(r: number, g: number, b: number, a: number): Color4;
  84149. /**
  84150. * Compute the Color4 hexadecimal code as a string
  84151. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84152. * @returns a string containing the hexadecimal representation of the Color4 object
  84153. */
  84154. toHexString(returnAsColor3?: boolean): string;
  84155. /**
  84156. * Computes a new Color4 converted from the current one to linear space
  84157. * @returns a new Color4 object
  84158. */
  84159. toLinearSpace(): Color4;
  84160. /**
  84161. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84162. * @param convertedColor defines the Color4 object where to store the linear space version
  84163. * @returns the unmodified Color4
  84164. */
  84165. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84166. /**
  84167. * Computes a new Color4 converted from the current one to gamma space
  84168. * @returns a new Color4 object
  84169. */
  84170. toGammaSpace(): Color4;
  84171. /**
  84172. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84173. * @param convertedColor defines the Color4 object where to store the gamma space version
  84174. * @returns the unmodified Color4
  84175. */
  84176. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84177. /**
  84178. * Creates a new Color4 from the string containing valid hexadecimal values
  84179. * @param hex defines a string containing valid hexadecimal values
  84180. * @returns a new Color4 object
  84181. */
  84182. static FromHexString(hex: string): Color4;
  84183. /**
  84184. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84185. * @param left defines the start value
  84186. * @param right defines the end value
  84187. * @param amount defines the gradient factor
  84188. * @returns a new Color4 object
  84189. */
  84190. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84191. /**
  84192. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84193. * @param left defines the start value
  84194. * @param right defines the end value
  84195. * @param amount defines the gradient factor
  84196. * @param result defines the Color4 object where to store data
  84197. */
  84198. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84199. /**
  84200. * Creates a new Color4 from a Color3 and an alpha value
  84201. * @param color3 defines the source Color3 to read from
  84202. * @param alpha defines the alpha component (1.0 by default)
  84203. * @returns a new Color4 object
  84204. */
  84205. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84206. /**
  84207. * Creates a new Color4 from the starting index element of the given array
  84208. * @param array defines the source array to read from
  84209. * @param offset defines the offset in the source array
  84210. * @returns a new Color4 object
  84211. */
  84212. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84213. /**
  84214. * Creates a new Color3 from integer values (< 256)
  84215. * @param r defines the red component to read from (value between 0 and 255)
  84216. * @param g defines the green component to read from (value between 0 and 255)
  84217. * @param b defines the blue component to read from (value between 0 and 255)
  84218. * @param a defines the alpha component to read from (value between 0 and 255)
  84219. * @returns a new Color3 object
  84220. */
  84221. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84222. /**
  84223. * Check the content of a given array and convert it to an array containing RGBA data
  84224. * If the original array was already containing count * 4 values then it is returned directly
  84225. * @param colors defines the array to check
  84226. * @param count defines the number of RGBA data to expect
  84227. * @returns an array containing count * 4 values (RGBA)
  84228. */
  84229. static CheckColors4(colors: number[], count: number): number[];
  84230. }
  84231. /**
  84232. * @hidden
  84233. */
  84234. export class TmpColors {
  84235. static Color3: Color3[];
  84236. static Color4: Color4[];
  84237. }
  84238. }
  84239. declare module BABYLON {
  84240. /**
  84241. * Defines an interface which represents an animation key frame
  84242. */
  84243. export interface IAnimationKey {
  84244. /**
  84245. * Frame of the key frame
  84246. */
  84247. frame: number;
  84248. /**
  84249. * Value at the specifies key frame
  84250. */
  84251. value: any;
  84252. /**
  84253. * The input tangent for the cubic hermite spline
  84254. */
  84255. inTangent?: any;
  84256. /**
  84257. * The output tangent for the cubic hermite spline
  84258. */
  84259. outTangent?: any;
  84260. /**
  84261. * The animation interpolation type
  84262. */
  84263. interpolation?: AnimationKeyInterpolation;
  84264. }
  84265. /**
  84266. * Enum for the animation key frame interpolation type
  84267. */
  84268. export enum AnimationKeyInterpolation {
  84269. /**
  84270. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84271. */
  84272. STEP = 1
  84273. }
  84274. }
  84275. declare module BABYLON {
  84276. /**
  84277. * Represents the range of an animation
  84278. */
  84279. export class AnimationRange {
  84280. /**The name of the animation range**/
  84281. name: string;
  84282. /**The starting frame of the animation */
  84283. from: number;
  84284. /**The ending frame of the animation*/
  84285. to: number;
  84286. /**
  84287. * Initializes the range of an animation
  84288. * @param name The name of the animation range
  84289. * @param from The starting frame of the animation
  84290. * @param to The ending frame of the animation
  84291. */
  84292. constructor(
  84293. /**The name of the animation range**/
  84294. name: string,
  84295. /**The starting frame of the animation */
  84296. from: number,
  84297. /**The ending frame of the animation*/
  84298. to: number);
  84299. /**
  84300. * Makes a copy of the animation range
  84301. * @returns A copy of the animation range
  84302. */
  84303. clone(): AnimationRange;
  84304. }
  84305. }
  84306. declare module BABYLON {
  84307. /**
  84308. * Composed of a frame, and an action function
  84309. */
  84310. export class AnimationEvent {
  84311. /** The frame for which the event is triggered **/
  84312. frame: number;
  84313. /** The event to perform when triggered **/
  84314. action: (currentFrame: number) => void;
  84315. /** Specifies if the event should be triggered only once**/
  84316. onlyOnce?: boolean | undefined;
  84317. /**
  84318. * Specifies if the animation event is done
  84319. */
  84320. isDone: boolean;
  84321. /**
  84322. * Initializes the animation event
  84323. * @param frame The frame for which the event is triggered
  84324. * @param action The event to perform when triggered
  84325. * @param onlyOnce Specifies if the event should be triggered only once
  84326. */
  84327. constructor(
  84328. /** The frame for which the event is triggered **/
  84329. frame: number,
  84330. /** The event to perform when triggered **/
  84331. action: (currentFrame: number) => void,
  84332. /** Specifies if the event should be triggered only once**/
  84333. onlyOnce?: boolean | undefined);
  84334. /** @hidden */
  84335. _clone(): AnimationEvent;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /**
  84340. * Interface used to define a behavior
  84341. */
  84342. export interface Behavior<T> {
  84343. /** gets or sets behavior's name */
  84344. name: string;
  84345. /**
  84346. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84347. */
  84348. init(): void;
  84349. /**
  84350. * Called when the behavior is attached to a target
  84351. * @param target defines the target where the behavior is attached to
  84352. */
  84353. attach(target: T): void;
  84354. /**
  84355. * Called when the behavior is detached from its target
  84356. */
  84357. detach(): void;
  84358. }
  84359. /**
  84360. * Interface implemented by classes supporting behaviors
  84361. */
  84362. export interface IBehaviorAware<T> {
  84363. /**
  84364. * Attach a behavior
  84365. * @param behavior defines the behavior to attach
  84366. * @returns the current host
  84367. */
  84368. addBehavior(behavior: Behavior<T>): T;
  84369. /**
  84370. * Remove a behavior from the current object
  84371. * @param behavior defines the behavior to detach
  84372. * @returns the current host
  84373. */
  84374. removeBehavior(behavior: Behavior<T>): T;
  84375. /**
  84376. * Gets a behavior using its name to search
  84377. * @param name defines the name to search
  84378. * @returns the behavior or null if not found
  84379. */
  84380. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84381. }
  84382. }
  84383. declare module BABYLON {
  84384. /**
  84385. * Defines an array and its length.
  84386. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84387. */
  84388. export interface ISmartArrayLike<T> {
  84389. /**
  84390. * The data of the array.
  84391. */
  84392. data: Array<T>;
  84393. /**
  84394. * The active length of the array.
  84395. */
  84396. length: number;
  84397. }
  84398. /**
  84399. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84400. */
  84401. export class SmartArray<T> implements ISmartArrayLike<T> {
  84402. /**
  84403. * The full set of data from the array.
  84404. */
  84405. data: Array<T>;
  84406. /**
  84407. * The active length of the array.
  84408. */
  84409. length: number;
  84410. protected _id: number;
  84411. /**
  84412. * Instantiates a Smart Array.
  84413. * @param capacity defines the default capacity of the array.
  84414. */
  84415. constructor(capacity: number);
  84416. /**
  84417. * Pushes a value at the end of the active data.
  84418. * @param value defines the object to push in the array.
  84419. */
  84420. push(value: T): void;
  84421. /**
  84422. * Iterates over the active data and apply the lambda to them.
  84423. * @param func defines the action to apply on each value.
  84424. */
  84425. forEach(func: (content: T) => void): void;
  84426. /**
  84427. * Sorts the full sets of data.
  84428. * @param compareFn defines the comparison function to apply.
  84429. */
  84430. sort(compareFn: (a: T, b: T) => number): void;
  84431. /**
  84432. * Resets the active data to an empty array.
  84433. */
  84434. reset(): void;
  84435. /**
  84436. * Releases all the data from the array as well as the array.
  84437. */
  84438. dispose(): void;
  84439. /**
  84440. * Concats the active data with a given array.
  84441. * @param array defines the data to concatenate with.
  84442. */
  84443. concat(array: any): void;
  84444. /**
  84445. * Returns the position of a value in the active data.
  84446. * @param value defines the value to find the index for
  84447. * @returns the index if found in the active data otherwise -1
  84448. */
  84449. indexOf(value: T): number;
  84450. /**
  84451. * Returns whether an element is part of the active data.
  84452. * @param value defines the value to look for
  84453. * @returns true if found in the active data otherwise false
  84454. */
  84455. contains(value: T): boolean;
  84456. private static _GlobalId;
  84457. }
  84458. /**
  84459. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84460. * The data in this array can only be present once
  84461. */
  84462. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84463. private _duplicateId;
  84464. /**
  84465. * Pushes a value at the end of the active data.
  84466. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84467. * @param value defines the object to push in the array.
  84468. */
  84469. push(value: T): void;
  84470. /**
  84471. * Pushes a value at the end of the active data.
  84472. * If the data is already present, it won t be added again
  84473. * @param value defines the object to push in the array.
  84474. * @returns true if added false if it was already present
  84475. */
  84476. pushNoDuplicate(value: T): boolean;
  84477. /**
  84478. * Resets the active data to an empty array.
  84479. */
  84480. reset(): void;
  84481. /**
  84482. * Concats the active data with a given array.
  84483. * This ensures no dupplicate will be present in the result.
  84484. * @param array defines the data to concatenate with.
  84485. */
  84486. concatWithNoDuplicate(array: any): void;
  84487. }
  84488. }
  84489. declare module BABYLON {
  84490. /**
  84491. * @ignore
  84492. * This is a list of all the different input types that are available in the application.
  84493. * Fo instance: ArcRotateCameraGamepadInput...
  84494. */
  84495. export var CameraInputTypes: {};
  84496. /**
  84497. * This is the contract to implement in order to create a new input class.
  84498. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84499. */
  84500. export interface ICameraInput<TCamera extends Camera> {
  84501. /**
  84502. * Defines the camera the input is attached to.
  84503. */
  84504. camera: Nullable<TCamera>;
  84505. /**
  84506. * Gets the class name of the current intput.
  84507. * @returns the class name
  84508. */
  84509. getClassName(): string;
  84510. /**
  84511. * Get the friendly name associated with the input class.
  84512. * @returns the input friendly name
  84513. */
  84514. getSimpleName(): string;
  84515. /**
  84516. * Attach the input controls to a specific dom element to get the input from.
  84517. * @param element Defines the element the controls should be listened from
  84518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84519. */
  84520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84521. /**
  84522. * Detach the current controls from the specified dom element.
  84523. * @param element Defines the element to stop listening the inputs from
  84524. */
  84525. detachControl(element: Nullable<HTMLElement>): void;
  84526. /**
  84527. * Update the current camera state depending on the inputs that have been used this frame.
  84528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84529. */
  84530. checkInputs?: () => void;
  84531. }
  84532. /**
  84533. * Represents a map of input types to input instance or input index to input instance.
  84534. */
  84535. export interface CameraInputsMap<TCamera extends Camera> {
  84536. /**
  84537. * Accessor to the input by input type.
  84538. */
  84539. [name: string]: ICameraInput<TCamera>;
  84540. /**
  84541. * Accessor to the input by input index.
  84542. */
  84543. [idx: number]: ICameraInput<TCamera>;
  84544. }
  84545. /**
  84546. * This represents the input manager used within a camera.
  84547. * It helps dealing with all the different kind of input attached to a camera.
  84548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84549. */
  84550. export class CameraInputsManager<TCamera extends Camera> {
  84551. /**
  84552. * Defines the list of inputs attahed to the camera.
  84553. */
  84554. attached: CameraInputsMap<TCamera>;
  84555. /**
  84556. * Defines the dom element the camera is collecting inputs from.
  84557. * This is null if the controls have not been attached.
  84558. */
  84559. attachedElement: Nullable<HTMLElement>;
  84560. /**
  84561. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84562. */
  84563. noPreventDefault: boolean;
  84564. /**
  84565. * Defined the camera the input manager belongs to.
  84566. */
  84567. camera: TCamera;
  84568. /**
  84569. * Update the current camera state depending on the inputs that have been used this frame.
  84570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84571. */
  84572. checkInputs: () => void;
  84573. /**
  84574. * Instantiate a new Camera Input Manager.
  84575. * @param camera Defines the camera the input manager blongs to
  84576. */
  84577. constructor(camera: TCamera);
  84578. /**
  84579. * Add an input method to a camera
  84580. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84581. * @param input camera input method
  84582. */
  84583. add(input: ICameraInput<TCamera>): void;
  84584. /**
  84585. * Remove a specific input method from a camera
  84586. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84587. * @param inputToRemove camera input method
  84588. */
  84589. remove(inputToRemove: ICameraInput<TCamera>): void;
  84590. /**
  84591. * Remove a specific input type from a camera
  84592. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84593. * @param inputType the type of the input to remove
  84594. */
  84595. removeByType(inputType: string): void;
  84596. private _addCheckInputs;
  84597. /**
  84598. * Attach the input controls to the currently attached dom element to listen the events from.
  84599. * @param input Defines the input to attach
  84600. */
  84601. attachInput(input: ICameraInput<TCamera>): void;
  84602. /**
  84603. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84604. * @param element Defines the dom element to collect the events from
  84605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84606. */
  84607. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84608. /**
  84609. * Detach the current manager inputs controls from a specific dom element.
  84610. * @param element Defines the dom element to collect the events from
  84611. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84612. */
  84613. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84614. /**
  84615. * Rebuild the dynamic inputCheck function from the current list of
  84616. * defined inputs in the manager.
  84617. */
  84618. rebuildInputCheck(): void;
  84619. /**
  84620. * Remove all attached input methods from a camera
  84621. */
  84622. clear(): void;
  84623. /**
  84624. * Serialize the current input manager attached to a camera.
  84625. * This ensures than once parsed,
  84626. * the input associated to the camera will be identical to the current ones
  84627. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84628. */
  84629. serialize(serializedCamera: any): void;
  84630. /**
  84631. * Parses an input manager serialized JSON to restore the previous list of inputs
  84632. * and states associated to a camera.
  84633. * @param parsedCamera Defines the JSON to parse
  84634. */
  84635. parse(parsedCamera: any): void;
  84636. }
  84637. }
  84638. declare module BABYLON {
  84639. /**
  84640. * Class used to store data that will be store in GPU memory
  84641. */
  84642. export class Buffer {
  84643. private _engine;
  84644. private _buffer;
  84645. /** @hidden */
  84646. _data: Nullable<DataArray>;
  84647. private _updatable;
  84648. private _instanced;
  84649. private _divisor;
  84650. /**
  84651. * Gets the byte stride.
  84652. */
  84653. readonly byteStride: number;
  84654. /**
  84655. * Constructor
  84656. * @param engine the engine
  84657. * @param data the data to use for this buffer
  84658. * @param updatable whether the data is updatable
  84659. * @param stride the stride (optional)
  84660. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84661. * @param instanced whether the buffer is instanced (optional)
  84662. * @param useBytes set to true if the stride in in bytes (optional)
  84663. * @param divisor sets an optional divisor for instances (1 by default)
  84664. */
  84665. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84666. /**
  84667. * Create a new VertexBuffer based on the current buffer
  84668. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84669. * @param offset defines offset in the buffer (0 by default)
  84670. * @param size defines the size in floats of attributes (position is 3 for instance)
  84671. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84672. * @param instanced defines if the vertex buffer contains indexed data
  84673. * @param useBytes defines if the offset and stride are in bytes *
  84674. * @param divisor sets an optional divisor for instances (1 by default)
  84675. * @returns the new vertex buffer
  84676. */
  84677. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84678. /**
  84679. * Gets a boolean indicating if the Buffer is updatable?
  84680. * @returns true if the buffer is updatable
  84681. */
  84682. isUpdatable(): boolean;
  84683. /**
  84684. * Gets current buffer's data
  84685. * @returns a DataArray or null
  84686. */
  84687. getData(): Nullable<DataArray>;
  84688. /**
  84689. * Gets underlying native buffer
  84690. * @returns underlying native buffer
  84691. */
  84692. getBuffer(): Nullable<DataBuffer>;
  84693. /**
  84694. * Gets the stride in float32 units (i.e. byte stride / 4).
  84695. * May not be an integer if the byte stride is not divisible by 4.
  84696. * @returns the stride in float32 units
  84697. * @deprecated Please use byteStride instead.
  84698. */
  84699. getStrideSize(): number;
  84700. /**
  84701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84702. * @param data defines the data to store
  84703. */
  84704. create(data?: Nullable<DataArray>): void;
  84705. /** @hidden */
  84706. _rebuild(): void;
  84707. /**
  84708. * Update current buffer data
  84709. * @param data defines the data to store
  84710. */
  84711. update(data: DataArray): void;
  84712. /**
  84713. * Updates the data directly.
  84714. * @param data the new data
  84715. * @param offset the new offset
  84716. * @param vertexCount the vertex count (optional)
  84717. * @param useBytes set to true if the offset is in bytes
  84718. */
  84719. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84720. /**
  84721. * Release all resources
  84722. */
  84723. dispose(): void;
  84724. }
  84725. /**
  84726. * Specialized buffer used to store vertex data
  84727. */
  84728. export class VertexBuffer {
  84729. /** @hidden */
  84730. _buffer: Buffer;
  84731. private _kind;
  84732. private _size;
  84733. private _ownsBuffer;
  84734. private _instanced;
  84735. private _instanceDivisor;
  84736. /**
  84737. * The byte type.
  84738. */
  84739. static readonly BYTE: number;
  84740. /**
  84741. * The unsigned byte type.
  84742. */
  84743. static readonly UNSIGNED_BYTE: number;
  84744. /**
  84745. * The short type.
  84746. */
  84747. static readonly SHORT: number;
  84748. /**
  84749. * The unsigned short type.
  84750. */
  84751. static readonly UNSIGNED_SHORT: number;
  84752. /**
  84753. * The integer type.
  84754. */
  84755. static readonly INT: number;
  84756. /**
  84757. * The unsigned integer type.
  84758. */
  84759. static readonly UNSIGNED_INT: number;
  84760. /**
  84761. * The float type.
  84762. */
  84763. static readonly FLOAT: number;
  84764. /**
  84765. * Gets or sets the instance divisor when in instanced mode
  84766. */
  84767. get instanceDivisor(): number;
  84768. set instanceDivisor(value: number);
  84769. /**
  84770. * Gets the byte stride.
  84771. */
  84772. readonly byteStride: number;
  84773. /**
  84774. * Gets the byte offset.
  84775. */
  84776. readonly byteOffset: number;
  84777. /**
  84778. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84779. */
  84780. readonly normalized: boolean;
  84781. /**
  84782. * Gets the data type of each component in the array.
  84783. */
  84784. readonly type: number;
  84785. /**
  84786. * Constructor
  84787. * @param engine the engine
  84788. * @param data the data to use for this vertex buffer
  84789. * @param kind the vertex buffer kind
  84790. * @param updatable whether the data is updatable
  84791. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84792. * @param stride the stride (optional)
  84793. * @param instanced whether the buffer is instanced (optional)
  84794. * @param offset the offset of the data (optional)
  84795. * @param size the number of components (optional)
  84796. * @param type the type of the component (optional)
  84797. * @param normalized whether the data contains normalized data (optional)
  84798. * @param useBytes set to true if stride and offset are in bytes (optional)
  84799. * @param divisor defines the instance divisor to use (1 by default)
  84800. */
  84801. 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);
  84802. /** @hidden */
  84803. _rebuild(): void;
  84804. /**
  84805. * Returns the kind of the VertexBuffer (string)
  84806. * @returns a string
  84807. */
  84808. getKind(): string;
  84809. /**
  84810. * Gets a boolean indicating if the VertexBuffer is updatable?
  84811. * @returns true if the buffer is updatable
  84812. */
  84813. isUpdatable(): boolean;
  84814. /**
  84815. * Gets current buffer's data
  84816. * @returns a DataArray or null
  84817. */
  84818. getData(): Nullable<DataArray>;
  84819. /**
  84820. * Gets underlying native buffer
  84821. * @returns underlying native buffer
  84822. */
  84823. getBuffer(): Nullable<DataBuffer>;
  84824. /**
  84825. * Gets the stride in float32 units (i.e. byte stride / 4).
  84826. * May not be an integer if the byte stride is not divisible by 4.
  84827. * @returns the stride in float32 units
  84828. * @deprecated Please use byteStride instead.
  84829. */
  84830. getStrideSize(): number;
  84831. /**
  84832. * Returns the offset as a multiple of the type byte length.
  84833. * @returns the offset in bytes
  84834. * @deprecated Please use byteOffset instead.
  84835. */
  84836. getOffset(): number;
  84837. /**
  84838. * Returns the number of components per vertex attribute (integer)
  84839. * @returns the size in float
  84840. */
  84841. getSize(): number;
  84842. /**
  84843. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84844. * @returns true if this buffer is instanced
  84845. */
  84846. getIsInstanced(): boolean;
  84847. /**
  84848. * Returns the instancing divisor, zero for non-instanced (integer).
  84849. * @returns a number
  84850. */
  84851. getInstanceDivisor(): number;
  84852. /**
  84853. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84854. * @param data defines the data to store
  84855. */
  84856. create(data?: DataArray): void;
  84857. /**
  84858. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84859. * This function will create a new buffer if the current one is not updatable
  84860. * @param data defines the data to store
  84861. */
  84862. update(data: DataArray): void;
  84863. /**
  84864. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84865. * Returns the directly updated WebGLBuffer.
  84866. * @param data the new data
  84867. * @param offset the new offset
  84868. * @param useBytes set to true if the offset is in bytes
  84869. */
  84870. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84871. /**
  84872. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84873. */
  84874. dispose(): void;
  84875. /**
  84876. * Enumerates each value of this vertex buffer as numbers.
  84877. * @param count the number of values to enumerate
  84878. * @param callback the callback function called for each value
  84879. */
  84880. forEach(count: number, callback: (value: number, index: number) => void): void;
  84881. /**
  84882. * Positions
  84883. */
  84884. static readonly PositionKind: string;
  84885. /**
  84886. * Normals
  84887. */
  84888. static readonly NormalKind: string;
  84889. /**
  84890. * Tangents
  84891. */
  84892. static readonly TangentKind: string;
  84893. /**
  84894. * Texture coordinates
  84895. */
  84896. static readonly UVKind: string;
  84897. /**
  84898. * Texture coordinates 2
  84899. */
  84900. static readonly UV2Kind: string;
  84901. /**
  84902. * Texture coordinates 3
  84903. */
  84904. static readonly UV3Kind: string;
  84905. /**
  84906. * Texture coordinates 4
  84907. */
  84908. static readonly UV4Kind: string;
  84909. /**
  84910. * Texture coordinates 5
  84911. */
  84912. static readonly UV5Kind: string;
  84913. /**
  84914. * Texture coordinates 6
  84915. */
  84916. static readonly UV6Kind: string;
  84917. /**
  84918. * Colors
  84919. */
  84920. static readonly ColorKind: string;
  84921. /**
  84922. * Matrix indices (for bones)
  84923. */
  84924. static readonly MatricesIndicesKind: string;
  84925. /**
  84926. * Matrix weights (for bones)
  84927. */
  84928. static readonly MatricesWeightsKind: string;
  84929. /**
  84930. * Additional matrix indices (for bones)
  84931. */
  84932. static readonly MatricesIndicesExtraKind: string;
  84933. /**
  84934. * Additional matrix weights (for bones)
  84935. */
  84936. static readonly MatricesWeightsExtraKind: string;
  84937. /**
  84938. * Deduces the stride given a kind.
  84939. * @param kind The kind string to deduce
  84940. * @returns The deduced stride
  84941. */
  84942. static DeduceStride(kind: string): number;
  84943. /**
  84944. * Gets the byte length of the given type.
  84945. * @param type the type
  84946. * @returns the number of bytes
  84947. */
  84948. static GetTypeByteLength(type: number): number;
  84949. /**
  84950. * Enumerates each value of the given parameters as numbers.
  84951. * @param data the data to enumerate
  84952. * @param byteOffset the byte offset of the data
  84953. * @param byteStride the byte stride of the data
  84954. * @param componentCount the number of components per element
  84955. * @param componentType the type of the component
  84956. * @param count the number of values to enumerate
  84957. * @param normalized whether the data is normalized
  84958. * @param callback the callback function called for each value
  84959. */
  84960. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84961. private static _GetFloatValue;
  84962. }
  84963. }
  84964. declare module BABYLON {
  84965. /**
  84966. * @hidden
  84967. */
  84968. export class IntersectionInfo {
  84969. bu: Nullable<number>;
  84970. bv: Nullable<number>;
  84971. distance: number;
  84972. faceId: number;
  84973. subMeshId: number;
  84974. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84975. }
  84976. }
  84977. declare module BABYLON {
  84978. /**
  84979. * Class used to store bounding sphere information
  84980. */
  84981. export class BoundingSphere {
  84982. /**
  84983. * Gets the center of the bounding sphere in local space
  84984. */
  84985. readonly center: Vector3;
  84986. /**
  84987. * Radius of the bounding sphere in local space
  84988. */
  84989. radius: number;
  84990. /**
  84991. * Gets the center of the bounding sphere in world space
  84992. */
  84993. readonly centerWorld: Vector3;
  84994. /**
  84995. * Radius of the bounding sphere in world space
  84996. */
  84997. radiusWorld: number;
  84998. /**
  84999. * Gets the minimum vector in local space
  85000. */
  85001. readonly minimum: Vector3;
  85002. /**
  85003. * Gets the maximum vector in local space
  85004. */
  85005. readonly maximum: Vector3;
  85006. private _worldMatrix;
  85007. private static readonly TmpVector3;
  85008. /**
  85009. * Creates a new bounding sphere
  85010. * @param min defines the minimum vector (in local space)
  85011. * @param max defines the maximum vector (in local space)
  85012. * @param worldMatrix defines the new world matrix
  85013. */
  85014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85015. /**
  85016. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85017. * @param min defines the new minimum vector (in local space)
  85018. * @param max defines the new maximum vector (in local space)
  85019. * @param worldMatrix defines the new world matrix
  85020. */
  85021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85022. /**
  85023. * Scale the current bounding sphere by applying a scale factor
  85024. * @param factor defines the scale factor to apply
  85025. * @returns the current bounding box
  85026. */
  85027. scale(factor: number): BoundingSphere;
  85028. /**
  85029. * Gets the world matrix of the bounding box
  85030. * @returns a matrix
  85031. */
  85032. getWorldMatrix(): DeepImmutable<Matrix>;
  85033. /** @hidden */
  85034. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85035. /**
  85036. * Tests if the bounding sphere is intersecting the frustum planes
  85037. * @param frustumPlanes defines the frustum planes to test
  85038. * @returns true if there is an intersection
  85039. */
  85040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85041. /**
  85042. * Tests if the bounding sphere center is in between the frustum planes.
  85043. * Used for optimistic fast inclusion.
  85044. * @param frustumPlanes defines the frustum planes to test
  85045. * @returns true if the sphere center is in between the frustum planes
  85046. */
  85047. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85048. /**
  85049. * Tests if a point is inside the bounding sphere
  85050. * @param point defines the point to test
  85051. * @returns true if the point is inside the bounding sphere
  85052. */
  85053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85054. /**
  85055. * Checks if two sphere intersct
  85056. * @param sphere0 sphere 0
  85057. * @param sphere1 sphere 1
  85058. * @returns true if the speres intersect
  85059. */
  85060. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85061. }
  85062. }
  85063. declare module BABYLON {
  85064. /**
  85065. * Class used to store bounding box information
  85066. */
  85067. export class BoundingBox implements ICullable {
  85068. /**
  85069. * Gets the 8 vectors representing the bounding box in local space
  85070. */
  85071. readonly vectors: Vector3[];
  85072. /**
  85073. * Gets the center of the bounding box in local space
  85074. */
  85075. readonly center: Vector3;
  85076. /**
  85077. * Gets the center of the bounding box in world space
  85078. */
  85079. readonly centerWorld: Vector3;
  85080. /**
  85081. * Gets the extend size in local space
  85082. */
  85083. readonly extendSize: Vector3;
  85084. /**
  85085. * Gets the extend size in world space
  85086. */
  85087. readonly extendSizeWorld: Vector3;
  85088. /**
  85089. * Gets the OBB (object bounding box) directions
  85090. */
  85091. readonly directions: Vector3[];
  85092. /**
  85093. * Gets the 8 vectors representing the bounding box in world space
  85094. */
  85095. readonly vectorsWorld: Vector3[];
  85096. /**
  85097. * Gets the minimum vector in world space
  85098. */
  85099. readonly minimumWorld: Vector3;
  85100. /**
  85101. * Gets the maximum vector in world space
  85102. */
  85103. readonly maximumWorld: Vector3;
  85104. /**
  85105. * Gets the minimum vector in local space
  85106. */
  85107. readonly minimum: Vector3;
  85108. /**
  85109. * Gets the maximum vector in local space
  85110. */
  85111. readonly maximum: Vector3;
  85112. private _worldMatrix;
  85113. private static readonly TmpVector3;
  85114. /**
  85115. * @hidden
  85116. */
  85117. _tag: number;
  85118. /**
  85119. * Creates a new bounding box
  85120. * @param min defines the minimum vector (in local space)
  85121. * @param max defines the maximum vector (in local space)
  85122. * @param worldMatrix defines the new world matrix
  85123. */
  85124. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85125. /**
  85126. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85127. * @param min defines the new minimum vector (in local space)
  85128. * @param max defines the new maximum vector (in local space)
  85129. * @param worldMatrix defines the new world matrix
  85130. */
  85131. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85132. /**
  85133. * Scale the current bounding box by applying a scale factor
  85134. * @param factor defines the scale factor to apply
  85135. * @returns the current bounding box
  85136. */
  85137. scale(factor: number): BoundingBox;
  85138. /**
  85139. * Gets the world matrix of the bounding box
  85140. * @returns a matrix
  85141. */
  85142. getWorldMatrix(): DeepImmutable<Matrix>;
  85143. /** @hidden */
  85144. _update(world: DeepImmutable<Matrix>): void;
  85145. /**
  85146. * Tests if the bounding box is intersecting the frustum planes
  85147. * @param frustumPlanes defines the frustum planes to test
  85148. * @returns true if there is an intersection
  85149. */
  85150. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85151. /**
  85152. * Tests if the bounding box is entirely inside the frustum planes
  85153. * @param frustumPlanes defines the frustum planes to test
  85154. * @returns true if there is an inclusion
  85155. */
  85156. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85157. /**
  85158. * Tests if a point is inside the bounding box
  85159. * @param point defines the point to test
  85160. * @returns true if the point is inside the bounding box
  85161. */
  85162. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85163. /**
  85164. * Tests if the bounding box intersects with a bounding sphere
  85165. * @param sphere defines the sphere to test
  85166. * @returns true if there is an intersection
  85167. */
  85168. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85169. /**
  85170. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85171. * @param min defines the min vector to use
  85172. * @param max defines the max vector to use
  85173. * @returns true if there is an intersection
  85174. */
  85175. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85176. /**
  85177. * Tests if two bounding boxes are intersections
  85178. * @param box0 defines the first box to test
  85179. * @param box1 defines the second box to test
  85180. * @returns true if there is an intersection
  85181. */
  85182. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85183. /**
  85184. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85185. * @param minPoint defines the minimum vector of the bounding box
  85186. * @param maxPoint defines the maximum vector of the bounding box
  85187. * @param sphereCenter defines the sphere center
  85188. * @param sphereRadius defines the sphere radius
  85189. * @returns true if there is an intersection
  85190. */
  85191. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85192. /**
  85193. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85195. * @param frustumPlanes defines the frustum planes to test
  85196. * @return true if there is an inclusion
  85197. */
  85198. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85199. /**
  85200. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85202. * @param frustumPlanes defines the frustum planes to test
  85203. * @return true if there is an intersection
  85204. */
  85205. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85206. }
  85207. }
  85208. declare module BABYLON {
  85209. /** @hidden */
  85210. export class Collider {
  85211. /** Define if a collision was found */
  85212. collisionFound: boolean;
  85213. /**
  85214. * Define last intersection point in local space
  85215. */
  85216. intersectionPoint: Vector3;
  85217. /**
  85218. * Define last collided mesh
  85219. */
  85220. collidedMesh: Nullable<AbstractMesh>;
  85221. private _collisionPoint;
  85222. private _planeIntersectionPoint;
  85223. private _tempVector;
  85224. private _tempVector2;
  85225. private _tempVector3;
  85226. private _tempVector4;
  85227. private _edge;
  85228. private _baseToVertex;
  85229. private _destinationPoint;
  85230. private _slidePlaneNormal;
  85231. private _displacementVector;
  85232. /** @hidden */
  85233. _radius: Vector3;
  85234. /** @hidden */
  85235. _retry: number;
  85236. private _velocity;
  85237. private _basePoint;
  85238. private _epsilon;
  85239. /** @hidden */
  85240. _velocityWorldLength: number;
  85241. /** @hidden */
  85242. _basePointWorld: Vector3;
  85243. private _velocityWorld;
  85244. private _normalizedVelocity;
  85245. /** @hidden */
  85246. _initialVelocity: Vector3;
  85247. /** @hidden */
  85248. _initialPosition: Vector3;
  85249. private _nearestDistance;
  85250. private _collisionMask;
  85251. get collisionMask(): number;
  85252. set collisionMask(mask: number);
  85253. /**
  85254. * Gets the plane normal used to compute the sliding response (in local space)
  85255. */
  85256. get slidePlaneNormal(): Vector3;
  85257. /** @hidden */
  85258. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85259. /** @hidden */
  85260. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85261. /** @hidden */
  85262. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85263. /** @hidden */
  85264. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85265. /** @hidden */
  85266. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85267. /** @hidden */
  85268. _getResponse(pos: Vector3, vel: Vector3): void;
  85269. }
  85270. }
  85271. declare module BABYLON {
  85272. /**
  85273. * Interface for cullable objects
  85274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85275. */
  85276. export interface ICullable {
  85277. /**
  85278. * Checks if the object or part of the object is in the frustum
  85279. * @param frustumPlanes Camera near/planes
  85280. * @returns true if the object is in frustum otherwise false
  85281. */
  85282. isInFrustum(frustumPlanes: Plane[]): boolean;
  85283. /**
  85284. * Checks if a cullable object (mesh...) is in the camera frustum
  85285. * Unlike isInFrustum this cheks the full bounding box
  85286. * @param frustumPlanes Camera near/planes
  85287. * @returns true if the object is in frustum otherwise false
  85288. */
  85289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85290. }
  85291. /**
  85292. * Info for a bounding data of a mesh
  85293. */
  85294. export class BoundingInfo implements ICullable {
  85295. /**
  85296. * Bounding box for the mesh
  85297. */
  85298. readonly boundingBox: BoundingBox;
  85299. /**
  85300. * Bounding sphere for the mesh
  85301. */
  85302. readonly boundingSphere: BoundingSphere;
  85303. private _isLocked;
  85304. private static readonly TmpVector3;
  85305. /**
  85306. * Constructs bounding info
  85307. * @param minimum min vector of the bounding box/sphere
  85308. * @param maximum max vector of the bounding box/sphere
  85309. * @param worldMatrix defines the new world matrix
  85310. */
  85311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85312. /**
  85313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85314. * @param min defines the new minimum vector (in local space)
  85315. * @param max defines the new maximum vector (in local space)
  85316. * @param worldMatrix defines the new world matrix
  85317. */
  85318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85319. /**
  85320. * min vector of the bounding box/sphere
  85321. */
  85322. get minimum(): Vector3;
  85323. /**
  85324. * max vector of the bounding box/sphere
  85325. */
  85326. get maximum(): Vector3;
  85327. /**
  85328. * If the info is locked and won't be updated to avoid perf overhead
  85329. */
  85330. get isLocked(): boolean;
  85331. set isLocked(value: boolean);
  85332. /**
  85333. * Updates the bounding sphere and box
  85334. * @param world world matrix to be used to update
  85335. */
  85336. update(world: DeepImmutable<Matrix>): void;
  85337. /**
  85338. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85339. * @param center New center of the bounding info
  85340. * @param extend New extend of the bounding info
  85341. * @returns the current bounding info
  85342. */
  85343. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85344. /**
  85345. * Scale the current bounding info by applying a scale factor
  85346. * @param factor defines the scale factor to apply
  85347. * @returns the current bounding info
  85348. */
  85349. scale(factor: number): BoundingInfo;
  85350. /**
  85351. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85352. * @param frustumPlanes defines the frustum to test
  85353. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85354. * @returns true if the bounding info is in the frustum planes
  85355. */
  85356. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85357. /**
  85358. * Gets the world distance between the min and max points of the bounding box
  85359. */
  85360. get diagonalLength(): number;
  85361. /**
  85362. * Checks if a cullable object (mesh...) is in the camera frustum
  85363. * Unlike isInFrustum this cheks the full bounding box
  85364. * @param frustumPlanes Camera near/planes
  85365. * @returns true if the object is in frustum otherwise false
  85366. */
  85367. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85368. /** @hidden */
  85369. _checkCollision(collider: Collider): boolean;
  85370. /**
  85371. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85373. * @param point the point to check intersection with
  85374. * @returns if the point intersects
  85375. */
  85376. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85377. /**
  85378. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85380. * @param boundingInfo the bounding info to check intersection with
  85381. * @param precise if the intersection should be done using OBB
  85382. * @returns if the bounding info intersects
  85383. */
  85384. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85385. }
  85386. }
  85387. declare module BABYLON {
  85388. /**
  85389. * Extracts minimum and maximum values from a list of indexed positions
  85390. * @param positions defines the positions to use
  85391. * @param indices defines the indices to the positions
  85392. * @param indexStart defines the start index
  85393. * @param indexCount defines the end index
  85394. * @param bias defines bias value to add to the result
  85395. * @return minimum and maximum values
  85396. */
  85397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85398. minimum: Vector3;
  85399. maximum: Vector3;
  85400. };
  85401. /**
  85402. * Extracts minimum and maximum values from a list of positions
  85403. * @param positions defines the positions to use
  85404. * @param start defines the start index in the positions array
  85405. * @param count defines the number of positions to handle
  85406. * @param bias defines bias value to add to the result
  85407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85408. * @return minimum and maximum values
  85409. */
  85410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85411. minimum: Vector3;
  85412. maximum: Vector3;
  85413. };
  85414. }
  85415. declare module BABYLON {
  85416. /** @hidden */
  85417. export class WebGLDataBuffer extends DataBuffer {
  85418. private _buffer;
  85419. constructor(resource: WebGLBuffer);
  85420. get underlyingResource(): any;
  85421. }
  85422. }
  85423. declare module BABYLON {
  85424. /** @hidden */
  85425. export class WebGLPipelineContext implements IPipelineContext {
  85426. engine: ThinEngine;
  85427. program: Nullable<WebGLProgram>;
  85428. context?: WebGLRenderingContext;
  85429. vertexShader?: WebGLShader;
  85430. fragmentShader?: WebGLShader;
  85431. isParallelCompiled: boolean;
  85432. onCompiled?: () => void;
  85433. transformFeedback?: WebGLTransformFeedback | null;
  85434. vertexCompilationError: Nullable<string>;
  85435. fragmentCompilationError: Nullable<string>;
  85436. programLinkError: Nullable<string>;
  85437. programValidationError: Nullable<string>;
  85438. get isAsync(): boolean;
  85439. get isReady(): boolean;
  85440. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85441. _getVertexShaderCode(): string | null;
  85442. _getFragmentShaderCode(): string | null;
  85443. }
  85444. }
  85445. declare module BABYLON {
  85446. interface ThinEngine {
  85447. /**
  85448. * Create an uniform buffer
  85449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85450. * @param elements defines the content of the uniform buffer
  85451. * @returns the webGL uniform buffer
  85452. */
  85453. createUniformBuffer(elements: FloatArray): DataBuffer;
  85454. /**
  85455. * Create a dynamic uniform buffer
  85456. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85457. * @param elements defines the content of the uniform buffer
  85458. * @returns the webGL uniform buffer
  85459. */
  85460. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85461. /**
  85462. * Update an existing uniform buffer
  85463. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85464. * @param uniformBuffer defines the target uniform buffer
  85465. * @param elements defines the content to update
  85466. * @param offset defines the offset in the uniform buffer where update should start
  85467. * @param count defines the size of the data to update
  85468. */
  85469. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85470. /**
  85471. * Bind an uniform buffer to the current webGL context
  85472. * @param buffer defines the buffer to bind
  85473. */
  85474. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85475. /**
  85476. * Bind a buffer to the current webGL context at a given location
  85477. * @param buffer defines the buffer to bind
  85478. * @param location defines the index where to bind the buffer
  85479. */
  85480. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85481. /**
  85482. * Bind a specific block at a given index in a specific shader program
  85483. * @param pipelineContext defines the pipeline context to use
  85484. * @param blockName defines the block name
  85485. * @param index defines the index where to bind the block
  85486. */
  85487. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85488. }
  85489. }
  85490. declare module BABYLON {
  85491. /**
  85492. * Uniform buffer objects.
  85493. *
  85494. * Handles blocks of uniform on the GPU.
  85495. *
  85496. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85497. *
  85498. * For more information, please refer to :
  85499. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85500. */
  85501. export class UniformBuffer {
  85502. private _engine;
  85503. private _buffer;
  85504. private _data;
  85505. private _bufferData;
  85506. private _dynamic?;
  85507. private _uniformLocations;
  85508. private _uniformSizes;
  85509. private _uniformLocationPointer;
  85510. private _needSync;
  85511. private _noUBO;
  85512. private _currentEffect;
  85513. /** @hidden */
  85514. _alreadyBound: boolean;
  85515. private static _MAX_UNIFORM_SIZE;
  85516. private static _tempBuffer;
  85517. /**
  85518. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85519. * This is dynamic to allow compat with webgl 1 and 2.
  85520. * You will need to pass the name of the uniform as well as the value.
  85521. */
  85522. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85523. /**
  85524. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85525. * This is dynamic to allow compat with webgl 1 and 2.
  85526. * You will need to pass the name of the uniform as well as the value.
  85527. */
  85528. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85529. /**
  85530. * Lambda to Update a single float in a uniform buffer.
  85531. * This is dynamic to allow compat with webgl 1 and 2.
  85532. * You will need to pass the name of the uniform as well as the value.
  85533. */
  85534. updateFloat: (name: string, x: number) => void;
  85535. /**
  85536. * Lambda to Update a vec2 of float in a uniform buffer.
  85537. * This is dynamic to allow compat with webgl 1 and 2.
  85538. * You will need to pass the name of the uniform as well as the value.
  85539. */
  85540. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85541. /**
  85542. * Lambda to Update a vec3 of float in a uniform buffer.
  85543. * This is dynamic to allow compat with webgl 1 and 2.
  85544. * You will need to pass the name of the uniform as well as the value.
  85545. */
  85546. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85547. /**
  85548. * Lambda to Update a vec4 of float in a uniform buffer.
  85549. * This is dynamic to allow compat with webgl 1 and 2.
  85550. * You will need to pass the name of the uniform as well as the value.
  85551. */
  85552. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85553. /**
  85554. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85555. * This is dynamic to allow compat with webgl 1 and 2.
  85556. * You will need to pass the name of the uniform as well as the value.
  85557. */
  85558. updateMatrix: (name: string, mat: Matrix) => void;
  85559. /**
  85560. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85561. * This is dynamic to allow compat with webgl 1 and 2.
  85562. * You will need to pass the name of the uniform as well as the value.
  85563. */
  85564. updateVector3: (name: string, vector: Vector3) => void;
  85565. /**
  85566. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85567. * This is dynamic to allow compat with webgl 1 and 2.
  85568. * You will need to pass the name of the uniform as well as the value.
  85569. */
  85570. updateVector4: (name: string, vector: Vector4) => void;
  85571. /**
  85572. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85573. * This is dynamic to allow compat with webgl 1 and 2.
  85574. * You will need to pass the name of the uniform as well as the value.
  85575. */
  85576. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85577. /**
  85578. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85579. * This is dynamic to allow compat with webgl 1 and 2.
  85580. * You will need to pass the name of the uniform as well as the value.
  85581. */
  85582. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85583. /**
  85584. * Instantiates a new Uniform buffer objects.
  85585. *
  85586. * Handles blocks of uniform on the GPU.
  85587. *
  85588. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85589. *
  85590. * For more information, please refer to :
  85591. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85592. * @param engine Define the engine the buffer is associated with
  85593. * @param data Define the data contained in the buffer
  85594. * @param dynamic Define if the buffer is updatable
  85595. */
  85596. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85597. /**
  85598. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85599. * or just falling back on setUniformXXX calls.
  85600. */
  85601. get useUbo(): boolean;
  85602. /**
  85603. * Indicates if the WebGL underlying uniform buffer is in sync
  85604. * with the javascript cache data.
  85605. */
  85606. get isSync(): boolean;
  85607. /**
  85608. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85609. * Also, a dynamic UniformBuffer will disable cache verification and always
  85610. * update the underlying WebGL uniform buffer to the GPU.
  85611. * @returns if Dynamic, otherwise false
  85612. */
  85613. isDynamic(): boolean;
  85614. /**
  85615. * The data cache on JS side.
  85616. * @returns the underlying data as a float array
  85617. */
  85618. getData(): Float32Array;
  85619. /**
  85620. * The underlying WebGL Uniform buffer.
  85621. * @returns the webgl buffer
  85622. */
  85623. getBuffer(): Nullable<DataBuffer>;
  85624. /**
  85625. * std140 layout specifies how to align data within an UBO structure.
  85626. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85627. * for specs.
  85628. */
  85629. private _fillAlignment;
  85630. /**
  85631. * Adds an uniform in the buffer.
  85632. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85633. * for the layout to be correct !
  85634. * @param name Name of the uniform, as used in the uniform block in the shader.
  85635. * @param size Data size, or data directly.
  85636. */
  85637. addUniform(name: string, size: number | number[]): void;
  85638. /**
  85639. * Adds a Matrix 4x4 to the uniform buffer.
  85640. * @param name Name of the uniform, as used in the uniform block in the shader.
  85641. * @param mat A 4x4 matrix.
  85642. */
  85643. addMatrix(name: string, mat: Matrix): void;
  85644. /**
  85645. * Adds a vec2 to the uniform buffer.
  85646. * @param name Name of the uniform, as used in the uniform block in the shader.
  85647. * @param x Define the x component value of the vec2
  85648. * @param y Define the y component value of the vec2
  85649. */
  85650. addFloat2(name: string, x: number, y: number): void;
  85651. /**
  85652. * Adds a vec3 to the uniform buffer.
  85653. * @param name Name of the uniform, as used in the uniform block in the shader.
  85654. * @param x Define the x component value of the vec3
  85655. * @param y Define the y component value of the vec3
  85656. * @param z Define the z component value of the vec3
  85657. */
  85658. addFloat3(name: string, x: number, y: number, z: number): void;
  85659. /**
  85660. * Adds a vec3 to the uniform buffer.
  85661. * @param name Name of the uniform, as used in the uniform block in the shader.
  85662. * @param color Define the vec3 from a Color
  85663. */
  85664. addColor3(name: string, color: Color3): void;
  85665. /**
  85666. * Adds a vec4 to the uniform buffer.
  85667. * @param name Name of the uniform, as used in the uniform block in the shader.
  85668. * @param color Define the rgb components from a Color
  85669. * @param alpha Define the a component of the vec4
  85670. */
  85671. addColor4(name: string, color: Color3, alpha: number): void;
  85672. /**
  85673. * Adds a vec3 to the uniform buffer.
  85674. * @param name Name of the uniform, as used in the uniform block in the shader.
  85675. * @param vector Define the vec3 components from a Vector
  85676. */
  85677. addVector3(name: string, vector: Vector3): void;
  85678. /**
  85679. * Adds a Matrix 3x3 to the uniform buffer.
  85680. * @param name Name of the uniform, as used in the uniform block in the shader.
  85681. */
  85682. addMatrix3x3(name: string): void;
  85683. /**
  85684. * Adds a Matrix 2x2 to the uniform buffer.
  85685. * @param name Name of the uniform, as used in the uniform block in the shader.
  85686. */
  85687. addMatrix2x2(name: string): void;
  85688. /**
  85689. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85690. */
  85691. create(): void;
  85692. /** @hidden */
  85693. _rebuild(): void;
  85694. /**
  85695. * Updates the WebGL Uniform Buffer on the GPU.
  85696. * If the `dynamic` flag is set to true, no cache comparison is done.
  85697. * Otherwise, the buffer will be updated only if the cache differs.
  85698. */
  85699. update(): void;
  85700. /**
  85701. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85702. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85703. * @param data Define the flattened data
  85704. * @param size Define the size of the data.
  85705. */
  85706. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85707. private _valueCache;
  85708. private _cacheMatrix;
  85709. private _updateMatrix3x3ForUniform;
  85710. private _updateMatrix3x3ForEffect;
  85711. private _updateMatrix2x2ForEffect;
  85712. private _updateMatrix2x2ForUniform;
  85713. private _updateFloatForEffect;
  85714. private _updateFloatForUniform;
  85715. private _updateFloat2ForEffect;
  85716. private _updateFloat2ForUniform;
  85717. private _updateFloat3ForEffect;
  85718. private _updateFloat3ForUniform;
  85719. private _updateFloat4ForEffect;
  85720. private _updateFloat4ForUniform;
  85721. private _updateMatrixForEffect;
  85722. private _updateMatrixForUniform;
  85723. private _updateVector3ForEffect;
  85724. private _updateVector3ForUniform;
  85725. private _updateVector4ForEffect;
  85726. private _updateVector4ForUniform;
  85727. private _updateColor3ForEffect;
  85728. private _updateColor3ForUniform;
  85729. private _updateColor4ForEffect;
  85730. private _updateColor4ForUniform;
  85731. /**
  85732. * Sets a sampler uniform on the effect.
  85733. * @param name Define the name of the sampler.
  85734. * @param texture Define the texture to set in the sampler
  85735. */
  85736. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85737. /**
  85738. * Directly updates the value of the uniform in the cache AND on the GPU.
  85739. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85740. * @param data Define the flattened data
  85741. */
  85742. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85743. /**
  85744. * Binds this uniform buffer to an effect.
  85745. * @param effect Define the effect to bind the buffer to
  85746. * @param name Name of the uniform block in the shader.
  85747. */
  85748. bindToEffect(effect: Effect, name: string): void;
  85749. /**
  85750. * Disposes the uniform buffer.
  85751. */
  85752. dispose(): void;
  85753. }
  85754. }
  85755. declare module BABYLON {
  85756. /**
  85757. * Enum that determines the text-wrapping mode to use.
  85758. */
  85759. export enum InspectableType {
  85760. /**
  85761. * Checkbox for booleans
  85762. */
  85763. Checkbox = 0,
  85764. /**
  85765. * Sliders for numbers
  85766. */
  85767. Slider = 1,
  85768. /**
  85769. * Vector3
  85770. */
  85771. Vector3 = 2,
  85772. /**
  85773. * Quaternions
  85774. */
  85775. Quaternion = 3,
  85776. /**
  85777. * Color3
  85778. */
  85779. Color3 = 4,
  85780. /**
  85781. * String
  85782. */
  85783. String = 5
  85784. }
  85785. /**
  85786. * Interface used to define custom inspectable properties.
  85787. * This interface is used by the inspector to display custom property grids
  85788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85789. */
  85790. export interface IInspectable {
  85791. /**
  85792. * Gets the label to display
  85793. */
  85794. label: string;
  85795. /**
  85796. * Gets the name of the property to edit
  85797. */
  85798. propertyName: string;
  85799. /**
  85800. * Gets the type of the editor to use
  85801. */
  85802. type: InspectableType;
  85803. /**
  85804. * Gets the minimum value of the property when using in "slider" mode
  85805. */
  85806. min?: number;
  85807. /**
  85808. * Gets the maximum value of the property when using in "slider" mode
  85809. */
  85810. max?: number;
  85811. /**
  85812. * Gets the setp to use when using in "slider" mode
  85813. */
  85814. step?: number;
  85815. }
  85816. }
  85817. declare module BABYLON {
  85818. /**
  85819. * Class used to provide helper for timing
  85820. */
  85821. export class TimingTools {
  85822. /**
  85823. * Polyfill for setImmediate
  85824. * @param action defines the action to execute after the current execution block
  85825. */
  85826. static SetImmediate(action: () => void): void;
  85827. }
  85828. }
  85829. declare module BABYLON {
  85830. /**
  85831. * Class used to enable instatition of objects by class name
  85832. */
  85833. export class InstantiationTools {
  85834. /**
  85835. * Use this object to register external classes like custom textures or material
  85836. * to allow the laoders to instantiate them
  85837. */
  85838. static RegisteredExternalClasses: {
  85839. [key: string]: Object;
  85840. };
  85841. /**
  85842. * Tries to instantiate a new object from a given class name
  85843. * @param className defines the class name to instantiate
  85844. * @returns the new object or null if the system was not able to do the instantiation
  85845. */
  85846. static Instantiate(className: string): any;
  85847. }
  85848. }
  85849. declare module BABYLON {
  85850. /**
  85851. * Define options used to create a depth texture
  85852. */
  85853. export class DepthTextureCreationOptions {
  85854. /** Specifies whether or not a stencil should be allocated in the texture */
  85855. generateStencil?: boolean;
  85856. /** Specifies whether or not bilinear filtering is enable on the texture */
  85857. bilinearFiltering?: boolean;
  85858. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85859. comparisonFunction?: number;
  85860. /** Specifies if the created texture is a cube texture */
  85861. isCube?: boolean;
  85862. }
  85863. }
  85864. declare module BABYLON {
  85865. interface ThinEngine {
  85866. /**
  85867. * Creates a depth stencil cube texture.
  85868. * This is only available in WebGL 2.
  85869. * @param size The size of face edge in the cube texture.
  85870. * @param options The options defining the cube texture.
  85871. * @returns The cube texture
  85872. */
  85873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85874. /**
  85875. * Creates a cube texture
  85876. * @param rootUrl defines the url where the files to load is located
  85877. * @param scene defines the current scene
  85878. * @param files defines the list of files to load (1 per face)
  85879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85880. * @param onLoad defines an optional callback raised when the texture is loaded
  85881. * @param onError defines an optional callback raised if there is an issue to load the texture
  85882. * @param format defines the format of the data
  85883. * @param forcedExtension defines the extension to use to pick the right loader
  85884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85888. * @returns the cube texture as an InternalTexture
  85889. */
  85890. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  85891. /**
  85892. * Creates a cube texture
  85893. * @param rootUrl defines the url where the files to load is located
  85894. * @param scene defines the current scene
  85895. * @param files defines the list of files to load (1 per face)
  85896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85897. * @param onLoad defines an optional callback raised when the texture is loaded
  85898. * @param onError defines an optional callback raised if there is an issue to load the texture
  85899. * @param format defines the format of the data
  85900. * @param forcedExtension defines the extension to use to pick the right loader
  85901. * @returns the cube texture as an InternalTexture
  85902. */
  85903. 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;
  85904. /**
  85905. * Creates a cube texture
  85906. * @param rootUrl defines the url where the files to load is located
  85907. * @param scene defines the current scene
  85908. * @param files defines the list of files to load (1 per face)
  85909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85910. * @param onLoad defines an optional callback raised when the texture is loaded
  85911. * @param onError defines an optional callback raised if there is an issue to load the texture
  85912. * @param format defines the format of the data
  85913. * @param forcedExtension defines the extension to use to pick the right loader
  85914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85917. * @returns the cube texture as an InternalTexture
  85918. */
  85919. 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;
  85920. /** @hidden */
  85921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85922. /** @hidden */
  85923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85924. /** @hidden */
  85925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85926. /** @hidden */
  85927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85928. /**
  85929. * @hidden
  85930. */
  85931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85932. }
  85933. }
  85934. declare module BABYLON {
  85935. /**
  85936. * Class for creating a cube texture
  85937. */
  85938. export class CubeTexture extends BaseTexture {
  85939. private _delayedOnLoad;
  85940. /**
  85941. * Observable triggered once the texture has been loaded.
  85942. */
  85943. onLoadObservable: Observable<CubeTexture>;
  85944. /**
  85945. * The url of the texture
  85946. */
  85947. url: string;
  85948. /**
  85949. * Gets or sets the center of the bounding box associated with the cube texture.
  85950. * It must define where the camera used to render the texture was set
  85951. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85952. */
  85953. boundingBoxPosition: Vector3;
  85954. private _boundingBoxSize;
  85955. /**
  85956. * Gets or sets the size of the bounding box associated with the cube texture
  85957. * When defined, the cubemap will switch to local mode
  85958. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85959. * @example https://www.babylonjs-playground.com/#RNASML
  85960. */
  85961. set boundingBoxSize(value: Vector3);
  85962. /**
  85963. * Returns the bounding box size
  85964. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85965. */
  85966. get boundingBoxSize(): Vector3;
  85967. protected _rotationY: number;
  85968. /**
  85969. * Sets texture matrix rotation angle around Y axis in radians.
  85970. */
  85971. set rotationY(value: number);
  85972. /**
  85973. * Gets texture matrix rotation angle around Y axis radians.
  85974. */
  85975. get rotationY(): number;
  85976. /**
  85977. * Are mip maps generated for this texture or not.
  85978. */
  85979. get noMipmap(): boolean;
  85980. private _noMipmap;
  85981. private _files;
  85982. protected _forcedExtension: Nullable<string>;
  85983. private _extensions;
  85984. private _textureMatrix;
  85985. private _format;
  85986. private _createPolynomials;
  85987. /**
  85988. * Creates a cube texture from an array of image urls
  85989. * @param files defines an array of image urls
  85990. * @param scene defines the hosting scene
  85991. * @param noMipmap specifies if mip maps are not used
  85992. * @returns a cube texture
  85993. */
  85994. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85995. /**
  85996. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85997. * @param url defines the url of the prefiltered texture
  85998. * @param scene defines the scene the texture is attached to
  85999. * @param forcedExtension defines the extension of the file if different from the url
  86000. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86001. * @return the prefiltered texture
  86002. */
  86003. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86004. /**
  86005. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86006. * as prefiltered data.
  86007. * @param rootUrl defines the url of the texture or the root name of the six images
  86008. * @param null defines the scene or engine the texture is attached to
  86009. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86010. * @param noMipmap defines if mipmaps should be created or not
  86011. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86012. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86013. * @param onError defines a callback triggered in case of error during load
  86014. * @param format defines the internal format to use for the texture once loaded
  86015. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86016. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86017. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86018. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86019. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86020. * @return the cube texture
  86021. */
  86022. 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);
  86023. /**
  86024. * Get the current class name of the texture useful for serialization or dynamic coding.
  86025. * @returns "CubeTexture"
  86026. */
  86027. getClassName(): string;
  86028. /**
  86029. * Update the url (and optional buffer) of this texture if url was null during construction.
  86030. * @param url the url of the texture
  86031. * @param forcedExtension defines the extension to use
  86032. * @param onLoad callback called when the texture is loaded (defaults to null)
  86033. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86034. */
  86035. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86036. /**
  86037. * Delays loading of the cube texture
  86038. * @param forcedExtension defines the extension to use
  86039. */
  86040. delayLoad(forcedExtension?: string): void;
  86041. /**
  86042. * Returns the reflection texture matrix
  86043. * @returns the reflection texture matrix
  86044. */
  86045. getReflectionTextureMatrix(): Matrix;
  86046. /**
  86047. * Sets the reflection texture matrix
  86048. * @param value Reflection texture matrix
  86049. */
  86050. setReflectionTextureMatrix(value: Matrix): void;
  86051. /**
  86052. * Parses text to create a cube texture
  86053. * @param parsedTexture define the serialized text to read from
  86054. * @param scene defines the hosting scene
  86055. * @param rootUrl defines the root url of the cube texture
  86056. * @returns a cube texture
  86057. */
  86058. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86059. /**
  86060. * Makes a clone, or deep copy, of the cube texture
  86061. * @returns a new cube texture
  86062. */
  86063. clone(): CubeTexture;
  86064. }
  86065. }
  86066. declare module BABYLON {
  86067. /**
  86068. * Manages the defines for the Material
  86069. */
  86070. export class MaterialDefines {
  86071. /** @hidden */
  86072. protected _keys: string[];
  86073. private _isDirty;
  86074. /** @hidden */
  86075. _renderId: number;
  86076. /** @hidden */
  86077. _areLightsDirty: boolean;
  86078. /** @hidden */
  86079. _areLightsDisposed: boolean;
  86080. /** @hidden */
  86081. _areAttributesDirty: boolean;
  86082. /** @hidden */
  86083. _areTexturesDirty: boolean;
  86084. /** @hidden */
  86085. _areFresnelDirty: boolean;
  86086. /** @hidden */
  86087. _areMiscDirty: boolean;
  86088. /** @hidden */
  86089. _areImageProcessingDirty: boolean;
  86090. /** @hidden */
  86091. _normals: boolean;
  86092. /** @hidden */
  86093. _uvs: boolean;
  86094. /** @hidden */
  86095. _needNormals: boolean;
  86096. /** @hidden */
  86097. _needUVs: boolean;
  86098. [id: string]: any;
  86099. /**
  86100. * Specifies if the material needs to be re-calculated
  86101. */
  86102. get isDirty(): boolean;
  86103. /**
  86104. * Marks the material to indicate that it has been re-calculated
  86105. */
  86106. markAsProcessed(): void;
  86107. /**
  86108. * Marks the material to indicate that it needs to be re-calculated
  86109. */
  86110. markAsUnprocessed(): void;
  86111. /**
  86112. * Marks the material to indicate all of its defines need to be re-calculated
  86113. */
  86114. markAllAsDirty(): void;
  86115. /**
  86116. * Marks the material to indicate that image processing needs to be re-calculated
  86117. */
  86118. markAsImageProcessingDirty(): void;
  86119. /**
  86120. * Marks the material to indicate the lights need to be re-calculated
  86121. * @param disposed Defines whether the light is dirty due to dispose or not
  86122. */
  86123. markAsLightDirty(disposed?: boolean): void;
  86124. /**
  86125. * Marks the attribute state as changed
  86126. */
  86127. markAsAttributesDirty(): void;
  86128. /**
  86129. * Marks the texture state as changed
  86130. */
  86131. markAsTexturesDirty(): void;
  86132. /**
  86133. * Marks the fresnel state as changed
  86134. */
  86135. markAsFresnelDirty(): void;
  86136. /**
  86137. * Marks the misc state as changed
  86138. */
  86139. markAsMiscDirty(): void;
  86140. /**
  86141. * Rebuilds the material defines
  86142. */
  86143. rebuild(): void;
  86144. /**
  86145. * Specifies if two material defines are equal
  86146. * @param other - A material define instance to compare to
  86147. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86148. */
  86149. isEqual(other: MaterialDefines): boolean;
  86150. /**
  86151. * Clones this instance's defines to another instance
  86152. * @param other - material defines to clone values to
  86153. */
  86154. cloneTo(other: MaterialDefines): void;
  86155. /**
  86156. * Resets the material define values
  86157. */
  86158. reset(): void;
  86159. /**
  86160. * Converts the material define values to a string
  86161. * @returns - String of material define information
  86162. */
  86163. toString(): string;
  86164. }
  86165. }
  86166. declare module BABYLON {
  86167. /**
  86168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86170. * 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;
  86171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86172. */
  86173. export class ColorCurves {
  86174. private _dirty;
  86175. private _tempColor;
  86176. private _globalCurve;
  86177. private _highlightsCurve;
  86178. private _midtonesCurve;
  86179. private _shadowsCurve;
  86180. private _positiveCurve;
  86181. private _negativeCurve;
  86182. private _globalHue;
  86183. private _globalDensity;
  86184. private _globalSaturation;
  86185. private _globalExposure;
  86186. /**
  86187. * Gets the global Hue value.
  86188. * 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).
  86189. */
  86190. get globalHue(): number;
  86191. /**
  86192. * Sets the global Hue value.
  86193. * 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).
  86194. */
  86195. set globalHue(value: number);
  86196. /**
  86197. * Gets the global Density value.
  86198. * 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.
  86199. * Values less than zero provide a filter of opposite hue.
  86200. */
  86201. get globalDensity(): number;
  86202. /**
  86203. * Sets the global Density value.
  86204. * 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.
  86205. * Values less than zero provide a filter of opposite hue.
  86206. */
  86207. set globalDensity(value: number);
  86208. /**
  86209. * Gets the global Saturation value.
  86210. * 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.
  86211. */
  86212. get globalSaturation(): number;
  86213. /**
  86214. * Sets the global Saturation value.
  86215. * 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.
  86216. */
  86217. set globalSaturation(value: number);
  86218. /**
  86219. * Gets the global Exposure value.
  86220. * 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.
  86221. */
  86222. get globalExposure(): number;
  86223. /**
  86224. * Sets the global Exposure value.
  86225. * 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.
  86226. */
  86227. set globalExposure(value: number);
  86228. private _highlightsHue;
  86229. private _highlightsDensity;
  86230. private _highlightsSaturation;
  86231. private _highlightsExposure;
  86232. /**
  86233. * Gets the highlights Hue value.
  86234. * 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).
  86235. */
  86236. get highlightsHue(): number;
  86237. /**
  86238. * Sets the highlights Hue value.
  86239. * 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).
  86240. */
  86241. set highlightsHue(value: number);
  86242. /**
  86243. * Gets the highlights Density value.
  86244. * 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.
  86245. * Values less than zero provide a filter of opposite hue.
  86246. */
  86247. get highlightsDensity(): number;
  86248. /**
  86249. * Sets the highlights Density value.
  86250. * 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.
  86251. * Values less than zero provide a filter of opposite hue.
  86252. */
  86253. set highlightsDensity(value: number);
  86254. /**
  86255. * Gets the highlights Saturation value.
  86256. * 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.
  86257. */
  86258. get highlightsSaturation(): number;
  86259. /**
  86260. * Sets the highlights Saturation value.
  86261. * 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.
  86262. */
  86263. set highlightsSaturation(value: number);
  86264. /**
  86265. * Gets the highlights Exposure value.
  86266. * 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.
  86267. */
  86268. get highlightsExposure(): number;
  86269. /**
  86270. * Sets the highlights Exposure value.
  86271. * 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.
  86272. */
  86273. set highlightsExposure(value: number);
  86274. private _midtonesHue;
  86275. private _midtonesDensity;
  86276. private _midtonesSaturation;
  86277. private _midtonesExposure;
  86278. /**
  86279. * Gets the midtones Hue value.
  86280. * 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).
  86281. */
  86282. get midtonesHue(): number;
  86283. /**
  86284. * Sets the midtones Hue value.
  86285. * 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).
  86286. */
  86287. set midtonesHue(value: number);
  86288. /**
  86289. * Gets the midtones Density value.
  86290. * 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.
  86291. * Values less than zero provide a filter of opposite hue.
  86292. */
  86293. get midtonesDensity(): number;
  86294. /**
  86295. * Sets the midtones Density value.
  86296. * 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.
  86297. * Values less than zero provide a filter of opposite hue.
  86298. */
  86299. set midtonesDensity(value: number);
  86300. /**
  86301. * Gets the midtones Saturation value.
  86302. * 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.
  86303. */
  86304. get midtonesSaturation(): number;
  86305. /**
  86306. * Sets the midtones Saturation value.
  86307. * 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.
  86308. */
  86309. set midtonesSaturation(value: number);
  86310. /**
  86311. * Gets the midtones Exposure value.
  86312. * 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.
  86313. */
  86314. get midtonesExposure(): number;
  86315. /**
  86316. * Sets the midtones Exposure value.
  86317. * 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.
  86318. */
  86319. set midtonesExposure(value: number);
  86320. private _shadowsHue;
  86321. private _shadowsDensity;
  86322. private _shadowsSaturation;
  86323. private _shadowsExposure;
  86324. /**
  86325. * Gets the shadows Hue value.
  86326. * 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).
  86327. */
  86328. get shadowsHue(): number;
  86329. /**
  86330. * Sets the shadows Hue value.
  86331. * 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).
  86332. */
  86333. set shadowsHue(value: number);
  86334. /**
  86335. * Gets the shadows Density value.
  86336. * 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.
  86337. * Values less than zero provide a filter of opposite hue.
  86338. */
  86339. get shadowsDensity(): number;
  86340. /**
  86341. * Sets the shadows Density value.
  86342. * 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.
  86343. * Values less than zero provide a filter of opposite hue.
  86344. */
  86345. set shadowsDensity(value: number);
  86346. /**
  86347. * Gets the shadows Saturation value.
  86348. * 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.
  86349. */
  86350. get shadowsSaturation(): number;
  86351. /**
  86352. * Sets the shadows Saturation value.
  86353. * 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.
  86354. */
  86355. set shadowsSaturation(value: number);
  86356. /**
  86357. * Gets the shadows Exposure value.
  86358. * 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.
  86359. */
  86360. get shadowsExposure(): number;
  86361. /**
  86362. * Sets the shadows Exposure value.
  86363. * 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.
  86364. */
  86365. set shadowsExposure(value: number);
  86366. /**
  86367. * Returns the class name
  86368. * @returns The class name
  86369. */
  86370. getClassName(): string;
  86371. /**
  86372. * Binds the color curves to the shader.
  86373. * @param colorCurves The color curve to bind
  86374. * @param effect The effect to bind to
  86375. * @param positiveUniform The positive uniform shader parameter
  86376. * @param neutralUniform The neutral uniform shader parameter
  86377. * @param negativeUniform The negative uniform shader parameter
  86378. */
  86379. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86380. /**
  86381. * Prepare the list of uniforms associated with the ColorCurves effects.
  86382. * @param uniformsList The list of uniforms used in the effect
  86383. */
  86384. static PrepareUniforms(uniformsList: string[]): void;
  86385. /**
  86386. * Returns color grading data based on a hue, density, saturation and exposure value.
  86387. * @param filterHue The hue of the color filter.
  86388. * @param filterDensity The density of the color filter.
  86389. * @param saturation The saturation.
  86390. * @param exposure The exposure.
  86391. * @param result The result data container.
  86392. */
  86393. private getColorGradingDataToRef;
  86394. /**
  86395. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86396. * @param value The input slider value in range [-100,100].
  86397. * @returns Adjusted value.
  86398. */
  86399. private static applyColorGradingSliderNonlinear;
  86400. /**
  86401. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86402. * @param hue The hue (H) input.
  86403. * @param saturation The saturation (S) input.
  86404. * @param brightness The brightness (B) input.
  86405. * @result An RGBA color represented as Vector4.
  86406. */
  86407. private static fromHSBToRef;
  86408. /**
  86409. * Returns a value clamped between min and max
  86410. * @param value The value to clamp
  86411. * @param min The minimum of value
  86412. * @param max The maximum of value
  86413. * @returns The clamped value.
  86414. */
  86415. private static clamp;
  86416. /**
  86417. * Clones the current color curve instance.
  86418. * @return The cloned curves
  86419. */
  86420. clone(): ColorCurves;
  86421. /**
  86422. * Serializes the current color curve instance to a json representation.
  86423. * @return a JSON representation
  86424. */
  86425. serialize(): any;
  86426. /**
  86427. * Parses the color curve from a json representation.
  86428. * @param source the JSON source to parse
  86429. * @return The parsed curves
  86430. */
  86431. static Parse(source: any): ColorCurves;
  86432. }
  86433. }
  86434. declare module BABYLON {
  86435. /**
  86436. * Interface to follow in your material defines to integrate easily the
  86437. * Image proccessing functions.
  86438. * @hidden
  86439. */
  86440. export interface IImageProcessingConfigurationDefines {
  86441. IMAGEPROCESSING: boolean;
  86442. VIGNETTE: boolean;
  86443. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86444. VIGNETTEBLENDMODEOPAQUE: boolean;
  86445. TONEMAPPING: boolean;
  86446. TONEMAPPING_ACES: boolean;
  86447. CONTRAST: boolean;
  86448. EXPOSURE: boolean;
  86449. COLORCURVES: boolean;
  86450. COLORGRADING: boolean;
  86451. COLORGRADING3D: boolean;
  86452. SAMPLER3DGREENDEPTH: boolean;
  86453. SAMPLER3DBGRMAP: boolean;
  86454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86455. }
  86456. /**
  86457. * @hidden
  86458. */
  86459. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86460. IMAGEPROCESSING: boolean;
  86461. VIGNETTE: boolean;
  86462. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86463. VIGNETTEBLENDMODEOPAQUE: boolean;
  86464. TONEMAPPING: boolean;
  86465. TONEMAPPING_ACES: boolean;
  86466. CONTRAST: boolean;
  86467. COLORCURVES: boolean;
  86468. COLORGRADING: boolean;
  86469. COLORGRADING3D: boolean;
  86470. SAMPLER3DGREENDEPTH: boolean;
  86471. SAMPLER3DBGRMAP: boolean;
  86472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86473. EXPOSURE: boolean;
  86474. constructor();
  86475. }
  86476. /**
  86477. * This groups together the common properties used for image processing either in direct forward pass
  86478. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86479. * or not.
  86480. */
  86481. export class ImageProcessingConfiguration {
  86482. /**
  86483. * Default tone mapping applied in BabylonJS.
  86484. */
  86485. static readonly TONEMAPPING_STANDARD: number;
  86486. /**
  86487. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86488. * to other engines rendering to increase portability.
  86489. */
  86490. static readonly TONEMAPPING_ACES: number;
  86491. /**
  86492. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86493. */
  86494. colorCurves: Nullable<ColorCurves>;
  86495. private _colorCurvesEnabled;
  86496. /**
  86497. * Gets wether the color curves effect is enabled.
  86498. */
  86499. get colorCurvesEnabled(): boolean;
  86500. /**
  86501. * Sets wether the color curves effect is enabled.
  86502. */
  86503. set colorCurvesEnabled(value: boolean);
  86504. private _colorGradingTexture;
  86505. /**
  86506. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86507. */
  86508. get colorGradingTexture(): Nullable<BaseTexture>;
  86509. /**
  86510. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86511. */
  86512. set colorGradingTexture(value: Nullable<BaseTexture>);
  86513. private _colorGradingEnabled;
  86514. /**
  86515. * Gets wether the color grading effect is enabled.
  86516. */
  86517. get colorGradingEnabled(): boolean;
  86518. /**
  86519. * Sets wether the color grading effect is enabled.
  86520. */
  86521. set colorGradingEnabled(value: boolean);
  86522. private _colorGradingWithGreenDepth;
  86523. /**
  86524. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86525. */
  86526. get colorGradingWithGreenDepth(): boolean;
  86527. /**
  86528. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86529. */
  86530. set colorGradingWithGreenDepth(value: boolean);
  86531. private _colorGradingBGR;
  86532. /**
  86533. * Gets wether the color grading texture contains BGR values.
  86534. */
  86535. get colorGradingBGR(): boolean;
  86536. /**
  86537. * Sets wether the color grading texture contains BGR values.
  86538. */
  86539. set colorGradingBGR(value: boolean);
  86540. /** @hidden */
  86541. _exposure: number;
  86542. /**
  86543. * Gets the Exposure used in the effect.
  86544. */
  86545. get exposure(): number;
  86546. /**
  86547. * Sets the Exposure used in the effect.
  86548. */
  86549. set exposure(value: number);
  86550. private _toneMappingEnabled;
  86551. /**
  86552. * Gets wether the tone mapping effect is enabled.
  86553. */
  86554. get toneMappingEnabled(): boolean;
  86555. /**
  86556. * Sets wether the tone mapping effect is enabled.
  86557. */
  86558. set toneMappingEnabled(value: boolean);
  86559. private _toneMappingType;
  86560. /**
  86561. * Gets the type of tone mapping effect.
  86562. */
  86563. get toneMappingType(): number;
  86564. /**
  86565. * Sets the type of tone mapping effect used in BabylonJS.
  86566. */
  86567. set toneMappingType(value: number);
  86568. protected _contrast: number;
  86569. /**
  86570. * Gets the contrast used in the effect.
  86571. */
  86572. get contrast(): number;
  86573. /**
  86574. * Sets the contrast used in the effect.
  86575. */
  86576. set contrast(value: number);
  86577. /**
  86578. * Vignette stretch size.
  86579. */
  86580. vignetteStretch: number;
  86581. /**
  86582. * Vignette centre X Offset.
  86583. */
  86584. vignetteCentreX: number;
  86585. /**
  86586. * Vignette centre Y Offset.
  86587. */
  86588. vignetteCentreY: number;
  86589. /**
  86590. * Vignette weight or intensity of the vignette effect.
  86591. */
  86592. vignetteWeight: number;
  86593. /**
  86594. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86595. * if vignetteEnabled is set to true.
  86596. */
  86597. vignetteColor: Color4;
  86598. /**
  86599. * Camera field of view used by the Vignette effect.
  86600. */
  86601. vignetteCameraFov: number;
  86602. private _vignetteBlendMode;
  86603. /**
  86604. * Gets the vignette blend mode allowing different kind of effect.
  86605. */
  86606. get vignetteBlendMode(): number;
  86607. /**
  86608. * Sets the vignette blend mode allowing different kind of effect.
  86609. */
  86610. set vignetteBlendMode(value: number);
  86611. private _vignetteEnabled;
  86612. /**
  86613. * Gets wether the vignette effect is enabled.
  86614. */
  86615. get vignetteEnabled(): boolean;
  86616. /**
  86617. * Sets wether the vignette effect is enabled.
  86618. */
  86619. set vignetteEnabled(value: boolean);
  86620. private _applyByPostProcess;
  86621. /**
  86622. * Gets wether the image processing is applied through a post process or not.
  86623. */
  86624. get applyByPostProcess(): boolean;
  86625. /**
  86626. * Sets wether the image processing is applied through a post process or not.
  86627. */
  86628. set applyByPostProcess(value: boolean);
  86629. private _isEnabled;
  86630. /**
  86631. * Gets wether the image processing is enabled or not.
  86632. */
  86633. get isEnabled(): boolean;
  86634. /**
  86635. * Sets wether the image processing is enabled or not.
  86636. */
  86637. set isEnabled(value: boolean);
  86638. /**
  86639. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86640. */
  86641. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86642. /**
  86643. * Method called each time the image processing information changes requires to recompile the effect.
  86644. */
  86645. protected _updateParameters(): void;
  86646. /**
  86647. * Gets the current class name.
  86648. * @return "ImageProcessingConfiguration"
  86649. */
  86650. getClassName(): string;
  86651. /**
  86652. * Prepare the list of uniforms associated with the Image Processing effects.
  86653. * @param uniforms The list of uniforms used in the effect
  86654. * @param defines the list of defines currently in use
  86655. */
  86656. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86657. /**
  86658. * Prepare the list of samplers associated with the Image Processing effects.
  86659. * @param samplersList The list of uniforms used in the effect
  86660. * @param defines the list of defines currently in use
  86661. */
  86662. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86663. /**
  86664. * Prepare the list of defines associated to the shader.
  86665. * @param defines the list of defines to complete
  86666. * @param forPostProcess Define if we are currently in post process mode or not
  86667. */
  86668. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86669. /**
  86670. * Returns true if all the image processing information are ready.
  86671. * @returns True if ready, otherwise, false
  86672. */
  86673. isReady(): boolean;
  86674. /**
  86675. * Binds the image processing to the shader.
  86676. * @param effect The effect to bind to
  86677. * @param overrideAspectRatio Override the aspect ratio of the effect
  86678. */
  86679. bind(effect: Effect, overrideAspectRatio?: number): void;
  86680. /**
  86681. * Clones the current image processing instance.
  86682. * @return The cloned image processing
  86683. */
  86684. clone(): ImageProcessingConfiguration;
  86685. /**
  86686. * Serializes the current image processing instance to a json representation.
  86687. * @return a JSON representation
  86688. */
  86689. serialize(): any;
  86690. /**
  86691. * Parses the image processing from a json representation.
  86692. * @param source the JSON source to parse
  86693. * @return The parsed image processing
  86694. */
  86695. static Parse(source: any): ImageProcessingConfiguration;
  86696. private static _VIGNETTEMODE_MULTIPLY;
  86697. private static _VIGNETTEMODE_OPAQUE;
  86698. /**
  86699. * Used to apply the vignette as a mix with the pixel color.
  86700. */
  86701. static get VIGNETTEMODE_MULTIPLY(): number;
  86702. /**
  86703. * Used to apply the vignette as a replacement of the pixel color.
  86704. */
  86705. static get VIGNETTEMODE_OPAQUE(): number;
  86706. }
  86707. }
  86708. declare module BABYLON {
  86709. /** @hidden */
  86710. export var postprocessVertexShader: {
  86711. name: string;
  86712. shader: string;
  86713. };
  86714. }
  86715. declare module BABYLON {
  86716. interface ThinEngine {
  86717. /**
  86718. * Creates a new render target texture
  86719. * @param size defines the size of the texture
  86720. * @param options defines the options used to create the texture
  86721. * @returns a new render target texture stored in an InternalTexture
  86722. */
  86723. createRenderTargetTexture(size: number | {
  86724. width: number;
  86725. height: number;
  86726. layers?: number;
  86727. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86728. /**
  86729. * Creates a depth stencil texture.
  86730. * This is only available in WebGL 2 or with the depth texture extension available.
  86731. * @param size The size of face edge in the texture.
  86732. * @param options The options defining the texture.
  86733. * @returns The texture
  86734. */
  86735. createDepthStencilTexture(size: number | {
  86736. width: number;
  86737. height: number;
  86738. layers?: number;
  86739. }, options: DepthTextureCreationOptions): InternalTexture;
  86740. /** @hidden */
  86741. _createDepthStencilTexture(size: number | {
  86742. width: number;
  86743. height: number;
  86744. layers?: number;
  86745. }, options: DepthTextureCreationOptions): InternalTexture;
  86746. }
  86747. }
  86748. declare module BABYLON {
  86749. /**
  86750. * Defines the kind of connection point for node based material
  86751. */
  86752. export enum NodeMaterialBlockConnectionPointTypes {
  86753. /** Float */
  86754. Float = 1,
  86755. /** Int */
  86756. Int = 2,
  86757. /** Vector2 */
  86758. Vector2 = 4,
  86759. /** Vector3 */
  86760. Vector3 = 8,
  86761. /** Vector4 */
  86762. Vector4 = 16,
  86763. /** Color3 */
  86764. Color3 = 32,
  86765. /** Color4 */
  86766. Color4 = 64,
  86767. /** Matrix */
  86768. Matrix = 128,
  86769. /** Custom object */
  86770. Object = 256,
  86771. /** Detect type based on connection */
  86772. AutoDetect = 1024,
  86773. /** Output type that will be defined by input type */
  86774. BasedOnInput = 2048
  86775. }
  86776. }
  86777. declare module BABYLON {
  86778. /**
  86779. * Enum used to define the target of a block
  86780. */
  86781. export enum NodeMaterialBlockTargets {
  86782. /** Vertex shader */
  86783. Vertex = 1,
  86784. /** Fragment shader */
  86785. Fragment = 2,
  86786. /** Neutral */
  86787. Neutral = 4,
  86788. /** Vertex and Fragment */
  86789. VertexAndFragment = 3
  86790. }
  86791. }
  86792. declare module BABYLON {
  86793. /**
  86794. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86795. */
  86796. export enum NodeMaterialBlockConnectionPointMode {
  86797. /** Value is an uniform */
  86798. Uniform = 0,
  86799. /** Value is a mesh attribute */
  86800. Attribute = 1,
  86801. /** Value is a varying between vertex and fragment shaders */
  86802. Varying = 2,
  86803. /** Mode is undefined */
  86804. Undefined = 3
  86805. }
  86806. }
  86807. declare module BABYLON {
  86808. /**
  86809. * Enum used to define system values e.g. values automatically provided by the system
  86810. */
  86811. export enum NodeMaterialSystemValues {
  86812. /** World */
  86813. World = 1,
  86814. /** View */
  86815. View = 2,
  86816. /** Projection */
  86817. Projection = 3,
  86818. /** ViewProjection */
  86819. ViewProjection = 4,
  86820. /** WorldView */
  86821. WorldView = 5,
  86822. /** WorldViewProjection */
  86823. WorldViewProjection = 6,
  86824. /** CameraPosition */
  86825. CameraPosition = 7,
  86826. /** Fog Color */
  86827. FogColor = 8,
  86828. /** Delta time */
  86829. DeltaTime = 9
  86830. }
  86831. }
  86832. declare module BABYLON {
  86833. /** Defines supported spaces */
  86834. export enum Space {
  86835. /** Local (object) space */
  86836. LOCAL = 0,
  86837. /** World space */
  86838. WORLD = 1,
  86839. /** Bone space */
  86840. BONE = 2
  86841. }
  86842. /** Defines the 3 main axes */
  86843. export class Axis {
  86844. /** X axis */
  86845. static X: Vector3;
  86846. /** Y axis */
  86847. static Y: Vector3;
  86848. /** Z axis */
  86849. static Z: Vector3;
  86850. }
  86851. }
  86852. declare module BABYLON {
  86853. /**
  86854. * Represents a camera frustum
  86855. */
  86856. export class Frustum {
  86857. /**
  86858. * Gets the planes representing the frustum
  86859. * @param transform matrix to be applied to the returned planes
  86860. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86861. */
  86862. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86863. /**
  86864. * Gets the near frustum plane transformed by the transform matrix
  86865. * @param transform transformation matrix to be applied to the resulting frustum plane
  86866. * @param frustumPlane the resuling frustum plane
  86867. */
  86868. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86869. /**
  86870. * Gets the far frustum plane transformed by the transform matrix
  86871. * @param transform transformation matrix to be applied to the resulting frustum plane
  86872. * @param frustumPlane the resuling frustum plane
  86873. */
  86874. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86875. /**
  86876. * Gets the left frustum plane transformed by the transform matrix
  86877. * @param transform transformation matrix to be applied to the resulting frustum plane
  86878. * @param frustumPlane the resuling frustum plane
  86879. */
  86880. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86881. /**
  86882. * Gets the right frustum plane transformed by the transform matrix
  86883. * @param transform transformation matrix to be applied to the resulting frustum plane
  86884. * @param frustumPlane the resuling frustum plane
  86885. */
  86886. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86887. /**
  86888. * Gets the top frustum plane transformed by the transform matrix
  86889. * @param transform transformation matrix to be applied to the resulting frustum plane
  86890. * @param frustumPlane the resuling frustum plane
  86891. */
  86892. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86893. /**
  86894. * Gets the bottom frustum plane transformed by the transform matrix
  86895. * @param transform transformation matrix to be applied to the resulting frustum plane
  86896. * @param frustumPlane the resuling frustum plane
  86897. */
  86898. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86899. /**
  86900. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86901. * @param transform transformation matrix to be applied to the resulting frustum planes
  86902. * @param frustumPlanes the resuling frustum planes
  86903. */
  86904. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86905. }
  86906. }
  86907. declare module BABYLON {
  86908. /**
  86909. * Interface for the size containing width and height
  86910. */
  86911. export interface ISize {
  86912. /**
  86913. * Width
  86914. */
  86915. width: number;
  86916. /**
  86917. * Heighht
  86918. */
  86919. height: number;
  86920. }
  86921. /**
  86922. * Size containing widht and height
  86923. */
  86924. export class Size implements ISize {
  86925. /**
  86926. * Width
  86927. */
  86928. width: number;
  86929. /**
  86930. * Height
  86931. */
  86932. height: number;
  86933. /**
  86934. * Creates a Size object from the given width and height (floats).
  86935. * @param width width of the new size
  86936. * @param height height of the new size
  86937. */
  86938. constructor(width: number, height: number);
  86939. /**
  86940. * Returns a string with the Size width and height
  86941. * @returns a string with the Size width and height
  86942. */
  86943. toString(): string;
  86944. /**
  86945. * "Size"
  86946. * @returns the string "Size"
  86947. */
  86948. getClassName(): string;
  86949. /**
  86950. * Returns the Size hash code.
  86951. * @returns a hash code for a unique width and height
  86952. */
  86953. getHashCode(): number;
  86954. /**
  86955. * Updates the current size from the given one.
  86956. * @param src the given size
  86957. */
  86958. copyFrom(src: Size): void;
  86959. /**
  86960. * Updates in place the current Size from the given floats.
  86961. * @param width width of the new size
  86962. * @param height height of the new size
  86963. * @returns the updated Size.
  86964. */
  86965. copyFromFloats(width: number, height: number): Size;
  86966. /**
  86967. * Updates in place the current Size from the given floats.
  86968. * @param width width to set
  86969. * @param height height to set
  86970. * @returns the updated Size.
  86971. */
  86972. set(width: number, height: number): Size;
  86973. /**
  86974. * Multiplies the width and height by numbers
  86975. * @param w factor to multiple the width by
  86976. * @param h factor to multiple the height by
  86977. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86978. */
  86979. multiplyByFloats(w: number, h: number): Size;
  86980. /**
  86981. * Clones the size
  86982. * @returns a new Size copied from the given one.
  86983. */
  86984. clone(): Size;
  86985. /**
  86986. * True if the current Size and the given one width and height are strictly equal.
  86987. * @param other the other size to compare against
  86988. * @returns True if the current Size and the given one width and height are strictly equal.
  86989. */
  86990. equals(other: Size): boolean;
  86991. /**
  86992. * The surface of the Size : width * height (float).
  86993. */
  86994. get surface(): number;
  86995. /**
  86996. * Create a new size of zero
  86997. * @returns a new Size set to (0.0, 0.0)
  86998. */
  86999. static Zero(): Size;
  87000. /**
  87001. * Sums the width and height of two sizes
  87002. * @param otherSize size to add to this size
  87003. * @returns a new Size set as the addition result of the current Size and the given one.
  87004. */
  87005. add(otherSize: Size): Size;
  87006. /**
  87007. * Subtracts the width and height of two
  87008. * @param otherSize size to subtract to this size
  87009. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87010. */
  87011. subtract(otherSize: Size): Size;
  87012. /**
  87013. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87014. * @param start starting size to lerp between
  87015. * @param end end size to lerp between
  87016. * @param amount amount to lerp between the start and end values
  87017. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87018. */
  87019. static Lerp(start: Size, end: Size, amount: number): Size;
  87020. }
  87021. }
  87022. declare module BABYLON {
  87023. /**
  87024. * Contains position and normal vectors for a vertex
  87025. */
  87026. export class PositionNormalVertex {
  87027. /** the position of the vertex (defaut: 0,0,0) */
  87028. position: Vector3;
  87029. /** the normal of the vertex (defaut: 0,1,0) */
  87030. normal: Vector3;
  87031. /**
  87032. * Creates a PositionNormalVertex
  87033. * @param position the position of the vertex (defaut: 0,0,0)
  87034. * @param normal the normal of the vertex (defaut: 0,1,0)
  87035. */
  87036. constructor(
  87037. /** the position of the vertex (defaut: 0,0,0) */
  87038. position?: Vector3,
  87039. /** the normal of the vertex (defaut: 0,1,0) */
  87040. normal?: Vector3);
  87041. /**
  87042. * Clones the PositionNormalVertex
  87043. * @returns the cloned PositionNormalVertex
  87044. */
  87045. clone(): PositionNormalVertex;
  87046. }
  87047. /**
  87048. * Contains position, normal and uv vectors for a vertex
  87049. */
  87050. export class PositionNormalTextureVertex {
  87051. /** the position of the vertex (defaut: 0,0,0) */
  87052. position: Vector3;
  87053. /** the normal of the vertex (defaut: 0,1,0) */
  87054. normal: Vector3;
  87055. /** the uv of the vertex (default: 0,0) */
  87056. uv: Vector2;
  87057. /**
  87058. * Creates a PositionNormalTextureVertex
  87059. * @param position the position of the vertex (defaut: 0,0,0)
  87060. * @param normal the normal of the vertex (defaut: 0,1,0)
  87061. * @param uv the uv of the vertex (default: 0,0)
  87062. */
  87063. constructor(
  87064. /** the position of the vertex (defaut: 0,0,0) */
  87065. position?: Vector3,
  87066. /** the normal of the vertex (defaut: 0,1,0) */
  87067. normal?: Vector3,
  87068. /** the uv of the vertex (default: 0,0) */
  87069. uv?: Vector2);
  87070. /**
  87071. * Clones the PositionNormalTextureVertex
  87072. * @returns the cloned PositionNormalTextureVertex
  87073. */
  87074. clone(): PositionNormalTextureVertex;
  87075. }
  87076. }
  87077. declare module BABYLON {
  87078. /**
  87079. * Enum defining the type of animations supported by InputBlock
  87080. */
  87081. export enum AnimatedInputBlockTypes {
  87082. /** No animation */
  87083. None = 0,
  87084. /** Time based animation. Will only work for floats */
  87085. Time = 1
  87086. }
  87087. }
  87088. declare module BABYLON {
  87089. /**
  87090. * Interface describing all the common properties and methods a shadow light needs to implement.
  87091. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87092. * as well as binding the different shadow properties to the effects.
  87093. */
  87094. export interface IShadowLight extends Light {
  87095. /**
  87096. * The light id in the scene (used in scene.findLighById for instance)
  87097. */
  87098. id: string;
  87099. /**
  87100. * The position the shdow will be casted from.
  87101. */
  87102. position: Vector3;
  87103. /**
  87104. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87105. */
  87106. direction: Vector3;
  87107. /**
  87108. * The transformed position. Position of the light in world space taking parenting in account.
  87109. */
  87110. transformedPosition: Vector3;
  87111. /**
  87112. * The transformed direction. Direction of the light in world space taking parenting in account.
  87113. */
  87114. transformedDirection: Vector3;
  87115. /**
  87116. * The friendly name of the light in the scene.
  87117. */
  87118. name: string;
  87119. /**
  87120. * Defines the shadow projection clipping minimum z value.
  87121. */
  87122. shadowMinZ: number;
  87123. /**
  87124. * Defines the shadow projection clipping maximum z value.
  87125. */
  87126. shadowMaxZ: number;
  87127. /**
  87128. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87129. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87130. */
  87131. computeTransformedInformation(): boolean;
  87132. /**
  87133. * Gets the scene the light belongs to.
  87134. * @returns The scene
  87135. */
  87136. getScene(): Scene;
  87137. /**
  87138. * Callback defining a custom Projection Matrix Builder.
  87139. * This can be used to override the default projection matrix computation.
  87140. */
  87141. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87142. /**
  87143. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87144. * @param matrix The materix to updated with the projection information
  87145. * @param viewMatrix The transform matrix of the light
  87146. * @param renderList The list of mesh to render in the map
  87147. * @returns The current light
  87148. */
  87149. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87150. /**
  87151. * Gets the current depth scale used in ESM.
  87152. * @returns The scale
  87153. */
  87154. getDepthScale(): number;
  87155. /**
  87156. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87157. * @returns true if a cube texture needs to be use
  87158. */
  87159. needCube(): boolean;
  87160. /**
  87161. * Detects if the projection matrix requires to be recomputed this frame.
  87162. * @returns true if it requires to be recomputed otherwise, false.
  87163. */
  87164. needProjectionMatrixCompute(): boolean;
  87165. /**
  87166. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87167. */
  87168. forceProjectionMatrixCompute(): void;
  87169. /**
  87170. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87171. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87172. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87173. */
  87174. getShadowDirection(faceIndex?: number): Vector3;
  87175. /**
  87176. * Gets the minZ used for shadow according to both the scene and the light.
  87177. * @param activeCamera The camera we are returning the min for
  87178. * @returns the depth min z
  87179. */
  87180. getDepthMinZ(activeCamera: Camera): number;
  87181. /**
  87182. * Gets the maxZ used for shadow according to both the scene and the light.
  87183. * @param activeCamera The camera we are returning the max for
  87184. * @returns the depth max z
  87185. */
  87186. getDepthMaxZ(activeCamera: Camera): number;
  87187. }
  87188. /**
  87189. * Base implementation IShadowLight
  87190. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87191. */
  87192. export abstract class ShadowLight extends Light implements IShadowLight {
  87193. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87194. protected _position: Vector3;
  87195. protected _setPosition(value: Vector3): void;
  87196. /**
  87197. * Sets the position the shadow will be casted from. Also use as the light position for both
  87198. * point and spot lights.
  87199. */
  87200. get position(): Vector3;
  87201. /**
  87202. * Sets the position the shadow will be casted from. Also use as the light position for both
  87203. * point and spot lights.
  87204. */
  87205. set position(value: Vector3);
  87206. protected _direction: Vector3;
  87207. protected _setDirection(value: Vector3): void;
  87208. /**
  87209. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87210. * Also use as the light direction on spot and directional lights.
  87211. */
  87212. get direction(): Vector3;
  87213. /**
  87214. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87215. * Also use as the light direction on spot and directional lights.
  87216. */
  87217. set direction(value: Vector3);
  87218. protected _shadowMinZ: number;
  87219. /**
  87220. * Gets the shadow projection clipping minimum z value.
  87221. */
  87222. get shadowMinZ(): number;
  87223. /**
  87224. * Sets the shadow projection clipping minimum z value.
  87225. */
  87226. set shadowMinZ(value: number);
  87227. protected _shadowMaxZ: number;
  87228. /**
  87229. * Sets the shadow projection clipping maximum z value.
  87230. */
  87231. get shadowMaxZ(): number;
  87232. /**
  87233. * Gets the shadow projection clipping maximum z value.
  87234. */
  87235. set shadowMaxZ(value: number);
  87236. /**
  87237. * Callback defining a custom Projection Matrix Builder.
  87238. * This can be used to override the default projection matrix computation.
  87239. */
  87240. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87241. /**
  87242. * The transformed position. Position of the light in world space taking parenting in account.
  87243. */
  87244. transformedPosition: Vector3;
  87245. /**
  87246. * The transformed direction. Direction of the light in world space taking parenting in account.
  87247. */
  87248. transformedDirection: Vector3;
  87249. private _needProjectionMatrixCompute;
  87250. /**
  87251. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87252. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87253. */
  87254. computeTransformedInformation(): boolean;
  87255. /**
  87256. * Return the depth scale used for the shadow map.
  87257. * @returns the depth scale.
  87258. */
  87259. getDepthScale(): number;
  87260. /**
  87261. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87262. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87263. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87264. */
  87265. getShadowDirection(faceIndex?: number): Vector3;
  87266. /**
  87267. * Returns the ShadowLight absolute position in the World.
  87268. * @returns the position vector in world space
  87269. */
  87270. getAbsolutePosition(): Vector3;
  87271. /**
  87272. * Sets the ShadowLight direction toward the passed target.
  87273. * @param target The point to target in local space
  87274. * @returns the updated ShadowLight direction
  87275. */
  87276. setDirectionToTarget(target: Vector3): Vector3;
  87277. /**
  87278. * Returns the light rotation in euler definition.
  87279. * @returns the x y z rotation in local space.
  87280. */
  87281. getRotation(): Vector3;
  87282. /**
  87283. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87284. * @returns true if a cube texture needs to be use
  87285. */
  87286. needCube(): boolean;
  87287. /**
  87288. * Detects if the projection matrix requires to be recomputed this frame.
  87289. * @returns true if it requires to be recomputed otherwise, false.
  87290. */
  87291. needProjectionMatrixCompute(): boolean;
  87292. /**
  87293. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87294. */
  87295. forceProjectionMatrixCompute(): void;
  87296. /** @hidden */
  87297. _initCache(): void;
  87298. /** @hidden */
  87299. _isSynchronized(): boolean;
  87300. /**
  87301. * Computes the world matrix of the node
  87302. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87303. * @returns the world matrix
  87304. */
  87305. computeWorldMatrix(force?: boolean): Matrix;
  87306. /**
  87307. * Gets the minZ used for shadow according to both the scene and the light.
  87308. * @param activeCamera The camera we are returning the min for
  87309. * @returns the depth min z
  87310. */
  87311. getDepthMinZ(activeCamera: Camera): number;
  87312. /**
  87313. * Gets the maxZ used for shadow according to both the scene and the light.
  87314. * @param activeCamera The camera we are returning the max for
  87315. * @returns the depth max z
  87316. */
  87317. getDepthMaxZ(activeCamera: Camera): number;
  87318. /**
  87319. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87320. * @param matrix The materix to updated with the projection information
  87321. * @param viewMatrix The transform matrix of the light
  87322. * @param renderList The list of mesh to render in the map
  87323. * @returns The current light
  87324. */
  87325. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87326. }
  87327. }
  87328. declare module BABYLON {
  87329. /** @hidden */
  87330. export var packingFunctions: {
  87331. name: string;
  87332. shader: string;
  87333. };
  87334. }
  87335. declare module BABYLON {
  87336. /** @hidden */
  87337. export var bayerDitherFunctions: {
  87338. name: string;
  87339. shader: string;
  87340. };
  87341. }
  87342. declare module BABYLON {
  87343. /** @hidden */
  87344. export var shadowMapFragmentDeclaration: {
  87345. name: string;
  87346. shader: string;
  87347. };
  87348. }
  87349. declare module BABYLON {
  87350. /** @hidden */
  87351. export var clipPlaneFragmentDeclaration: {
  87352. name: string;
  87353. shader: string;
  87354. };
  87355. }
  87356. declare module BABYLON {
  87357. /** @hidden */
  87358. export var clipPlaneFragment: {
  87359. name: string;
  87360. shader: string;
  87361. };
  87362. }
  87363. declare module BABYLON {
  87364. /** @hidden */
  87365. export var shadowMapFragment: {
  87366. name: string;
  87367. shader: string;
  87368. };
  87369. }
  87370. declare module BABYLON {
  87371. /** @hidden */
  87372. export var shadowMapPixelShader: {
  87373. name: string;
  87374. shader: string;
  87375. };
  87376. }
  87377. declare module BABYLON {
  87378. /** @hidden */
  87379. export var bonesDeclaration: {
  87380. name: string;
  87381. shader: string;
  87382. };
  87383. }
  87384. declare module BABYLON {
  87385. /** @hidden */
  87386. export var morphTargetsVertexGlobalDeclaration: {
  87387. name: string;
  87388. shader: string;
  87389. };
  87390. }
  87391. declare module BABYLON {
  87392. /** @hidden */
  87393. export var morphTargetsVertexDeclaration: {
  87394. name: string;
  87395. shader: string;
  87396. };
  87397. }
  87398. declare module BABYLON {
  87399. /** @hidden */
  87400. export var instancesDeclaration: {
  87401. name: string;
  87402. shader: string;
  87403. };
  87404. }
  87405. declare module BABYLON {
  87406. /** @hidden */
  87407. export var helperFunctions: {
  87408. name: string;
  87409. shader: string;
  87410. };
  87411. }
  87412. declare module BABYLON {
  87413. /** @hidden */
  87414. export var shadowMapVertexDeclaration: {
  87415. name: string;
  87416. shader: string;
  87417. };
  87418. }
  87419. declare module BABYLON {
  87420. /** @hidden */
  87421. export var clipPlaneVertexDeclaration: {
  87422. name: string;
  87423. shader: string;
  87424. };
  87425. }
  87426. declare module BABYLON {
  87427. /** @hidden */
  87428. export var morphTargetsVertex: {
  87429. name: string;
  87430. shader: string;
  87431. };
  87432. }
  87433. declare module BABYLON {
  87434. /** @hidden */
  87435. export var instancesVertex: {
  87436. name: string;
  87437. shader: string;
  87438. };
  87439. }
  87440. declare module BABYLON {
  87441. /** @hidden */
  87442. export var bonesVertex: {
  87443. name: string;
  87444. shader: string;
  87445. };
  87446. }
  87447. declare module BABYLON {
  87448. /** @hidden */
  87449. export var shadowMapVertexNormalBias: {
  87450. name: string;
  87451. shader: string;
  87452. };
  87453. }
  87454. declare module BABYLON {
  87455. /** @hidden */
  87456. export var shadowMapVertexMetric: {
  87457. name: string;
  87458. shader: string;
  87459. };
  87460. }
  87461. declare module BABYLON {
  87462. /** @hidden */
  87463. export var clipPlaneVertex: {
  87464. name: string;
  87465. shader: string;
  87466. };
  87467. }
  87468. declare module BABYLON {
  87469. /** @hidden */
  87470. export var shadowMapVertexShader: {
  87471. name: string;
  87472. shader: string;
  87473. };
  87474. }
  87475. declare module BABYLON {
  87476. /** @hidden */
  87477. export var depthBoxBlurPixelShader: {
  87478. name: string;
  87479. shader: string;
  87480. };
  87481. }
  87482. declare module BABYLON {
  87483. /** @hidden */
  87484. export var shadowMapFragmentSoftTransparentShadow: {
  87485. name: string;
  87486. shader: string;
  87487. };
  87488. }
  87489. declare module BABYLON {
  87490. /**
  87491. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87492. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87493. */
  87494. export class EffectFallbacks implements IEffectFallbacks {
  87495. private _defines;
  87496. private _currentRank;
  87497. private _maxRank;
  87498. private _mesh;
  87499. /**
  87500. * Removes the fallback from the bound mesh.
  87501. */
  87502. unBindMesh(): void;
  87503. /**
  87504. * Adds a fallback on the specified property.
  87505. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87506. * @param define The name of the define in the shader
  87507. */
  87508. addFallback(rank: number, define: string): void;
  87509. /**
  87510. * Sets the mesh to use CPU skinning when needing to fallback.
  87511. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87512. * @param mesh The mesh to use the fallbacks.
  87513. */
  87514. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87515. /**
  87516. * Checks to see if more fallbacks are still availible.
  87517. */
  87518. get hasMoreFallbacks(): boolean;
  87519. /**
  87520. * Removes the defines that should be removed when falling back.
  87521. * @param currentDefines defines the current define statements for the shader.
  87522. * @param effect defines the current effect we try to compile
  87523. * @returns The resulting defines with defines of the current rank removed.
  87524. */
  87525. reduce(currentDefines: string, effect: Effect): string;
  87526. }
  87527. }
  87528. declare module BABYLON {
  87529. /**
  87530. * Interface used to define Action
  87531. */
  87532. export interface IAction {
  87533. /**
  87534. * Trigger for the action
  87535. */
  87536. trigger: number;
  87537. /** Options of the trigger */
  87538. triggerOptions: any;
  87539. /**
  87540. * Gets the trigger parameters
  87541. * @returns the trigger parameters
  87542. */
  87543. getTriggerParameter(): any;
  87544. /**
  87545. * Internal only - executes current action event
  87546. * @hidden
  87547. */
  87548. _executeCurrent(evt?: ActionEvent): void;
  87549. /**
  87550. * Serialize placeholder for child classes
  87551. * @param parent of child
  87552. * @returns the serialized object
  87553. */
  87554. serialize(parent: any): any;
  87555. /**
  87556. * Internal only
  87557. * @hidden
  87558. */
  87559. _prepare(): void;
  87560. /**
  87561. * Internal only - manager for action
  87562. * @hidden
  87563. */
  87564. _actionManager: AbstractActionManager;
  87565. /**
  87566. * Adds action to chain of actions, may be a DoNothingAction
  87567. * @param action defines the next action to execute
  87568. * @returns The action passed in
  87569. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87570. */
  87571. then(action: IAction): IAction;
  87572. }
  87573. /**
  87574. * The action to be carried out following a trigger
  87575. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87576. */
  87577. export class Action implements IAction {
  87578. /** the trigger, with or without parameters, for the action */
  87579. triggerOptions: any;
  87580. /**
  87581. * Trigger for the action
  87582. */
  87583. trigger: number;
  87584. /**
  87585. * Internal only - manager for action
  87586. * @hidden
  87587. */
  87588. _actionManager: ActionManager;
  87589. private _nextActiveAction;
  87590. private _child;
  87591. private _condition?;
  87592. private _triggerParameter;
  87593. /**
  87594. * An event triggered prior to action being executed.
  87595. */
  87596. onBeforeExecuteObservable: Observable<Action>;
  87597. /**
  87598. * Creates a new Action
  87599. * @param triggerOptions the trigger, with or without parameters, for the action
  87600. * @param condition an optional determinant of action
  87601. */
  87602. constructor(
  87603. /** the trigger, with or without parameters, for the action */
  87604. triggerOptions: any, condition?: Condition);
  87605. /**
  87606. * Internal only
  87607. * @hidden
  87608. */
  87609. _prepare(): void;
  87610. /**
  87611. * Gets the trigger parameters
  87612. * @returns the trigger parameters
  87613. */
  87614. getTriggerParameter(): any;
  87615. /**
  87616. * Internal only - executes current action event
  87617. * @hidden
  87618. */
  87619. _executeCurrent(evt?: ActionEvent): void;
  87620. /**
  87621. * Execute placeholder for child classes
  87622. * @param evt optional action event
  87623. */
  87624. execute(evt?: ActionEvent): void;
  87625. /**
  87626. * Skips to next active action
  87627. */
  87628. skipToNextActiveAction(): void;
  87629. /**
  87630. * Adds action to chain of actions, may be a DoNothingAction
  87631. * @param action defines the next action to execute
  87632. * @returns The action passed in
  87633. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87634. */
  87635. then(action: Action): Action;
  87636. /**
  87637. * Internal only
  87638. * @hidden
  87639. */
  87640. _getProperty(propertyPath: string): string;
  87641. /**
  87642. * Internal only
  87643. * @hidden
  87644. */
  87645. _getEffectiveTarget(target: any, propertyPath: string): any;
  87646. /**
  87647. * Serialize placeholder for child classes
  87648. * @param parent of child
  87649. * @returns the serialized object
  87650. */
  87651. serialize(parent: any): any;
  87652. /**
  87653. * Internal only called by serialize
  87654. * @hidden
  87655. */
  87656. protected _serialize(serializedAction: any, parent?: any): any;
  87657. /**
  87658. * Internal only
  87659. * @hidden
  87660. */
  87661. static _SerializeValueAsString: (value: any) => string;
  87662. /**
  87663. * Internal only
  87664. * @hidden
  87665. */
  87666. static _GetTargetProperty: (target: Scene | Node) => {
  87667. name: string;
  87668. targetType: string;
  87669. value: string;
  87670. };
  87671. }
  87672. }
  87673. declare module BABYLON {
  87674. /**
  87675. * A Condition applied to an Action
  87676. */
  87677. export class Condition {
  87678. /**
  87679. * Internal only - manager for action
  87680. * @hidden
  87681. */
  87682. _actionManager: ActionManager;
  87683. /**
  87684. * Internal only
  87685. * @hidden
  87686. */
  87687. _evaluationId: number;
  87688. /**
  87689. * Internal only
  87690. * @hidden
  87691. */
  87692. _currentResult: boolean;
  87693. /**
  87694. * Creates a new Condition
  87695. * @param actionManager the manager of the action the condition is applied to
  87696. */
  87697. constructor(actionManager: ActionManager);
  87698. /**
  87699. * Check if the current condition is valid
  87700. * @returns a boolean
  87701. */
  87702. isValid(): boolean;
  87703. /**
  87704. * Internal only
  87705. * @hidden
  87706. */
  87707. _getProperty(propertyPath: string): string;
  87708. /**
  87709. * Internal only
  87710. * @hidden
  87711. */
  87712. _getEffectiveTarget(target: any, propertyPath: string): any;
  87713. /**
  87714. * Serialize placeholder for child classes
  87715. * @returns the serialized object
  87716. */
  87717. serialize(): any;
  87718. /**
  87719. * Internal only
  87720. * @hidden
  87721. */
  87722. protected _serialize(serializedCondition: any): any;
  87723. }
  87724. /**
  87725. * Defines specific conditional operators as extensions of Condition
  87726. */
  87727. export class ValueCondition extends Condition {
  87728. /** path to specify the property of the target the conditional operator uses */
  87729. propertyPath: string;
  87730. /** the value compared by the conditional operator against the current value of the property */
  87731. value: any;
  87732. /** the conditional operator, default ValueCondition.IsEqual */
  87733. operator: number;
  87734. /**
  87735. * Internal only
  87736. * @hidden
  87737. */
  87738. private static _IsEqual;
  87739. /**
  87740. * Internal only
  87741. * @hidden
  87742. */
  87743. private static _IsDifferent;
  87744. /**
  87745. * Internal only
  87746. * @hidden
  87747. */
  87748. private static _IsGreater;
  87749. /**
  87750. * Internal only
  87751. * @hidden
  87752. */
  87753. private static _IsLesser;
  87754. /**
  87755. * returns the number for IsEqual
  87756. */
  87757. static get IsEqual(): number;
  87758. /**
  87759. * Returns the number for IsDifferent
  87760. */
  87761. static get IsDifferent(): number;
  87762. /**
  87763. * Returns the number for IsGreater
  87764. */
  87765. static get IsGreater(): number;
  87766. /**
  87767. * Returns the number for IsLesser
  87768. */
  87769. static get IsLesser(): number;
  87770. /**
  87771. * Internal only The action manager for the condition
  87772. * @hidden
  87773. */
  87774. _actionManager: ActionManager;
  87775. /**
  87776. * Internal only
  87777. * @hidden
  87778. */
  87779. private _target;
  87780. /**
  87781. * Internal only
  87782. * @hidden
  87783. */
  87784. private _effectiveTarget;
  87785. /**
  87786. * Internal only
  87787. * @hidden
  87788. */
  87789. private _property;
  87790. /**
  87791. * Creates a new ValueCondition
  87792. * @param actionManager manager for the action the condition applies to
  87793. * @param target for the action
  87794. * @param propertyPath path to specify the property of the target the conditional operator uses
  87795. * @param value the value compared by the conditional operator against the current value of the property
  87796. * @param operator the conditional operator, default ValueCondition.IsEqual
  87797. */
  87798. constructor(actionManager: ActionManager, target: any,
  87799. /** path to specify the property of the target the conditional operator uses */
  87800. propertyPath: string,
  87801. /** the value compared by the conditional operator against the current value of the property */
  87802. value: any,
  87803. /** the conditional operator, default ValueCondition.IsEqual */
  87804. operator?: number);
  87805. /**
  87806. * Compares the given value with the property value for the specified conditional operator
  87807. * @returns the result of the comparison
  87808. */
  87809. isValid(): boolean;
  87810. /**
  87811. * Serialize the ValueCondition into a JSON compatible object
  87812. * @returns serialization object
  87813. */
  87814. serialize(): any;
  87815. /**
  87816. * Gets the name of the conditional operator for the ValueCondition
  87817. * @param operator the conditional operator
  87818. * @returns the name
  87819. */
  87820. static GetOperatorName(operator: number): string;
  87821. }
  87822. /**
  87823. * Defines a predicate condition as an extension of Condition
  87824. */
  87825. export class PredicateCondition extends Condition {
  87826. /** defines the predicate function used to validate the condition */
  87827. predicate: () => boolean;
  87828. /**
  87829. * Internal only - manager for action
  87830. * @hidden
  87831. */
  87832. _actionManager: ActionManager;
  87833. /**
  87834. * Creates a new PredicateCondition
  87835. * @param actionManager manager for the action the condition applies to
  87836. * @param predicate defines the predicate function used to validate the condition
  87837. */
  87838. constructor(actionManager: ActionManager,
  87839. /** defines the predicate function used to validate the condition */
  87840. predicate: () => boolean);
  87841. /**
  87842. * @returns the validity of the predicate condition
  87843. */
  87844. isValid(): boolean;
  87845. }
  87846. /**
  87847. * Defines a state condition as an extension of Condition
  87848. */
  87849. export class StateCondition extends Condition {
  87850. /** Value to compare with target state */
  87851. value: string;
  87852. /**
  87853. * Internal only - manager for action
  87854. * @hidden
  87855. */
  87856. _actionManager: ActionManager;
  87857. /**
  87858. * Internal only
  87859. * @hidden
  87860. */
  87861. private _target;
  87862. /**
  87863. * Creates a new StateCondition
  87864. * @param actionManager manager for the action the condition applies to
  87865. * @param target of the condition
  87866. * @param value to compare with target state
  87867. */
  87868. constructor(actionManager: ActionManager, target: any,
  87869. /** Value to compare with target state */
  87870. value: string);
  87871. /**
  87872. * Gets a boolean indicating if the current condition is met
  87873. * @returns the validity of the state
  87874. */
  87875. isValid(): boolean;
  87876. /**
  87877. * Serialize the StateCondition into a JSON compatible object
  87878. * @returns serialization object
  87879. */
  87880. serialize(): any;
  87881. }
  87882. }
  87883. declare module BABYLON {
  87884. /**
  87885. * This defines an action responsible to toggle a boolean once triggered.
  87886. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87887. */
  87888. export class SwitchBooleanAction extends Action {
  87889. /**
  87890. * The path to the boolean property in the target object
  87891. */
  87892. propertyPath: string;
  87893. private _target;
  87894. private _effectiveTarget;
  87895. private _property;
  87896. /**
  87897. * Instantiate the action
  87898. * @param triggerOptions defines the trigger options
  87899. * @param target defines the object containing the boolean
  87900. * @param propertyPath defines the path to the boolean property in the target object
  87901. * @param condition defines the trigger related conditions
  87902. */
  87903. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87904. /** @hidden */
  87905. _prepare(): void;
  87906. /**
  87907. * Execute the action toggle the boolean value.
  87908. */
  87909. execute(): void;
  87910. /**
  87911. * Serializes the actions and its related information.
  87912. * @param parent defines the object to serialize in
  87913. * @returns the serialized object
  87914. */
  87915. serialize(parent: any): any;
  87916. }
  87917. /**
  87918. * This defines an action responsible to set a the state field of the target
  87919. * to a desired value once triggered.
  87920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87921. */
  87922. export class SetStateAction extends Action {
  87923. /**
  87924. * The value to store in the state field.
  87925. */
  87926. value: string;
  87927. private _target;
  87928. /**
  87929. * Instantiate the action
  87930. * @param triggerOptions defines the trigger options
  87931. * @param target defines the object containing the state property
  87932. * @param value defines the value to store in the state field
  87933. * @param condition defines the trigger related conditions
  87934. */
  87935. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87936. /**
  87937. * Execute the action and store the value on the target state property.
  87938. */
  87939. execute(): void;
  87940. /**
  87941. * Serializes the actions and its related information.
  87942. * @param parent defines the object to serialize in
  87943. * @returns the serialized object
  87944. */
  87945. serialize(parent: any): any;
  87946. }
  87947. /**
  87948. * This defines an action responsible to set a property of the target
  87949. * to a desired value once triggered.
  87950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87951. */
  87952. export class SetValueAction extends Action {
  87953. /**
  87954. * The path of the property to set in the target.
  87955. */
  87956. propertyPath: string;
  87957. /**
  87958. * The value to set in the property
  87959. */
  87960. value: any;
  87961. private _target;
  87962. private _effectiveTarget;
  87963. private _property;
  87964. /**
  87965. * Instantiate the action
  87966. * @param triggerOptions defines the trigger options
  87967. * @param target defines the object containing the property
  87968. * @param propertyPath defines the path of the property to set in the target
  87969. * @param value defines the value to set in the property
  87970. * @param condition defines the trigger related conditions
  87971. */
  87972. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87973. /** @hidden */
  87974. _prepare(): void;
  87975. /**
  87976. * Execute the action and set the targetted property to the desired value.
  87977. */
  87978. execute(): void;
  87979. /**
  87980. * Serializes the actions and its related information.
  87981. * @param parent defines the object to serialize in
  87982. * @returns the serialized object
  87983. */
  87984. serialize(parent: any): any;
  87985. }
  87986. /**
  87987. * This defines an action responsible to increment the target value
  87988. * to a desired value once triggered.
  87989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87990. */
  87991. export class IncrementValueAction extends Action {
  87992. /**
  87993. * The path of the property to increment in the target.
  87994. */
  87995. propertyPath: string;
  87996. /**
  87997. * The value we should increment the property by.
  87998. */
  87999. value: any;
  88000. private _target;
  88001. private _effectiveTarget;
  88002. private _property;
  88003. /**
  88004. * Instantiate the action
  88005. * @param triggerOptions defines the trigger options
  88006. * @param target defines the object containing the property
  88007. * @param propertyPath defines the path of the property to increment in the target
  88008. * @param value defines the value value we should increment the property by
  88009. * @param condition defines the trigger related conditions
  88010. */
  88011. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88012. /** @hidden */
  88013. _prepare(): void;
  88014. /**
  88015. * Execute the action and increment the target of the value amount.
  88016. */
  88017. execute(): void;
  88018. /**
  88019. * Serializes the actions and its related information.
  88020. * @param parent defines the object to serialize in
  88021. * @returns the serialized object
  88022. */
  88023. serialize(parent: any): any;
  88024. }
  88025. /**
  88026. * This defines an action responsible to start an animation once triggered.
  88027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88028. */
  88029. export class PlayAnimationAction extends Action {
  88030. /**
  88031. * Where the animation should start (animation frame)
  88032. */
  88033. from: number;
  88034. /**
  88035. * Where the animation should stop (animation frame)
  88036. */
  88037. to: number;
  88038. /**
  88039. * Define if the animation should loop or stop after the first play.
  88040. */
  88041. loop?: boolean;
  88042. private _target;
  88043. /**
  88044. * Instantiate the action
  88045. * @param triggerOptions defines the trigger options
  88046. * @param target defines the target animation or animation name
  88047. * @param from defines from where the animation should start (animation frame)
  88048. * @param end defines where the animation should stop (animation frame)
  88049. * @param loop defines if the animation should loop or stop after the first play
  88050. * @param condition defines the trigger related conditions
  88051. */
  88052. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88053. /** @hidden */
  88054. _prepare(): void;
  88055. /**
  88056. * Execute the action and play the animation.
  88057. */
  88058. execute(): void;
  88059. /**
  88060. * Serializes the actions and its related information.
  88061. * @param parent defines the object to serialize in
  88062. * @returns the serialized object
  88063. */
  88064. serialize(parent: any): any;
  88065. }
  88066. /**
  88067. * This defines an action responsible to stop an animation once triggered.
  88068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88069. */
  88070. export class StopAnimationAction extends Action {
  88071. private _target;
  88072. /**
  88073. * Instantiate the action
  88074. * @param triggerOptions defines the trigger options
  88075. * @param target defines the target animation or animation name
  88076. * @param condition defines the trigger related conditions
  88077. */
  88078. constructor(triggerOptions: any, target: any, condition?: Condition);
  88079. /** @hidden */
  88080. _prepare(): void;
  88081. /**
  88082. * Execute the action and stop the animation.
  88083. */
  88084. execute(): void;
  88085. /**
  88086. * Serializes the actions and its related information.
  88087. * @param parent defines the object to serialize in
  88088. * @returns the serialized object
  88089. */
  88090. serialize(parent: any): any;
  88091. }
  88092. /**
  88093. * This defines an action responsible that does nothing once triggered.
  88094. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88095. */
  88096. export class DoNothingAction extends Action {
  88097. /**
  88098. * Instantiate the action
  88099. * @param triggerOptions defines the trigger options
  88100. * @param condition defines the trigger related conditions
  88101. */
  88102. constructor(triggerOptions?: any, condition?: Condition);
  88103. /**
  88104. * Execute the action and do nothing.
  88105. */
  88106. execute(): void;
  88107. /**
  88108. * Serializes the actions and its related information.
  88109. * @param parent defines the object to serialize in
  88110. * @returns the serialized object
  88111. */
  88112. serialize(parent: any): any;
  88113. }
  88114. /**
  88115. * This defines an action responsible to trigger several actions once triggered.
  88116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88117. */
  88118. export class CombineAction extends Action {
  88119. /**
  88120. * The list of aggregated animations to run.
  88121. */
  88122. children: Action[];
  88123. /**
  88124. * Instantiate the action
  88125. * @param triggerOptions defines the trigger options
  88126. * @param children defines the list of aggregated animations to run
  88127. * @param condition defines the trigger related conditions
  88128. */
  88129. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88130. /** @hidden */
  88131. _prepare(): void;
  88132. /**
  88133. * Execute the action and executes all the aggregated actions.
  88134. */
  88135. execute(evt: ActionEvent): void;
  88136. /**
  88137. * Serializes the actions and its related information.
  88138. * @param parent defines the object to serialize in
  88139. * @returns the serialized object
  88140. */
  88141. serialize(parent: any): any;
  88142. }
  88143. /**
  88144. * This defines an action responsible to run code (external event) once triggered.
  88145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88146. */
  88147. export class ExecuteCodeAction extends Action {
  88148. /**
  88149. * The callback function to run.
  88150. */
  88151. func: (evt: ActionEvent) => void;
  88152. /**
  88153. * Instantiate the action
  88154. * @param triggerOptions defines the trigger options
  88155. * @param func defines the callback function to run
  88156. * @param condition defines the trigger related conditions
  88157. */
  88158. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88159. /**
  88160. * Execute the action and run the attached code.
  88161. */
  88162. execute(evt: ActionEvent): void;
  88163. }
  88164. /**
  88165. * This defines an action responsible to set the parent property of the target once triggered.
  88166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88167. */
  88168. export class SetParentAction extends Action {
  88169. private _parent;
  88170. private _target;
  88171. /**
  88172. * Instantiate the action
  88173. * @param triggerOptions defines the trigger options
  88174. * @param target defines the target containing the parent property
  88175. * @param parent defines from where the animation should start (animation frame)
  88176. * @param condition defines the trigger related conditions
  88177. */
  88178. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88179. /** @hidden */
  88180. _prepare(): void;
  88181. /**
  88182. * Execute the action and set the parent property.
  88183. */
  88184. execute(): void;
  88185. /**
  88186. * Serializes the actions and its related information.
  88187. * @param parent defines the object to serialize in
  88188. * @returns the serialized object
  88189. */
  88190. serialize(parent: any): any;
  88191. }
  88192. }
  88193. declare module BABYLON {
  88194. /**
  88195. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88196. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88198. */
  88199. export class ActionManager extends AbstractActionManager {
  88200. /**
  88201. * Nothing
  88202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88203. */
  88204. static readonly NothingTrigger: number;
  88205. /**
  88206. * On pick
  88207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88208. */
  88209. static readonly OnPickTrigger: number;
  88210. /**
  88211. * On left pick
  88212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88213. */
  88214. static readonly OnLeftPickTrigger: number;
  88215. /**
  88216. * On right pick
  88217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88218. */
  88219. static readonly OnRightPickTrigger: number;
  88220. /**
  88221. * On center pick
  88222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88223. */
  88224. static readonly OnCenterPickTrigger: number;
  88225. /**
  88226. * On pick down
  88227. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88228. */
  88229. static readonly OnPickDownTrigger: number;
  88230. /**
  88231. * On double pick
  88232. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88233. */
  88234. static readonly OnDoublePickTrigger: number;
  88235. /**
  88236. * On pick up
  88237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88238. */
  88239. static readonly OnPickUpTrigger: number;
  88240. /**
  88241. * On pick out.
  88242. * This trigger will only be raised if you also declared a OnPickDown
  88243. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88244. */
  88245. static readonly OnPickOutTrigger: number;
  88246. /**
  88247. * On long press
  88248. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88249. */
  88250. static readonly OnLongPressTrigger: number;
  88251. /**
  88252. * On pointer over
  88253. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88254. */
  88255. static readonly OnPointerOverTrigger: number;
  88256. /**
  88257. * On pointer out
  88258. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88259. */
  88260. static readonly OnPointerOutTrigger: number;
  88261. /**
  88262. * On every frame
  88263. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88264. */
  88265. static readonly OnEveryFrameTrigger: number;
  88266. /**
  88267. * On intersection enter
  88268. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88269. */
  88270. static readonly OnIntersectionEnterTrigger: number;
  88271. /**
  88272. * On intersection exit
  88273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88274. */
  88275. static readonly OnIntersectionExitTrigger: number;
  88276. /**
  88277. * On key down
  88278. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88279. */
  88280. static readonly OnKeyDownTrigger: number;
  88281. /**
  88282. * On key up
  88283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88284. */
  88285. static readonly OnKeyUpTrigger: number;
  88286. private _scene;
  88287. /**
  88288. * Creates a new action manager
  88289. * @param scene defines the hosting scene
  88290. */
  88291. constructor(scene: Scene);
  88292. /**
  88293. * Releases all associated resources
  88294. */
  88295. dispose(): void;
  88296. /**
  88297. * Gets hosting scene
  88298. * @returns the hosting scene
  88299. */
  88300. getScene(): Scene;
  88301. /**
  88302. * Does this action manager handles actions of any of the given triggers
  88303. * @param triggers defines the triggers to be tested
  88304. * @return a boolean indicating whether one (or more) of the triggers is handled
  88305. */
  88306. hasSpecificTriggers(triggers: number[]): boolean;
  88307. /**
  88308. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88309. * speed.
  88310. * @param triggerA defines the trigger to be tested
  88311. * @param triggerB defines the trigger to be tested
  88312. * @return a boolean indicating whether one (or more) of the triggers is handled
  88313. */
  88314. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88315. /**
  88316. * Does this action manager handles actions of a given trigger
  88317. * @param trigger defines the trigger to be tested
  88318. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88319. * @return whether the trigger is handled
  88320. */
  88321. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88322. /**
  88323. * Does this action manager has pointer triggers
  88324. */
  88325. get hasPointerTriggers(): boolean;
  88326. /**
  88327. * Does this action manager has pick triggers
  88328. */
  88329. get hasPickTriggers(): boolean;
  88330. /**
  88331. * Registers an action to this action manager
  88332. * @param action defines the action to be registered
  88333. * @return the action amended (prepared) after registration
  88334. */
  88335. registerAction(action: IAction): Nullable<IAction>;
  88336. /**
  88337. * Unregisters an action to this action manager
  88338. * @param action defines the action to be unregistered
  88339. * @return a boolean indicating whether the action has been unregistered
  88340. */
  88341. unregisterAction(action: IAction): Boolean;
  88342. /**
  88343. * Process a specific trigger
  88344. * @param trigger defines the trigger to process
  88345. * @param evt defines the event details to be processed
  88346. */
  88347. processTrigger(trigger: number, evt?: IActionEvent): void;
  88348. /** @hidden */
  88349. _getEffectiveTarget(target: any, propertyPath: string): any;
  88350. /** @hidden */
  88351. _getProperty(propertyPath: string): string;
  88352. /**
  88353. * Serialize this manager to a JSON object
  88354. * @param name defines the property name to store this manager
  88355. * @returns a JSON representation of this manager
  88356. */
  88357. serialize(name: string): any;
  88358. /**
  88359. * Creates a new ActionManager from a JSON data
  88360. * @param parsedActions defines the JSON data to read from
  88361. * @param object defines the hosting mesh
  88362. * @param scene defines the hosting scene
  88363. */
  88364. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88365. /**
  88366. * Get a trigger name by index
  88367. * @param trigger defines the trigger index
  88368. * @returns a trigger name
  88369. */
  88370. static GetTriggerName(trigger: number): string;
  88371. }
  88372. }
  88373. declare module BABYLON {
  88374. /**
  88375. * Class used to represent a sprite
  88376. * @see https://doc.babylonjs.com/babylon101/sprites
  88377. */
  88378. export class Sprite implements IAnimatable {
  88379. /** defines the name */
  88380. name: string;
  88381. /** Gets or sets the current world position */
  88382. position: Vector3;
  88383. /** Gets or sets the main color */
  88384. color: Color4;
  88385. /** Gets or sets the width */
  88386. width: number;
  88387. /** Gets or sets the height */
  88388. height: number;
  88389. /** Gets or sets rotation angle */
  88390. angle: number;
  88391. /** Gets or sets the cell index in the sprite sheet */
  88392. cellIndex: number;
  88393. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88394. cellRef: string;
  88395. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88396. invertU: boolean;
  88397. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88398. invertV: boolean;
  88399. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88400. disposeWhenFinishedAnimating: boolean;
  88401. /** Gets the list of attached animations */
  88402. animations: Nullable<Array<Animation>>;
  88403. /** Gets or sets a boolean indicating if the sprite can be picked */
  88404. isPickable: boolean;
  88405. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88406. useAlphaForPicking: boolean;
  88407. /** @hidden */
  88408. _xOffset: number;
  88409. /** @hidden */
  88410. _yOffset: number;
  88411. /** @hidden */
  88412. _xSize: number;
  88413. /** @hidden */
  88414. _ySize: number;
  88415. /**
  88416. * Gets or sets the associated action manager
  88417. */
  88418. actionManager: Nullable<ActionManager>;
  88419. /**
  88420. * An event triggered when the control has been disposed
  88421. */
  88422. onDisposeObservable: Observable<Sprite>;
  88423. private _animationStarted;
  88424. private _loopAnimation;
  88425. private _fromIndex;
  88426. private _toIndex;
  88427. private _delay;
  88428. private _direction;
  88429. private _manager;
  88430. private _time;
  88431. private _onAnimationEnd;
  88432. /**
  88433. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88434. */
  88435. isVisible: boolean;
  88436. /**
  88437. * Gets or sets the sprite size
  88438. */
  88439. get size(): number;
  88440. set size(value: number);
  88441. /**
  88442. * Returns a boolean indicating if the animation is started
  88443. */
  88444. get animationStarted(): boolean;
  88445. /**
  88446. * Gets or sets the unique id of the sprite
  88447. */
  88448. uniqueId: number;
  88449. /**
  88450. * Gets the manager of this sprite
  88451. */
  88452. get manager(): ISpriteManager;
  88453. /**
  88454. * Creates a new Sprite
  88455. * @param name defines the name
  88456. * @param manager defines the manager
  88457. */
  88458. constructor(
  88459. /** defines the name */
  88460. name: string, manager: ISpriteManager);
  88461. /**
  88462. * Returns the string "Sprite"
  88463. * @returns "Sprite"
  88464. */
  88465. getClassName(): string;
  88466. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88467. get fromIndex(): number;
  88468. set fromIndex(value: number);
  88469. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88470. get toIndex(): number;
  88471. set toIndex(value: number);
  88472. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88473. get loopAnimation(): boolean;
  88474. set loopAnimation(value: boolean);
  88475. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88476. get delay(): number;
  88477. set delay(value: number);
  88478. /**
  88479. * Starts an animation
  88480. * @param from defines the initial key
  88481. * @param to defines the end key
  88482. * @param loop defines if the animation must loop
  88483. * @param delay defines the start delay (in ms)
  88484. * @param onAnimationEnd defines a callback to call when animation ends
  88485. */
  88486. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88487. /** Stops current animation (if any) */
  88488. stopAnimation(): void;
  88489. /** @hidden */
  88490. _animate(deltaTime: number): void;
  88491. /** Release associated resources */
  88492. dispose(): void;
  88493. /**
  88494. * Serializes the sprite to a JSON object
  88495. * @returns the JSON object
  88496. */
  88497. serialize(): any;
  88498. /**
  88499. * Parses a JSON object to create a new sprite
  88500. * @param parsedSprite The JSON object to parse
  88501. * @param manager defines the hosting manager
  88502. * @returns the new sprite
  88503. */
  88504. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88505. }
  88506. }
  88507. declare module BABYLON {
  88508. /**
  88509. * Information about the result of picking within a scene
  88510. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88511. */
  88512. export class PickingInfo {
  88513. /** @hidden */
  88514. _pickingUnavailable: boolean;
  88515. /**
  88516. * If the pick collided with an object
  88517. */
  88518. hit: boolean;
  88519. /**
  88520. * Distance away where the pick collided
  88521. */
  88522. distance: number;
  88523. /**
  88524. * The location of pick collision
  88525. */
  88526. pickedPoint: Nullable<Vector3>;
  88527. /**
  88528. * The mesh corresponding the the pick collision
  88529. */
  88530. pickedMesh: Nullable<AbstractMesh>;
  88531. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88532. bu: number;
  88533. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88534. bv: number;
  88535. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88536. faceId: number;
  88537. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88538. subMeshFaceId: number;
  88539. /** Id of the the submesh that was picked */
  88540. subMeshId: number;
  88541. /** If a sprite was picked, this will be the sprite the pick collided with */
  88542. pickedSprite: Nullable<Sprite>;
  88543. /**
  88544. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88545. */
  88546. originMesh: Nullable<AbstractMesh>;
  88547. /**
  88548. * The ray that was used to perform the picking.
  88549. */
  88550. ray: Nullable<Ray>;
  88551. /**
  88552. * Gets the normal correspodning to the face the pick collided with
  88553. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88554. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88555. * @returns The normal correspodning to the face the pick collided with
  88556. */
  88557. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88558. /**
  88559. * Gets the texture coordinates of where the pick occured
  88560. * @returns the vector containing the coordnates of the texture
  88561. */
  88562. getTextureCoordinates(): Nullable<Vector2>;
  88563. }
  88564. }
  88565. declare module BABYLON {
  88566. /**
  88567. * Class representing a ray with position and direction
  88568. */
  88569. export class Ray {
  88570. /** origin point */
  88571. origin: Vector3;
  88572. /** direction */
  88573. direction: Vector3;
  88574. /** length of the ray */
  88575. length: number;
  88576. private static readonly TmpVector3;
  88577. private _tmpRay;
  88578. /**
  88579. * Creates a new ray
  88580. * @param origin origin point
  88581. * @param direction direction
  88582. * @param length length of the ray
  88583. */
  88584. constructor(
  88585. /** origin point */
  88586. origin: Vector3,
  88587. /** direction */
  88588. direction: Vector3,
  88589. /** length of the ray */
  88590. length?: number);
  88591. /**
  88592. * Checks if the ray intersects a box
  88593. * This does not account for the ray lenght by design to improve perfs.
  88594. * @param minimum bound of the box
  88595. * @param maximum bound of the box
  88596. * @param intersectionTreshold extra extend to be added to the box in all direction
  88597. * @returns if the box was hit
  88598. */
  88599. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88600. /**
  88601. * Checks if the ray intersects a box
  88602. * This does not account for the ray lenght by design to improve perfs.
  88603. * @param box the bounding box to check
  88604. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88605. * @returns if the box was hit
  88606. */
  88607. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88608. /**
  88609. * If the ray hits a sphere
  88610. * @param sphere the bounding sphere to check
  88611. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88612. * @returns true if it hits the sphere
  88613. */
  88614. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88615. /**
  88616. * If the ray hits a triange
  88617. * @param vertex0 triangle vertex
  88618. * @param vertex1 triangle vertex
  88619. * @param vertex2 triangle vertex
  88620. * @returns intersection information if hit
  88621. */
  88622. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88623. /**
  88624. * Checks if ray intersects a plane
  88625. * @param plane the plane to check
  88626. * @returns the distance away it was hit
  88627. */
  88628. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88629. /**
  88630. * Calculate the intercept of a ray on a given axis
  88631. * @param axis to check 'x' | 'y' | 'z'
  88632. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88633. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88634. */
  88635. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88636. /**
  88637. * Checks if ray intersects a mesh
  88638. * @param mesh the mesh to check
  88639. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88640. * @returns picking info of the intersecton
  88641. */
  88642. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88643. /**
  88644. * Checks if ray intersects a mesh
  88645. * @param meshes the meshes to check
  88646. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88647. * @param results array to store result in
  88648. * @returns Array of picking infos
  88649. */
  88650. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88651. private _comparePickingInfo;
  88652. private static smallnum;
  88653. private static rayl;
  88654. /**
  88655. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88656. * @param sega the first point of the segment to test the intersection against
  88657. * @param segb the second point of the segment to test the intersection against
  88658. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88659. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88660. */
  88661. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88662. /**
  88663. * Update the ray from viewport position
  88664. * @param x position
  88665. * @param y y position
  88666. * @param viewportWidth viewport width
  88667. * @param viewportHeight viewport height
  88668. * @param world world matrix
  88669. * @param view view matrix
  88670. * @param projection projection matrix
  88671. * @returns this ray updated
  88672. */
  88673. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88674. /**
  88675. * Creates a ray with origin and direction of 0,0,0
  88676. * @returns the new ray
  88677. */
  88678. static Zero(): Ray;
  88679. /**
  88680. * Creates a new ray from screen space and viewport
  88681. * @param x position
  88682. * @param y y position
  88683. * @param viewportWidth viewport width
  88684. * @param viewportHeight viewport height
  88685. * @param world world matrix
  88686. * @param view view matrix
  88687. * @param projection projection matrix
  88688. * @returns new ray
  88689. */
  88690. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88691. /**
  88692. * 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
  88693. * transformed to the given world matrix.
  88694. * @param origin The origin point
  88695. * @param end The end point
  88696. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88697. * @returns the new ray
  88698. */
  88699. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88700. /**
  88701. * Transforms a ray by a matrix
  88702. * @param ray ray to transform
  88703. * @param matrix matrix to apply
  88704. * @returns the resulting new ray
  88705. */
  88706. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88707. /**
  88708. * Transforms a ray by a matrix
  88709. * @param ray ray to transform
  88710. * @param matrix matrix to apply
  88711. * @param result ray to store result in
  88712. */
  88713. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88714. /**
  88715. * Unproject a ray from screen space to object space
  88716. * @param sourceX defines the screen space x coordinate to use
  88717. * @param sourceY defines the screen space y coordinate to use
  88718. * @param viewportWidth defines the current width of the viewport
  88719. * @param viewportHeight defines the current height of the viewport
  88720. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88721. * @param view defines the view matrix to use
  88722. * @param projection defines the projection matrix to use
  88723. */
  88724. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88725. }
  88726. /**
  88727. * Type used to define predicate used to select faces when a mesh intersection is detected
  88728. */
  88729. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88730. interface Scene {
  88731. /** @hidden */
  88732. _tempPickingRay: Nullable<Ray>;
  88733. /** @hidden */
  88734. _cachedRayForTransform: Ray;
  88735. /** @hidden */
  88736. _pickWithRayInverseMatrix: Matrix;
  88737. /** @hidden */
  88738. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88739. /** @hidden */
  88740. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88741. }
  88742. }
  88743. declare module BABYLON {
  88744. /**
  88745. * Groups all the scene component constants in one place to ease maintenance.
  88746. * @hidden
  88747. */
  88748. export class SceneComponentConstants {
  88749. static readonly NAME_EFFECTLAYER: string;
  88750. static readonly NAME_LAYER: string;
  88751. static readonly NAME_LENSFLARESYSTEM: string;
  88752. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88753. static readonly NAME_PARTICLESYSTEM: string;
  88754. static readonly NAME_GAMEPAD: string;
  88755. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88756. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88757. static readonly NAME_PREPASSRENDERER: string;
  88758. static readonly NAME_DEPTHRENDERER: string;
  88759. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88760. static readonly NAME_SPRITE: string;
  88761. static readonly NAME_OUTLINERENDERER: string;
  88762. static readonly NAME_PROCEDURALTEXTURE: string;
  88763. static readonly NAME_SHADOWGENERATOR: string;
  88764. static readonly NAME_OCTREE: string;
  88765. static readonly NAME_PHYSICSENGINE: string;
  88766. static readonly NAME_AUDIO: string;
  88767. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88768. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88769. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88770. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88771. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88772. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88773. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88774. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88788. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88789. static readonly STEP_AFTERRENDER_AUDIO: number;
  88790. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88791. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88792. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88793. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88794. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88795. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88796. static readonly STEP_POINTERMOVE_SPRITE: number;
  88797. static readonly STEP_POINTERDOWN_SPRITE: number;
  88798. static readonly STEP_POINTERUP_SPRITE: number;
  88799. }
  88800. /**
  88801. * This represents a scene component.
  88802. *
  88803. * This is used to decouple the dependency the scene is having on the different workloads like
  88804. * layers, post processes...
  88805. */
  88806. export interface ISceneComponent {
  88807. /**
  88808. * The name of the component. Each component must have a unique name.
  88809. */
  88810. name: string;
  88811. /**
  88812. * The scene the component belongs to.
  88813. */
  88814. scene: Scene;
  88815. /**
  88816. * Register the component to one instance of a scene.
  88817. */
  88818. register(): void;
  88819. /**
  88820. * Rebuilds the elements related to this component in case of
  88821. * context lost for instance.
  88822. */
  88823. rebuild(): void;
  88824. /**
  88825. * Disposes the component and the associated ressources.
  88826. */
  88827. dispose(): void;
  88828. }
  88829. /**
  88830. * This represents a SERIALIZABLE scene component.
  88831. *
  88832. * This extends Scene Component to add Serialization methods on top.
  88833. */
  88834. export interface ISceneSerializableComponent extends ISceneComponent {
  88835. /**
  88836. * Adds all the elements from the container to the scene
  88837. * @param container the container holding the elements
  88838. */
  88839. addFromContainer(container: AbstractScene): void;
  88840. /**
  88841. * Removes all the elements in the container from the scene
  88842. * @param container contains the elements to remove
  88843. * @param dispose if the removed element should be disposed (default: false)
  88844. */
  88845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88846. /**
  88847. * Serializes the component data to the specified json object
  88848. * @param serializationObject The object to serialize to
  88849. */
  88850. serialize(serializationObject: any): void;
  88851. }
  88852. /**
  88853. * Strong typing of a Mesh related stage step action
  88854. */
  88855. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88856. /**
  88857. * Strong typing of a Evaluate Sub Mesh related stage step action
  88858. */
  88859. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88860. /**
  88861. * Strong typing of a Active Mesh related stage step action
  88862. */
  88863. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88864. /**
  88865. * Strong typing of a Camera related stage step action
  88866. */
  88867. export type CameraStageAction = (camera: Camera) => void;
  88868. /**
  88869. * Strong typing of a Camera Frame buffer related stage step action
  88870. */
  88871. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88872. /**
  88873. * Strong typing of a Render Target related stage step action
  88874. */
  88875. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88876. /**
  88877. * Strong typing of a RenderingGroup related stage step action
  88878. */
  88879. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88880. /**
  88881. * Strong typing of a Mesh Render related stage step action
  88882. */
  88883. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88884. /**
  88885. * Strong typing of a simple stage step action
  88886. */
  88887. export type SimpleStageAction = () => void;
  88888. /**
  88889. * Strong typing of a render target action.
  88890. */
  88891. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88892. /**
  88893. * Strong typing of a pointer move action.
  88894. */
  88895. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88896. /**
  88897. * Strong typing of a pointer up/down action.
  88898. */
  88899. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88900. /**
  88901. * Representation of a stage in the scene (Basically a list of ordered steps)
  88902. * @hidden
  88903. */
  88904. export class Stage<T extends Function> extends Array<{
  88905. index: number;
  88906. component: ISceneComponent;
  88907. action: T;
  88908. }> {
  88909. /**
  88910. * Hide ctor from the rest of the world.
  88911. * @param items The items to add.
  88912. */
  88913. private constructor();
  88914. /**
  88915. * Creates a new Stage.
  88916. * @returns A new instance of a Stage
  88917. */
  88918. static Create<T extends Function>(): Stage<T>;
  88919. /**
  88920. * Registers a step in an ordered way in the targeted stage.
  88921. * @param index Defines the position to register the step in
  88922. * @param component Defines the component attached to the step
  88923. * @param action Defines the action to launch during the step
  88924. */
  88925. registerStep(index: number, component: ISceneComponent, action: T): void;
  88926. /**
  88927. * Clears all the steps from the stage.
  88928. */
  88929. clear(): void;
  88930. }
  88931. }
  88932. declare module BABYLON {
  88933. interface Scene {
  88934. /** @hidden */
  88935. _pointerOverSprite: Nullable<Sprite>;
  88936. /** @hidden */
  88937. _pickedDownSprite: Nullable<Sprite>;
  88938. /** @hidden */
  88939. _tempSpritePickingRay: Nullable<Ray>;
  88940. /**
  88941. * All of the sprite managers added to this scene
  88942. * @see https://doc.babylonjs.com/babylon101/sprites
  88943. */
  88944. spriteManagers: Array<ISpriteManager>;
  88945. /**
  88946. * An event triggered when sprites rendering is about to start
  88947. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88948. */
  88949. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88950. /**
  88951. * An event triggered when sprites rendering is done
  88952. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88953. */
  88954. onAfterSpritesRenderingObservable: Observable<Scene>;
  88955. /** @hidden */
  88956. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88957. /** Launch a ray to try to pick a sprite in the scene
  88958. * @param x position on screen
  88959. * @param y position on screen
  88960. * @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
  88961. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88962. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88963. * @returns a PickingInfo
  88964. */
  88965. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88966. /** Use the given ray to pick a sprite in the scene
  88967. * @param ray The ray (in world space) to use to pick meshes
  88968. * @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
  88969. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88970. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88971. * @returns a PickingInfo
  88972. */
  88973. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88974. /** @hidden */
  88975. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88976. /** Launch a ray to try to pick sprites in the scene
  88977. * @param x position on screen
  88978. * @param y position on screen
  88979. * @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
  88980. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88981. * @returns a PickingInfo array
  88982. */
  88983. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88984. /** Use the given ray to pick sprites in the scene
  88985. * @param ray The ray (in world space) to use to pick meshes
  88986. * @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
  88987. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88988. * @returns a PickingInfo array
  88989. */
  88990. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88991. /**
  88992. * Force the sprite under the pointer
  88993. * @param sprite defines the sprite to use
  88994. */
  88995. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88996. /**
  88997. * Gets the sprite under the pointer
  88998. * @returns a Sprite or null if no sprite is under the pointer
  88999. */
  89000. getPointerOverSprite(): Nullable<Sprite>;
  89001. }
  89002. /**
  89003. * Defines the sprite scene component responsible to manage sprites
  89004. * in a given scene.
  89005. */
  89006. export class SpriteSceneComponent implements ISceneComponent {
  89007. /**
  89008. * The component name helpfull to identify the component in the list of scene components.
  89009. */
  89010. readonly name: string;
  89011. /**
  89012. * The scene the component belongs to.
  89013. */
  89014. scene: Scene;
  89015. /** @hidden */
  89016. private _spritePredicate;
  89017. /**
  89018. * Creates a new instance of the component for the given scene
  89019. * @param scene Defines the scene to register the component in
  89020. */
  89021. constructor(scene: Scene);
  89022. /**
  89023. * Registers the component in a given scene
  89024. */
  89025. register(): void;
  89026. /**
  89027. * Rebuilds the elements related to this component in case of
  89028. * context lost for instance.
  89029. */
  89030. rebuild(): void;
  89031. /**
  89032. * Disposes the component and the associated ressources.
  89033. */
  89034. dispose(): void;
  89035. private _pickSpriteButKeepRay;
  89036. private _pointerMove;
  89037. private _pointerDown;
  89038. private _pointerUp;
  89039. }
  89040. }
  89041. declare module BABYLON {
  89042. /** @hidden */
  89043. export var fogFragmentDeclaration: {
  89044. name: string;
  89045. shader: string;
  89046. };
  89047. }
  89048. declare module BABYLON {
  89049. /** @hidden */
  89050. export var fogFragment: {
  89051. name: string;
  89052. shader: string;
  89053. };
  89054. }
  89055. declare module BABYLON {
  89056. /** @hidden */
  89057. export var spritesPixelShader: {
  89058. name: string;
  89059. shader: string;
  89060. };
  89061. }
  89062. declare module BABYLON {
  89063. /** @hidden */
  89064. export var fogVertexDeclaration: {
  89065. name: string;
  89066. shader: string;
  89067. };
  89068. }
  89069. declare module BABYLON {
  89070. /** @hidden */
  89071. export var spritesVertexShader: {
  89072. name: string;
  89073. shader: string;
  89074. };
  89075. }
  89076. declare module BABYLON {
  89077. /**
  89078. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89079. */
  89080. export interface ISpriteManager extends IDisposable {
  89081. /**
  89082. * Gets manager's name
  89083. */
  89084. name: string;
  89085. /**
  89086. * Restricts the camera to viewing objects with the same layerMask.
  89087. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89088. */
  89089. layerMask: number;
  89090. /**
  89091. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89092. */
  89093. isPickable: boolean;
  89094. /**
  89095. * Gets the hosting scene
  89096. */
  89097. scene: Scene;
  89098. /**
  89099. * Specifies the rendering group id for this mesh (0 by default)
  89100. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89101. */
  89102. renderingGroupId: number;
  89103. /**
  89104. * Defines the list of sprites managed by the manager.
  89105. */
  89106. sprites: Array<Sprite>;
  89107. /**
  89108. * Gets or sets the spritesheet texture
  89109. */
  89110. texture: Texture;
  89111. /** Defines the default width of a cell in the spritesheet */
  89112. cellWidth: number;
  89113. /** Defines the default height of a cell in the spritesheet */
  89114. cellHeight: number;
  89115. /**
  89116. * Tests the intersection of a sprite with a specific ray.
  89117. * @param ray The ray we are sending to test the collision
  89118. * @param camera The camera space we are sending rays in
  89119. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89120. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89121. * @returns picking info or null.
  89122. */
  89123. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89124. /**
  89125. * Intersects the sprites with a ray
  89126. * @param ray defines the ray to intersect with
  89127. * @param camera defines the current active camera
  89128. * @param predicate defines a predicate used to select candidate sprites
  89129. * @returns null if no hit or a PickingInfo array
  89130. */
  89131. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89132. /**
  89133. * Renders the list of sprites on screen.
  89134. */
  89135. render(): void;
  89136. }
  89137. /**
  89138. * Class used to manage multiple sprites on the same spritesheet
  89139. * @see https://doc.babylonjs.com/babylon101/sprites
  89140. */
  89141. export class SpriteManager implements ISpriteManager {
  89142. /** defines the manager's name */
  89143. name: string;
  89144. /** Define the Url to load snippets */
  89145. static SnippetUrl: string;
  89146. /** Snippet ID if the manager was created from the snippet server */
  89147. snippetId: string;
  89148. /** Gets the list of sprites */
  89149. sprites: Sprite[];
  89150. /** Gets or sets the rendering group id (0 by default) */
  89151. renderingGroupId: number;
  89152. /** Gets or sets camera layer mask */
  89153. layerMask: number;
  89154. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89155. fogEnabled: boolean;
  89156. /** Gets or sets a boolean indicating if the sprites are pickable */
  89157. isPickable: boolean;
  89158. /** Defines the default width of a cell in the spritesheet */
  89159. cellWidth: number;
  89160. /** Defines the default height of a cell in the spritesheet */
  89161. cellHeight: number;
  89162. /** Associative array from JSON sprite data file */
  89163. private _cellData;
  89164. /** Array of sprite names from JSON sprite data file */
  89165. private _spriteMap;
  89166. /** True when packed cell data from JSON file is ready*/
  89167. private _packedAndReady;
  89168. private _textureContent;
  89169. /**
  89170. * An event triggered when the manager is disposed.
  89171. */
  89172. onDisposeObservable: Observable<SpriteManager>;
  89173. private _onDisposeObserver;
  89174. /**
  89175. * Callback called when the manager is disposed
  89176. */
  89177. set onDispose(callback: () => void);
  89178. private _capacity;
  89179. private _fromPacked;
  89180. private _spriteTexture;
  89181. private _epsilon;
  89182. private _scene;
  89183. private _vertexData;
  89184. private _buffer;
  89185. private _vertexBuffers;
  89186. private _indexBuffer;
  89187. private _effectBase;
  89188. private _effectFog;
  89189. /**
  89190. * Gets or sets the unique id of the sprite
  89191. */
  89192. uniqueId: number;
  89193. /**
  89194. * Gets the array of sprites
  89195. */
  89196. get children(): Sprite[];
  89197. /**
  89198. * Gets the hosting scene
  89199. */
  89200. get scene(): Scene;
  89201. /**
  89202. * Gets the capacity of the manager
  89203. */
  89204. get capacity(): number;
  89205. /**
  89206. * Gets or sets the spritesheet texture
  89207. */
  89208. get texture(): Texture;
  89209. set texture(value: Texture);
  89210. private _blendMode;
  89211. /**
  89212. * Blend mode use to render the particle, it can be any of
  89213. * the static Constants.ALPHA_x properties provided in this class.
  89214. * Default value is Constants.ALPHA_COMBINE
  89215. */
  89216. get blendMode(): number;
  89217. set blendMode(blendMode: number);
  89218. /** Disables writing to the depth buffer when rendering the sprites.
  89219. * It can be handy to disable depth writing when using textures without alpha channel
  89220. * and setting some specific blend modes.
  89221. */
  89222. disableDepthWrite: boolean;
  89223. /**
  89224. * Creates a new sprite manager
  89225. * @param name defines the manager's name
  89226. * @param imgUrl defines the sprite sheet url
  89227. * @param capacity defines the maximum allowed number of sprites
  89228. * @param cellSize defines the size of a sprite cell
  89229. * @param scene defines the hosting scene
  89230. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89231. * @param samplingMode defines the smapling mode to use with spritesheet
  89232. * @param fromPacked set to false; do not alter
  89233. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89234. */
  89235. constructor(
  89236. /** defines the manager's name */
  89237. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89238. /**
  89239. * Returns the string "SpriteManager"
  89240. * @returns "SpriteManager"
  89241. */
  89242. getClassName(): string;
  89243. private _makePacked;
  89244. private _appendSpriteVertex;
  89245. private _checkTextureAlpha;
  89246. /**
  89247. * Intersects the sprites with a ray
  89248. * @param ray defines the ray to intersect with
  89249. * @param camera defines the current active camera
  89250. * @param predicate defines a predicate used to select candidate sprites
  89251. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89252. * @returns null if no hit or a PickingInfo
  89253. */
  89254. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89255. /**
  89256. * Intersects the sprites with a ray
  89257. * @param ray defines the ray to intersect with
  89258. * @param camera defines the current active camera
  89259. * @param predicate defines a predicate used to select candidate sprites
  89260. * @returns null if no hit or a PickingInfo array
  89261. */
  89262. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89263. /**
  89264. * Render all child sprites
  89265. */
  89266. render(): void;
  89267. /**
  89268. * Release associated resources
  89269. */
  89270. dispose(): void;
  89271. /**
  89272. * Serializes the sprite manager to a JSON object
  89273. * @param serializeTexture defines if the texture must be serialized as well
  89274. * @returns the JSON object
  89275. */
  89276. serialize(serializeTexture?: boolean): any;
  89277. /**
  89278. * Parses a JSON object to create a new sprite manager.
  89279. * @param parsedManager The JSON object to parse
  89280. * @param scene The scene to create the sprite managerin
  89281. * @param rootUrl The root url to use to load external dependencies like texture
  89282. * @returns the new sprite manager
  89283. */
  89284. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89285. /**
  89286. * Creates a sprite manager from a snippet saved in a remote file
  89287. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89288. * @param url defines the url to load from
  89289. * @param scene defines the hosting scene
  89290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89291. * @returns a promise that will resolve to the new sprite manager
  89292. */
  89293. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89294. /**
  89295. * Creates a sprite manager from a snippet saved by the sprite editor
  89296. * @param snippetId defines the snippet to load
  89297. * @param scene defines the hosting scene
  89298. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89299. * @returns a promise that will resolve to the new sprite manager
  89300. */
  89301. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89302. }
  89303. }
  89304. declare module BABYLON {
  89305. /** Interface used by value gradients (color, factor, ...) */
  89306. export interface IValueGradient {
  89307. /**
  89308. * Gets or sets the gradient value (between 0 and 1)
  89309. */
  89310. gradient: number;
  89311. }
  89312. /** Class used to store color4 gradient */
  89313. export class ColorGradient implements IValueGradient {
  89314. /**
  89315. * Gets or sets the gradient value (between 0 and 1)
  89316. */
  89317. gradient: number;
  89318. /**
  89319. * Gets or sets first associated color
  89320. */
  89321. color1: Color4;
  89322. /**
  89323. * Gets or sets second associated color
  89324. */
  89325. color2?: Color4 | undefined;
  89326. /**
  89327. * Creates a new color4 gradient
  89328. * @param gradient gets or sets the gradient value (between 0 and 1)
  89329. * @param color1 gets or sets first associated color
  89330. * @param color2 gets or sets first second color
  89331. */
  89332. constructor(
  89333. /**
  89334. * Gets or sets the gradient value (between 0 and 1)
  89335. */
  89336. gradient: number,
  89337. /**
  89338. * Gets or sets first associated color
  89339. */
  89340. color1: Color4,
  89341. /**
  89342. * Gets or sets second associated color
  89343. */
  89344. color2?: Color4 | undefined);
  89345. /**
  89346. * Will get a color picked randomly between color1 and color2.
  89347. * If color2 is undefined then color1 will be used
  89348. * @param result defines the target Color4 to store the result in
  89349. */
  89350. getColorToRef(result: Color4): void;
  89351. }
  89352. /** Class used to store color 3 gradient */
  89353. export class Color3Gradient implements IValueGradient {
  89354. /**
  89355. * Gets or sets the gradient value (between 0 and 1)
  89356. */
  89357. gradient: number;
  89358. /**
  89359. * Gets or sets the associated color
  89360. */
  89361. color: Color3;
  89362. /**
  89363. * Creates a new color3 gradient
  89364. * @param gradient gets or sets the gradient value (between 0 and 1)
  89365. * @param color gets or sets associated color
  89366. */
  89367. constructor(
  89368. /**
  89369. * Gets or sets the gradient value (between 0 and 1)
  89370. */
  89371. gradient: number,
  89372. /**
  89373. * Gets or sets the associated color
  89374. */
  89375. color: Color3);
  89376. }
  89377. /** Class used to store factor gradient */
  89378. export class FactorGradient implements IValueGradient {
  89379. /**
  89380. * Gets or sets the gradient value (between 0 and 1)
  89381. */
  89382. gradient: number;
  89383. /**
  89384. * Gets or sets first associated factor
  89385. */
  89386. factor1: number;
  89387. /**
  89388. * Gets or sets second associated factor
  89389. */
  89390. factor2?: number | undefined;
  89391. /**
  89392. * Creates a new factor gradient
  89393. * @param gradient gets or sets the gradient value (between 0 and 1)
  89394. * @param factor1 gets or sets first associated factor
  89395. * @param factor2 gets or sets second associated factor
  89396. */
  89397. constructor(
  89398. /**
  89399. * Gets or sets the gradient value (between 0 and 1)
  89400. */
  89401. gradient: number,
  89402. /**
  89403. * Gets or sets first associated factor
  89404. */
  89405. factor1: number,
  89406. /**
  89407. * Gets or sets second associated factor
  89408. */
  89409. factor2?: number | undefined);
  89410. /**
  89411. * Will get a number picked randomly between factor1 and factor2.
  89412. * If factor2 is undefined then factor1 will be used
  89413. * @returns the picked number
  89414. */
  89415. getFactor(): number;
  89416. }
  89417. /**
  89418. * Helper used to simplify some generic gradient tasks
  89419. */
  89420. export class GradientHelper {
  89421. /**
  89422. * Gets the current gradient from an array of IValueGradient
  89423. * @param ratio defines the current ratio to get
  89424. * @param gradients defines the array of IValueGradient
  89425. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89426. */
  89427. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89428. }
  89429. }
  89430. declare module BABYLON {
  89431. interface ThinEngine {
  89432. /**
  89433. * Creates a raw texture
  89434. * @param data defines the data to store in the texture
  89435. * @param width defines the width of the texture
  89436. * @param height defines the height of the texture
  89437. * @param format defines the format of the data
  89438. * @param generateMipMaps defines if the engine should generate the mip levels
  89439. * @param invertY defines if data must be stored with Y axis inverted
  89440. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89441. * @param compression defines the compression used (null by default)
  89442. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89443. * @returns the raw texture inside an InternalTexture
  89444. */
  89445. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89446. /**
  89447. * Update a raw texture
  89448. * @param texture defines the texture to update
  89449. * @param data defines the data to store in the texture
  89450. * @param format defines the format of the data
  89451. * @param invertY defines if data must be stored with Y axis inverted
  89452. */
  89453. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89454. /**
  89455. * Update a raw texture
  89456. * @param texture defines the texture to update
  89457. * @param data defines the data to store in the texture
  89458. * @param format defines the format of the data
  89459. * @param invertY defines if data must be stored with Y axis inverted
  89460. * @param compression defines the compression used (null by default)
  89461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89462. */
  89463. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89464. /**
  89465. * Creates a new raw cube texture
  89466. * @param data defines the array of data to use to create each face
  89467. * @param size defines the size of the textures
  89468. * @param format defines the format of the data
  89469. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89470. * @param generateMipMaps defines if the engine should generate the mip levels
  89471. * @param invertY defines if data must be stored with Y axis inverted
  89472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89473. * @param compression defines the compression used (null by default)
  89474. * @returns the cube texture as an InternalTexture
  89475. */
  89476. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89477. /**
  89478. * Update a raw cube texture
  89479. * @param texture defines the texture to udpdate
  89480. * @param data defines the data to store
  89481. * @param format defines the data format
  89482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89483. * @param invertY defines if data must be stored with Y axis inverted
  89484. */
  89485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89486. /**
  89487. * Update a raw cube texture
  89488. * @param texture defines the texture to udpdate
  89489. * @param data defines the data to store
  89490. * @param format defines the data format
  89491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89492. * @param invertY defines if data must be stored with Y axis inverted
  89493. * @param compression defines the compression used (null by default)
  89494. */
  89495. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89496. /**
  89497. * Update a raw cube texture
  89498. * @param texture defines the texture to udpdate
  89499. * @param data defines the data to store
  89500. * @param format defines the data format
  89501. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89502. * @param invertY defines if data must be stored with Y axis inverted
  89503. * @param compression defines the compression used (null by default)
  89504. * @param level defines which level of the texture to update
  89505. */
  89506. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89507. /**
  89508. * Creates a new raw cube texture from a specified url
  89509. * @param url defines the url where the data is located
  89510. * @param scene defines the current scene
  89511. * @param size defines the size of the textures
  89512. * @param format defines the format of the data
  89513. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89514. * @param noMipmap defines if the engine should avoid generating the mip levels
  89515. * @param callback defines a callback used to extract texture data from loaded data
  89516. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89517. * @param onLoad defines a callback called when texture is loaded
  89518. * @param onError defines a callback called if there is an error
  89519. * @returns the cube texture as an InternalTexture
  89520. */
  89521. 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;
  89522. /**
  89523. * Creates a new raw cube texture from a specified url
  89524. * @param url defines the url where the data is located
  89525. * @param scene defines the current scene
  89526. * @param size defines the size of the textures
  89527. * @param format defines the format of the data
  89528. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89529. * @param noMipmap defines if the engine should avoid generating the mip levels
  89530. * @param callback defines a callback used to extract texture data from loaded data
  89531. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89532. * @param onLoad defines a callback called when texture is loaded
  89533. * @param onError defines a callback called if there is an error
  89534. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89535. * @param invertY defines if data must be stored with Y axis inverted
  89536. * @returns the cube texture as an InternalTexture
  89537. */
  89538. 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;
  89539. /**
  89540. * Creates a new raw 3D texture
  89541. * @param data defines the data used to create the texture
  89542. * @param width defines the width of the texture
  89543. * @param height defines the height of the texture
  89544. * @param depth defines the depth of the texture
  89545. * @param format defines the format of the texture
  89546. * @param generateMipMaps defines if the engine must generate mip levels
  89547. * @param invertY defines if data must be stored with Y axis inverted
  89548. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89549. * @param compression defines the compressed used (can be null)
  89550. * @param textureType defines the compressed used (can be null)
  89551. * @returns a new raw 3D texture (stored in an InternalTexture)
  89552. */
  89553. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89554. /**
  89555. * Update a raw 3D texture
  89556. * @param texture defines the texture to update
  89557. * @param data defines the data to store
  89558. * @param format defines the data format
  89559. * @param invertY defines if data must be stored with Y axis inverted
  89560. */
  89561. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89562. /**
  89563. * Update a raw 3D texture
  89564. * @param texture defines the texture to update
  89565. * @param data defines the data to store
  89566. * @param format defines the data format
  89567. * @param invertY defines if data must be stored with Y axis inverted
  89568. * @param compression defines the used compression (can be null)
  89569. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89570. */
  89571. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89572. /**
  89573. * Creates a new raw 2D array texture
  89574. * @param data defines the data used to create the texture
  89575. * @param width defines the width of the texture
  89576. * @param height defines the height of the texture
  89577. * @param depth defines the number of layers of the texture
  89578. * @param format defines the format of the texture
  89579. * @param generateMipMaps defines if the engine must generate mip levels
  89580. * @param invertY defines if data must be stored with Y axis inverted
  89581. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89582. * @param compression defines the compressed used (can be null)
  89583. * @param textureType defines the compressed used (can be null)
  89584. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89585. */
  89586. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89587. /**
  89588. * Update a raw 2D array texture
  89589. * @param texture defines the texture to update
  89590. * @param data defines the data to store
  89591. * @param format defines the data format
  89592. * @param invertY defines if data must be stored with Y axis inverted
  89593. */
  89594. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89595. /**
  89596. * Update a raw 2D array texture
  89597. * @param texture defines the texture to update
  89598. * @param data defines the data to store
  89599. * @param format defines the data format
  89600. * @param invertY defines if data must be stored with Y axis inverted
  89601. * @param compression defines the used compression (can be null)
  89602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89603. */
  89604. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89605. }
  89606. }
  89607. declare module BABYLON {
  89608. /**
  89609. * Raw texture can help creating a texture directly from an array of data.
  89610. * This can be super useful if you either get the data from an uncompressed source or
  89611. * if you wish to create your texture pixel by pixel.
  89612. */
  89613. export class RawTexture extends Texture {
  89614. /**
  89615. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89616. */
  89617. format: number;
  89618. /**
  89619. * Instantiates a new RawTexture.
  89620. * Raw texture can help creating a texture directly from an array of data.
  89621. * This can be super useful if you either get the data from an uncompressed source or
  89622. * if you wish to create your texture pixel by pixel.
  89623. * @param data define the array of data to use to create the texture
  89624. * @param width define the width of the texture
  89625. * @param height define the height of the texture
  89626. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89627. * @param scene define the scene the texture belongs to
  89628. * @param generateMipMaps define whether mip maps should be generated or not
  89629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89631. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89632. */
  89633. constructor(data: ArrayBufferView, width: number, height: number,
  89634. /**
  89635. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89636. */
  89637. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89638. /**
  89639. * Updates the texture underlying data.
  89640. * @param data Define the new data of the texture
  89641. */
  89642. update(data: ArrayBufferView): void;
  89643. /**
  89644. * Creates a luminance texture from some data.
  89645. * @param data Define the texture data
  89646. * @param width Define the width of the texture
  89647. * @param height Define the height of the texture
  89648. * @param scene Define the scene the texture belongs to
  89649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89652. * @returns the luminance texture
  89653. */
  89654. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89655. /**
  89656. * Creates a luminance alpha texture from some data.
  89657. * @param data Define the texture data
  89658. * @param width Define the width of the texture
  89659. * @param height Define the height of the texture
  89660. * @param scene Define the scene the texture belongs to
  89661. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89664. * @returns the luminance alpha texture
  89665. */
  89666. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89667. /**
  89668. * Creates an alpha texture from some data.
  89669. * @param data Define the texture data
  89670. * @param width Define the width of the texture
  89671. * @param height Define the height of the texture
  89672. * @param scene Define the scene the texture belongs to
  89673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89676. * @returns the alpha texture
  89677. */
  89678. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89679. /**
  89680. * Creates a RGB texture from some data.
  89681. * @param data Define the texture data
  89682. * @param width Define the width of the texture
  89683. * @param height Define the height of the texture
  89684. * @param scene Define the scene the texture belongs to
  89685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89688. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89689. * @returns the RGB alpha texture
  89690. */
  89691. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89692. /**
  89693. * Creates a RGBA texture from some data.
  89694. * @param data Define the texture data
  89695. * @param width Define the width of the texture
  89696. * @param height Define the height of the texture
  89697. * @param scene Define the scene the texture belongs to
  89698. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89699. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89700. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89701. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89702. * @returns the RGBA texture
  89703. */
  89704. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89705. /**
  89706. * Creates a R texture from some data.
  89707. * @param data Define the texture data
  89708. * @param width Define the width of the texture
  89709. * @param height Define the height of the texture
  89710. * @param scene Define the scene the texture belongs to
  89711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89714. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89715. * @returns the R texture
  89716. */
  89717. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89718. }
  89719. }
  89720. declare module BABYLON {
  89721. interface AbstractScene {
  89722. /**
  89723. * The list of procedural textures added to the scene
  89724. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89725. */
  89726. proceduralTextures: Array<ProceduralTexture>;
  89727. }
  89728. /**
  89729. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89730. * in a given scene.
  89731. */
  89732. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89733. /**
  89734. * The component name helpfull to identify the component in the list of scene components.
  89735. */
  89736. readonly name: string;
  89737. /**
  89738. * The scene the component belongs to.
  89739. */
  89740. scene: Scene;
  89741. /**
  89742. * Creates a new instance of the component for the given scene
  89743. * @param scene Defines the scene to register the component in
  89744. */
  89745. constructor(scene: Scene);
  89746. /**
  89747. * Registers the component in a given scene
  89748. */
  89749. register(): void;
  89750. /**
  89751. * Rebuilds the elements related to this component in case of
  89752. * context lost for instance.
  89753. */
  89754. rebuild(): void;
  89755. /**
  89756. * Disposes the component and the associated ressources.
  89757. */
  89758. dispose(): void;
  89759. private _beforeClear;
  89760. }
  89761. }
  89762. declare module BABYLON {
  89763. interface ThinEngine {
  89764. /**
  89765. * Creates a new render target cube texture
  89766. * @param size defines the size of the texture
  89767. * @param options defines the options used to create the texture
  89768. * @returns a new render target cube texture stored in an InternalTexture
  89769. */
  89770. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89771. }
  89772. }
  89773. declare module BABYLON {
  89774. /** @hidden */
  89775. export var proceduralVertexShader: {
  89776. name: string;
  89777. shader: string;
  89778. };
  89779. }
  89780. declare module BABYLON {
  89781. /**
  89782. * 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.
  89783. * This is the base class of any Procedural texture and contains most of the shareable code.
  89784. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89785. */
  89786. export class ProceduralTexture extends Texture {
  89787. isCube: boolean;
  89788. /**
  89789. * Define if the texture is enabled or not (disabled texture will not render)
  89790. */
  89791. isEnabled: boolean;
  89792. /**
  89793. * Define if the texture must be cleared before rendering (default is true)
  89794. */
  89795. autoClear: boolean;
  89796. /**
  89797. * Callback called when the texture is generated
  89798. */
  89799. onGenerated: () => void;
  89800. /**
  89801. * Event raised when the texture is generated
  89802. */
  89803. onGeneratedObservable: Observable<ProceduralTexture>;
  89804. /** @hidden */
  89805. _generateMipMaps: boolean;
  89806. /** @hidden **/
  89807. _effect: Effect;
  89808. /** @hidden */
  89809. _textures: {
  89810. [key: string]: Texture;
  89811. };
  89812. /** @hidden */
  89813. protected _fallbackTexture: Nullable<Texture>;
  89814. private _size;
  89815. private _currentRefreshId;
  89816. private _frameId;
  89817. private _refreshRate;
  89818. private _vertexBuffers;
  89819. private _indexBuffer;
  89820. private _uniforms;
  89821. private _samplers;
  89822. private _fragment;
  89823. private _floats;
  89824. private _ints;
  89825. private _floatsArrays;
  89826. private _colors3;
  89827. private _colors4;
  89828. private _vectors2;
  89829. private _vectors3;
  89830. private _matrices;
  89831. private _fallbackTextureUsed;
  89832. private _fullEngine;
  89833. private _cachedDefines;
  89834. private _contentUpdateId;
  89835. private _contentData;
  89836. /**
  89837. * Instantiates a new procedural texture.
  89838. * 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.
  89839. * This is the base class of any Procedural texture and contains most of the shareable code.
  89840. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89841. * @param name Define the name of the texture
  89842. * @param size Define the size of the texture to create
  89843. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89844. * @param scene Define the scene the texture belongs to
  89845. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89846. * @param generateMipMaps Define if the texture should creates mip maps or not
  89847. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89848. */
  89849. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89850. /**
  89851. * The effect that is created when initializing the post process.
  89852. * @returns The created effect corresponding the the postprocess.
  89853. */
  89854. getEffect(): Effect;
  89855. /**
  89856. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89857. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89858. */
  89859. getContent(): Nullable<ArrayBufferView>;
  89860. private _createIndexBuffer;
  89861. /** @hidden */
  89862. _rebuild(): void;
  89863. /**
  89864. * Resets the texture in order to recreate its associated resources.
  89865. * This can be called in case of context loss
  89866. */
  89867. reset(): void;
  89868. protected _getDefines(): string;
  89869. /**
  89870. * Is the texture ready to be used ? (rendered at least once)
  89871. * @returns true if ready, otherwise, false.
  89872. */
  89873. isReady(): boolean;
  89874. /**
  89875. * Resets the refresh counter of the texture and start bak from scratch.
  89876. * Could be useful to regenerate the texture if it is setup to render only once.
  89877. */
  89878. resetRefreshCounter(): void;
  89879. /**
  89880. * Set the fragment shader to use in order to render the texture.
  89881. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89882. */
  89883. setFragment(fragment: any): void;
  89884. /**
  89885. * Define the refresh rate of the texture or the rendering frequency.
  89886. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89887. */
  89888. get refreshRate(): number;
  89889. set refreshRate(value: number);
  89890. /** @hidden */
  89891. _shouldRender(): boolean;
  89892. /**
  89893. * Get the size the texture is rendering at.
  89894. * @returns the size (texture is always squared)
  89895. */
  89896. getRenderSize(): number;
  89897. /**
  89898. * Resize the texture to new value.
  89899. * @param size Define the new size the texture should have
  89900. * @param generateMipMaps Define whether the new texture should create mip maps
  89901. */
  89902. resize(size: number, generateMipMaps: boolean): void;
  89903. private _checkUniform;
  89904. /**
  89905. * Set a texture in the shader program used to render.
  89906. * @param name Define the name of the uniform samplers as defined in the shader
  89907. * @param texture Define the texture to bind to this sampler
  89908. * @return the texture itself allowing "fluent" like uniform updates
  89909. */
  89910. setTexture(name: string, texture: Texture): ProceduralTexture;
  89911. /**
  89912. * Set a float in the shader.
  89913. * @param name Define the name of the uniform as defined in the shader
  89914. * @param value Define the value to give to the uniform
  89915. * @return the texture itself allowing "fluent" like uniform updates
  89916. */
  89917. setFloat(name: string, value: number): ProceduralTexture;
  89918. /**
  89919. * Set a int in the shader.
  89920. * @param name Define the name of the uniform as defined in the shader
  89921. * @param value Define the value to give to the uniform
  89922. * @return the texture itself allowing "fluent" like uniform updates
  89923. */
  89924. setInt(name: string, value: number): ProceduralTexture;
  89925. /**
  89926. * Set an array of floats in the shader.
  89927. * @param name Define the name of the uniform as defined in the shader
  89928. * @param value Define the value to give to the uniform
  89929. * @return the texture itself allowing "fluent" like uniform updates
  89930. */
  89931. setFloats(name: string, value: number[]): ProceduralTexture;
  89932. /**
  89933. * Set a vec3 in the shader from a Color3.
  89934. * @param name Define the name of the uniform as defined in the shader
  89935. * @param value Define the value to give to the uniform
  89936. * @return the texture itself allowing "fluent" like uniform updates
  89937. */
  89938. setColor3(name: string, value: Color3): ProceduralTexture;
  89939. /**
  89940. * Set a vec4 in the shader from a Color4.
  89941. * @param name Define the name of the uniform as defined in the shader
  89942. * @param value Define the value to give to the uniform
  89943. * @return the texture itself allowing "fluent" like uniform updates
  89944. */
  89945. setColor4(name: string, value: Color4): ProceduralTexture;
  89946. /**
  89947. * Set a vec2 in the shader from a Vector2.
  89948. * @param name Define the name of the uniform as defined in the shader
  89949. * @param value Define the value to give to the uniform
  89950. * @return the texture itself allowing "fluent" like uniform updates
  89951. */
  89952. setVector2(name: string, value: Vector2): ProceduralTexture;
  89953. /**
  89954. * Set a vec3 in the shader from a Vector3.
  89955. * @param name Define the name of the uniform as defined in the shader
  89956. * @param value Define the value to give to the uniform
  89957. * @return the texture itself allowing "fluent" like uniform updates
  89958. */
  89959. setVector3(name: string, value: Vector3): ProceduralTexture;
  89960. /**
  89961. * Set a mat4 in the shader from a MAtrix.
  89962. * @param name Define the name of the uniform as defined in the shader
  89963. * @param value Define the value to give to the uniform
  89964. * @return the texture itself allowing "fluent" like uniform updates
  89965. */
  89966. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89967. /**
  89968. * Render the texture to its associated render target.
  89969. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89970. */
  89971. render(useCameraPostProcess?: boolean): void;
  89972. /**
  89973. * Clone the texture.
  89974. * @returns the cloned texture
  89975. */
  89976. clone(): ProceduralTexture;
  89977. /**
  89978. * Dispose the texture and release its asoociated resources.
  89979. */
  89980. dispose(): void;
  89981. }
  89982. }
  89983. declare module BABYLON {
  89984. /**
  89985. * This represents the base class for particle system in Babylon.
  89986. * 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.
  89987. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89988. * @example https://doc.babylonjs.com/babylon101/particles
  89989. */
  89990. export class BaseParticleSystem {
  89991. /**
  89992. * Source color is added to the destination color without alpha affecting the result
  89993. */
  89994. static BLENDMODE_ONEONE: number;
  89995. /**
  89996. * Blend current color and particle color using particle’s alpha
  89997. */
  89998. static BLENDMODE_STANDARD: number;
  89999. /**
  90000. * Add current color and particle color multiplied by particle’s alpha
  90001. */
  90002. static BLENDMODE_ADD: number;
  90003. /**
  90004. * Multiply current color with particle color
  90005. */
  90006. static BLENDMODE_MULTIPLY: number;
  90007. /**
  90008. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90009. */
  90010. static BLENDMODE_MULTIPLYADD: number;
  90011. /**
  90012. * List of animations used by the particle system.
  90013. */
  90014. animations: Animation[];
  90015. /**
  90016. * Gets or sets the unique id of the particle system
  90017. */
  90018. uniqueId: number;
  90019. /**
  90020. * The id of the Particle system.
  90021. */
  90022. id: string;
  90023. /**
  90024. * The friendly name of the Particle system.
  90025. */
  90026. name: string;
  90027. /**
  90028. * Snippet ID if the particle system was created from the snippet server
  90029. */
  90030. snippetId: string;
  90031. /**
  90032. * The rendering group used by the Particle system to chose when to render.
  90033. */
  90034. renderingGroupId: number;
  90035. /**
  90036. * The emitter represents the Mesh or position we are attaching the particle system to.
  90037. */
  90038. emitter: Nullable<AbstractMesh | Vector3>;
  90039. /**
  90040. * The maximum number of particles to emit per frame
  90041. */
  90042. emitRate: number;
  90043. /**
  90044. * If you want to launch only a few particles at once, that can be done, as well.
  90045. */
  90046. manualEmitCount: number;
  90047. /**
  90048. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90049. */
  90050. updateSpeed: number;
  90051. /**
  90052. * The amount of time the particle system is running (depends of the overall update speed).
  90053. */
  90054. targetStopDuration: number;
  90055. /**
  90056. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90057. */
  90058. disposeOnStop: boolean;
  90059. /**
  90060. * Minimum power of emitting particles.
  90061. */
  90062. minEmitPower: number;
  90063. /**
  90064. * Maximum power of emitting particles.
  90065. */
  90066. maxEmitPower: number;
  90067. /**
  90068. * Minimum life time of emitting particles.
  90069. */
  90070. minLifeTime: number;
  90071. /**
  90072. * Maximum life time of emitting particles.
  90073. */
  90074. maxLifeTime: number;
  90075. /**
  90076. * Minimum Size of emitting particles.
  90077. */
  90078. minSize: number;
  90079. /**
  90080. * Maximum Size of emitting particles.
  90081. */
  90082. maxSize: number;
  90083. /**
  90084. * Minimum scale of emitting particles on X axis.
  90085. */
  90086. minScaleX: number;
  90087. /**
  90088. * Maximum scale of emitting particles on X axis.
  90089. */
  90090. maxScaleX: number;
  90091. /**
  90092. * Minimum scale of emitting particles on Y axis.
  90093. */
  90094. minScaleY: number;
  90095. /**
  90096. * Maximum scale of emitting particles on Y axis.
  90097. */
  90098. maxScaleY: number;
  90099. /**
  90100. * Gets or sets the minimal initial rotation in radians.
  90101. */
  90102. minInitialRotation: number;
  90103. /**
  90104. * Gets or sets the maximal initial rotation in radians.
  90105. */
  90106. maxInitialRotation: number;
  90107. /**
  90108. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90109. */
  90110. minAngularSpeed: number;
  90111. /**
  90112. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90113. */
  90114. maxAngularSpeed: number;
  90115. /**
  90116. * The texture used to render each particle. (this can be a spritesheet)
  90117. */
  90118. particleTexture: Nullable<Texture>;
  90119. /**
  90120. * The layer mask we are rendering the particles through.
  90121. */
  90122. layerMask: number;
  90123. /**
  90124. * This can help using your own shader to render the particle system.
  90125. * The according effect will be created
  90126. */
  90127. customShader: any;
  90128. /**
  90129. * By default particle system starts as soon as they are created. This prevents the
  90130. * automatic start to happen and let you decide when to start emitting particles.
  90131. */
  90132. preventAutoStart: boolean;
  90133. private _noiseTexture;
  90134. /**
  90135. * Gets or sets a texture used to add random noise to particle positions
  90136. */
  90137. get noiseTexture(): Nullable<ProceduralTexture>;
  90138. set noiseTexture(value: Nullable<ProceduralTexture>);
  90139. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90140. noiseStrength: Vector3;
  90141. /**
  90142. * Callback triggered when the particle animation is ending.
  90143. */
  90144. onAnimationEnd: Nullable<() => void>;
  90145. /**
  90146. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90147. */
  90148. blendMode: number;
  90149. /**
  90150. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90151. * to override the particles.
  90152. */
  90153. forceDepthWrite: boolean;
  90154. /** 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 */
  90155. preWarmCycles: number;
  90156. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90157. preWarmStepOffset: number;
  90158. /**
  90159. * 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)
  90160. */
  90161. spriteCellChangeSpeed: number;
  90162. /**
  90163. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90164. */
  90165. startSpriteCellID: number;
  90166. /**
  90167. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90168. */
  90169. endSpriteCellID: number;
  90170. /**
  90171. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90172. */
  90173. spriteCellWidth: number;
  90174. /**
  90175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90176. */
  90177. spriteCellHeight: number;
  90178. /**
  90179. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90180. */
  90181. spriteRandomStartCell: boolean;
  90182. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90183. translationPivot: Vector2;
  90184. /** @hidden */
  90185. protected _isAnimationSheetEnabled: boolean;
  90186. /**
  90187. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90188. */
  90189. beginAnimationOnStart: boolean;
  90190. /**
  90191. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90192. */
  90193. beginAnimationFrom: number;
  90194. /**
  90195. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90196. */
  90197. beginAnimationTo: number;
  90198. /**
  90199. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90200. */
  90201. beginAnimationLoop: boolean;
  90202. /**
  90203. * Gets or sets a world offset applied to all particles
  90204. */
  90205. worldOffset: Vector3;
  90206. /**
  90207. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90208. */
  90209. get isAnimationSheetEnabled(): boolean;
  90210. set isAnimationSheetEnabled(value: boolean);
  90211. /**
  90212. * Get hosting scene
  90213. * @returns the scene
  90214. */
  90215. getScene(): Scene;
  90216. /**
  90217. * You can use gravity if you want to give an orientation to your particles.
  90218. */
  90219. gravity: Vector3;
  90220. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90221. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90222. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90223. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90224. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90225. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90226. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90227. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90228. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90229. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90230. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90231. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90232. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90233. /**
  90234. * Defines the delay in milliseconds before starting the system (0 by default)
  90235. */
  90236. startDelay: number;
  90237. /**
  90238. * Gets the current list of drag gradients.
  90239. * You must use addDragGradient and removeDragGradient to udpate this list
  90240. * @returns the list of drag gradients
  90241. */
  90242. getDragGradients(): Nullable<Array<FactorGradient>>;
  90243. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90244. limitVelocityDamping: number;
  90245. /**
  90246. * Gets the current list of limit velocity gradients.
  90247. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90248. * @returns the list of limit velocity gradients
  90249. */
  90250. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90251. /**
  90252. * Gets the current list of color gradients.
  90253. * You must use addColorGradient and removeColorGradient to udpate this list
  90254. * @returns the list of color gradients
  90255. */
  90256. getColorGradients(): Nullable<Array<ColorGradient>>;
  90257. /**
  90258. * Gets the current list of size gradients.
  90259. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90260. * @returns the list of size gradients
  90261. */
  90262. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90263. /**
  90264. * Gets the current list of color remap gradients.
  90265. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90266. * @returns the list of color remap gradients
  90267. */
  90268. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90269. /**
  90270. * Gets the current list of alpha remap gradients.
  90271. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90272. * @returns the list of alpha remap gradients
  90273. */
  90274. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90275. /**
  90276. * Gets the current list of life time gradients.
  90277. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90278. * @returns the list of life time gradients
  90279. */
  90280. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90281. /**
  90282. * Gets the current list of angular speed gradients.
  90283. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90284. * @returns the list of angular speed gradients
  90285. */
  90286. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90287. /**
  90288. * Gets the current list of velocity gradients.
  90289. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90290. * @returns the list of velocity gradients
  90291. */
  90292. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90293. /**
  90294. * Gets the current list of start size gradients.
  90295. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90296. * @returns the list of start size gradients
  90297. */
  90298. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90299. /**
  90300. * Gets the current list of emit rate gradients.
  90301. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90302. * @returns the list of emit rate gradients
  90303. */
  90304. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90305. /**
  90306. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90307. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90308. */
  90309. get direction1(): Vector3;
  90310. set direction1(value: Vector3);
  90311. /**
  90312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90313. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90314. */
  90315. get direction2(): Vector3;
  90316. set direction2(value: Vector3);
  90317. /**
  90318. * 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.
  90319. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90320. */
  90321. get minEmitBox(): Vector3;
  90322. set minEmitBox(value: Vector3);
  90323. /**
  90324. * 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.
  90325. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90326. */
  90327. get maxEmitBox(): Vector3;
  90328. set maxEmitBox(value: Vector3);
  90329. /**
  90330. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90331. */
  90332. color1: Color4;
  90333. /**
  90334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90335. */
  90336. color2: Color4;
  90337. /**
  90338. * Color the particle will have at the end of its lifetime
  90339. */
  90340. colorDead: Color4;
  90341. /**
  90342. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90343. */
  90344. textureMask: Color4;
  90345. /**
  90346. * The particle emitter type defines the emitter used by the particle system.
  90347. * It can be for example box, sphere, or cone...
  90348. */
  90349. particleEmitterType: IParticleEmitterType;
  90350. /** @hidden */
  90351. _isSubEmitter: boolean;
  90352. /**
  90353. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90354. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90355. */
  90356. billboardMode: number;
  90357. protected _isBillboardBased: boolean;
  90358. /**
  90359. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90360. */
  90361. get isBillboardBased(): boolean;
  90362. set isBillboardBased(value: boolean);
  90363. /**
  90364. * The scene the particle system belongs to.
  90365. */
  90366. protected _scene: Scene;
  90367. /**
  90368. * Local cache of defines for image processing.
  90369. */
  90370. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90371. /**
  90372. * Default configuration related to image processing available in the standard Material.
  90373. */
  90374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90375. /**
  90376. * Gets the image processing configuration used either in this material.
  90377. */
  90378. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90379. /**
  90380. * Sets the Default image processing configuration used either in the this material.
  90381. *
  90382. * If sets to null, the scene one is in use.
  90383. */
  90384. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90385. /**
  90386. * Attaches a new image processing configuration to the Standard Material.
  90387. * @param configuration
  90388. */
  90389. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90390. /** @hidden */
  90391. protected _reset(): void;
  90392. /** @hidden */
  90393. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90394. /**
  90395. * Instantiates a particle system.
  90396. * 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.
  90397. * @param name The name of the particle system
  90398. */
  90399. constructor(name: string);
  90400. /**
  90401. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90404. * @returns the emitter
  90405. */
  90406. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90407. /**
  90408. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90409. * @param radius The radius of the hemisphere to emit from
  90410. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90411. * @returns the emitter
  90412. */
  90413. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90414. /**
  90415. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90416. * @param radius The radius of the sphere to emit from
  90417. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90418. * @returns the emitter
  90419. */
  90420. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90421. /**
  90422. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90423. * @param radius The radius of the sphere to emit from
  90424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90426. * @returns the emitter
  90427. */
  90428. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90429. /**
  90430. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90431. * @param radius The radius of the emission cylinder
  90432. * @param height The height of the emission cylinder
  90433. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90434. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90435. * @returns the emitter
  90436. */
  90437. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90438. /**
  90439. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90440. * @param radius The radius of the cylinder to emit from
  90441. * @param height The height of the emission cylinder
  90442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90443. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90444. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90445. * @returns the emitter
  90446. */
  90447. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90448. /**
  90449. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90450. * @param radius The radius of the cone to emit from
  90451. * @param angle The base angle of the cone
  90452. * @returns the emitter
  90453. */
  90454. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90455. /**
  90456. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90459. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90460. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90461. * @returns the emitter
  90462. */
  90463. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90464. }
  90465. }
  90466. declare module BABYLON {
  90467. /**
  90468. * Type of sub emitter
  90469. */
  90470. export enum SubEmitterType {
  90471. /**
  90472. * Attached to the particle over it's lifetime
  90473. */
  90474. ATTACHED = 0,
  90475. /**
  90476. * Created when the particle dies
  90477. */
  90478. END = 1
  90479. }
  90480. /**
  90481. * Sub emitter class used to emit particles from an existing particle
  90482. */
  90483. export class SubEmitter {
  90484. /**
  90485. * the particle system to be used by the sub emitter
  90486. */
  90487. particleSystem: ParticleSystem;
  90488. /**
  90489. * Type of the submitter (Default: END)
  90490. */
  90491. type: SubEmitterType;
  90492. /**
  90493. * 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)
  90494. * Note: This only is supported when using an emitter of type Mesh
  90495. */
  90496. inheritDirection: boolean;
  90497. /**
  90498. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90499. */
  90500. inheritedVelocityAmount: number;
  90501. /**
  90502. * Creates a sub emitter
  90503. * @param particleSystem the particle system to be used by the sub emitter
  90504. */
  90505. constructor(
  90506. /**
  90507. * the particle system to be used by the sub emitter
  90508. */
  90509. particleSystem: ParticleSystem);
  90510. /**
  90511. * Clones the sub emitter
  90512. * @returns the cloned sub emitter
  90513. */
  90514. clone(): SubEmitter;
  90515. /**
  90516. * Serialize current object to a JSON object
  90517. * @returns the serialized object
  90518. */
  90519. serialize(): any;
  90520. /** @hidden */
  90521. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90522. /**
  90523. * Creates a new SubEmitter from a serialized JSON version
  90524. * @param serializationObject defines the JSON object to read from
  90525. * @param scene defines the hosting scene
  90526. * @param rootUrl defines the rootUrl for data loading
  90527. * @returns a new SubEmitter
  90528. */
  90529. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90530. /** Release associated resources */
  90531. dispose(): void;
  90532. }
  90533. }
  90534. declare module BABYLON {
  90535. /** @hidden */
  90536. export var imageProcessingDeclaration: {
  90537. name: string;
  90538. shader: string;
  90539. };
  90540. }
  90541. declare module BABYLON {
  90542. /** @hidden */
  90543. export var imageProcessingFunctions: {
  90544. name: string;
  90545. shader: string;
  90546. };
  90547. }
  90548. declare module BABYLON {
  90549. /** @hidden */
  90550. export var particlesPixelShader: {
  90551. name: string;
  90552. shader: string;
  90553. };
  90554. }
  90555. declare module BABYLON {
  90556. /** @hidden */
  90557. export var particlesVertexShader: {
  90558. name: string;
  90559. shader: string;
  90560. };
  90561. }
  90562. declare module BABYLON {
  90563. /**
  90564. * This represents a particle system in Babylon.
  90565. * 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.
  90566. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90567. * @example https://doc.babylonjs.com/babylon101/particles
  90568. */
  90569. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90570. /**
  90571. * Billboard mode will only apply to Y axis
  90572. */
  90573. static readonly BILLBOARDMODE_Y: number;
  90574. /**
  90575. * Billboard mode will apply to all axes
  90576. */
  90577. static readonly BILLBOARDMODE_ALL: number;
  90578. /**
  90579. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90580. */
  90581. static readonly BILLBOARDMODE_STRETCHED: number;
  90582. /**
  90583. * This function can be defined to provide custom update for active particles.
  90584. * This function will be called instead of regular update (age, position, color, etc.).
  90585. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90586. */
  90587. updateFunction: (particles: Particle[]) => void;
  90588. private _emitterWorldMatrix;
  90589. /**
  90590. * This function can be defined to specify initial direction for every new particle.
  90591. * It by default use the emitterType defined function
  90592. */
  90593. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90594. /**
  90595. * This function can be defined to specify initial position for every new particle.
  90596. * It by default use the emitterType defined function
  90597. */
  90598. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90599. /**
  90600. * @hidden
  90601. */
  90602. _inheritedVelocityOffset: Vector3;
  90603. /**
  90604. * An event triggered when the system is disposed
  90605. */
  90606. onDisposeObservable: Observable<IParticleSystem>;
  90607. private _onDisposeObserver;
  90608. /**
  90609. * Sets a callback that will be triggered when the system is disposed
  90610. */
  90611. set onDispose(callback: () => void);
  90612. private _particles;
  90613. private _epsilon;
  90614. private _capacity;
  90615. private _stockParticles;
  90616. private _newPartsExcess;
  90617. private _vertexData;
  90618. private _vertexBuffer;
  90619. private _vertexBuffers;
  90620. private _spriteBuffer;
  90621. private _indexBuffer;
  90622. private _effect;
  90623. private _customEffect;
  90624. private _cachedDefines;
  90625. private _scaledColorStep;
  90626. private _colorDiff;
  90627. private _scaledDirection;
  90628. private _scaledGravity;
  90629. private _currentRenderId;
  90630. private _alive;
  90631. private _useInstancing;
  90632. private _started;
  90633. private _stopped;
  90634. private _actualFrame;
  90635. private _scaledUpdateSpeed;
  90636. private _vertexBufferSize;
  90637. /** @hidden */
  90638. _currentEmitRateGradient: Nullable<FactorGradient>;
  90639. /** @hidden */
  90640. _currentEmitRate1: number;
  90641. /** @hidden */
  90642. _currentEmitRate2: number;
  90643. /** @hidden */
  90644. _currentStartSizeGradient: Nullable<FactorGradient>;
  90645. /** @hidden */
  90646. _currentStartSize1: number;
  90647. /** @hidden */
  90648. _currentStartSize2: number;
  90649. private readonly _rawTextureWidth;
  90650. private _rampGradientsTexture;
  90651. private _useRampGradients;
  90652. /** Gets or sets a boolean indicating that ramp gradients must be used
  90653. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90654. */
  90655. get useRampGradients(): boolean;
  90656. set useRampGradients(value: boolean);
  90657. /**
  90658. * 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.
  90659. * 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: [])
  90660. */
  90661. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90662. private _subEmitters;
  90663. /**
  90664. * @hidden
  90665. * If the particle systems emitter should be disposed when the particle system is disposed
  90666. */
  90667. _disposeEmitterOnDispose: boolean;
  90668. /**
  90669. * The current active Sub-systems, this property is used by the root particle system only.
  90670. */
  90671. activeSubSystems: Array<ParticleSystem>;
  90672. /**
  90673. * Specifies if the particles are updated in emitter local space or world space
  90674. */
  90675. isLocal: boolean;
  90676. private _rootParticleSystem;
  90677. /**
  90678. * Gets the current list of active particles
  90679. */
  90680. get particles(): Particle[];
  90681. /**
  90682. * Gets the number of particles active at the same time.
  90683. * @returns The number of active particles.
  90684. */
  90685. getActiveCount(): number;
  90686. /**
  90687. * Returns the string "ParticleSystem"
  90688. * @returns a string containing the class name
  90689. */
  90690. getClassName(): string;
  90691. /**
  90692. * Gets a boolean indicating that the system is stopping
  90693. * @returns true if the system is currently stopping
  90694. */
  90695. isStopping(): boolean;
  90696. /**
  90697. * Gets the custom effect used to render the particles
  90698. * @param blendMode Blend mode for which the effect should be retrieved
  90699. * @returns The effect
  90700. */
  90701. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90702. /**
  90703. * Sets the custom effect used to render the particles
  90704. * @param effect The effect to set
  90705. * @param blendMode Blend mode for which the effect should be set
  90706. */
  90707. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90708. /** @hidden */
  90709. private _onBeforeDrawParticlesObservable;
  90710. /**
  90711. * Observable that will be called just before the particles are drawn
  90712. */
  90713. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90714. /**
  90715. * Gets the name of the particle vertex shader
  90716. */
  90717. get vertexShaderName(): string;
  90718. /**
  90719. * Instantiates a particle system.
  90720. * 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.
  90721. * @param name The name of the particle system
  90722. * @param capacity The max number of particles alive at the same time
  90723. * @param scene The scene the particle system belongs to
  90724. * @param customEffect a custom effect used to change the way particles are rendered by default
  90725. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90726. * @param epsilon Offset used to render the particles
  90727. */
  90728. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90729. private _addFactorGradient;
  90730. private _removeFactorGradient;
  90731. /**
  90732. * Adds a new life time gradient
  90733. * @param gradient defines the gradient to use (between 0 and 1)
  90734. * @param factor defines the life time factor to affect to the specified gradient
  90735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90736. * @returns the current particle system
  90737. */
  90738. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90739. /**
  90740. * Remove a specific life time gradient
  90741. * @param gradient defines the gradient to remove
  90742. * @returns the current particle system
  90743. */
  90744. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90745. /**
  90746. * Adds a new size gradient
  90747. * @param gradient defines the gradient to use (between 0 and 1)
  90748. * @param factor defines the size factor to affect to the specified gradient
  90749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90750. * @returns the current particle system
  90751. */
  90752. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90753. /**
  90754. * Remove a specific size gradient
  90755. * @param gradient defines the gradient to remove
  90756. * @returns the current particle system
  90757. */
  90758. removeSizeGradient(gradient: number): IParticleSystem;
  90759. /**
  90760. * Adds a new color remap gradient
  90761. * @param gradient defines the gradient to use (between 0 and 1)
  90762. * @param min defines the color remap minimal range
  90763. * @param max defines the color remap maximal range
  90764. * @returns the current particle system
  90765. */
  90766. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90767. /**
  90768. * Remove a specific color remap gradient
  90769. * @param gradient defines the gradient to remove
  90770. * @returns the current particle system
  90771. */
  90772. removeColorRemapGradient(gradient: number): IParticleSystem;
  90773. /**
  90774. * Adds a new alpha remap gradient
  90775. * @param gradient defines the gradient to use (between 0 and 1)
  90776. * @param min defines the alpha remap minimal range
  90777. * @param max defines the alpha remap maximal range
  90778. * @returns the current particle system
  90779. */
  90780. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90781. /**
  90782. * Remove a specific alpha remap gradient
  90783. * @param gradient defines the gradient to remove
  90784. * @returns the current particle system
  90785. */
  90786. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90787. /**
  90788. * Adds a new angular speed gradient
  90789. * @param gradient defines the gradient to use (between 0 and 1)
  90790. * @param factor defines the angular speed to affect to the specified gradient
  90791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90792. * @returns the current particle system
  90793. */
  90794. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90795. /**
  90796. * Remove a specific angular speed gradient
  90797. * @param gradient defines the gradient to remove
  90798. * @returns the current particle system
  90799. */
  90800. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90801. /**
  90802. * Adds a new velocity gradient
  90803. * @param gradient defines the gradient to use (between 0 and 1)
  90804. * @param factor defines the velocity to affect to the specified gradient
  90805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90806. * @returns the current particle system
  90807. */
  90808. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90809. /**
  90810. * Remove a specific velocity gradient
  90811. * @param gradient defines the gradient to remove
  90812. * @returns the current particle system
  90813. */
  90814. removeVelocityGradient(gradient: number): IParticleSystem;
  90815. /**
  90816. * Adds a new limit velocity gradient
  90817. * @param gradient defines the gradient to use (between 0 and 1)
  90818. * @param factor defines the limit velocity value to affect to the specified gradient
  90819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90820. * @returns the current particle system
  90821. */
  90822. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90823. /**
  90824. * Remove a specific limit velocity gradient
  90825. * @param gradient defines the gradient to remove
  90826. * @returns the current particle system
  90827. */
  90828. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90829. /**
  90830. * Adds a new drag gradient
  90831. * @param gradient defines the gradient to use (between 0 and 1)
  90832. * @param factor defines the drag value to affect to the specified gradient
  90833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90834. * @returns the current particle system
  90835. */
  90836. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90837. /**
  90838. * Remove a specific drag gradient
  90839. * @param gradient defines the gradient to remove
  90840. * @returns the current particle system
  90841. */
  90842. removeDragGradient(gradient: number): IParticleSystem;
  90843. /**
  90844. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90845. * @param gradient defines the gradient to use (between 0 and 1)
  90846. * @param factor defines the emit rate value to affect to the specified gradient
  90847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90848. * @returns the current particle system
  90849. */
  90850. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90851. /**
  90852. * Remove a specific emit rate gradient
  90853. * @param gradient defines the gradient to remove
  90854. * @returns the current particle system
  90855. */
  90856. removeEmitRateGradient(gradient: number): IParticleSystem;
  90857. /**
  90858. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90859. * @param gradient defines the gradient to use (between 0 and 1)
  90860. * @param factor defines the start size value to affect to the specified gradient
  90861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90862. * @returns the current particle system
  90863. */
  90864. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90865. /**
  90866. * Remove a specific start size gradient
  90867. * @param gradient defines the gradient to remove
  90868. * @returns the current particle system
  90869. */
  90870. removeStartSizeGradient(gradient: number): IParticleSystem;
  90871. private _createRampGradientTexture;
  90872. /**
  90873. * Gets the current list of ramp gradients.
  90874. * You must use addRampGradient and removeRampGradient to udpate this list
  90875. * @returns the list of ramp gradients
  90876. */
  90877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90878. /** Force the system to rebuild all gradients that need to be resync */
  90879. forceRefreshGradients(): void;
  90880. private _syncRampGradientTexture;
  90881. /**
  90882. * Adds a new ramp gradient used to remap particle colors
  90883. * @param gradient defines the gradient to use (between 0 and 1)
  90884. * @param color defines the color to affect to the specified gradient
  90885. * @returns the current particle system
  90886. */
  90887. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90888. /**
  90889. * Remove a specific ramp gradient
  90890. * @param gradient defines the gradient to remove
  90891. * @returns the current particle system
  90892. */
  90893. removeRampGradient(gradient: number): ParticleSystem;
  90894. /**
  90895. * Adds a new color gradient
  90896. * @param gradient defines the gradient to use (between 0 and 1)
  90897. * @param color1 defines the color to affect to the specified gradient
  90898. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90899. * @returns this particle system
  90900. */
  90901. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90902. /**
  90903. * Remove a specific color gradient
  90904. * @param gradient defines the gradient to remove
  90905. * @returns this particle system
  90906. */
  90907. removeColorGradient(gradient: number): IParticleSystem;
  90908. private _fetchR;
  90909. protected _reset(): void;
  90910. private _resetEffect;
  90911. private _createVertexBuffers;
  90912. private _createIndexBuffer;
  90913. /**
  90914. * Gets the maximum number of particles active at the same time.
  90915. * @returns The max number of active particles.
  90916. */
  90917. getCapacity(): number;
  90918. /**
  90919. * Gets whether there are still active particles in the system.
  90920. * @returns True if it is alive, otherwise false.
  90921. */
  90922. isAlive(): boolean;
  90923. /**
  90924. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90925. * @returns True if it has been started, otherwise false.
  90926. */
  90927. isStarted(): boolean;
  90928. private _prepareSubEmitterInternalArray;
  90929. /**
  90930. * Starts the particle system and begins to emit
  90931. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90932. */
  90933. start(delay?: number): void;
  90934. /**
  90935. * Stops the particle system.
  90936. * @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.
  90937. */
  90938. stop(stopSubEmitters?: boolean): void;
  90939. /**
  90940. * Remove all active particles
  90941. */
  90942. reset(): void;
  90943. /**
  90944. * @hidden (for internal use only)
  90945. */
  90946. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90947. /**
  90948. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90949. * Its lifetime will start back at 0.
  90950. */
  90951. recycleParticle: (particle: Particle) => void;
  90952. private _stopSubEmitters;
  90953. private _createParticle;
  90954. private _removeFromRoot;
  90955. private _emitFromParticle;
  90956. private _update;
  90957. /** @hidden */
  90958. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90959. /** @hidden */
  90960. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90961. /**
  90962. * Fill the defines array according to the current settings of the particle system
  90963. * @param defines Array to be updated
  90964. * @param blendMode blend mode to take into account when updating the array
  90965. */
  90966. fillDefines(defines: Array<string>, blendMode: number): void;
  90967. /**
  90968. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90969. * @param uniforms Uniforms array to fill
  90970. * @param attributes Attributes array to fill
  90971. * @param samplers Samplers array to fill
  90972. */
  90973. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90974. /** @hidden */
  90975. private _getEffect;
  90976. /**
  90977. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90978. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90979. */
  90980. animate(preWarmOnly?: boolean): void;
  90981. private _appendParticleVertices;
  90982. /**
  90983. * Rebuilds the particle system.
  90984. */
  90985. rebuild(): void;
  90986. /**
  90987. * Is this system ready to be used/rendered
  90988. * @return true if the system is ready
  90989. */
  90990. isReady(): boolean;
  90991. private _render;
  90992. /**
  90993. * Renders the particle system in its current state.
  90994. * @returns the current number of particles
  90995. */
  90996. render(): number;
  90997. /**
  90998. * Disposes the particle system and free the associated resources
  90999. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91000. */
  91001. dispose(disposeTexture?: boolean): void;
  91002. /**
  91003. * Clones the particle system.
  91004. * @param name The name of the cloned object
  91005. * @param newEmitter The new emitter to use
  91006. * @returns the cloned particle system
  91007. */
  91008. clone(name: string, newEmitter: any): ParticleSystem;
  91009. /**
  91010. * Serializes the particle system to a JSON object
  91011. * @param serializeTexture defines if the texture must be serialized as well
  91012. * @returns the JSON object
  91013. */
  91014. serialize(serializeTexture?: boolean): any;
  91015. /** @hidden */
  91016. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91017. /** @hidden */
  91018. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91019. /**
  91020. * Parses a JSON object to create a particle system.
  91021. * @param parsedParticleSystem The JSON object to parse
  91022. * @param scene The scene to create the particle system in
  91023. * @param rootUrl The root url to use to load external dependencies like texture
  91024. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91025. * @returns the Parsed particle system
  91026. */
  91027. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91028. }
  91029. }
  91030. declare module BABYLON {
  91031. /**
  91032. * A particle represents one of the element emitted by a particle system.
  91033. * This is mainly define by its coordinates, direction, velocity and age.
  91034. */
  91035. export class Particle {
  91036. /**
  91037. * The particle system the particle belongs to.
  91038. */
  91039. particleSystem: ParticleSystem;
  91040. private static _Count;
  91041. /**
  91042. * Unique ID of the particle
  91043. */
  91044. id: number;
  91045. /**
  91046. * The world position of the particle in the scene.
  91047. */
  91048. position: Vector3;
  91049. /**
  91050. * The world direction of the particle in the scene.
  91051. */
  91052. direction: Vector3;
  91053. /**
  91054. * The color of the particle.
  91055. */
  91056. color: Color4;
  91057. /**
  91058. * The color change of the particle per step.
  91059. */
  91060. colorStep: Color4;
  91061. /**
  91062. * Defines how long will the life of the particle be.
  91063. */
  91064. lifeTime: number;
  91065. /**
  91066. * The current age of the particle.
  91067. */
  91068. age: number;
  91069. /**
  91070. * The current size of the particle.
  91071. */
  91072. size: number;
  91073. /**
  91074. * The current scale of the particle.
  91075. */
  91076. scale: Vector2;
  91077. /**
  91078. * The current angle of the particle.
  91079. */
  91080. angle: number;
  91081. /**
  91082. * Defines how fast is the angle changing.
  91083. */
  91084. angularSpeed: number;
  91085. /**
  91086. * Defines the cell index used by the particle to be rendered from a sprite.
  91087. */
  91088. cellIndex: number;
  91089. /**
  91090. * The information required to support color remapping
  91091. */
  91092. remapData: Vector4;
  91093. /** @hidden */
  91094. _randomCellOffset?: number;
  91095. /** @hidden */
  91096. _initialDirection: Nullable<Vector3>;
  91097. /** @hidden */
  91098. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91099. /** @hidden */
  91100. _initialStartSpriteCellID: number;
  91101. /** @hidden */
  91102. _initialEndSpriteCellID: number;
  91103. /** @hidden */
  91104. _currentColorGradient: Nullable<ColorGradient>;
  91105. /** @hidden */
  91106. _currentColor1: Color4;
  91107. /** @hidden */
  91108. _currentColor2: Color4;
  91109. /** @hidden */
  91110. _currentSizeGradient: Nullable<FactorGradient>;
  91111. /** @hidden */
  91112. _currentSize1: number;
  91113. /** @hidden */
  91114. _currentSize2: number;
  91115. /** @hidden */
  91116. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91117. /** @hidden */
  91118. _currentAngularSpeed1: number;
  91119. /** @hidden */
  91120. _currentAngularSpeed2: number;
  91121. /** @hidden */
  91122. _currentVelocityGradient: Nullable<FactorGradient>;
  91123. /** @hidden */
  91124. _currentVelocity1: number;
  91125. /** @hidden */
  91126. _currentVelocity2: number;
  91127. /** @hidden */
  91128. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91129. /** @hidden */
  91130. _currentLimitVelocity1: number;
  91131. /** @hidden */
  91132. _currentLimitVelocity2: number;
  91133. /** @hidden */
  91134. _currentDragGradient: Nullable<FactorGradient>;
  91135. /** @hidden */
  91136. _currentDrag1: number;
  91137. /** @hidden */
  91138. _currentDrag2: number;
  91139. /** @hidden */
  91140. _randomNoiseCoordinates1: Vector3;
  91141. /** @hidden */
  91142. _randomNoiseCoordinates2: Vector3;
  91143. /** @hidden */
  91144. _localPosition?: Vector3;
  91145. /**
  91146. * Creates a new instance Particle
  91147. * @param particleSystem the particle system the particle belongs to
  91148. */
  91149. constructor(
  91150. /**
  91151. * The particle system the particle belongs to.
  91152. */
  91153. particleSystem: ParticleSystem);
  91154. private updateCellInfoFromSystem;
  91155. /**
  91156. * Defines how the sprite cell index is updated for the particle
  91157. */
  91158. updateCellIndex(): void;
  91159. /** @hidden */
  91160. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91161. /** @hidden */
  91162. _inheritParticleInfoToSubEmitters(): void;
  91163. /** @hidden */
  91164. _reset(): void;
  91165. /**
  91166. * Copy the properties of particle to another one.
  91167. * @param other the particle to copy the information to.
  91168. */
  91169. copyTo(other: Particle): void;
  91170. }
  91171. }
  91172. declare module BABYLON {
  91173. /**
  91174. * Particle emitter represents a volume emitting particles.
  91175. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91176. */
  91177. export interface IParticleEmitterType {
  91178. /**
  91179. * Called by the particle System when the direction is computed for the created particle.
  91180. * @param worldMatrix is the world matrix of the particle system
  91181. * @param directionToUpdate is the direction vector to update with the result
  91182. * @param particle is the particle we are computed the direction for
  91183. * @param isLocal defines if the direction should be set in local space
  91184. */
  91185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91186. /**
  91187. * Called by the particle System when the position is computed for the created particle.
  91188. * @param worldMatrix is the world matrix of the particle system
  91189. * @param positionToUpdate is the position vector to update with the result
  91190. * @param particle is the particle we are computed the position for
  91191. * @param isLocal defines if the position should be set in local space
  91192. */
  91193. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91194. /**
  91195. * Clones the current emitter and returns a copy of it
  91196. * @returns the new emitter
  91197. */
  91198. clone(): IParticleEmitterType;
  91199. /**
  91200. * Called by the GPUParticleSystem to setup the update shader
  91201. * @param effect defines the update shader
  91202. */
  91203. applyToShader(effect: Effect): void;
  91204. /**
  91205. * Returns a string to use to update the GPU particles update shader
  91206. * @returns the effect defines string
  91207. */
  91208. getEffectDefines(): string;
  91209. /**
  91210. * Returns a string representing the class name
  91211. * @returns a string containing the class name
  91212. */
  91213. getClassName(): string;
  91214. /**
  91215. * Serializes the particle system to a JSON object.
  91216. * @returns the JSON object
  91217. */
  91218. serialize(): any;
  91219. /**
  91220. * Parse properties from a JSON object
  91221. * @param serializationObject defines the JSON object
  91222. * @param scene defines the hosting scene
  91223. */
  91224. parse(serializationObject: any, scene: Scene): void;
  91225. }
  91226. }
  91227. declare module BABYLON {
  91228. /**
  91229. * Particle emitter emitting particles from the inside of a box.
  91230. * It emits the particles randomly between 2 given directions.
  91231. */
  91232. export class BoxParticleEmitter implements IParticleEmitterType {
  91233. /**
  91234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91235. */
  91236. direction1: Vector3;
  91237. /**
  91238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91239. */
  91240. direction2: Vector3;
  91241. /**
  91242. * 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.
  91243. */
  91244. minEmitBox: Vector3;
  91245. /**
  91246. * 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.
  91247. */
  91248. maxEmitBox: Vector3;
  91249. /**
  91250. * Creates a new instance BoxParticleEmitter
  91251. */
  91252. constructor();
  91253. /**
  91254. * Called by the particle System when the direction is computed for the created particle.
  91255. * @param worldMatrix is the world matrix of the particle system
  91256. * @param directionToUpdate is the direction vector to update with the result
  91257. * @param particle is the particle we are computed the direction for
  91258. * @param isLocal defines if the direction should be set in local space
  91259. */
  91260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91261. /**
  91262. * Called by the particle System when the position is computed for the created particle.
  91263. * @param worldMatrix is the world matrix of the particle system
  91264. * @param positionToUpdate is the position vector to update with the result
  91265. * @param particle is the particle we are computed the position for
  91266. * @param isLocal defines if the position should be set in local space
  91267. */
  91268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91269. /**
  91270. * Clones the current emitter and returns a copy of it
  91271. * @returns the new emitter
  91272. */
  91273. clone(): BoxParticleEmitter;
  91274. /**
  91275. * Called by the GPUParticleSystem to setup the update shader
  91276. * @param effect defines the update shader
  91277. */
  91278. applyToShader(effect: Effect): void;
  91279. /**
  91280. * Returns a string to use to update the GPU particles update shader
  91281. * @returns a string containng the defines string
  91282. */
  91283. getEffectDefines(): string;
  91284. /**
  91285. * Returns the string "BoxParticleEmitter"
  91286. * @returns a string containing the class name
  91287. */
  91288. getClassName(): string;
  91289. /**
  91290. * Serializes the particle system to a JSON object.
  91291. * @returns the JSON object
  91292. */
  91293. serialize(): any;
  91294. /**
  91295. * Parse properties from a JSON object
  91296. * @param serializationObject defines the JSON object
  91297. */
  91298. parse(serializationObject: any): void;
  91299. }
  91300. }
  91301. declare module BABYLON {
  91302. /**
  91303. * Particle emitter emitting particles from the inside of a cone.
  91304. * It emits the particles alongside the cone volume from the base to the particle.
  91305. * The emission direction might be randomized.
  91306. */
  91307. export class ConeParticleEmitter implements IParticleEmitterType {
  91308. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91309. directionRandomizer: number;
  91310. private _radius;
  91311. private _angle;
  91312. private _height;
  91313. /**
  91314. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91315. */
  91316. radiusRange: number;
  91317. /**
  91318. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91319. */
  91320. heightRange: number;
  91321. /**
  91322. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91323. */
  91324. emitFromSpawnPointOnly: boolean;
  91325. /**
  91326. * Gets or sets the radius of the emission cone
  91327. */
  91328. get radius(): number;
  91329. set radius(value: number);
  91330. /**
  91331. * Gets or sets the angle of the emission cone
  91332. */
  91333. get angle(): number;
  91334. set angle(value: number);
  91335. private _buildHeight;
  91336. /**
  91337. * Creates a new instance ConeParticleEmitter
  91338. * @param radius the radius of the emission cone (1 by default)
  91339. * @param angle the cone base angle (PI by default)
  91340. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91341. */
  91342. constructor(radius?: number, angle?: number,
  91343. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91344. directionRandomizer?: number);
  91345. /**
  91346. * Called by the particle System when the direction is computed for the created particle.
  91347. * @param worldMatrix is the world matrix of the particle system
  91348. * @param directionToUpdate is the direction vector to update with the result
  91349. * @param particle is the particle we are computed the direction for
  91350. * @param isLocal defines if the direction should be set in local space
  91351. */
  91352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91353. /**
  91354. * Called by the particle System when the position is computed for the created particle.
  91355. * @param worldMatrix is the world matrix of the particle system
  91356. * @param positionToUpdate is the position vector to update with the result
  91357. * @param particle is the particle we are computed the position for
  91358. * @param isLocal defines if the position should be set in local space
  91359. */
  91360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91361. /**
  91362. * Clones the current emitter and returns a copy of it
  91363. * @returns the new emitter
  91364. */
  91365. clone(): ConeParticleEmitter;
  91366. /**
  91367. * Called by the GPUParticleSystem to setup the update shader
  91368. * @param effect defines the update shader
  91369. */
  91370. applyToShader(effect: Effect): void;
  91371. /**
  91372. * Returns a string to use to update the GPU particles update shader
  91373. * @returns a string containng the defines string
  91374. */
  91375. getEffectDefines(): string;
  91376. /**
  91377. * Returns the string "ConeParticleEmitter"
  91378. * @returns a string containing the class name
  91379. */
  91380. getClassName(): string;
  91381. /**
  91382. * Serializes the particle system to a JSON object.
  91383. * @returns the JSON object
  91384. */
  91385. serialize(): any;
  91386. /**
  91387. * Parse properties from a JSON object
  91388. * @param serializationObject defines the JSON object
  91389. */
  91390. parse(serializationObject: any): void;
  91391. }
  91392. }
  91393. declare module BABYLON {
  91394. /**
  91395. * Particle emitter emitting particles from the inside of a cylinder.
  91396. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91397. */
  91398. export class CylinderParticleEmitter implements IParticleEmitterType {
  91399. /**
  91400. * The radius of the emission cylinder.
  91401. */
  91402. radius: number;
  91403. /**
  91404. * The height of the emission cylinder.
  91405. */
  91406. height: number;
  91407. /**
  91408. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91409. */
  91410. radiusRange: number;
  91411. /**
  91412. * How much to randomize the particle direction [0-1].
  91413. */
  91414. directionRandomizer: number;
  91415. /**
  91416. * Creates a new instance CylinderParticleEmitter
  91417. * @param radius the radius of the emission cylinder (1 by default)
  91418. * @param height the height of the emission cylinder (1 by default)
  91419. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91420. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91421. */
  91422. constructor(
  91423. /**
  91424. * The radius of the emission cylinder.
  91425. */
  91426. radius?: number,
  91427. /**
  91428. * The height of the emission cylinder.
  91429. */
  91430. height?: number,
  91431. /**
  91432. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91433. */
  91434. radiusRange?: number,
  91435. /**
  91436. * How much to randomize the particle direction [0-1].
  91437. */
  91438. directionRandomizer?: number);
  91439. /**
  91440. * Called by the particle System when the direction is computed for the created particle.
  91441. * @param worldMatrix is the world matrix of the particle system
  91442. * @param directionToUpdate is the direction vector to update with the result
  91443. * @param particle is the particle we are computed the direction for
  91444. * @param isLocal defines if the direction should be set in local space
  91445. */
  91446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91447. /**
  91448. * Called by the particle System when the position is computed for the created particle.
  91449. * @param worldMatrix is the world matrix of the particle system
  91450. * @param positionToUpdate is the position vector to update with the result
  91451. * @param particle is the particle we are computed the position for
  91452. * @param isLocal defines if the position should be set in local space
  91453. */
  91454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91455. /**
  91456. * Clones the current emitter and returns a copy of it
  91457. * @returns the new emitter
  91458. */
  91459. clone(): CylinderParticleEmitter;
  91460. /**
  91461. * Called by the GPUParticleSystem to setup the update shader
  91462. * @param effect defines the update shader
  91463. */
  91464. applyToShader(effect: Effect): void;
  91465. /**
  91466. * Returns a string to use to update the GPU particles update shader
  91467. * @returns a string containng the defines string
  91468. */
  91469. getEffectDefines(): string;
  91470. /**
  91471. * Returns the string "CylinderParticleEmitter"
  91472. * @returns a string containing the class name
  91473. */
  91474. getClassName(): string;
  91475. /**
  91476. * Serializes the particle system to a JSON object.
  91477. * @returns the JSON object
  91478. */
  91479. serialize(): any;
  91480. /**
  91481. * Parse properties from a JSON object
  91482. * @param serializationObject defines the JSON object
  91483. */
  91484. parse(serializationObject: any): void;
  91485. }
  91486. /**
  91487. * Particle emitter emitting particles from the inside of a cylinder.
  91488. * It emits the particles randomly between two vectors.
  91489. */
  91490. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91491. /**
  91492. * The min limit of the emission direction.
  91493. */
  91494. direction1: Vector3;
  91495. /**
  91496. * The max limit of the emission direction.
  91497. */
  91498. direction2: Vector3;
  91499. /**
  91500. * Creates a new instance CylinderDirectedParticleEmitter
  91501. * @param radius the radius of the emission cylinder (1 by default)
  91502. * @param height the height of the emission cylinder (1 by default)
  91503. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91504. * @param direction1 the min limit of the emission direction (up vector by default)
  91505. * @param direction2 the max limit of the emission direction (up vector by default)
  91506. */
  91507. constructor(radius?: number, height?: number, radiusRange?: number,
  91508. /**
  91509. * The min limit of the emission direction.
  91510. */
  91511. direction1?: Vector3,
  91512. /**
  91513. * The max limit of the emission direction.
  91514. */
  91515. direction2?: Vector3);
  91516. /**
  91517. * Called by the particle System when the direction is computed for the created particle.
  91518. * @param worldMatrix is the world matrix of the particle system
  91519. * @param directionToUpdate is the direction vector to update with the result
  91520. * @param particle is the particle we are computed the direction for
  91521. */
  91522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91523. /**
  91524. * Clones the current emitter and returns a copy of it
  91525. * @returns the new emitter
  91526. */
  91527. clone(): CylinderDirectedParticleEmitter;
  91528. /**
  91529. * Called by the GPUParticleSystem to setup the update shader
  91530. * @param effect defines the update shader
  91531. */
  91532. applyToShader(effect: Effect): void;
  91533. /**
  91534. * Returns a string to use to update the GPU particles update shader
  91535. * @returns a string containng the defines string
  91536. */
  91537. getEffectDefines(): string;
  91538. /**
  91539. * Returns the string "CylinderDirectedParticleEmitter"
  91540. * @returns a string containing the class name
  91541. */
  91542. getClassName(): string;
  91543. /**
  91544. * Serializes the particle system to a JSON object.
  91545. * @returns the JSON object
  91546. */
  91547. serialize(): any;
  91548. /**
  91549. * Parse properties from a JSON object
  91550. * @param serializationObject defines the JSON object
  91551. */
  91552. parse(serializationObject: any): void;
  91553. }
  91554. }
  91555. declare module BABYLON {
  91556. /**
  91557. * Particle emitter emitting particles from the inside of a hemisphere.
  91558. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91559. */
  91560. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91561. /**
  91562. * The radius of the emission hemisphere.
  91563. */
  91564. radius: number;
  91565. /**
  91566. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91567. */
  91568. radiusRange: number;
  91569. /**
  91570. * How much to randomize the particle direction [0-1].
  91571. */
  91572. directionRandomizer: number;
  91573. /**
  91574. * Creates a new instance HemisphericParticleEmitter
  91575. * @param radius the radius of the emission hemisphere (1 by default)
  91576. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91577. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91578. */
  91579. constructor(
  91580. /**
  91581. * The radius of the emission hemisphere.
  91582. */
  91583. radius?: number,
  91584. /**
  91585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91586. */
  91587. radiusRange?: number,
  91588. /**
  91589. * How much to randomize the particle direction [0-1].
  91590. */
  91591. directionRandomizer?: number);
  91592. /**
  91593. * Called by the particle System when the direction is computed for the created particle.
  91594. * @param worldMatrix is the world matrix of the particle system
  91595. * @param directionToUpdate is the direction vector to update with the result
  91596. * @param particle is the particle we are computed the direction for
  91597. * @param isLocal defines if the direction should be set in local space
  91598. */
  91599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91600. /**
  91601. * Called by the particle System when the position is computed for the created particle.
  91602. * @param worldMatrix is the world matrix of the particle system
  91603. * @param positionToUpdate is the position vector to update with the result
  91604. * @param particle is the particle we are computed the position for
  91605. * @param isLocal defines if the position should be set in local space
  91606. */
  91607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91608. /**
  91609. * Clones the current emitter and returns a copy of it
  91610. * @returns the new emitter
  91611. */
  91612. clone(): HemisphericParticleEmitter;
  91613. /**
  91614. * Called by the GPUParticleSystem to setup the update shader
  91615. * @param effect defines the update shader
  91616. */
  91617. applyToShader(effect: Effect): void;
  91618. /**
  91619. * Returns a string to use to update the GPU particles update shader
  91620. * @returns a string containng the defines string
  91621. */
  91622. getEffectDefines(): string;
  91623. /**
  91624. * Returns the string "HemisphericParticleEmitter"
  91625. * @returns a string containing the class name
  91626. */
  91627. getClassName(): string;
  91628. /**
  91629. * Serializes the particle system to a JSON object.
  91630. * @returns the JSON object
  91631. */
  91632. serialize(): any;
  91633. /**
  91634. * Parse properties from a JSON object
  91635. * @param serializationObject defines the JSON object
  91636. */
  91637. parse(serializationObject: any): void;
  91638. }
  91639. }
  91640. declare module BABYLON {
  91641. /**
  91642. * Particle emitter emitting particles from a point.
  91643. * It emits the particles randomly between 2 given directions.
  91644. */
  91645. export class PointParticleEmitter implements IParticleEmitterType {
  91646. /**
  91647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91648. */
  91649. direction1: Vector3;
  91650. /**
  91651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91652. */
  91653. direction2: Vector3;
  91654. /**
  91655. * Creates a new instance PointParticleEmitter
  91656. */
  91657. constructor();
  91658. /**
  91659. * Called by the particle System when the direction is computed for the created particle.
  91660. * @param worldMatrix is the world matrix of the particle system
  91661. * @param directionToUpdate is the direction vector to update with the result
  91662. * @param particle is the particle we are computed the direction for
  91663. * @param isLocal defines if the direction should be set in local space
  91664. */
  91665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91666. /**
  91667. * Called by the particle System when the position is computed for the created particle.
  91668. * @param worldMatrix is the world matrix of the particle system
  91669. * @param positionToUpdate is the position vector to update with the result
  91670. * @param particle is the particle we are computed the position for
  91671. * @param isLocal defines if the position should be set in local space
  91672. */
  91673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91674. /**
  91675. * Clones the current emitter and returns a copy of it
  91676. * @returns the new emitter
  91677. */
  91678. clone(): PointParticleEmitter;
  91679. /**
  91680. * Called by the GPUParticleSystem to setup the update shader
  91681. * @param effect defines the update shader
  91682. */
  91683. applyToShader(effect: Effect): void;
  91684. /**
  91685. * Returns a string to use to update the GPU particles update shader
  91686. * @returns a string containng the defines string
  91687. */
  91688. getEffectDefines(): string;
  91689. /**
  91690. * Returns the string "PointParticleEmitter"
  91691. * @returns a string containing the class name
  91692. */
  91693. getClassName(): string;
  91694. /**
  91695. * Serializes the particle system to a JSON object.
  91696. * @returns the JSON object
  91697. */
  91698. serialize(): any;
  91699. /**
  91700. * Parse properties from a JSON object
  91701. * @param serializationObject defines the JSON object
  91702. */
  91703. parse(serializationObject: any): void;
  91704. }
  91705. }
  91706. declare module BABYLON {
  91707. /**
  91708. * Particle emitter emitting particles from the inside of a sphere.
  91709. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91710. */
  91711. export class SphereParticleEmitter implements IParticleEmitterType {
  91712. /**
  91713. * The radius of the emission sphere.
  91714. */
  91715. radius: number;
  91716. /**
  91717. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91718. */
  91719. radiusRange: number;
  91720. /**
  91721. * How much to randomize the particle direction [0-1].
  91722. */
  91723. directionRandomizer: number;
  91724. /**
  91725. * Creates a new instance SphereParticleEmitter
  91726. * @param radius the radius of the emission sphere (1 by default)
  91727. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91728. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91729. */
  91730. constructor(
  91731. /**
  91732. * The radius of the emission sphere.
  91733. */
  91734. radius?: number,
  91735. /**
  91736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91737. */
  91738. radiusRange?: number,
  91739. /**
  91740. * How much to randomize the particle direction [0-1].
  91741. */
  91742. directionRandomizer?: number);
  91743. /**
  91744. * Called by the particle System when the direction is computed for the created particle.
  91745. * @param worldMatrix is the world matrix of the particle system
  91746. * @param directionToUpdate is the direction vector to update with the result
  91747. * @param particle is the particle we are computed the direction for
  91748. * @param isLocal defines if the direction should be set in local space
  91749. */
  91750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91751. /**
  91752. * Called by the particle System when the position is computed for the created particle.
  91753. * @param worldMatrix is the world matrix of the particle system
  91754. * @param positionToUpdate is the position vector to update with the result
  91755. * @param particle is the particle we are computed the position for
  91756. * @param isLocal defines if the position should be set in local space
  91757. */
  91758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91759. /**
  91760. * Clones the current emitter and returns a copy of it
  91761. * @returns the new emitter
  91762. */
  91763. clone(): SphereParticleEmitter;
  91764. /**
  91765. * Called by the GPUParticleSystem to setup the update shader
  91766. * @param effect defines the update shader
  91767. */
  91768. applyToShader(effect: Effect): void;
  91769. /**
  91770. * Returns a string to use to update the GPU particles update shader
  91771. * @returns a string containng the defines string
  91772. */
  91773. getEffectDefines(): string;
  91774. /**
  91775. * Returns the string "SphereParticleEmitter"
  91776. * @returns a string containing the class name
  91777. */
  91778. getClassName(): string;
  91779. /**
  91780. * Serializes the particle system to a JSON object.
  91781. * @returns the JSON object
  91782. */
  91783. serialize(): any;
  91784. /**
  91785. * Parse properties from a JSON object
  91786. * @param serializationObject defines the JSON object
  91787. */
  91788. parse(serializationObject: any): void;
  91789. }
  91790. /**
  91791. * Particle emitter emitting particles from the inside of a sphere.
  91792. * It emits the particles randomly between two vectors.
  91793. */
  91794. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91795. /**
  91796. * The min limit of the emission direction.
  91797. */
  91798. direction1: Vector3;
  91799. /**
  91800. * The max limit of the emission direction.
  91801. */
  91802. direction2: Vector3;
  91803. /**
  91804. * Creates a new instance SphereDirectedParticleEmitter
  91805. * @param radius the radius of the emission sphere (1 by default)
  91806. * @param direction1 the min limit of the emission direction (up vector by default)
  91807. * @param direction2 the max limit of the emission direction (up vector by default)
  91808. */
  91809. constructor(radius?: number,
  91810. /**
  91811. * The min limit of the emission direction.
  91812. */
  91813. direction1?: Vector3,
  91814. /**
  91815. * The max limit of the emission direction.
  91816. */
  91817. direction2?: Vector3);
  91818. /**
  91819. * Called by the particle System when the direction is computed for the created particle.
  91820. * @param worldMatrix is the world matrix of the particle system
  91821. * @param directionToUpdate is the direction vector to update with the result
  91822. * @param particle is the particle we are computed the direction for
  91823. */
  91824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91825. /**
  91826. * Clones the current emitter and returns a copy of it
  91827. * @returns the new emitter
  91828. */
  91829. clone(): SphereDirectedParticleEmitter;
  91830. /**
  91831. * Called by the GPUParticleSystem to setup the update shader
  91832. * @param effect defines the update shader
  91833. */
  91834. applyToShader(effect: Effect): void;
  91835. /**
  91836. * Returns a string to use to update the GPU particles update shader
  91837. * @returns a string containng the defines string
  91838. */
  91839. getEffectDefines(): string;
  91840. /**
  91841. * Returns the string "SphereDirectedParticleEmitter"
  91842. * @returns a string containing the class name
  91843. */
  91844. getClassName(): string;
  91845. /**
  91846. * Serializes the particle system to a JSON object.
  91847. * @returns the JSON object
  91848. */
  91849. serialize(): any;
  91850. /**
  91851. * Parse properties from a JSON object
  91852. * @param serializationObject defines the JSON object
  91853. */
  91854. parse(serializationObject: any): void;
  91855. }
  91856. }
  91857. declare module BABYLON {
  91858. /**
  91859. * Particle emitter emitting particles from a custom list of positions.
  91860. */
  91861. export class CustomParticleEmitter implements IParticleEmitterType {
  91862. /**
  91863. * Gets or sets the position generator that will create the inital position of each particle.
  91864. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91865. */
  91866. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91867. /**
  91868. * Gets or sets the destination generator that will create the final destination of each particle.
  91869. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91870. */
  91871. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91872. /**
  91873. * Creates a new instance CustomParticleEmitter
  91874. */
  91875. constructor();
  91876. /**
  91877. * Called by the particle System when the direction is computed for the created particle.
  91878. * @param worldMatrix is the world matrix of the particle system
  91879. * @param directionToUpdate is the direction vector to update with the result
  91880. * @param particle is the particle we are computed the direction for
  91881. * @param isLocal defines if the direction should be set in local space
  91882. */
  91883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91884. /**
  91885. * Called by the particle System when the position is computed for the created particle.
  91886. * @param worldMatrix is the world matrix of the particle system
  91887. * @param positionToUpdate is the position vector to update with the result
  91888. * @param particle is the particle we are computed the position for
  91889. * @param isLocal defines if the position should be set in local space
  91890. */
  91891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91892. /**
  91893. * Clones the current emitter and returns a copy of it
  91894. * @returns the new emitter
  91895. */
  91896. clone(): CustomParticleEmitter;
  91897. /**
  91898. * Called by the GPUParticleSystem to setup the update shader
  91899. * @param effect defines the update shader
  91900. */
  91901. applyToShader(effect: Effect): void;
  91902. /**
  91903. * Returns a string to use to update the GPU particles update shader
  91904. * @returns a string containng the defines string
  91905. */
  91906. getEffectDefines(): string;
  91907. /**
  91908. * Returns the string "PointParticleEmitter"
  91909. * @returns a string containing the class name
  91910. */
  91911. getClassName(): string;
  91912. /**
  91913. * Serializes the particle system to a JSON object.
  91914. * @returns the JSON object
  91915. */
  91916. serialize(): any;
  91917. /**
  91918. * Parse properties from a JSON object
  91919. * @param serializationObject defines the JSON object
  91920. */
  91921. parse(serializationObject: any): void;
  91922. }
  91923. }
  91924. declare module BABYLON {
  91925. /**
  91926. * Particle emitter emitting particles from the inside of a box.
  91927. * It emits the particles randomly between 2 given directions.
  91928. */
  91929. export class MeshParticleEmitter implements IParticleEmitterType {
  91930. private _indices;
  91931. private _positions;
  91932. private _normals;
  91933. private _storedNormal;
  91934. private _mesh;
  91935. /**
  91936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91937. */
  91938. direction1: Vector3;
  91939. /**
  91940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91941. */
  91942. direction2: Vector3;
  91943. /**
  91944. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91945. */
  91946. useMeshNormalsForDirection: boolean;
  91947. /** Defines the mesh to use as source */
  91948. get mesh(): Nullable<AbstractMesh>;
  91949. set mesh(value: Nullable<AbstractMesh>);
  91950. /**
  91951. * Creates a new instance MeshParticleEmitter
  91952. * @param mesh defines the mesh to use as source
  91953. */
  91954. constructor(mesh?: Nullable<AbstractMesh>);
  91955. /**
  91956. * Called by the particle System when the direction is computed for the created particle.
  91957. * @param worldMatrix is the world matrix of the particle system
  91958. * @param directionToUpdate is the direction vector to update with the result
  91959. * @param particle is the particle we are computed the direction for
  91960. * @param isLocal defines if the direction should be set in local space
  91961. */
  91962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91963. /**
  91964. * Called by the particle System when the position is computed for the created particle.
  91965. * @param worldMatrix is the world matrix of the particle system
  91966. * @param positionToUpdate is the position vector to update with the result
  91967. * @param particle is the particle we are computed the position for
  91968. * @param isLocal defines if the position should be set in local space
  91969. */
  91970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91971. /**
  91972. * Clones the current emitter and returns a copy of it
  91973. * @returns the new emitter
  91974. */
  91975. clone(): MeshParticleEmitter;
  91976. /**
  91977. * Called by the GPUParticleSystem to setup the update shader
  91978. * @param effect defines the update shader
  91979. */
  91980. applyToShader(effect: Effect): void;
  91981. /**
  91982. * Returns a string to use to update the GPU particles update shader
  91983. * @returns a string containng the defines string
  91984. */
  91985. getEffectDefines(): string;
  91986. /**
  91987. * Returns the string "BoxParticleEmitter"
  91988. * @returns a string containing the class name
  91989. */
  91990. getClassName(): string;
  91991. /**
  91992. * Serializes the particle system to a JSON object.
  91993. * @returns the JSON object
  91994. */
  91995. serialize(): any;
  91996. /**
  91997. * Parse properties from a JSON object
  91998. * @param serializationObject defines the JSON object
  91999. * @param scene defines the hosting scene
  92000. */
  92001. parse(serializationObject: any, scene: Scene): void;
  92002. }
  92003. }
  92004. declare module BABYLON {
  92005. /**
  92006. * Interface representing a particle system in Babylon.js.
  92007. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92008. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92009. */
  92010. export interface IParticleSystem {
  92011. /**
  92012. * List of animations used by the particle system.
  92013. */
  92014. animations: Animation[];
  92015. /**
  92016. * The id of the Particle system.
  92017. */
  92018. id: string;
  92019. /**
  92020. * The name of the Particle system.
  92021. */
  92022. name: string;
  92023. /**
  92024. * The emitter represents the Mesh or position we are attaching the particle system to.
  92025. */
  92026. emitter: Nullable<AbstractMesh | Vector3>;
  92027. /**
  92028. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92029. */
  92030. isBillboardBased: boolean;
  92031. /**
  92032. * The rendering group used by the Particle system to chose when to render.
  92033. */
  92034. renderingGroupId: number;
  92035. /**
  92036. * The layer mask we are rendering the particles through.
  92037. */
  92038. layerMask: number;
  92039. /**
  92040. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92041. */
  92042. updateSpeed: number;
  92043. /**
  92044. * The amount of time the particle system is running (depends of the overall update speed).
  92045. */
  92046. targetStopDuration: number;
  92047. /**
  92048. * The texture used to render each particle. (this can be a spritesheet)
  92049. */
  92050. particleTexture: Nullable<Texture>;
  92051. /**
  92052. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92053. */
  92054. blendMode: number;
  92055. /**
  92056. * Minimum life time of emitting particles.
  92057. */
  92058. minLifeTime: number;
  92059. /**
  92060. * Maximum life time of emitting particles.
  92061. */
  92062. maxLifeTime: number;
  92063. /**
  92064. * Minimum Size of emitting particles.
  92065. */
  92066. minSize: number;
  92067. /**
  92068. * Maximum Size of emitting particles.
  92069. */
  92070. maxSize: number;
  92071. /**
  92072. * Minimum scale of emitting particles on X axis.
  92073. */
  92074. minScaleX: number;
  92075. /**
  92076. * Maximum scale of emitting particles on X axis.
  92077. */
  92078. maxScaleX: number;
  92079. /**
  92080. * Minimum scale of emitting particles on Y axis.
  92081. */
  92082. minScaleY: number;
  92083. /**
  92084. * Maximum scale of emitting particles on Y axis.
  92085. */
  92086. maxScaleY: number;
  92087. /**
  92088. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92089. */
  92090. color1: Color4;
  92091. /**
  92092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92093. */
  92094. color2: Color4;
  92095. /**
  92096. * Color the particle will have at the end of its lifetime.
  92097. */
  92098. colorDead: Color4;
  92099. /**
  92100. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92101. */
  92102. emitRate: number;
  92103. /**
  92104. * You can use gravity if you want to give an orientation to your particles.
  92105. */
  92106. gravity: Vector3;
  92107. /**
  92108. * Minimum power of emitting particles.
  92109. */
  92110. minEmitPower: number;
  92111. /**
  92112. * Maximum power of emitting particles.
  92113. */
  92114. maxEmitPower: number;
  92115. /**
  92116. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92117. */
  92118. minAngularSpeed: number;
  92119. /**
  92120. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92121. */
  92122. maxAngularSpeed: number;
  92123. /**
  92124. * Gets or sets the minimal initial rotation in radians.
  92125. */
  92126. minInitialRotation: number;
  92127. /**
  92128. * Gets or sets the maximal initial rotation in radians.
  92129. */
  92130. maxInitialRotation: number;
  92131. /**
  92132. * The particle emitter type defines the emitter used by the particle system.
  92133. * It can be for example box, sphere, or cone...
  92134. */
  92135. particleEmitterType: Nullable<IParticleEmitterType>;
  92136. /**
  92137. * Defines the delay in milliseconds before starting the system (0 by default)
  92138. */
  92139. startDelay: number;
  92140. /**
  92141. * 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
  92142. */
  92143. preWarmCycles: number;
  92144. /**
  92145. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92146. */
  92147. preWarmStepOffset: number;
  92148. /**
  92149. * 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)
  92150. */
  92151. spriteCellChangeSpeed: number;
  92152. /**
  92153. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92154. */
  92155. startSpriteCellID: number;
  92156. /**
  92157. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92158. */
  92159. endSpriteCellID: number;
  92160. /**
  92161. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92162. */
  92163. spriteCellWidth: number;
  92164. /**
  92165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92166. */
  92167. spriteCellHeight: number;
  92168. /**
  92169. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92170. */
  92171. spriteRandomStartCell: boolean;
  92172. /**
  92173. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92174. */
  92175. isAnimationSheetEnabled: boolean;
  92176. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92177. translationPivot: Vector2;
  92178. /**
  92179. * Gets or sets a texture used to add random noise to particle positions
  92180. */
  92181. noiseTexture: Nullable<BaseTexture>;
  92182. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92183. noiseStrength: Vector3;
  92184. /**
  92185. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92186. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92187. */
  92188. billboardMode: number;
  92189. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92190. limitVelocityDamping: number;
  92191. /**
  92192. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92193. */
  92194. beginAnimationOnStart: boolean;
  92195. /**
  92196. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92197. */
  92198. beginAnimationFrom: number;
  92199. /**
  92200. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92201. */
  92202. beginAnimationTo: number;
  92203. /**
  92204. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92205. */
  92206. beginAnimationLoop: boolean;
  92207. /**
  92208. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92209. */
  92210. disposeOnStop: boolean;
  92211. /**
  92212. * Specifies if the particles are updated in emitter local space or world space
  92213. */
  92214. isLocal: boolean;
  92215. /** Snippet ID if the particle system was created from the snippet server */
  92216. snippetId: string;
  92217. /**
  92218. * Gets the maximum number of particles active at the same time.
  92219. * @returns The max number of active particles.
  92220. */
  92221. getCapacity(): number;
  92222. /**
  92223. * Gets the number of particles active at the same time.
  92224. * @returns The number of active particles.
  92225. */
  92226. getActiveCount(): number;
  92227. /**
  92228. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92229. * @returns True if it has been started, otherwise false.
  92230. */
  92231. isStarted(): boolean;
  92232. /**
  92233. * Animates the particle system for this frame.
  92234. */
  92235. animate(): void;
  92236. /**
  92237. * Renders the particle system in its current state.
  92238. * @returns the current number of particles
  92239. */
  92240. render(): number;
  92241. /**
  92242. * Dispose the particle system and frees its associated resources.
  92243. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92244. */
  92245. dispose(disposeTexture?: boolean): void;
  92246. /**
  92247. * An event triggered when the system is disposed
  92248. */
  92249. onDisposeObservable: Observable<IParticleSystem>;
  92250. /**
  92251. * Clones the particle system.
  92252. * @param name The name of the cloned object
  92253. * @param newEmitter The new emitter to use
  92254. * @returns the cloned particle system
  92255. */
  92256. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92257. /**
  92258. * Serializes the particle system to a JSON object
  92259. * @param serializeTexture defines if the texture must be serialized as well
  92260. * @returns the JSON object
  92261. */
  92262. serialize(serializeTexture: boolean): any;
  92263. /**
  92264. * Rebuild the particle system
  92265. */
  92266. rebuild(): void;
  92267. /** Force the system to rebuild all gradients that need to be resync */
  92268. forceRefreshGradients(): void;
  92269. /**
  92270. * Starts the particle system and begins to emit
  92271. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92272. */
  92273. start(delay?: number): void;
  92274. /**
  92275. * Stops the particle system.
  92276. */
  92277. stop(): void;
  92278. /**
  92279. * Remove all active particles
  92280. */
  92281. reset(): void;
  92282. /**
  92283. * Gets a boolean indicating that the system is stopping
  92284. * @returns true if the system is currently stopping
  92285. */
  92286. isStopping(): boolean;
  92287. /**
  92288. * Is this system ready to be used/rendered
  92289. * @return true if the system is ready
  92290. */
  92291. isReady(): boolean;
  92292. /**
  92293. * Returns the string "ParticleSystem"
  92294. * @returns a string containing the class name
  92295. */
  92296. getClassName(): string;
  92297. /**
  92298. * Gets the custom effect used to render the particles
  92299. * @param blendMode Blend mode for which the effect should be retrieved
  92300. * @returns The effect
  92301. */
  92302. getCustomEffect(blendMode: number): Nullable<Effect>;
  92303. /**
  92304. * Sets the custom effect used to render the particles
  92305. * @param effect The effect to set
  92306. * @param blendMode Blend mode for which the effect should be set
  92307. */
  92308. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92309. /**
  92310. * Fill the defines array according to the current settings of the particle system
  92311. * @param defines Array to be updated
  92312. * @param blendMode blend mode to take into account when updating the array
  92313. */
  92314. fillDefines(defines: Array<string>, blendMode: number): void;
  92315. /**
  92316. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92317. * @param uniforms Uniforms array to fill
  92318. * @param attributes Attributes array to fill
  92319. * @param samplers Samplers array to fill
  92320. */
  92321. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92322. /**
  92323. * Observable that will be called just before the particles are drawn
  92324. */
  92325. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92326. /**
  92327. * Gets the name of the particle vertex shader
  92328. */
  92329. vertexShaderName: string;
  92330. /**
  92331. * Adds a new color gradient
  92332. * @param gradient defines the gradient to use (between 0 and 1)
  92333. * @param color1 defines the color to affect to the specified gradient
  92334. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92335. * @returns the current particle system
  92336. */
  92337. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92338. /**
  92339. * Remove a specific color gradient
  92340. * @param gradient defines the gradient to remove
  92341. * @returns the current particle system
  92342. */
  92343. removeColorGradient(gradient: number): IParticleSystem;
  92344. /**
  92345. * Adds a new size gradient
  92346. * @param gradient defines the gradient to use (between 0 and 1)
  92347. * @param factor defines the size factor to affect to the specified gradient
  92348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92349. * @returns the current particle system
  92350. */
  92351. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92352. /**
  92353. * Remove a specific size gradient
  92354. * @param gradient defines the gradient to remove
  92355. * @returns the current particle system
  92356. */
  92357. removeSizeGradient(gradient: number): IParticleSystem;
  92358. /**
  92359. * Gets the current list of color gradients.
  92360. * You must use addColorGradient and removeColorGradient to udpate this list
  92361. * @returns the list of color gradients
  92362. */
  92363. getColorGradients(): Nullable<Array<ColorGradient>>;
  92364. /**
  92365. * Gets the current list of size gradients.
  92366. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92367. * @returns the list of size gradients
  92368. */
  92369. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92370. /**
  92371. * Gets the current list of angular speed gradients.
  92372. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92373. * @returns the list of angular speed gradients
  92374. */
  92375. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92376. /**
  92377. * Adds a new angular speed gradient
  92378. * @param gradient defines the gradient to use (between 0 and 1)
  92379. * @param factor defines the angular speed to affect to the specified gradient
  92380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92381. * @returns the current particle system
  92382. */
  92383. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92384. /**
  92385. * Remove a specific angular speed gradient
  92386. * @param gradient defines the gradient to remove
  92387. * @returns the current particle system
  92388. */
  92389. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92390. /**
  92391. * Gets the current list of velocity gradients.
  92392. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92393. * @returns the list of velocity gradients
  92394. */
  92395. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92396. /**
  92397. * Adds a new velocity gradient
  92398. * @param gradient defines the gradient to use (between 0 and 1)
  92399. * @param factor defines the velocity to affect to the specified gradient
  92400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92401. * @returns the current particle system
  92402. */
  92403. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92404. /**
  92405. * Remove a specific velocity gradient
  92406. * @param gradient defines the gradient to remove
  92407. * @returns the current particle system
  92408. */
  92409. removeVelocityGradient(gradient: number): IParticleSystem;
  92410. /**
  92411. * Gets the current list of limit velocity gradients.
  92412. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92413. * @returns the list of limit velocity gradients
  92414. */
  92415. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92416. /**
  92417. * Adds a new limit velocity gradient
  92418. * @param gradient defines the gradient to use (between 0 and 1)
  92419. * @param factor defines the limit velocity to affect to the specified gradient
  92420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92421. * @returns the current particle system
  92422. */
  92423. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92424. /**
  92425. * Remove a specific limit velocity gradient
  92426. * @param gradient defines the gradient to remove
  92427. * @returns the current particle system
  92428. */
  92429. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92430. /**
  92431. * Adds a new drag gradient
  92432. * @param gradient defines the gradient to use (between 0 and 1)
  92433. * @param factor defines the drag to affect to the specified gradient
  92434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92435. * @returns the current particle system
  92436. */
  92437. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92438. /**
  92439. * Remove a specific drag gradient
  92440. * @param gradient defines the gradient to remove
  92441. * @returns the current particle system
  92442. */
  92443. removeDragGradient(gradient: number): IParticleSystem;
  92444. /**
  92445. * Gets the current list of drag gradients.
  92446. * You must use addDragGradient and removeDragGradient to udpate this list
  92447. * @returns the list of drag gradients
  92448. */
  92449. getDragGradients(): Nullable<Array<FactorGradient>>;
  92450. /**
  92451. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92452. * @param gradient defines the gradient to use (between 0 and 1)
  92453. * @param factor defines the emit rate to affect to the specified gradient
  92454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92455. * @returns the current particle system
  92456. */
  92457. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92458. /**
  92459. * Remove a specific emit rate gradient
  92460. * @param gradient defines the gradient to remove
  92461. * @returns the current particle system
  92462. */
  92463. removeEmitRateGradient(gradient: number): IParticleSystem;
  92464. /**
  92465. * Gets the current list of emit rate gradients.
  92466. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92467. * @returns the list of emit rate gradients
  92468. */
  92469. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92470. /**
  92471. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92472. * @param gradient defines the gradient to use (between 0 and 1)
  92473. * @param factor defines the start size to affect to the specified gradient
  92474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92475. * @returns the current particle system
  92476. */
  92477. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92478. /**
  92479. * Remove a specific start size gradient
  92480. * @param gradient defines the gradient to remove
  92481. * @returns the current particle system
  92482. */
  92483. removeStartSizeGradient(gradient: number): IParticleSystem;
  92484. /**
  92485. * Gets the current list of start size gradients.
  92486. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92487. * @returns the list of start size gradients
  92488. */
  92489. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92490. /**
  92491. * Adds a new life time gradient
  92492. * @param gradient defines the gradient to use (between 0 and 1)
  92493. * @param factor defines the life time factor to affect to the specified gradient
  92494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92495. * @returns the current particle system
  92496. */
  92497. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92498. /**
  92499. * Remove a specific life time gradient
  92500. * @param gradient defines the gradient to remove
  92501. * @returns the current particle system
  92502. */
  92503. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92504. /**
  92505. * Gets the current list of life time gradients.
  92506. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92507. * @returns the list of life time gradients
  92508. */
  92509. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92510. /**
  92511. * Gets the current list of color gradients.
  92512. * You must use addColorGradient and removeColorGradient to udpate this list
  92513. * @returns the list of color gradients
  92514. */
  92515. getColorGradients(): Nullable<Array<ColorGradient>>;
  92516. /**
  92517. * Adds a new ramp gradient used to remap particle colors
  92518. * @param gradient defines the gradient to use (between 0 and 1)
  92519. * @param color defines the color to affect to the specified gradient
  92520. * @returns the current particle system
  92521. */
  92522. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92523. /**
  92524. * Gets the current list of ramp gradients.
  92525. * You must use addRampGradient and removeRampGradient to udpate this list
  92526. * @returns the list of ramp gradients
  92527. */
  92528. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92529. /** Gets or sets a boolean indicating that ramp gradients must be used
  92530. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92531. */
  92532. useRampGradients: boolean;
  92533. /**
  92534. * Adds a new color remap gradient
  92535. * @param gradient defines the gradient to use (between 0 and 1)
  92536. * @param min defines the color remap minimal range
  92537. * @param max defines the color remap maximal range
  92538. * @returns the current particle system
  92539. */
  92540. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92541. /**
  92542. * Gets the current list of color remap gradients.
  92543. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92544. * @returns the list of color remap gradients
  92545. */
  92546. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92547. /**
  92548. * Adds a new alpha remap gradient
  92549. * @param gradient defines the gradient to use (between 0 and 1)
  92550. * @param min defines the alpha remap minimal range
  92551. * @param max defines the alpha remap maximal range
  92552. * @returns the current particle system
  92553. */
  92554. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92555. /**
  92556. * Gets the current list of alpha remap gradients.
  92557. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92558. * @returns the list of alpha remap gradients
  92559. */
  92560. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92561. /**
  92562. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92565. * @returns the emitter
  92566. */
  92567. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92568. /**
  92569. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92570. * @param radius The radius of the hemisphere to emit from
  92571. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92572. * @returns the emitter
  92573. */
  92574. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92575. /**
  92576. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92577. * @param radius The radius of the sphere to emit from
  92578. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92579. * @returns the emitter
  92580. */
  92581. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92582. /**
  92583. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92584. * @param radius The radius of the sphere to emit from
  92585. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92586. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92587. * @returns the emitter
  92588. */
  92589. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92590. /**
  92591. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92592. * @param radius The radius of the emission cylinder
  92593. * @param height The height of the emission cylinder
  92594. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92595. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92596. * @returns the emitter
  92597. */
  92598. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92599. /**
  92600. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92601. * @param radius The radius of the cylinder to emit from
  92602. * @param height The height of the emission cylinder
  92603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92606. * @returns the emitter
  92607. */
  92608. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92609. /**
  92610. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92611. * @param radius The radius of the cone to emit from
  92612. * @param angle The base angle of the cone
  92613. * @returns the emitter
  92614. */
  92615. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92616. /**
  92617. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92620. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92621. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92622. * @returns the emitter
  92623. */
  92624. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92625. /**
  92626. * Get hosting scene
  92627. * @returns the scene
  92628. */
  92629. getScene(): Scene;
  92630. }
  92631. }
  92632. declare module BABYLON {
  92633. /**
  92634. * 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.
  92635. * @see https://doc.babylonjs.com/how_to/transformnode
  92636. */
  92637. export class TransformNode extends Node {
  92638. /**
  92639. * Object will not rotate to face the camera
  92640. */
  92641. static BILLBOARDMODE_NONE: number;
  92642. /**
  92643. * Object will rotate to face the camera but only on the x axis
  92644. */
  92645. static BILLBOARDMODE_X: number;
  92646. /**
  92647. * Object will rotate to face the camera but only on the y axis
  92648. */
  92649. static BILLBOARDMODE_Y: number;
  92650. /**
  92651. * Object will rotate to face the camera but only on the z axis
  92652. */
  92653. static BILLBOARDMODE_Z: number;
  92654. /**
  92655. * Object will rotate to face the camera
  92656. */
  92657. static BILLBOARDMODE_ALL: number;
  92658. /**
  92659. * Object will rotate to face the camera's position instead of orientation
  92660. */
  92661. static BILLBOARDMODE_USE_POSITION: number;
  92662. private static _TmpRotation;
  92663. private static _TmpScaling;
  92664. private static _TmpTranslation;
  92665. private _forward;
  92666. private _forwardInverted;
  92667. private _up;
  92668. private _right;
  92669. private _rightInverted;
  92670. private _position;
  92671. private _rotation;
  92672. private _rotationQuaternion;
  92673. protected _scaling: Vector3;
  92674. protected _isDirty: boolean;
  92675. private _transformToBoneReferal;
  92676. private _isAbsoluteSynced;
  92677. private _billboardMode;
  92678. /**
  92679. * Gets or sets the billboard mode. Default is 0.
  92680. *
  92681. * | Value | Type | Description |
  92682. * | --- | --- | --- |
  92683. * | 0 | BILLBOARDMODE_NONE | |
  92684. * | 1 | BILLBOARDMODE_X | |
  92685. * | 2 | BILLBOARDMODE_Y | |
  92686. * | 4 | BILLBOARDMODE_Z | |
  92687. * | 7 | BILLBOARDMODE_ALL | |
  92688. *
  92689. */
  92690. get billboardMode(): number;
  92691. set billboardMode(value: number);
  92692. private _preserveParentRotationForBillboard;
  92693. /**
  92694. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92695. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92696. */
  92697. get preserveParentRotationForBillboard(): boolean;
  92698. set preserveParentRotationForBillboard(value: boolean);
  92699. /**
  92700. * 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
  92701. */
  92702. scalingDeterminant: number;
  92703. private _infiniteDistance;
  92704. /**
  92705. * Gets or sets the distance of the object to max, often used by skybox
  92706. */
  92707. get infiniteDistance(): boolean;
  92708. set infiniteDistance(value: boolean);
  92709. /**
  92710. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92711. * By default the system will update normals to compensate
  92712. */
  92713. ignoreNonUniformScaling: boolean;
  92714. /**
  92715. * 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
  92716. */
  92717. reIntegrateRotationIntoRotationQuaternion: boolean;
  92718. /** @hidden */
  92719. _poseMatrix: Nullable<Matrix>;
  92720. /** @hidden */
  92721. _localMatrix: Matrix;
  92722. private _usePivotMatrix;
  92723. private _absolutePosition;
  92724. private _absoluteScaling;
  92725. private _absoluteRotationQuaternion;
  92726. private _pivotMatrix;
  92727. private _pivotMatrixInverse;
  92728. protected _postMultiplyPivotMatrix: boolean;
  92729. protected _isWorldMatrixFrozen: boolean;
  92730. /** @hidden */
  92731. _indexInSceneTransformNodesArray: number;
  92732. /**
  92733. * An event triggered after the world matrix is updated
  92734. */
  92735. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92736. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92737. /**
  92738. * Gets a string identifying the name of the class
  92739. * @returns "TransformNode" string
  92740. */
  92741. getClassName(): string;
  92742. /**
  92743. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92744. */
  92745. get position(): Vector3;
  92746. set position(newPosition: Vector3);
  92747. /**
  92748. * 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)).
  92749. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92750. */
  92751. get rotation(): Vector3;
  92752. set rotation(newRotation: Vector3);
  92753. /**
  92754. * 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)).
  92755. */
  92756. get scaling(): Vector3;
  92757. set scaling(newScaling: Vector3);
  92758. /**
  92759. * 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).
  92760. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92761. */
  92762. get rotationQuaternion(): Nullable<Quaternion>;
  92763. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92764. /**
  92765. * The forward direction of that transform in world space.
  92766. */
  92767. get forward(): Vector3;
  92768. /**
  92769. * The up direction of that transform in world space.
  92770. */
  92771. get up(): Vector3;
  92772. /**
  92773. * The right direction of that transform in world space.
  92774. */
  92775. get right(): Vector3;
  92776. /**
  92777. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92778. * @param matrix the matrix to copy the pose from
  92779. * @returns this TransformNode.
  92780. */
  92781. updatePoseMatrix(matrix: Matrix): TransformNode;
  92782. /**
  92783. * Returns the mesh Pose matrix.
  92784. * @returns the pose matrix
  92785. */
  92786. getPoseMatrix(): Matrix;
  92787. /** @hidden */
  92788. _isSynchronized(): boolean;
  92789. /** @hidden */
  92790. _initCache(): void;
  92791. /**
  92792. * Flag the transform node as dirty (Forcing it to update everything)
  92793. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92794. * @returns this transform node
  92795. */
  92796. markAsDirty(property: string): TransformNode;
  92797. /**
  92798. * Returns the current mesh absolute position.
  92799. * Returns a Vector3.
  92800. */
  92801. get absolutePosition(): Vector3;
  92802. /**
  92803. * Returns the current mesh absolute scaling.
  92804. * Returns a Vector3.
  92805. */
  92806. get absoluteScaling(): Vector3;
  92807. /**
  92808. * Returns the current mesh absolute rotation.
  92809. * Returns a Quaternion.
  92810. */
  92811. get absoluteRotationQuaternion(): Quaternion;
  92812. /**
  92813. * Sets a new matrix to apply before all other transformation
  92814. * @param matrix defines the transform matrix
  92815. * @returns the current TransformNode
  92816. */
  92817. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92818. /**
  92819. * Sets a new pivot matrix to the current node
  92820. * @param matrix defines the new pivot matrix to use
  92821. * @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
  92822. * @returns the current TransformNode
  92823. */
  92824. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92825. /**
  92826. * Returns the mesh pivot matrix.
  92827. * Default : Identity.
  92828. * @returns the matrix
  92829. */
  92830. getPivotMatrix(): Matrix;
  92831. /**
  92832. * Instantiate (when possible) or clone that node with its hierarchy
  92833. * @param newParent defines the new parent to use for the instance (or clone)
  92834. * @param options defines options to configure how copy is done
  92835. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92836. * @returns an instance (or a clone) of the current node with its hiearchy
  92837. */
  92838. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92839. doNotInstantiate: boolean;
  92840. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92841. /**
  92842. * Prevents the World matrix to be computed any longer
  92843. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92844. * @returns the TransformNode.
  92845. */
  92846. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92847. /**
  92848. * Allows back the World matrix computation.
  92849. * @returns the TransformNode.
  92850. */
  92851. unfreezeWorldMatrix(): this;
  92852. /**
  92853. * True if the World matrix has been frozen.
  92854. */
  92855. get isWorldMatrixFrozen(): boolean;
  92856. /**
  92857. * Retuns the mesh absolute position in the World.
  92858. * @returns a Vector3.
  92859. */
  92860. getAbsolutePosition(): Vector3;
  92861. /**
  92862. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92863. * @param absolutePosition the absolute position to set
  92864. * @returns the TransformNode.
  92865. */
  92866. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92867. /**
  92868. * Sets the mesh position in its local space.
  92869. * @param vector3 the position to set in localspace
  92870. * @returns the TransformNode.
  92871. */
  92872. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92873. /**
  92874. * Returns the mesh position in the local space from the current World matrix values.
  92875. * @returns a new Vector3.
  92876. */
  92877. getPositionExpressedInLocalSpace(): Vector3;
  92878. /**
  92879. * Translates the mesh along the passed Vector3 in its local space.
  92880. * @param vector3 the distance to translate in localspace
  92881. * @returns the TransformNode.
  92882. */
  92883. locallyTranslate(vector3: Vector3): TransformNode;
  92884. private static _lookAtVectorCache;
  92885. /**
  92886. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92887. * @param targetPoint the position (must be in same space as current mesh) to look at
  92888. * @param yawCor optional yaw (y-axis) correction in radians
  92889. * @param pitchCor optional pitch (x-axis) correction in radians
  92890. * @param rollCor optional roll (z-axis) correction in radians
  92891. * @param space the choosen space of the target
  92892. * @returns the TransformNode.
  92893. */
  92894. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92895. /**
  92896. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92897. * This Vector3 is expressed in the World space.
  92898. * @param localAxis axis to rotate
  92899. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92900. */
  92901. getDirection(localAxis: Vector3): Vector3;
  92902. /**
  92903. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92904. * localAxis is expressed in the mesh local space.
  92905. * result is computed in the Wordl space from the mesh World matrix.
  92906. * @param localAxis axis to rotate
  92907. * @param result the resulting transformnode
  92908. * @returns this TransformNode.
  92909. */
  92910. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92911. /**
  92912. * Sets this transform node rotation to the given local axis.
  92913. * @param localAxis the axis in local space
  92914. * @param yawCor optional yaw (y-axis) correction in radians
  92915. * @param pitchCor optional pitch (x-axis) correction in radians
  92916. * @param rollCor optional roll (z-axis) correction in radians
  92917. * @returns this TransformNode
  92918. */
  92919. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92920. /**
  92921. * Sets a new pivot point to the current node
  92922. * @param point defines the new pivot point to use
  92923. * @param space defines if the point is in world or local space (local by default)
  92924. * @returns the current TransformNode
  92925. */
  92926. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92927. /**
  92928. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92929. * @returns the pivot point
  92930. */
  92931. getPivotPoint(): Vector3;
  92932. /**
  92933. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92934. * @param result the vector3 to store the result
  92935. * @returns this TransformNode.
  92936. */
  92937. getPivotPointToRef(result: Vector3): TransformNode;
  92938. /**
  92939. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92940. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92941. */
  92942. getAbsolutePivotPoint(): Vector3;
  92943. /**
  92944. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92945. * @param result vector3 to store the result
  92946. * @returns this TransformNode.
  92947. */
  92948. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92949. /**
  92950. * Defines the passed node as the parent of the current node.
  92951. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92952. * @see https://doc.babylonjs.com/how_to/parenting
  92953. * @param node the node ot set as the parent
  92954. * @returns this TransformNode.
  92955. */
  92956. setParent(node: Nullable<Node>): TransformNode;
  92957. private _nonUniformScaling;
  92958. /**
  92959. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92960. */
  92961. get nonUniformScaling(): boolean;
  92962. /** @hidden */
  92963. _updateNonUniformScalingState(value: boolean): boolean;
  92964. /**
  92965. * Attach the current TransformNode to another TransformNode associated with a bone
  92966. * @param bone Bone affecting the TransformNode
  92967. * @param affectedTransformNode TransformNode associated with the bone
  92968. * @returns this object
  92969. */
  92970. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92971. /**
  92972. * Detach the transform node if its associated with a bone
  92973. * @returns this object
  92974. */
  92975. detachFromBone(): TransformNode;
  92976. private static _rotationAxisCache;
  92977. /**
  92978. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92979. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92980. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92981. * The passed axis is also normalized.
  92982. * @param axis the axis to rotate around
  92983. * @param amount the amount to rotate in radians
  92984. * @param space Space to rotate in (Default: local)
  92985. * @returns the TransformNode.
  92986. */
  92987. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92988. /**
  92989. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92990. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92991. * The passed axis is also normalized. .
  92992. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92993. * @param point the point to rotate around
  92994. * @param axis the axis to rotate around
  92995. * @param amount the amount to rotate in radians
  92996. * @returns the TransformNode
  92997. */
  92998. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92999. /**
  93000. * Translates the mesh along the axis vector for the passed distance in the given space.
  93001. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93002. * @param axis the axis to translate in
  93003. * @param distance the distance to translate
  93004. * @param space Space to rotate in (Default: local)
  93005. * @returns the TransformNode.
  93006. */
  93007. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93008. /**
  93009. * Adds a rotation step to the mesh current rotation.
  93010. * x, y, z are Euler angles expressed in radians.
  93011. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93012. * This means this rotation is made in the mesh local space only.
  93013. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93014. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93015. * ```javascript
  93016. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93017. * ```
  93018. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93019. * 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.
  93020. * @param x Rotation to add
  93021. * @param y Rotation to add
  93022. * @param z Rotation to add
  93023. * @returns the TransformNode.
  93024. */
  93025. addRotation(x: number, y: number, z: number): TransformNode;
  93026. /**
  93027. * @hidden
  93028. */
  93029. protected _getEffectiveParent(): Nullable<Node>;
  93030. /**
  93031. * Computes the world matrix of the node
  93032. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93033. * @returns the world matrix
  93034. */
  93035. computeWorldMatrix(force?: boolean): Matrix;
  93036. /**
  93037. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93038. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93039. */
  93040. resetLocalMatrix(independentOfChildren?: boolean): void;
  93041. protected _afterComputeWorldMatrix(): void;
  93042. /**
  93043. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93044. * @param func callback function to add
  93045. *
  93046. * @returns the TransformNode.
  93047. */
  93048. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93049. /**
  93050. * Removes a registered callback function.
  93051. * @param func callback function to remove
  93052. * @returns the TransformNode.
  93053. */
  93054. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93055. /**
  93056. * Gets the position of the current mesh in camera space
  93057. * @param camera defines the camera to use
  93058. * @returns a position
  93059. */
  93060. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93061. /**
  93062. * Returns the distance from the mesh to the active camera
  93063. * @param camera defines the camera to use
  93064. * @returns the distance
  93065. */
  93066. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93067. /**
  93068. * Clone the current transform node
  93069. * @param name Name of the new clone
  93070. * @param newParent New parent for the clone
  93071. * @param doNotCloneChildren Do not clone children hierarchy
  93072. * @returns the new transform node
  93073. */
  93074. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93075. /**
  93076. * Serializes the objects information.
  93077. * @param currentSerializationObject defines the object to serialize in
  93078. * @returns the serialized object
  93079. */
  93080. serialize(currentSerializationObject?: any): any;
  93081. /**
  93082. * Returns a new TransformNode object parsed from the source provided.
  93083. * @param parsedTransformNode is the source.
  93084. * @param scene the scne the object belongs to
  93085. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93086. * @returns a new TransformNode object parsed from the source provided.
  93087. */
  93088. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93089. /**
  93090. * Get all child-transformNodes of this node
  93091. * @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
  93092. * @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
  93093. * @returns an array of TransformNode
  93094. */
  93095. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93096. /**
  93097. * Releases resources associated with this transform node.
  93098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93100. */
  93101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93102. /**
  93103. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93104. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93105. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93106. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93107. * @returns the current mesh
  93108. */
  93109. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93110. private _syncAbsoluteScalingAndRotation;
  93111. }
  93112. }
  93113. declare module BABYLON {
  93114. /**
  93115. * Class used to override all child animations of a given target
  93116. */
  93117. export class AnimationPropertiesOverride {
  93118. /**
  93119. * Gets or sets a value indicating if animation blending must be used
  93120. */
  93121. enableBlending: boolean;
  93122. /**
  93123. * Gets or sets the blending speed to use when enableBlending is true
  93124. */
  93125. blendingSpeed: number;
  93126. /**
  93127. * Gets or sets the default loop mode to use
  93128. */
  93129. loopMode: number;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /**
  93134. * Class used to store bone information
  93135. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93136. */
  93137. export class Bone extends Node {
  93138. /**
  93139. * defines the bone name
  93140. */
  93141. name: string;
  93142. private static _tmpVecs;
  93143. private static _tmpQuat;
  93144. private static _tmpMats;
  93145. /**
  93146. * Gets the list of child bones
  93147. */
  93148. children: Bone[];
  93149. /** Gets the animations associated with this bone */
  93150. animations: Animation[];
  93151. /**
  93152. * Gets or sets bone length
  93153. */
  93154. length: number;
  93155. /**
  93156. * @hidden Internal only
  93157. * Set this value to map this bone to a different index in the transform matrices
  93158. * Set this value to -1 to exclude the bone from the transform matrices
  93159. */
  93160. _index: Nullable<number>;
  93161. private _skeleton;
  93162. private _localMatrix;
  93163. private _restPose;
  93164. private _baseMatrix;
  93165. private _absoluteTransform;
  93166. private _invertedAbsoluteTransform;
  93167. private _parent;
  93168. private _scalingDeterminant;
  93169. private _worldTransform;
  93170. private _localScaling;
  93171. private _localRotation;
  93172. private _localPosition;
  93173. private _needToDecompose;
  93174. private _needToCompose;
  93175. /** @hidden */
  93176. _linkedTransformNode: Nullable<TransformNode>;
  93177. /** @hidden */
  93178. _waitingTransformNodeId: Nullable<string>;
  93179. /** @hidden */
  93180. get _matrix(): Matrix;
  93181. /** @hidden */
  93182. set _matrix(value: Matrix);
  93183. /**
  93184. * Create a new bone
  93185. * @param name defines the bone name
  93186. * @param skeleton defines the parent skeleton
  93187. * @param parentBone defines the parent (can be null if the bone is the root)
  93188. * @param localMatrix defines the local matrix
  93189. * @param restPose defines the rest pose matrix
  93190. * @param baseMatrix defines the base matrix
  93191. * @param index defines index of the bone in the hiearchy
  93192. */
  93193. constructor(
  93194. /**
  93195. * defines the bone name
  93196. */
  93197. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93198. /**
  93199. * Gets the current object class name.
  93200. * @return the class name
  93201. */
  93202. getClassName(): string;
  93203. /**
  93204. * Gets the parent skeleton
  93205. * @returns a skeleton
  93206. */
  93207. getSkeleton(): Skeleton;
  93208. /**
  93209. * Gets parent bone
  93210. * @returns a bone or null if the bone is the root of the bone hierarchy
  93211. */
  93212. getParent(): Nullable<Bone>;
  93213. /**
  93214. * Returns an array containing the root bones
  93215. * @returns an array containing the root bones
  93216. */
  93217. getChildren(): Array<Bone>;
  93218. /**
  93219. * Gets the node index in matrix array generated for rendering
  93220. * @returns the node index
  93221. */
  93222. getIndex(): number;
  93223. /**
  93224. * Sets the parent bone
  93225. * @param parent defines the parent (can be null if the bone is the root)
  93226. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93227. */
  93228. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93229. /**
  93230. * Gets the local matrix
  93231. * @returns a matrix
  93232. */
  93233. getLocalMatrix(): Matrix;
  93234. /**
  93235. * Gets the base matrix (initial matrix which remains unchanged)
  93236. * @returns a matrix
  93237. */
  93238. getBaseMatrix(): Matrix;
  93239. /**
  93240. * Gets the rest pose matrix
  93241. * @returns a matrix
  93242. */
  93243. getRestPose(): Matrix;
  93244. /**
  93245. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93246. */
  93247. getWorldMatrix(): Matrix;
  93248. /**
  93249. * Sets the local matrix to rest pose matrix
  93250. */
  93251. returnToRest(): void;
  93252. /**
  93253. * Gets the inverse of the absolute transform matrix.
  93254. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93255. * @returns a matrix
  93256. */
  93257. getInvertedAbsoluteTransform(): Matrix;
  93258. /**
  93259. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93260. * @returns a matrix
  93261. */
  93262. getAbsoluteTransform(): Matrix;
  93263. /**
  93264. * Links with the given transform node.
  93265. * The local matrix of this bone is copied from the transform node every frame.
  93266. * @param transformNode defines the transform node to link to
  93267. */
  93268. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93269. /**
  93270. * Gets the node used to drive the bone's transformation
  93271. * @returns a transform node or null
  93272. */
  93273. getTransformNode(): Nullable<TransformNode>;
  93274. /** Gets or sets current position (in local space) */
  93275. get position(): Vector3;
  93276. set position(newPosition: Vector3);
  93277. /** Gets or sets current rotation (in local space) */
  93278. get rotation(): Vector3;
  93279. set rotation(newRotation: Vector3);
  93280. /** Gets or sets current rotation quaternion (in local space) */
  93281. get rotationQuaternion(): Quaternion;
  93282. set rotationQuaternion(newRotation: Quaternion);
  93283. /** Gets or sets current scaling (in local space) */
  93284. get scaling(): Vector3;
  93285. set scaling(newScaling: Vector3);
  93286. /**
  93287. * Gets the animation properties override
  93288. */
  93289. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93290. private _decompose;
  93291. private _compose;
  93292. /**
  93293. * Update the base and local matrices
  93294. * @param matrix defines the new base or local matrix
  93295. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93296. * @param updateLocalMatrix defines if the local matrix should be updated
  93297. */
  93298. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93299. /** @hidden */
  93300. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93301. /**
  93302. * Flag the bone as dirty (Forcing it to update everything)
  93303. */
  93304. markAsDirty(): void;
  93305. /** @hidden */
  93306. _markAsDirtyAndCompose(): void;
  93307. private _markAsDirtyAndDecompose;
  93308. /**
  93309. * Translate the bone in local or world space
  93310. * @param vec The amount to translate the bone
  93311. * @param space The space that the translation is in
  93312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93313. */
  93314. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93315. /**
  93316. * Set the postion of the bone in local or world space
  93317. * @param position The position to set the bone
  93318. * @param space The space that the position is in
  93319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93320. */
  93321. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93322. /**
  93323. * Set the absolute position of the bone (world space)
  93324. * @param position The position to set the bone
  93325. * @param mesh The mesh that this bone is attached to
  93326. */
  93327. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93328. /**
  93329. * Scale the bone on the x, y and z axes (in local space)
  93330. * @param x The amount to scale the bone on the x axis
  93331. * @param y The amount to scale the bone on the y axis
  93332. * @param z The amount to scale the bone on the z axis
  93333. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93334. */
  93335. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93336. /**
  93337. * Set the bone scaling in local space
  93338. * @param scale defines the scaling vector
  93339. */
  93340. setScale(scale: Vector3): void;
  93341. /**
  93342. * Gets the current scaling in local space
  93343. * @returns the current scaling vector
  93344. */
  93345. getScale(): Vector3;
  93346. /**
  93347. * Gets the current scaling in local space and stores it in a target vector
  93348. * @param result defines the target vector
  93349. */
  93350. getScaleToRef(result: Vector3): void;
  93351. /**
  93352. * Set the yaw, pitch, and roll of the bone in local or world space
  93353. * @param yaw The rotation of the bone on the y axis
  93354. * @param pitch The rotation of the bone on the x axis
  93355. * @param roll The rotation of the bone on the z axis
  93356. * @param space The space that the axes of rotation are in
  93357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93358. */
  93359. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93360. /**
  93361. * Add a rotation to the bone on an axis in local or world space
  93362. * @param axis The axis to rotate the bone on
  93363. * @param amount The amount to rotate the bone
  93364. * @param space The space that the axis is in
  93365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93366. */
  93367. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93368. /**
  93369. * Set the rotation of the bone to a particular axis angle in local or world space
  93370. * @param axis The axis to rotate the bone on
  93371. * @param angle The angle that the bone should be rotated to
  93372. * @param space The space that the axis is in
  93373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93374. */
  93375. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93376. /**
  93377. * Set the euler rotation of the bone in local of world space
  93378. * @param rotation The euler rotation that the bone should be set to
  93379. * @param space The space that the rotation is in
  93380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93381. */
  93382. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93383. /**
  93384. * Set the quaternion rotation of the bone in local of world space
  93385. * @param quat The quaternion rotation that the bone should be set to
  93386. * @param space The space that the rotation is in
  93387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93388. */
  93389. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93390. /**
  93391. * Set the rotation matrix of the bone in local of world space
  93392. * @param rotMat The rotation matrix that the bone should be set to
  93393. * @param space The space that the rotation is in
  93394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93395. */
  93396. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93397. private _rotateWithMatrix;
  93398. private _getNegativeRotationToRef;
  93399. /**
  93400. * Get the position of the bone in local or world space
  93401. * @param space The space that the returned position is in
  93402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93403. * @returns The position of the bone
  93404. */
  93405. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93406. /**
  93407. * Copy the position of the bone to a vector3 in local or world space
  93408. * @param space The space that the returned position is in
  93409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93410. * @param result The vector3 to copy the position to
  93411. */
  93412. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93413. /**
  93414. * Get the absolute position of the bone (world space)
  93415. * @param mesh The mesh that this bone is attached to
  93416. * @returns The absolute position of the bone
  93417. */
  93418. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93419. /**
  93420. * Copy the absolute position of the bone (world space) to the result param
  93421. * @param mesh The mesh that this bone is attached to
  93422. * @param result The vector3 to copy the absolute position to
  93423. */
  93424. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93425. /**
  93426. * Compute the absolute transforms of this bone and its children
  93427. */
  93428. computeAbsoluteTransforms(): void;
  93429. /**
  93430. * Get the world direction from an axis that is in the local space of the bone
  93431. * @param localAxis The local direction that is used to compute the world direction
  93432. * @param mesh The mesh that this bone is attached to
  93433. * @returns The world direction
  93434. */
  93435. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93436. /**
  93437. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93438. * @param localAxis The local direction that is used to compute the world direction
  93439. * @param mesh The mesh that this bone is attached to
  93440. * @param result The vector3 that the world direction will be copied to
  93441. */
  93442. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93443. /**
  93444. * Get the euler rotation of the bone in local or world space
  93445. * @param space The space that the rotation should be in
  93446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93447. * @returns The euler rotation
  93448. */
  93449. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93450. /**
  93451. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93452. * @param space The space that the rotation should be in
  93453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93454. * @param result The vector3 that the rotation should be copied to
  93455. */
  93456. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93457. /**
  93458. * Get the quaternion rotation of the bone in either local or world space
  93459. * @param space The space that the rotation should be in
  93460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93461. * @returns The quaternion rotation
  93462. */
  93463. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93464. /**
  93465. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93466. * @param space The space that the rotation should be in
  93467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93468. * @param result The quaternion that the rotation should be copied to
  93469. */
  93470. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93471. /**
  93472. * Get the rotation matrix of the bone in local or world space
  93473. * @param space The space that the rotation should be in
  93474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93475. * @returns The rotation matrix
  93476. */
  93477. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93478. /**
  93479. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93480. * @param space The space that the rotation should be in
  93481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93482. * @param result The quaternion that the rotation should be copied to
  93483. */
  93484. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93485. /**
  93486. * Get the world position of a point that is in the local space of the bone
  93487. * @param position The local position
  93488. * @param mesh The mesh that this bone is attached to
  93489. * @returns The world position
  93490. */
  93491. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93492. /**
  93493. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93494. * @param position The local position
  93495. * @param mesh The mesh that this bone is attached to
  93496. * @param result The vector3 that the world position should be copied to
  93497. */
  93498. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93499. /**
  93500. * Get the local position of a point that is in world space
  93501. * @param position The world position
  93502. * @param mesh The mesh that this bone is attached to
  93503. * @returns The local position
  93504. */
  93505. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93506. /**
  93507. * Get the local position of a point that is in world space and copy it to the result param
  93508. * @param position The world position
  93509. * @param mesh The mesh that this bone is attached to
  93510. * @param result The vector3 that the local position should be copied to
  93511. */
  93512. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93513. }
  93514. }
  93515. declare module BABYLON {
  93516. /**
  93517. * Defines a runtime animation
  93518. */
  93519. export class RuntimeAnimation {
  93520. private _events;
  93521. /**
  93522. * The current frame of the runtime animation
  93523. */
  93524. private _currentFrame;
  93525. /**
  93526. * The animation used by the runtime animation
  93527. */
  93528. private _animation;
  93529. /**
  93530. * The target of the runtime animation
  93531. */
  93532. private _target;
  93533. /**
  93534. * The initiating animatable
  93535. */
  93536. private _host;
  93537. /**
  93538. * The original value of the runtime animation
  93539. */
  93540. private _originalValue;
  93541. /**
  93542. * The original blend value of the runtime animation
  93543. */
  93544. private _originalBlendValue;
  93545. /**
  93546. * The offsets cache of the runtime animation
  93547. */
  93548. private _offsetsCache;
  93549. /**
  93550. * The high limits cache of the runtime animation
  93551. */
  93552. private _highLimitsCache;
  93553. /**
  93554. * Specifies if the runtime animation has been stopped
  93555. */
  93556. private _stopped;
  93557. /**
  93558. * The blending factor of the runtime animation
  93559. */
  93560. private _blendingFactor;
  93561. /**
  93562. * The BabylonJS scene
  93563. */
  93564. private _scene;
  93565. /**
  93566. * The current value of the runtime animation
  93567. */
  93568. private _currentValue;
  93569. /** @hidden */
  93570. _animationState: _IAnimationState;
  93571. /**
  93572. * The active target of the runtime animation
  93573. */
  93574. private _activeTargets;
  93575. private _currentActiveTarget;
  93576. private _directTarget;
  93577. /**
  93578. * The target path of the runtime animation
  93579. */
  93580. private _targetPath;
  93581. /**
  93582. * The weight of the runtime animation
  93583. */
  93584. private _weight;
  93585. /**
  93586. * The ratio offset of the runtime animation
  93587. */
  93588. private _ratioOffset;
  93589. /**
  93590. * The previous delay of the runtime animation
  93591. */
  93592. private _previousDelay;
  93593. /**
  93594. * The previous ratio of the runtime animation
  93595. */
  93596. private _previousRatio;
  93597. private _enableBlending;
  93598. private _keys;
  93599. private _minFrame;
  93600. private _maxFrame;
  93601. private _minValue;
  93602. private _maxValue;
  93603. private _targetIsArray;
  93604. /**
  93605. * Gets the current frame of the runtime animation
  93606. */
  93607. get currentFrame(): number;
  93608. /**
  93609. * Gets the weight of the runtime animation
  93610. */
  93611. get weight(): number;
  93612. /**
  93613. * Gets the current value of the runtime animation
  93614. */
  93615. get currentValue(): any;
  93616. /**
  93617. * Gets the target path of the runtime animation
  93618. */
  93619. get targetPath(): string;
  93620. /**
  93621. * Gets the actual target of the runtime animation
  93622. */
  93623. get target(): any;
  93624. /**
  93625. * Gets the additive state of the runtime animation
  93626. */
  93627. get isAdditive(): boolean;
  93628. /** @hidden */
  93629. _onLoop: () => void;
  93630. /**
  93631. * Create a new RuntimeAnimation object
  93632. * @param target defines the target of the animation
  93633. * @param animation defines the source animation object
  93634. * @param scene defines the hosting scene
  93635. * @param host defines the initiating Animatable
  93636. */
  93637. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93638. private _preparePath;
  93639. /**
  93640. * Gets the animation from the runtime animation
  93641. */
  93642. get animation(): Animation;
  93643. /**
  93644. * Resets the runtime animation to the beginning
  93645. * @param restoreOriginal defines whether to restore the target property to the original value
  93646. */
  93647. reset(restoreOriginal?: boolean): void;
  93648. /**
  93649. * Specifies if the runtime animation is stopped
  93650. * @returns Boolean specifying if the runtime animation is stopped
  93651. */
  93652. isStopped(): boolean;
  93653. /**
  93654. * Disposes of the runtime animation
  93655. */
  93656. dispose(): void;
  93657. /**
  93658. * Apply the interpolated value to the target
  93659. * @param currentValue defines the value computed by the animation
  93660. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93661. */
  93662. setValue(currentValue: any, weight: number): void;
  93663. private _getOriginalValues;
  93664. private _setValue;
  93665. /**
  93666. * Gets the loop pmode of the runtime animation
  93667. * @returns Loop Mode
  93668. */
  93669. private _getCorrectLoopMode;
  93670. /**
  93671. * Move the current animation to a given frame
  93672. * @param frame defines the frame to move to
  93673. */
  93674. goToFrame(frame: number): void;
  93675. /**
  93676. * @hidden Internal use only
  93677. */
  93678. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93679. /**
  93680. * Execute the current animation
  93681. * @param delay defines the delay to add to the current frame
  93682. * @param from defines the lower bound of the animation range
  93683. * @param to defines the upper bound of the animation range
  93684. * @param loop defines if the current animation must loop
  93685. * @param speedRatio defines the current speed ratio
  93686. * @param weight defines the weight of the animation (default is -1 so no weight)
  93687. * @param onLoop optional callback called when animation loops
  93688. * @returns a boolean indicating if the animation is running
  93689. */
  93690. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93691. }
  93692. }
  93693. declare module BABYLON {
  93694. /**
  93695. * Class used to store an actual running animation
  93696. */
  93697. export class Animatable {
  93698. /** defines the target object */
  93699. target: any;
  93700. /** defines the starting frame number (default is 0) */
  93701. fromFrame: number;
  93702. /** defines the ending frame number (default is 100) */
  93703. toFrame: number;
  93704. /** defines if the animation must loop (default is false) */
  93705. loopAnimation: boolean;
  93706. /** defines a callback to call when animation ends if it is not looping */
  93707. onAnimationEnd?: (() => void) | null | undefined;
  93708. /** defines a callback to call when animation loops */
  93709. onAnimationLoop?: (() => void) | null | undefined;
  93710. /** defines whether the animation should be evaluated additively */
  93711. isAdditive: boolean;
  93712. private _localDelayOffset;
  93713. private _pausedDelay;
  93714. private _runtimeAnimations;
  93715. private _paused;
  93716. private _scene;
  93717. private _speedRatio;
  93718. private _weight;
  93719. private _syncRoot;
  93720. /**
  93721. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93722. * This will only apply for non looping animation (default is true)
  93723. */
  93724. disposeOnEnd: boolean;
  93725. /**
  93726. * Gets a boolean indicating if the animation has started
  93727. */
  93728. animationStarted: boolean;
  93729. /**
  93730. * Observer raised when the animation ends
  93731. */
  93732. onAnimationEndObservable: Observable<Animatable>;
  93733. /**
  93734. * Observer raised when the animation loops
  93735. */
  93736. onAnimationLoopObservable: Observable<Animatable>;
  93737. /**
  93738. * Gets the root Animatable used to synchronize and normalize animations
  93739. */
  93740. get syncRoot(): Nullable<Animatable>;
  93741. /**
  93742. * Gets the current frame of the first RuntimeAnimation
  93743. * Used to synchronize Animatables
  93744. */
  93745. get masterFrame(): number;
  93746. /**
  93747. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93748. */
  93749. get weight(): number;
  93750. set weight(value: number);
  93751. /**
  93752. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93753. */
  93754. get speedRatio(): number;
  93755. set speedRatio(value: number);
  93756. /**
  93757. * Creates a new Animatable
  93758. * @param scene defines the hosting scene
  93759. * @param target defines the target object
  93760. * @param fromFrame defines the starting frame number (default is 0)
  93761. * @param toFrame defines the ending frame number (default is 100)
  93762. * @param loopAnimation defines if the animation must loop (default is false)
  93763. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93764. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93765. * @param animations defines a group of animation to add to the new Animatable
  93766. * @param onAnimationLoop defines a callback to call when animation loops
  93767. * @param isAdditive defines whether the animation should be evaluated additively
  93768. */
  93769. constructor(scene: Scene,
  93770. /** defines the target object */
  93771. target: any,
  93772. /** defines the starting frame number (default is 0) */
  93773. fromFrame?: number,
  93774. /** defines the ending frame number (default is 100) */
  93775. toFrame?: number,
  93776. /** defines if the animation must loop (default is false) */
  93777. loopAnimation?: boolean, speedRatio?: number,
  93778. /** defines a callback to call when animation ends if it is not looping */
  93779. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93780. /** defines a callback to call when animation loops */
  93781. onAnimationLoop?: (() => void) | null | undefined,
  93782. /** defines whether the animation should be evaluated additively */
  93783. isAdditive?: boolean);
  93784. /**
  93785. * Synchronize and normalize current Animatable with a source Animatable
  93786. * This is useful when using animation weights and when animations are not of the same length
  93787. * @param root defines the root Animatable to synchronize with
  93788. * @returns the current Animatable
  93789. */
  93790. syncWith(root: Animatable): Animatable;
  93791. /**
  93792. * Gets the list of runtime animations
  93793. * @returns an array of RuntimeAnimation
  93794. */
  93795. getAnimations(): RuntimeAnimation[];
  93796. /**
  93797. * Adds more animations to the current animatable
  93798. * @param target defines the target of the animations
  93799. * @param animations defines the new animations to add
  93800. */
  93801. appendAnimations(target: any, animations: Animation[]): void;
  93802. /**
  93803. * Gets the source animation for a specific property
  93804. * @param property defines the propertyu to look for
  93805. * @returns null or the source animation for the given property
  93806. */
  93807. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93808. /**
  93809. * Gets the runtime animation for a specific property
  93810. * @param property defines the propertyu to look for
  93811. * @returns null or the runtime animation for the given property
  93812. */
  93813. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93814. /**
  93815. * Resets the animatable to its original state
  93816. */
  93817. reset(): void;
  93818. /**
  93819. * Allows the animatable to blend with current running animations
  93820. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93821. * @param blendingSpeed defines the blending speed to use
  93822. */
  93823. enableBlending(blendingSpeed: number): void;
  93824. /**
  93825. * Disable animation blending
  93826. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93827. */
  93828. disableBlending(): void;
  93829. /**
  93830. * Jump directly to a given frame
  93831. * @param frame defines the frame to jump to
  93832. */
  93833. goToFrame(frame: number): void;
  93834. /**
  93835. * Pause the animation
  93836. */
  93837. pause(): void;
  93838. /**
  93839. * Restart the animation
  93840. */
  93841. restart(): void;
  93842. private _raiseOnAnimationEnd;
  93843. /**
  93844. * Stop and delete the current animation
  93845. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93846. * @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)
  93847. */
  93848. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93849. /**
  93850. * Wait asynchronously for the animation to end
  93851. * @returns a promise which will be fullfilled when the animation ends
  93852. */
  93853. waitAsync(): Promise<Animatable>;
  93854. /** @hidden */
  93855. _animate(delay: number): boolean;
  93856. }
  93857. interface Scene {
  93858. /** @hidden */
  93859. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93860. /** @hidden */
  93861. _processLateAnimationBindingsForMatrices(holder: {
  93862. totalWeight: number;
  93863. totalAdditiveWeight: number;
  93864. animations: RuntimeAnimation[];
  93865. additiveAnimations: RuntimeAnimation[];
  93866. originalValue: Matrix;
  93867. }): any;
  93868. /** @hidden */
  93869. _processLateAnimationBindingsForQuaternions(holder: {
  93870. totalWeight: number;
  93871. totalAdditiveWeight: number;
  93872. animations: RuntimeAnimation[];
  93873. additiveAnimations: RuntimeAnimation[];
  93874. originalValue: Quaternion;
  93875. }, refQuaternion: Quaternion): Quaternion;
  93876. /** @hidden */
  93877. _processLateAnimationBindings(): void;
  93878. /**
  93879. * Will start the animation sequence of a given target
  93880. * @param target defines the target
  93881. * @param from defines from which frame should animation start
  93882. * @param to defines until which frame should animation run.
  93883. * @param weight defines the weight to apply to the animation (1.0 by default)
  93884. * @param loop defines if the animation loops
  93885. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93886. * @param onAnimationEnd defines the function to be executed when the animation ends
  93887. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93888. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93889. * @param onAnimationLoop defines the callback to call when an animation loops
  93890. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93891. * @returns the animatable object created for this animation
  93892. */
  93893. 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;
  93894. /**
  93895. * Will start the animation sequence of a given target
  93896. * @param target defines the target
  93897. * @param from defines from which frame should animation start
  93898. * @param to defines until which frame should animation run.
  93899. * @param loop defines if the animation loops
  93900. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93901. * @param onAnimationEnd defines the function to be executed when the animation ends
  93902. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93903. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93904. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93905. * @param onAnimationLoop defines the callback to call when an animation loops
  93906. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93907. * @returns the animatable object created for this animation
  93908. */
  93909. 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;
  93910. /**
  93911. * Will start the animation sequence of a given target and its hierarchy
  93912. * @param target defines the target
  93913. * @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.
  93914. * @param from defines from which frame should animation start
  93915. * @param to defines until which frame should animation run.
  93916. * @param loop defines if the animation loops
  93917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93918. * @param onAnimationEnd defines the function to be executed when the animation ends
  93919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93920. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93921. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93922. * @param onAnimationLoop defines the callback to call when an animation loops
  93923. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93924. * @returns the list of created animatables
  93925. */
  93926. 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[];
  93927. /**
  93928. * Begin a new animation on a given node
  93929. * @param target defines the target where the animation will take place
  93930. * @param animations defines the list of animations to start
  93931. * @param from defines the initial value
  93932. * @param to defines the final value
  93933. * @param loop defines if you want animation to loop (off by default)
  93934. * @param speedRatio defines the speed ratio to apply to all animations
  93935. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93936. * @param onAnimationLoop defines the callback to call when an animation loops
  93937. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93938. * @returns the list of created animatables
  93939. */
  93940. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93941. /**
  93942. * Begin a new animation on a given node and its hierarchy
  93943. * @param target defines the root node where the animation will take place
  93944. * @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.
  93945. * @param animations defines the list of animations to start
  93946. * @param from defines the initial value
  93947. * @param to defines the final value
  93948. * @param loop defines if you want animation to loop (off by default)
  93949. * @param speedRatio defines the speed ratio to apply to all animations
  93950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93951. * @param onAnimationLoop defines the callback to call when an animation loops
  93952. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93953. * @returns the list of animatables created for all nodes
  93954. */
  93955. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93956. /**
  93957. * Gets the animatable associated with a specific target
  93958. * @param target defines the target of the animatable
  93959. * @returns the required animatable if found
  93960. */
  93961. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93962. /**
  93963. * Gets all animatables associated with a given target
  93964. * @param target defines the target to look animatables for
  93965. * @returns an array of Animatables
  93966. */
  93967. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93968. /**
  93969. * Stops and removes all animations that have been applied to the scene
  93970. */
  93971. stopAllAnimations(): void;
  93972. /**
  93973. * Gets the current delta time used by animation engine
  93974. */
  93975. deltaTime: number;
  93976. }
  93977. interface Bone {
  93978. /**
  93979. * Copy an animation range from another bone
  93980. * @param source defines the source bone
  93981. * @param rangeName defines the range name to copy
  93982. * @param frameOffset defines the frame offset
  93983. * @param rescaleAsRequired defines if rescaling must be applied if required
  93984. * @param skelDimensionsRatio defines the scaling ratio
  93985. * @returns true if operation was successful
  93986. */
  93987. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93988. }
  93989. }
  93990. declare module BABYLON {
  93991. /**
  93992. * Class used to handle skinning animations
  93993. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93994. */
  93995. export class Skeleton implements IAnimatable {
  93996. /** defines the skeleton name */
  93997. name: string;
  93998. /** defines the skeleton Id */
  93999. id: string;
  94000. /**
  94001. * Defines the list of child bones
  94002. */
  94003. bones: Bone[];
  94004. /**
  94005. * Defines an estimate of the dimension of the skeleton at rest
  94006. */
  94007. dimensionsAtRest: Vector3;
  94008. /**
  94009. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94010. */
  94011. needInitialSkinMatrix: boolean;
  94012. /**
  94013. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94014. */
  94015. overrideMesh: Nullable<AbstractMesh>;
  94016. /**
  94017. * Gets the list of animations attached to this skeleton
  94018. */
  94019. animations: Array<Animation>;
  94020. private _scene;
  94021. private _isDirty;
  94022. private _transformMatrices;
  94023. private _transformMatrixTexture;
  94024. private _meshesWithPoseMatrix;
  94025. private _animatables;
  94026. private _identity;
  94027. private _synchronizedWithMesh;
  94028. private _ranges;
  94029. private _lastAbsoluteTransformsUpdateId;
  94030. private _canUseTextureForBones;
  94031. private _uniqueId;
  94032. /** @hidden */
  94033. _numBonesWithLinkedTransformNode: number;
  94034. /** @hidden */
  94035. _hasWaitingData: Nullable<boolean>;
  94036. /**
  94037. * Specifies if the skeleton should be serialized
  94038. */
  94039. doNotSerialize: boolean;
  94040. private _useTextureToStoreBoneMatrices;
  94041. /**
  94042. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94043. * Please note that this option is not available if the hardware does not support it
  94044. */
  94045. get useTextureToStoreBoneMatrices(): boolean;
  94046. set useTextureToStoreBoneMatrices(value: boolean);
  94047. private _animationPropertiesOverride;
  94048. /**
  94049. * Gets or sets the animation properties override
  94050. */
  94051. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94052. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94053. /**
  94054. * List of inspectable custom properties (used by the Inspector)
  94055. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94056. */
  94057. inspectableCustomProperties: IInspectable[];
  94058. /**
  94059. * An observable triggered before computing the skeleton's matrices
  94060. */
  94061. onBeforeComputeObservable: Observable<Skeleton>;
  94062. /**
  94063. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94064. */
  94065. get isUsingTextureForMatrices(): boolean;
  94066. /**
  94067. * Gets the unique ID of this skeleton
  94068. */
  94069. get uniqueId(): number;
  94070. /**
  94071. * Creates a new skeleton
  94072. * @param name defines the skeleton name
  94073. * @param id defines the skeleton Id
  94074. * @param scene defines the hosting scene
  94075. */
  94076. constructor(
  94077. /** defines the skeleton name */
  94078. name: string,
  94079. /** defines the skeleton Id */
  94080. id: string, scene: Scene);
  94081. /**
  94082. * Gets the current object class name.
  94083. * @return the class name
  94084. */
  94085. getClassName(): string;
  94086. /**
  94087. * Returns an array containing the root bones
  94088. * @returns an array containing the root bones
  94089. */
  94090. getChildren(): Array<Bone>;
  94091. /**
  94092. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94093. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94094. * @returns a Float32Array containing matrices data
  94095. */
  94096. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94097. /**
  94098. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94099. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94100. * @returns a raw texture containing the data
  94101. */
  94102. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94103. /**
  94104. * Gets the current hosting scene
  94105. * @returns a scene object
  94106. */
  94107. getScene(): Scene;
  94108. /**
  94109. * Gets a string representing the current skeleton data
  94110. * @param fullDetails defines a boolean indicating if we want a verbose version
  94111. * @returns a string representing the current skeleton data
  94112. */
  94113. toString(fullDetails?: boolean): string;
  94114. /**
  94115. * Get bone's index searching by name
  94116. * @param name defines bone's name to search for
  94117. * @return the indice of the bone. Returns -1 if not found
  94118. */
  94119. getBoneIndexByName(name: string): number;
  94120. /**
  94121. * Creater a new animation range
  94122. * @param name defines the name of the range
  94123. * @param from defines the start key
  94124. * @param to defines the end key
  94125. */
  94126. createAnimationRange(name: string, from: number, to: number): void;
  94127. /**
  94128. * Delete a specific animation range
  94129. * @param name defines the name of the range
  94130. * @param deleteFrames defines if frames must be removed as well
  94131. */
  94132. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94133. /**
  94134. * Gets a specific animation range
  94135. * @param name defines the name of the range to look for
  94136. * @returns the requested animation range or null if not found
  94137. */
  94138. getAnimationRange(name: string): Nullable<AnimationRange>;
  94139. /**
  94140. * Gets the list of all animation ranges defined on this skeleton
  94141. * @returns an array
  94142. */
  94143. getAnimationRanges(): Nullable<AnimationRange>[];
  94144. /**
  94145. * Copy animation range from a source skeleton.
  94146. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94147. * @param source defines the source skeleton
  94148. * @param name defines the name of the range to copy
  94149. * @param rescaleAsRequired defines if rescaling must be applied if required
  94150. * @returns true if operation was successful
  94151. */
  94152. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94153. /**
  94154. * Forces the skeleton to go to rest pose
  94155. */
  94156. returnToRest(): void;
  94157. private _getHighestAnimationFrame;
  94158. /**
  94159. * Begin a specific animation range
  94160. * @param name defines the name of the range to start
  94161. * @param loop defines if looping must be turned on (false by default)
  94162. * @param speedRatio defines the speed ratio to apply (1 by default)
  94163. * @param onAnimationEnd defines a callback which will be called when animation will end
  94164. * @returns a new animatable
  94165. */
  94166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94167. /**
  94168. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94169. * @param skeleton defines the Skeleton containing the animation range to convert
  94170. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94171. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94172. * @returns the original skeleton
  94173. */
  94174. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94175. /** @hidden */
  94176. _markAsDirty(): void;
  94177. /** @hidden */
  94178. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94179. /** @hidden */
  94180. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94181. private _computeTransformMatrices;
  94182. /**
  94183. * Build all resources required to render a skeleton
  94184. */
  94185. prepare(): void;
  94186. /**
  94187. * Gets the list of animatables currently running for this skeleton
  94188. * @returns an array of animatables
  94189. */
  94190. getAnimatables(): IAnimatable[];
  94191. /**
  94192. * Clone the current skeleton
  94193. * @param name defines the name of the new skeleton
  94194. * @param id defines the id of the new skeleton
  94195. * @returns the new skeleton
  94196. */
  94197. clone(name: string, id?: string): Skeleton;
  94198. /**
  94199. * Enable animation blending for this skeleton
  94200. * @param blendingSpeed defines the blending speed to apply
  94201. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94202. */
  94203. enableBlending(blendingSpeed?: number): void;
  94204. /**
  94205. * Releases all resources associated with the current skeleton
  94206. */
  94207. dispose(): void;
  94208. /**
  94209. * Serialize the skeleton in a JSON object
  94210. * @returns a JSON object
  94211. */
  94212. serialize(): any;
  94213. /**
  94214. * Creates a new skeleton from serialized data
  94215. * @param parsedSkeleton defines the serialized data
  94216. * @param scene defines the hosting scene
  94217. * @returns a new skeleton
  94218. */
  94219. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94220. /**
  94221. * Compute all node absolute transforms
  94222. * @param forceUpdate defines if computation must be done even if cache is up to date
  94223. */
  94224. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94225. /**
  94226. * Gets the root pose matrix
  94227. * @returns a matrix
  94228. */
  94229. getPoseMatrix(): Nullable<Matrix>;
  94230. /**
  94231. * Sorts bones per internal index
  94232. */
  94233. sortBones(): void;
  94234. private _sortBones;
  94235. }
  94236. }
  94237. declare module BABYLON {
  94238. /**
  94239. * Creates an instance based on a source mesh.
  94240. */
  94241. export class InstancedMesh extends AbstractMesh {
  94242. private _sourceMesh;
  94243. private _currentLOD;
  94244. /** @hidden */
  94245. _indexInSourceMeshInstanceArray: number;
  94246. constructor(name: string, source: Mesh);
  94247. /**
  94248. * Returns the string "InstancedMesh".
  94249. */
  94250. getClassName(): string;
  94251. /** Gets the list of lights affecting that mesh */
  94252. get lightSources(): Light[];
  94253. _resyncLightSources(): void;
  94254. _resyncLightSource(light: Light): void;
  94255. _removeLightSource(light: Light, dispose: boolean): void;
  94256. /**
  94257. * If the source mesh receives shadows
  94258. */
  94259. get receiveShadows(): boolean;
  94260. /**
  94261. * The material of the source mesh
  94262. */
  94263. get material(): Nullable<Material>;
  94264. /**
  94265. * Visibility of the source mesh
  94266. */
  94267. get visibility(): number;
  94268. /**
  94269. * Skeleton of the source mesh
  94270. */
  94271. get skeleton(): Nullable<Skeleton>;
  94272. /**
  94273. * Rendering ground id of the source mesh
  94274. */
  94275. get renderingGroupId(): number;
  94276. set renderingGroupId(value: number);
  94277. /**
  94278. * Returns the total number of vertices (integer).
  94279. */
  94280. getTotalVertices(): number;
  94281. /**
  94282. * Returns a positive integer : the total number of indices in this mesh geometry.
  94283. * @returns the numner of indices or zero if the mesh has no geometry.
  94284. */
  94285. getTotalIndices(): number;
  94286. /**
  94287. * The source mesh of the instance
  94288. */
  94289. get sourceMesh(): Mesh;
  94290. /**
  94291. * Creates a new InstancedMesh object from the mesh model.
  94292. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94293. * @param name defines the name of the new instance
  94294. * @returns a new InstancedMesh
  94295. */
  94296. createInstance(name: string): InstancedMesh;
  94297. /**
  94298. * Is this node ready to be used/rendered
  94299. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94300. * @return {boolean} is it ready
  94301. */
  94302. isReady(completeCheck?: boolean): boolean;
  94303. /**
  94304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94305. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94306. * @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.
  94307. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94308. */
  94309. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94310. /**
  94311. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94312. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94313. * The `data` are either a numeric array either a Float32Array.
  94314. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94315. * 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).
  94316. * Note that a new underlying VertexBuffer object is created each call.
  94317. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94318. *
  94319. * Possible `kind` values :
  94320. * - VertexBuffer.PositionKind
  94321. * - VertexBuffer.UVKind
  94322. * - VertexBuffer.UV2Kind
  94323. * - VertexBuffer.UV3Kind
  94324. * - VertexBuffer.UV4Kind
  94325. * - VertexBuffer.UV5Kind
  94326. * - VertexBuffer.UV6Kind
  94327. * - VertexBuffer.ColorKind
  94328. * - VertexBuffer.MatricesIndicesKind
  94329. * - VertexBuffer.MatricesIndicesExtraKind
  94330. * - VertexBuffer.MatricesWeightsKind
  94331. * - VertexBuffer.MatricesWeightsExtraKind
  94332. *
  94333. * Returns the Mesh.
  94334. */
  94335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94336. /**
  94337. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94338. * If the mesh has no geometry, it is simply returned as it is.
  94339. * The `data` are either a numeric array either a Float32Array.
  94340. * No new underlying VertexBuffer object is created.
  94341. * 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.
  94342. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94343. *
  94344. * Possible `kind` values :
  94345. * - VertexBuffer.PositionKind
  94346. * - VertexBuffer.UVKind
  94347. * - VertexBuffer.UV2Kind
  94348. * - VertexBuffer.UV3Kind
  94349. * - VertexBuffer.UV4Kind
  94350. * - VertexBuffer.UV5Kind
  94351. * - VertexBuffer.UV6Kind
  94352. * - VertexBuffer.ColorKind
  94353. * - VertexBuffer.MatricesIndicesKind
  94354. * - VertexBuffer.MatricesIndicesExtraKind
  94355. * - VertexBuffer.MatricesWeightsKind
  94356. * - VertexBuffer.MatricesWeightsExtraKind
  94357. *
  94358. * Returns the Mesh.
  94359. */
  94360. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94361. /**
  94362. * Sets the mesh indices.
  94363. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94364. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94365. * This method creates a new index buffer each call.
  94366. * Returns the Mesh.
  94367. */
  94368. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94369. /**
  94370. * Boolean : True if the mesh owns the requested kind of data.
  94371. */
  94372. isVerticesDataPresent(kind: string): boolean;
  94373. /**
  94374. * Returns an array of indices (IndicesArray).
  94375. */
  94376. getIndices(): Nullable<IndicesArray>;
  94377. get _positions(): Nullable<Vector3[]>;
  94378. /**
  94379. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94380. * This means the mesh underlying bounding box and sphere are recomputed.
  94381. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94382. * @returns the current mesh
  94383. */
  94384. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94385. /** @hidden */
  94386. _preActivate(): InstancedMesh;
  94387. /** @hidden */
  94388. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94389. /** @hidden */
  94390. _postActivate(): void;
  94391. getWorldMatrix(): Matrix;
  94392. get isAnInstance(): boolean;
  94393. /**
  94394. * Returns the current associated LOD AbstractMesh.
  94395. */
  94396. getLOD(camera: Camera): AbstractMesh;
  94397. /** @hidden */
  94398. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94399. /** @hidden */
  94400. _syncSubMeshes(): InstancedMesh;
  94401. /** @hidden */
  94402. _generatePointsArray(): boolean;
  94403. /**
  94404. * Creates a new InstancedMesh from the current mesh.
  94405. * - name (string) : the cloned mesh name
  94406. * - newParent (optional Node) : the optional Node to parent the clone to.
  94407. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94408. *
  94409. * Returns the clone.
  94410. */
  94411. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94412. /**
  94413. * Disposes the InstancedMesh.
  94414. * Returns nothing.
  94415. */
  94416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94417. }
  94418. interface Mesh {
  94419. /**
  94420. * Register a custom buffer that will be instanced
  94421. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94422. * @param kind defines the buffer kind
  94423. * @param stride defines the stride in floats
  94424. */
  94425. registerInstancedBuffer(kind: string, stride: number): void;
  94426. /**
  94427. * true to use the edge renderer for all instances of this mesh
  94428. */
  94429. edgesShareWithInstances: boolean;
  94430. /** @hidden */
  94431. _userInstancedBuffersStorage: {
  94432. data: {
  94433. [key: string]: Float32Array;
  94434. };
  94435. sizes: {
  94436. [key: string]: number;
  94437. };
  94438. vertexBuffers: {
  94439. [key: string]: Nullable<VertexBuffer>;
  94440. };
  94441. strides: {
  94442. [key: string]: number;
  94443. };
  94444. };
  94445. }
  94446. interface AbstractMesh {
  94447. /**
  94448. * Object used to store instanced buffers defined by user
  94449. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94450. */
  94451. instancedBuffers: {
  94452. [key: string]: any;
  94453. };
  94454. }
  94455. }
  94456. declare module BABYLON {
  94457. /**
  94458. * Defines the options associated with the creation of a shader material.
  94459. */
  94460. export interface IShaderMaterialOptions {
  94461. /**
  94462. * Does the material work in alpha blend mode
  94463. */
  94464. needAlphaBlending: boolean;
  94465. /**
  94466. * Does the material work in alpha test mode
  94467. */
  94468. needAlphaTesting: boolean;
  94469. /**
  94470. * The list of attribute names used in the shader
  94471. */
  94472. attributes: string[];
  94473. /**
  94474. * The list of unifrom names used in the shader
  94475. */
  94476. uniforms: string[];
  94477. /**
  94478. * The list of UBO names used in the shader
  94479. */
  94480. uniformBuffers: string[];
  94481. /**
  94482. * The list of sampler names used in the shader
  94483. */
  94484. samplers: string[];
  94485. /**
  94486. * The list of defines used in the shader
  94487. */
  94488. defines: string[];
  94489. }
  94490. /**
  94491. * 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.
  94492. *
  94493. * This returned material effects how the mesh will look based on the code in the shaders.
  94494. *
  94495. * @see https://doc.babylonjs.com/how_to/shader_material
  94496. */
  94497. export class ShaderMaterial extends Material {
  94498. private _shaderPath;
  94499. private _options;
  94500. private _textures;
  94501. private _textureArrays;
  94502. private _floats;
  94503. private _ints;
  94504. private _floatsArrays;
  94505. private _colors3;
  94506. private _colors3Arrays;
  94507. private _colors4;
  94508. private _colors4Arrays;
  94509. private _vectors2;
  94510. private _vectors3;
  94511. private _vectors4;
  94512. private _matrices;
  94513. private _matrixArrays;
  94514. private _matrices3x3;
  94515. private _matrices2x2;
  94516. private _vectors2Arrays;
  94517. private _vectors3Arrays;
  94518. private _vectors4Arrays;
  94519. private _cachedWorldViewMatrix;
  94520. private _cachedWorldViewProjectionMatrix;
  94521. private _renderId;
  94522. private _multiview;
  94523. private _cachedDefines;
  94524. /** Define the Url to load snippets */
  94525. static SnippetUrl: string;
  94526. /** Snippet ID if the material was created from the snippet server */
  94527. snippetId: string;
  94528. /**
  94529. * Instantiate a new shader material.
  94530. * 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.
  94531. * This returned material effects how the mesh will look based on the code in the shaders.
  94532. * @see https://doc.babylonjs.com/how_to/shader_material
  94533. * @param name Define the name of the material in the scene
  94534. * @param scene Define the scene the material belongs to
  94535. * @param shaderPath Defines the route to the shader code in one of three ways:
  94536. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94537. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94538. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94539. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94540. * @param options Define the options used to create the shader
  94541. */
  94542. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94543. /**
  94544. * Gets the shader path used to define the shader code
  94545. * It can be modified to trigger a new compilation
  94546. */
  94547. get shaderPath(): any;
  94548. /**
  94549. * Sets the shader path used to define the shader code
  94550. * It can be modified to trigger a new compilation
  94551. */
  94552. set shaderPath(shaderPath: any);
  94553. /**
  94554. * Gets the options used to compile the shader.
  94555. * They can be modified to trigger a new compilation
  94556. */
  94557. get options(): IShaderMaterialOptions;
  94558. /**
  94559. * Gets the current class name of the material e.g. "ShaderMaterial"
  94560. * Mainly use in serialization.
  94561. * @returns the class name
  94562. */
  94563. getClassName(): string;
  94564. /**
  94565. * Specifies if the material will require alpha blending
  94566. * @returns a boolean specifying if alpha blending is needed
  94567. */
  94568. needAlphaBlending(): boolean;
  94569. /**
  94570. * Specifies if this material should be rendered in alpha test mode
  94571. * @returns a boolean specifying if an alpha test is needed.
  94572. */
  94573. needAlphaTesting(): boolean;
  94574. private _checkUniform;
  94575. /**
  94576. * Set a texture in the shader.
  94577. * @param name Define the name of the uniform samplers as defined in the shader
  94578. * @param texture Define the texture to bind to this sampler
  94579. * @return the material itself allowing "fluent" like uniform updates
  94580. */
  94581. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94582. /**
  94583. * Set a texture array in the shader.
  94584. * @param name Define the name of the uniform sampler array as defined in the shader
  94585. * @param textures Define the list of textures to bind to this sampler
  94586. * @return the material itself allowing "fluent" like uniform updates
  94587. */
  94588. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94589. /**
  94590. * Set a float in the shader.
  94591. * @param name Define the name of the uniform as defined in the shader
  94592. * @param value Define the value to give to the uniform
  94593. * @return the material itself allowing "fluent" like uniform updates
  94594. */
  94595. setFloat(name: string, value: number): ShaderMaterial;
  94596. /**
  94597. * Set a int in the shader.
  94598. * @param name Define the name of the uniform as defined in the shader
  94599. * @param value Define the value to give to the uniform
  94600. * @return the material itself allowing "fluent" like uniform updates
  94601. */
  94602. setInt(name: string, value: number): ShaderMaterial;
  94603. /**
  94604. * Set an array of floats in the shader.
  94605. * @param name Define the name of the uniform as defined in the shader
  94606. * @param value Define the value to give to the uniform
  94607. * @return the material itself allowing "fluent" like uniform updates
  94608. */
  94609. setFloats(name: string, value: number[]): ShaderMaterial;
  94610. /**
  94611. * Set a vec3 in the shader from a Color3.
  94612. * @param name Define the name of the uniform as defined in the shader
  94613. * @param value Define the value to give to the uniform
  94614. * @return the material itself allowing "fluent" like uniform updates
  94615. */
  94616. setColor3(name: string, value: Color3): ShaderMaterial;
  94617. /**
  94618. * Set a vec3 array in the shader from a Color3 array.
  94619. * @param name Define the name of the uniform as defined in the shader
  94620. * @param value Define the value to give to the uniform
  94621. * @return the material itself allowing "fluent" like uniform updates
  94622. */
  94623. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94624. /**
  94625. * Set a vec4 in the shader from a Color4.
  94626. * @param name Define the name of the uniform as defined in the shader
  94627. * @param value Define the value to give to the uniform
  94628. * @return the material itself allowing "fluent" like uniform updates
  94629. */
  94630. setColor4(name: string, value: Color4): ShaderMaterial;
  94631. /**
  94632. * Set a vec4 array in the shader from a Color4 array.
  94633. * @param name Define the name of the uniform as defined in the shader
  94634. * @param value Define the value to give to the uniform
  94635. * @return the material itself allowing "fluent" like uniform updates
  94636. */
  94637. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94638. /**
  94639. * Set a vec2 in the shader from a Vector2.
  94640. * @param name Define the name of the uniform as defined in the shader
  94641. * @param value Define the value to give to the uniform
  94642. * @return the material itself allowing "fluent" like uniform updates
  94643. */
  94644. setVector2(name: string, value: Vector2): ShaderMaterial;
  94645. /**
  94646. * Set a vec3 in the shader from a Vector3.
  94647. * @param name Define the name of the uniform as defined in the shader
  94648. * @param value Define the value to give to the uniform
  94649. * @return the material itself allowing "fluent" like uniform updates
  94650. */
  94651. setVector3(name: string, value: Vector3): ShaderMaterial;
  94652. /**
  94653. * Set a vec4 in the shader from a Vector4.
  94654. * @param name Define the name of the uniform as defined in the shader
  94655. * @param value Define the value to give to the uniform
  94656. * @return the material itself allowing "fluent" like uniform updates
  94657. */
  94658. setVector4(name: string, value: Vector4): ShaderMaterial;
  94659. /**
  94660. * Set a mat4 in the shader from a Matrix.
  94661. * @param name Define the name of the uniform as defined in the shader
  94662. * @param value Define the value to give to the uniform
  94663. * @return the material itself allowing "fluent" like uniform updates
  94664. */
  94665. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94666. /**
  94667. * Set a float32Array in the shader from a matrix array.
  94668. * @param name Define the name of the uniform as defined in the shader
  94669. * @param value Define the value to give to the uniform
  94670. * @return the material itself allowing "fluent" like uniform updates
  94671. */
  94672. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94673. /**
  94674. * Set a mat3 in the shader from a Float32Array.
  94675. * @param name Define the name of the uniform as defined in the shader
  94676. * @param value Define the value to give to the uniform
  94677. * @return the material itself allowing "fluent" like uniform updates
  94678. */
  94679. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94680. /**
  94681. * Set a mat2 in the shader from a Float32Array.
  94682. * @param name Define the name of the uniform as defined in the shader
  94683. * @param value Define the value to give to the uniform
  94684. * @return the material itself allowing "fluent" like uniform updates
  94685. */
  94686. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94687. /**
  94688. * Set a vec2 array in the shader from a number array.
  94689. * @param name Define the name of the uniform as defined in the shader
  94690. * @param value Define the value to give to the uniform
  94691. * @return the material itself allowing "fluent" like uniform updates
  94692. */
  94693. setArray2(name: string, value: number[]): ShaderMaterial;
  94694. /**
  94695. * Set a vec3 array in the shader from a number array.
  94696. * @param name Define the name of the uniform as defined in the shader
  94697. * @param value Define the value to give to the uniform
  94698. * @return the material itself allowing "fluent" like uniform updates
  94699. */
  94700. setArray3(name: string, value: number[]): ShaderMaterial;
  94701. /**
  94702. * Set a vec4 array in the shader from a number array.
  94703. * @param name Define the name of the uniform as defined in the shader
  94704. * @param value Define the value to give to the uniform
  94705. * @return the material itself allowing "fluent" like uniform updates
  94706. */
  94707. setArray4(name: string, value: number[]): ShaderMaterial;
  94708. private _checkCache;
  94709. /**
  94710. * Specifies that the submesh is ready to be used
  94711. * @param mesh defines the mesh to check
  94712. * @param subMesh defines which submesh to check
  94713. * @param useInstances specifies that instances should be used
  94714. * @returns a boolean indicating that the submesh is ready or not
  94715. */
  94716. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94717. /**
  94718. * Checks if the material is ready to render the requested mesh
  94719. * @param mesh Define the mesh to render
  94720. * @param useInstances Define whether or not the material is used with instances
  94721. * @returns true if ready, otherwise false
  94722. */
  94723. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94724. /**
  94725. * Binds the world matrix to the material
  94726. * @param world defines the world transformation matrix
  94727. * @param effectOverride - If provided, use this effect instead of internal effect
  94728. */
  94729. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94730. /**
  94731. * Binds the submesh to this material by preparing the effect and shader to draw
  94732. * @param world defines the world transformation matrix
  94733. * @param mesh defines the mesh containing the submesh
  94734. * @param subMesh defines the submesh to bind the material to
  94735. */
  94736. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94737. /**
  94738. * Binds the material to the mesh
  94739. * @param world defines the world transformation matrix
  94740. * @param mesh defines the mesh to bind the material to
  94741. * @param effectOverride - If provided, use this effect instead of internal effect
  94742. */
  94743. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94744. protected _afterBind(mesh?: Mesh): void;
  94745. /**
  94746. * Gets the active textures from the material
  94747. * @returns an array of textures
  94748. */
  94749. getActiveTextures(): BaseTexture[];
  94750. /**
  94751. * Specifies if the material uses a texture
  94752. * @param texture defines the texture to check against the material
  94753. * @returns a boolean specifying if the material uses the texture
  94754. */
  94755. hasTexture(texture: BaseTexture): boolean;
  94756. /**
  94757. * Makes a duplicate of the material, and gives it a new name
  94758. * @param name defines the new name for the duplicated material
  94759. * @returns the cloned material
  94760. */
  94761. clone(name: string): ShaderMaterial;
  94762. /**
  94763. * Disposes the material
  94764. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94765. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94766. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94767. */
  94768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94769. /**
  94770. * Serializes this material in a JSON representation
  94771. * @returns the serialized material object
  94772. */
  94773. serialize(): any;
  94774. /**
  94775. * Creates a shader material from parsed shader material data
  94776. * @param source defines the JSON represnetation of the material
  94777. * @param scene defines the hosting scene
  94778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94779. * @returns a new material
  94780. */
  94781. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94782. /**
  94783. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94784. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94785. * @param url defines the url to load from
  94786. * @param scene defines the hosting scene
  94787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94788. * @returns a promise that will resolve to the new ShaderMaterial
  94789. */
  94790. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94791. /**
  94792. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94793. * @param snippetId defines the snippet to load
  94794. * @param scene defines the hosting scene
  94795. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94796. * @returns a promise that will resolve to the new ShaderMaterial
  94797. */
  94798. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94799. }
  94800. }
  94801. declare module BABYLON {
  94802. /** @hidden */
  94803. export var colorPixelShader: {
  94804. name: string;
  94805. shader: string;
  94806. };
  94807. }
  94808. declare module BABYLON {
  94809. /** @hidden */
  94810. export var colorVertexShader: {
  94811. name: string;
  94812. shader: string;
  94813. };
  94814. }
  94815. declare module BABYLON {
  94816. /**
  94817. * Line mesh
  94818. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94819. */
  94820. export class LinesMesh extends Mesh {
  94821. /**
  94822. * If vertex color should be applied to the mesh
  94823. */
  94824. readonly useVertexColor?: boolean | undefined;
  94825. /**
  94826. * If vertex alpha should be applied to the mesh
  94827. */
  94828. readonly useVertexAlpha?: boolean | undefined;
  94829. /**
  94830. * Color of the line (Default: White)
  94831. */
  94832. color: Color3;
  94833. /**
  94834. * Alpha of the line (Default: 1)
  94835. */
  94836. alpha: number;
  94837. /**
  94838. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94839. * This margin is expressed in world space coordinates, so its value may vary.
  94840. * Default value is 0.1
  94841. */
  94842. intersectionThreshold: number;
  94843. private _colorShader;
  94844. private color4;
  94845. /**
  94846. * Creates a new LinesMesh
  94847. * @param name defines the name
  94848. * @param scene defines the hosting scene
  94849. * @param parent defines the parent mesh if any
  94850. * @param source defines the optional source LinesMesh used to clone data from
  94851. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94852. * When false, achieved by calling a clone(), also passing False.
  94853. * This will make creation of children, recursive.
  94854. * @param useVertexColor defines if this LinesMesh supports vertex color
  94855. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94856. */
  94857. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94858. /**
  94859. * If vertex color should be applied to the mesh
  94860. */
  94861. useVertexColor?: boolean | undefined,
  94862. /**
  94863. * If vertex alpha should be applied to the mesh
  94864. */
  94865. useVertexAlpha?: boolean | undefined);
  94866. private _addClipPlaneDefine;
  94867. private _removeClipPlaneDefine;
  94868. isReady(): boolean;
  94869. /**
  94870. * Returns the string "LineMesh"
  94871. */
  94872. getClassName(): string;
  94873. /**
  94874. * @hidden
  94875. */
  94876. get material(): Material;
  94877. /**
  94878. * @hidden
  94879. */
  94880. set material(value: Material);
  94881. /**
  94882. * @hidden
  94883. */
  94884. get checkCollisions(): boolean;
  94885. /** @hidden */
  94886. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94887. /** @hidden */
  94888. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94889. /**
  94890. * Disposes of the line mesh
  94891. * @param doNotRecurse If children should be disposed
  94892. */
  94893. dispose(doNotRecurse?: boolean): void;
  94894. /**
  94895. * Returns a new LineMesh object cloned from the current one.
  94896. */
  94897. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94898. /**
  94899. * Creates a new InstancedLinesMesh object from the mesh model.
  94900. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94901. * @param name defines the name of the new instance
  94902. * @returns a new InstancedLinesMesh
  94903. */
  94904. createInstance(name: string): InstancedLinesMesh;
  94905. }
  94906. /**
  94907. * Creates an instance based on a source LinesMesh
  94908. */
  94909. export class InstancedLinesMesh extends InstancedMesh {
  94910. /**
  94911. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94912. * This margin is expressed in world space coordinates, so its value may vary.
  94913. * Initilized with the intersectionThreshold value of the source LinesMesh
  94914. */
  94915. intersectionThreshold: number;
  94916. constructor(name: string, source: LinesMesh);
  94917. /**
  94918. * Returns the string "InstancedLinesMesh".
  94919. */
  94920. getClassName(): string;
  94921. }
  94922. }
  94923. declare module BABYLON {
  94924. /** @hidden */
  94925. export var linePixelShader: {
  94926. name: string;
  94927. shader: string;
  94928. };
  94929. }
  94930. declare module BABYLON {
  94931. /** @hidden */
  94932. export var lineVertexShader: {
  94933. name: string;
  94934. shader: string;
  94935. };
  94936. }
  94937. declare module BABYLON {
  94938. interface Scene {
  94939. /** @hidden */
  94940. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94941. }
  94942. interface AbstractMesh {
  94943. /**
  94944. * Gets the edgesRenderer associated with the mesh
  94945. */
  94946. edgesRenderer: Nullable<EdgesRenderer>;
  94947. }
  94948. interface LinesMesh {
  94949. /**
  94950. * Enables the edge rendering mode on the mesh.
  94951. * This mode makes the mesh edges visible
  94952. * @param epsilon defines the maximal distance between two angles to detect a face
  94953. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94954. * @returns the currentAbstractMesh
  94955. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94956. */
  94957. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94958. }
  94959. interface InstancedLinesMesh {
  94960. /**
  94961. * Enables the edge rendering mode on the mesh.
  94962. * This mode makes the mesh edges visible
  94963. * @param epsilon defines the maximal distance between two angles to detect a face
  94964. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94965. * @returns the current InstancedLinesMesh
  94966. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94967. */
  94968. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94969. }
  94970. /**
  94971. * Defines the minimum contract an Edges renderer should follow.
  94972. */
  94973. export interface IEdgesRenderer extends IDisposable {
  94974. /**
  94975. * Gets or sets a boolean indicating if the edgesRenderer is active
  94976. */
  94977. isEnabled: boolean;
  94978. /**
  94979. * Renders the edges of the attached mesh,
  94980. */
  94981. render(): void;
  94982. /**
  94983. * Checks wether or not the edges renderer is ready to render.
  94984. * @return true if ready, otherwise false.
  94985. */
  94986. isReady(): boolean;
  94987. /**
  94988. * List of instances to render in case the source mesh has instances
  94989. */
  94990. customInstances: SmartArray<Matrix>;
  94991. }
  94992. /**
  94993. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94994. */
  94995. export class EdgesRenderer implements IEdgesRenderer {
  94996. /**
  94997. * Define the size of the edges with an orthographic camera
  94998. */
  94999. edgesWidthScalerForOrthographic: number;
  95000. /**
  95001. * Define the size of the edges with a perspective camera
  95002. */
  95003. edgesWidthScalerForPerspective: number;
  95004. protected _source: AbstractMesh;
  95005. protected _linesPositions: number[];
  95006. protected _linesNormals: number[];
  95007. protected _linesIndices: number[];
  95008. protected _epsilon: number;
  95009. protected _indicesCount: number;
  95010. protected _lineShader: ShaderMaterial;
  95011. protected _ib: DataBuffer;
  95012. protected _buffers: {
  95013. [key: string]: Nullable<VertexBuffer>;
  95014. };
  95015. protected _buffersForInstances: {
  95016. [key: string]: Nullable<VertexBuffer>;
  95017. };
  95018. protected _checkVerticesInsteadOfIndices: boolean;
  95019. private _meshRebuildObserver;
  95020. private _meshDisposeObserver;
  95021. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95022. isEnabled: boolean;
  95023. /**
  95024. * List of instances to render in case the source mesh has instances
  95025. */
  95026. customInstances: SmartArray<Matrix>;
  95027. private static GetShader;
  95028. /**
  95029. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95030. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95031. * @param source Mesh used to create edges
  95032. * @param epsilon sum of angles in adjacency to check for edge
  95033. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  95034. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95035. */
  95036. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  95037. protected _prepareRessources(): void;
  95038. /** @hidden */
  95039. _rebuild(): void;
  95040. /**
  95041. * Releases the required resources for the edges renderer
  95042. */
  95043. dispose(): void;
  95044. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95045. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95046. /**
  95047. * Checks if the pair of p0 and p1 is en edge
  95048. * @param faceIndex
  95049. * @param edge
  95050. * @param faceNormals
  95051. * @param p0
  95052. * @param p1
  95053. * @private
  95054. */
  95055. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95056. /**
  95057. * push line into the position, normal and index buffer
  95058. * @protected
  95059. */
  95060. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95061. /**
  95062. * Generates lines edges from adjacencjes
  95063. * @private
  95064. */
  95065. _generateEdgesLines(): void;
  95066. /**
  95067. * Checks wether or not the edges renderer is ready to render.
  95068. * @return true if ready, otherwise false.
  95069. */
  95070. isReady(): boolean;
  95071. /**
  95072. * Renders the edges of the attached mesh,
  95073. */
  95074. render(): void;
  95075. }
  95076. /**
  95077. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95078. */
  95079. export class LineEdgesRenderer extends EdgesRenderer {
  95080. /**
  95081. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95082. * @param source LineMesh used to generate edges
  95083. * @param epsilon not important (specified angle for edge detection)
  95084. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95085. */
  95086. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95087. /**
  95088. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95089. */
  95090. _generateEdgesLines(): void;
  95091. }
  95092. }
  95093. declare module BABYLON {
  95094. /**
  95095. * This represents the object necessary to create a rendering group.
  95096. * This is exclusively used and created by the rendering manager.
  95097. * To modify the behavior, you use the available helpers in your scene or meshes.
  95098. * @hidden
  95099. */
  95100. export class RenderingGroup {
  95101. index: number;
  95102. private static _zeroVector;
  95103. private _scene;
  95104. private _opaqueSubMeshes;
  95105. private _transparentSubMeshes;
  95106. private _alphaTestSubMeshes;
  95107. private _depthOnlySubMeshes;
  95108. private _particleSystems;
  95109. private _spriteManagers;
  95110. private _opaqueSortCompareFn;
  95111. private _alphaTestSortCompareFn;
  95112. private _transparentSortCompareFn;
  95113. private _renderOpaque;
  95114. private _renderAlphaTest;
  95115. private _renderTransparent;
  95116. /** @hidden */
  95117. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95118. onBeforeTransparentRendering: () => void;
  95119. /**
  95120. * Set the opaque sort comparison function.
  95121. * If null the sub meshes will be render in the order they were created
  95122. */
  95123. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95124. /**
  95125. * Set the alpha test sort comparison function.
  95126. * If null the sub meshes will be render in the order they were created
  95127. */
  95128. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95129. /**
  95130. * Set the transparent sort comparison function.
  95131. * If null the sub meshes will be render in the order they were created
  95132. */
  95133. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95134. /**
  95135. * Creates a new rendering group.
  95136. * @param index The rendering group index
  95137. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95138. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95139. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95140. */
  95141. 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>);
  95142. /**
  95143. * Render all the sub meshes contained in the group.
  95144. * @param customRenderFunction Used to override the default render behaviour of the group.
  95145. * @returns true if rendered some submeshes.
  95146. */
  95147. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95148. /**
  95149. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95150. * @param subMeshes The submeshes to render
  95151. */
  95152. private renderOpaqueSorted;
  95153. /**
  95154. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95155. * @param subMeshes The submeshes to render
  95156. */
  95157. private renderAlphaTestSorted;
  95158. /**
  95159. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95160. * @param subMeshes The submeshes to render
  95161. */
  95162. private renderTransparentSorted;
  95163. /**
  95164. * Renders the submeshes in a specified order.
  95165. * @param subMeshes The submeshes to sort before render
  95166. * @param sortCompareFn The comparison function use to sort
  95167. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95168. * @param transparent Specifies to activate blending if true
  95169. */
  95170. private static renderSorted;
  95171. /**
  95172. * Renders the submeshes in the order they were dispatched (no sort applied).
  95173. * @param subMeshes The submeshes to render
  95174. */
  95175. private static renderUnsorted;
  95176. /**
  95177. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95178. * are rendered back to front if in the same alpha index.
  95179. *
  95180. * @param a The first submesh
  95181. * @param b The second submesh
  95182. * @returns The result of the comparison
  95183. */
  95184. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95185. /**
  95186. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95187. * are rendered back to front.
  95188. *
  95189. * @param a The first submesh
  95190. * @param b The second submesh
  95191. * @returns The result of the comparison
  95192. */
  95193. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95194. /**
  95195. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95196. * are rendered front to back (prevent overdraw).
  95197. *
  95198. * @param a The first submesh
  95199. * @param b The second submesh
  95200. * @returns The result of the comparison
  95201. */
  95202. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95203. /**
  95204. * Resets the different lists of submeshes to prepare a new frame.
  95205. */
  95206. prepare(): void;
  95207. dispose(): void;
  95208. /**
  95209. * Inserts the submesh in its correct queue depending on its material.
  95210. * @param subMesh The submesh to dispatch
  95211. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95212. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95213. */
  95214. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95215. dispatchSprites(spriteManager: ISpriteManager): void;
  95216. dispatchParticles(particleSystem: IParticleSystem): void;
  95217. private _renderParticles;
  95218. private _renderSprites;
  95219. }
  95220. }
  95221. declare module BABYLON {
  95222. /**
  95223. * Interface describing the different options available in the rendering manager
  95224. * regarding Auto Clear between groups.
  95225. */
  95226. export interface IRenderingManagerAutoClearSetup {
  95227. /**
  95228. * Defines whether or not autoclear is enable.
  95229. */
  95230. autoClear: boolean;
  95231. /**
  95232. * Defines whether or not to autoclear the depth buffer.
  95233. */
  95234. depth: boolean;
  95235. /**
  95236. * Defines whether or not to autoclear the stencil buffer.
  95237. */
  95238. stencil: boolean;
  95239. }
  95240. /**
  95241. * This class is used by the onRenderingGroupObservable
  95242. */
  95243. export class RenderingGroupInfo {
  95244. /**
  95245. * The Scene that being rendered
  95246. */
  95247. scene: Scene;
  95248. /**
  95249. * The camera currently used for the rendering pass
  95250. */
  95251. camera: Nullable<Camera>;
  95252. /**
  95253. * The ID of the renderingGroup being processed
  95254. */
  95255. renderingGroupId: number;
  95256. }
  95257. /**
  95258. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95259. * It is enable to manage the different groups as well as the different necessary sort functions.
  95260. * This should not be used directly aside of the few static configurations
  95261. */
  95262. export class RenderingManager {
  95263. /**
  95264. * The max id used for rendering groups (not included)
  95265. */
  95266. static MAX_RENDERINGGROUPS: number;
  95267. /**
  95268. * The min id used for rendering groups (included)
  95269. */
  95270. static MIN_RENDERINGGROUPS: number;
  95271. /**
  95272. * Used to globally prevent autoclearing scenes.
  95273. */
  95274. static AUTOCLEAR: boolean;
  95275. /**
  95276. * @hidden
  95277. */
  95278. _useSceneAutoClearSetup: boolean;
  95279. private _scene;
  95280. private _renderingGroups;
  95281. private _depthStencilBufferAlreadyCleaned;
  95282. private _autoClearDepthStencil;
  95283. private _customOpaqueSortCompareFn;
  95284. private _customAlphaTestSortCompareFn;
  95285. private _customTransparentSortCompareFn;
  95286. private _renderingGroupInfo;
  95287. /**
  95288. * Instantiates a new rendering group for a particular scene
  95289. * @param scene Defines the scene the groups belongs to
  95290. */
  95291. constructor(scene: Scene);
  95292. private _clearDepthStencilBuffer;
  95293. /**
  95294. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95295. * @hidden
  95296. */
  95297. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95298. /**
  95299. * Resets the different information of the group to prepare a new frame
  95300. * @hidden
  95301. */
  95302. reset(): void;
  95303. /**
  95304. * Dispose and release the group and its associated resources.
  95305. * @hidden
  95306. */
  95307. dispose(): void;
  95308. /**
  95309. * Clear the info related to rendering groups preventing retention points during dispose.
  95310. */
  95311. freeRenderingGroups(): void;
  95312. private _prepareRenderingGroup;
  95313. /**
  95314. * Add a sprite manager to the rendering manager in order to render it this frame.
  95315. * @param spriteManager Define the sprite manager to render
  95316. */
  95317. dispatchSprites(spriteManager: ISpriteManager): void;
  95318. /**
  95319. * Add a particle system to the rendering manager in order to render it this frame.
  95320. * @param particleSystem Define the particle system to render
  95321. */
  95322. dispatchParticles(particleSystem: IParticleSystem): void;
  95323. /**
  95324. * Add a submesh to the manager in order to render it this frame
  95325. * @param subMesh The submesh to dispatch
  95326. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95327. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95328. */
  95329. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95330. /**
  95331. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95332. * This allowed control for front to back rendering or reversly depending of the special needs.
  95333. *
  95334. * @param renderingGroupId The rendering group id corresponding to its index
  95335. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95336. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95337. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95338. */
  95339. 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;
  95340. /**
  95341. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95342. *
  95343. * @param renderingGroupId The rendering group id corresponding to its index
  95344. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95345. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95346. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95347. */
  95348. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95349. /**
  95350. * Gets the current auto clear configuration for one rendering group of the rendering
  95351. * manager.
  95352. * @param index the rendering group index to get the information for
  95353. * @returns The auto clear setup for the requested rendering group
  95354. */
  95355. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95356. }
  95357. }
  95358. declare module BABYLON {
  95359. /**
  95360. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95361. */
  95362. export interface ICustomShaderOptions {
  95363. /**
  95364. * Gets or sets the custom shader name to use
  95365. */
  95366. shaderName: string;
  95367. /**
  95368. * The list of attribute names used in the shader
  95369. */
  95370. attributes?: string[];
  95371. /**
  95372. * The list of unifrom names used in the shader
  95373. */
  95374. uniforms?: string[];
  95375. /**
  95376. * The list of sampler names used in the shader
  95377. */
  95378. samplers?: string[];
  95379. /**
  95380. * The list of defines used in the shader
  95381. */
  95382. defines?: string[];
  95383. }
  95384. /**
  95385. * Interface to implement to create a shadow generator compatible with BJS.
  95386. */
  95387. export interface IShadowGenerator {
  95388. /**
  95389. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95390. * @returns The render target texture if present otherwise, null
  95391. */
  95392. getShadowMap(): Nullable<RenderTargetTexture>;
  95393. /**
  95394. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95395. * @param subMesh The submesh we want to render in the shadow map
  95396. * @param useInstances Defines wether will draw in the map using instances
  95397. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95398. * @returns true if ready otherwise, false
  95399. */
  95400. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95401. /**
  95402. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95403. * @param defines Defines of the material we want to update
  95404. * @param lightIndex Index of the light in the enabled light list of the material
  95405. */
  95406. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95407. /**
  95408. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95409. * defined in the generator but impacting the effect).
  95410. * It implies the unifroms available on the materials are the standard BJS ones.
  95411. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95412. * @param effect The effect we are binfing the information for
  95413. */
  95414. bindShadowLight(lightIndex: string, effect: Effect): void;
  95415. /**
  95416. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95417. * (eq to shadow prjection matrix * light transform matrix)
  95418. * @returns The transform matrix used to create the shadow map
  95419. */
  95420. getTransformMatrix(): Matrix;
  95421. /**
  95422. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95423. * Cube and 2D textures for instance.
  95424. */
  95425. recreateShadowMap(): void;
  95426. /**
  95427. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95428. * @param onCompiled Callback triggered at the and of the effects compilation
  95429. * @param options Sets of optional options forcing the compilation with different modes
  95430. */
  95431. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95432. useInstances: boolean;
  95433. }>): void;
  95434. /**
  95435. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95436. * @param options Sets of optional options forcing the compilation with different modes
  95437. * @returns A promise that resolves when the compilation completes
  95438. */
  95439. forceCompilationAsync(options?: Partial<{
  95440. useInstances: boolean;
  95441. }>): Promise<void>;
  95442. /**
  95443. * Serializes the shadow generator setup to a json object.
  95444. * @returns The serialized JSON object
  95445. */
  95446. serialize(): any;
  95447. /**
  95448. * Disposes the Shadow map and related Textures and effects.
  95449. */
  95450. dispose(): void;
  95451. }
  95452. /**
  95453. * Default implementation IShadowGenerator.
  95454. * This is the main object responsible of generating shadows in the framework.
  95455. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95456. */
  95457. export class ShadowGenerator implements IShadowGenerator {
  95458. /**
  95459. * Name of the shadow generator class
  95460. */
  95461. static CLASSNAME: string;
  95462. /**
  95463. * Shadow generator mode None: no filtering applied.
  95464. */
  95465. static readonly FILTER_NONE: number;
  95466. /**
  95467. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95469. */
  95470. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95471. /**
  95472. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95473. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95474. */
  95475. static readonly FILTER_POISSONSAMPLING: number;
  95476. /**
  95477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95478. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95479. */
  95480. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95481. /**
  95482. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95483. * edge artifacts on steep falloff.
  95484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95485. */
  95486. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95487. /**
  95488. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95489. * edge artifacts on steep falloff.
  95490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95491. */
  95492. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95493. /**
  95494. * Shadow generator mode PCF: Percentage Closer Filtering
  95495. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95496. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95497. */
  95498. static readonly FILTER_PCF: number;
  95499. /**
  95500. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95501. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95502. * Contact Hardening
  95503. */
  95504. static readonly FILTER_PCSS: number;
  95505. /**
  95506. * Reserved for PCF and PCSS
  95507. * Highest Quality.
  95508. *
  95509. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95510. *
  95511. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95512. */
  95513. static readonly QUALITY_HIGH: number;
  95514. /**
  95515. * Reserved for PCF and PCSS
  95516. * Good tradeoff for quality/perf cross devices
  95517. *
  95518. * Execute PCF on a 3*3 kernel.
  95519. *
  95520. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95521. */
  95522. static readonly QUALITY_MEDIUM: number;
  95523. /**
  95524. * Reserved for PCF and PCSS
  95525. * The lowest quality but the fastest.
  95526. *
  95527. * Execute PCF on a 1*1 kernel.
  95528. *
  95529. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95530. */
  95531. static readonly QUALITY_LOW: number;
  95532. /** Gets or sets the custom shader name to use */
  95533. customShaderOptions: ICustomShaderOptions;
  95534. /**
  95535. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95536. */
  95537. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95538. /**
  95539. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95540. */
  95541. onAfterShadowMapRenderObservable: Observable<Effect>;
  95542. /**
  95543. * Observable triggered before a mesh is rendered in the shadow map.
  95544. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95545. */
  95546. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95547. /**
  95548. * Observable triggered after a mesh is rendered in the shadow map.
  95549. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95550. */
  95551. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95552. protected _bias: number;
  95553. /**
  95554. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95555. */
  95556. get bias(): number;
  95557. /**
  95558. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95559. */
  95560. set bias(bias: number);
  95561. protected _normalBias: number;
  95562. /**
  95563. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95564. */
  95565. get normalBias(): number;
  95566. /**
  95567. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95568. */
  95569. set normalBias(normalBias: number);
  95570. protected _blurBoxOffset: number;
  95571. /**
  95572. * Gets the blur box offset: offset applied during the blur pass.
  95573. * Only useful if useKernelBlur = false
  95574. */
  95575. get blurBoxOffset(): number;
  95576. /**
  95577. * Sets the blur box offset: offset applied during the blur pass.
  95578. * Only useful if useKernelBlur = false
  95579. */
  95580. set blurBoxOffset(value: number);
  95581. protected _blurScale: number;
  95582. /**
  95583. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95584. * 2 means half of the size.
  95585. */
  95586. get blurScale(): number;
  95587. /**
  95588. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95589. * 2 means half of the size.
  95590. */
  95591. set blurScale(value: number);
  95592. protected _blurKernel: number;
  95593. /**
  95594. * Gets the blur kernel: kernel size of the blur pass.
  95595. * Only useful if useKernelBlur = true
  95596. */
  95597. get blurKernel(): number;
  95598. /**
  95599. * Sets the blur kernel: kernel size of the blur pass.
  95600. * Only useful if useKernelBlur = true
  95601. */
  95602. set blurKernel(value: number);
  95603. protected _useKernelBlur: boolean;
  95604. /**
  95605. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95606. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95607. */
  95608. get useKernelBlur(): boolean;
  95609. /**
  95610. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95611. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95612. */
  95613. set useKernelBlur(value: boolean);
  95614. protected _depthScale: number;
  95615. /**
  95616. * Gets the depth scale used in ESM mode.
  95617. */
  95618. get depthScale(): number;
  95619. /**
  95620. * Sets the depth scale used in ESM mode.
  95621. * This can override the scale stored on the light.
  95622. */
  95623. set depthScale(value: number);
  95624. protected _validateFilter(filter: number): number;
  95625. protected _filter: number;
  95626. /**
  95627. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95628. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95629. */
  95630. get filter(): number;
  95631. /**
  95632. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95633. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95634. */
  95635. set filter(value: number);
  95636. /**
  95637. * Gets if the current filter is set to Poisson Sampling.
  95638. */
  95639. get usePoissonSampling(): boolean;
  95640. /**
  95641. * Sets the current filter to Poisson Sampling.
  95642. */
  95643. set usePoissonSampling(value: boolean);
  95644. /**
  95645. * Gets if the current filter is set to ESM.
  95646. */
  95647. get useExponentialShadowMap(): boolean;
  95648. /**
  95649. * Sets the current filter is to ESM.
  95650. */
  95651. set useExponentialShadowMap(value: boolean);
  95652. /**
  95653. * Gets if the current filter is set to filtered ESM.
  95654. */
  95655. get useBlurExponentialShadowMap(): boolean;
  95656. /**
  95657. * Gets if the current filter is set to filtered ESM.
  95658. */
  95659. set useBlurExponentialShadowMap(value: boolean);
  95660. /**
  95661. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95662. * exponential to prevent steep falloff artifacts).
  95663. */
  95664. get useCloseExponentialShadowMap(): boolean;
  95665. /**
  95666. * Sets the current filter to "close ESM" (using the inverse of the
  95667. * exponential to prevent steep falloff artifacts).
  95668. */
  95669. set useCloseExponentialShadowMap(value: boolean);
  95670. /**
  95671. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95672. * exponential to prevent steep falloff artifacts).
  95673. */
  95674. get useBlurCloseExponentialShadowMap(): boolean;
  95675. /**
  95676. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95677. * exponential to prevent steep falloff artifacts).
  95678. */
  95679. set useBlurCloseExponentialShadowMap(value: boolean);
  95680. /**
  95681. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95682. */
  95683. get usePercentageCloserFiltering(): boolean;
  95684. /**
  95685. * Sets the current filter to "PCF" (percentage closer filtering).
  95686. */
  95687. set usePercentageCloserFiltering(value: boolean);
  95688. protected _filteringQuality: number;
  95689. /**
  95690. * Gets the PCF or PCSS Quality.
  95691. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95692. */
  95693. get filteringQuality(): number;
  95694. /**
  95695. * Sets the PCF or PCSS Quality.
  95696. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95697. */
  95698. set filteringQuality(filteringQuality: number);
  95699. /**
  95700. * Gets if the current filter is set to "PCSS" (contact hardening).
  95701. */
  95702. get useContactHardeningShadow(): boolean;
  95703. /**
  95704. * Sets the current filter to "PCSS" (contact hardening).
  95705. */
  95706. set useContactHardeningShadow(value: boolean);
  95707. protected _contactHardeningLightSizeUVRatio: number;
  95708. /**
  95709. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95710. * Using a ratio helps keeping shape stability independently of the map size.
  95711. *
  95712. * It does not account for the light projection as it was having too much
  95713. * instability during the light setup or during light position changes.
  95714. *
  95715. * Only valid if useContactHardeningShadow is true.
  95716. */
  95717. get contactHardeningLightSizeUVRatio(): number;
  95718. /**
  95719. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95720. * Using a ratio helps keeping shape stability independently of the map size.
  95721. *
  95722. * It does not account for the light projection as it was having too much
  95723. * instability during the light setup or during light position changes.
  95724. *
  95725. * Only valid if useContactHardeningShadow is true.
  95726. */
  95727. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95728. protected _darkness: number;
  95729. /** Gets or sets the actual darkness of a shadow */
  95730. get darkness(): number;
  95731. set darkness(value: number);
  95732. /**
  95733. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95734. * 0 means strongest and 1 would means no shadow.
  95735. * @returns the darkness.
  95736. */
  95737. getDarkness(): number;
  95738. /**
  95739. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95740. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95741. * @returns the shadow generator allowing fluent coding.
  95742. */
  95743. setDarkness(darkness: number): ShadowGenerator;
  95744. protected _transparencyShadow: boolean;
  95745. /** Gets or sets the ability to have transparent shadow */
  95746. get transparencyShadow(): boolean;
  95747. set transparencyShadow(value: boolean);
  95748. /**
  95749. * Sets the ability to have transparent shadow (boolean).
  95750. * @param transparent True if transparent else False
  95751. * @returns the shadow generator allowing fluent coding
  95752. */
  95753. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95754. /**
  95755. * Enables or disables shadows with varying strength based on the transparency
  95756. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95757. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95758. * mesh.visibility * alphaTexture.a
  95759. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95760. */
  95761. enableSoftTransparentShadow: boolean;
  95762. protected _shadowMap: Nullable<RenderTargetTexture>;
  95763. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95764. /**
  95765. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95766. * @returns The render target texture if present otherwise, null
  95767. */
  95768. getShadowMap(): Nullable<RenderTargetTexture>;
  95769. /**
  95770. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95771. * @returns The render target texture if the shadow map is present otherwise, null
  95772. */
  95773. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95774. /**
  95775. * Gets the class name of that object
  95776. * @returns "ShadowGenerator"
  95777. */
  95778. getClassName(): string;
  95779. /**
  95780. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95781. * @param mesh Mesh to add
  95782. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95783. * @returns the Shadow Generator itself
  95784. */
  95785. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95786. /**
  95787. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95788. * @param mesh Mesh to remove
  95789. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95790. * @returns the Shadow Generator itself
  95791. */
  95792. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95793. /**
  95794. * Controls the extent to which the shadows fade out at the edge of the frustum
  95795. */
  95796. frustumEdgeFalloff: number;
  95797. protected _light: IShadowLight;
  95798. /**
  95799. * Returns the associated light object.
  95800. * @returns the light generating the shadow
  95801. */
  95802. getLight(): IShadowLight;
  95803. /**
  95804. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95805. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95806. * It might on the other hand introduce peter panning.
  95807. */
  95808. forceBackFacesOnly: boolean;
  95809. protected _scene: Scene;
  95810. protected _lightDirection: Vector3;
  95811. protected _effect: Effect;
  95812. protected _viewMatrix: Matrix;
  95813. protected _projectionMatrix: Matrix;
  95814. protected _transformMatrix: Matrix;
  95815. protected _cachedPosition: Vector3;
  95816. protected _cachedDirection: Vector3;
  95817. protected _cachedDefines: string;
  95818. protected _currentRenderID: number;
  95819. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95820. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95821. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95822. protected _blurPostProcesses: PostProcess[];
  95823. protected _mapSize: number;
  95824. protected _currentFaceIndex: number;
  95825. protected _currentFaceIndexCache: number;
  95826. protected _textureType: number;
  95827. protected _defaultTextureMatrix: Matrix;
  95828. protected _storedUniqueId: Nullable<number>;
  95829. /** @hidden */
  95830. static _SceneComponentInitialization: (scene: Scene) => void;
  95831. /**
  95832. * Creates a ShadowGenerator object.
  95833. * A ShadowGenerator is the required tool to use the shadows.
  95834. * Each light casting shadows needs to use its own ShadowGenerator.
  95835. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95836. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95837. * @param light The light object generating the shadows.
  95838. * @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.
  95839. */
  95840. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95841. protected _initializeGenerator(): void;
  95842. protected _createTargetRenderTexture(): void;
  95843. protected _initializeShadowMap(): void;
  95844. protected _initializeBlurRTTAndPostProcesses(): void;
  95845. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95846. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95847. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95848. protected _applyFilterValues(): void;
  95849. /**
  95850. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95851. * @param onCompiled Callback triggered at the and of the effects compilation
  95852. * @param options Sets of optional options forcing the compilation with different modes
  95853. */
  95854. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95855. useInstances: boolean;
  95856. }>): void;
  95857. /**
  95858. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95859. * @param options Sets of optional options forcing the compilation with different modes
  95860. * @returns A promise that resolves when the compilation completes
  95861. */
  95862. forceCompilationAsync(options?: Partial<{
  95863. useInstances: boolean;
  95864. }>): Promise<void>;
  95865. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95866. private _prepareShadowDefines;
  95867. /**
  95868. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95869. * @param subMesh The submesh we want to render in the shadow map
  95870. * @param useInstances Defines wether will draw in the map using instances
  95871. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95872. * @returns true if ready otherwise, false
  95873. */
  95874. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95875. /**
  95876. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95877. * @param defines Defines of the material we want to update
  95878. * @param lightIndex Index of the light in the enabled light list of the material
  95879. */
  95880. prepareDefines(defines: any, lightIndex: number): void;
  95881. /**
  95882. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95883. * defined in the generator but impacting the effect).
  95884. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95885. * @param effect The effect we are binfing the information for
  95886. */
  95887. bindShadowLight(lightIndex: string, effect: Effect): void;
  95888. /**
  95889. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95890. * (eq to shadow prjection matrix * light transform matrix)
  95891. * @returns The transform matrix used to create the shadow map
  95892. */
  95893. getTransformMatrix(): Matrix;
  95894. /**
  95895. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95896. * Cube and 2D textures for instance.
  95897. */
  95898. recreateShadowMap(): void;
  95899. protected _disposeBlurPostProcesses(): void;
  95900. protected _disposeRTTandPostProcesses(): void;
  95901. /**
  95902. * Disposes the ShadowGenerator.
  95903. * Returns nothing.
  95904. */
  95905. dispose(): void;
  95906. /**
  95907. * Serializes the shadow generator setup to a json object.
  95908. * @returns The serialized JSON object
  95909. */
  95910. serialize(): any;
  95911. /**
  95912. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95913. * @param parsedShadowGenerator The JSON object to parse
  95914. * @param scene The scene to create the shadow map for
  95915. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95916. * @returns The parsed shadow generator
  95917. */
  95918. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95919. }
  95920. }
  95921. declare module BABYLON {
  95922. /**
  95923. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95924. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95925. * 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.
  95926. */
  95927. export abstract class Light extends Node {
  95928. /**
  95929. * Falloff Default: light is falling off following the material specification:
  95930. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95931. */
  95932. static readonly FALLOFF_DEFAULT: number;
  95933. /**
  95934. * Falloff Physical: light is falling off following the inverse squared distance law.
  95935. */
  95936. static readonly FALLOFF_PHYSICAL: number;
  95937. /**
  95938. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95939. * to enhance interoperability with other engines.
  95940. */
  95941. static readonly FALLOFF_GLTF: number;
  95942. /**
  95943. * Falloff Standard: light is falling off like in the standard material
  95944. * to enhance interoperability with other materials.
  95945. */
  95946. static readonly FALLOFF_STANDARD: number;
  95947. /**
  95948. * If every light affecting the material is in this lightmapMode,
  95949. * material.lightmapTexture adds or multiplies
  95950. * (depends on material.useLightmapAsShadowmap)
  95951. * after every other light calculations.
  95952. */
  95953. static readonly LIGHTMAP_DEFAULT: number;
  95954. /**
  95955. * material.lightmapTexture as only diffuse lighting from this light
  95956. * adds only specular lighting from this light
  95957. * adds dynamic shadows
  95958. */
  95959. static readonly LIGHTMAP_SPECULAR: number;
  95960. /**
  95961. * material.lightmapTexture as only lighting
  95962. * no light calculation from this light
  95963. * only adds dynamic shadows from this light
  95964. */
  95965. static readonly LIGHTMAP_SHADOWSONLY: number;
  95966. /**
  95967. * Each light type uses the default quantity according to its type:
  95968. * point/spot lights use luminous intensity
  95969. * directional lights use illuminance
  95970. */
  95971. static readonly INTENSITYMODE_AUTOMATIC: number;
  95972. /**
  95973. * lumen (lm)
  95974. */
  95975. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95976. /**
  95977. * candela (lm/sr)
  95978. */
  95979. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95980. /**
  95981. * lux (lm/m^2)
  95982. */
  95983. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95984. /**
  95985. * nit (cd/m^2)
  95986. */
  95987. static readonly INTENSITYMODE_LUMINANCE: number;
  95988. /**
  95989. * Light type const id of the point light.
  95990. */
  95991. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95992. /**
  95993. * Light type const id of the directional light.
  95994. */
  95995. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95996. /**
  95997. * Light type const id of the spot light.
  95998. */
  95999. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96000. /**
  96001. * Light type const id of the hemispheric light.
  96002. */
  96003. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96004. /**
  96005. * Diffuse gives the basic color to an object.
  96006. */
  96007. diffuse: Color3;
  96008. /**
  96009. * Specular produces a highlight color on an object.
  96010. * Note: This is note affecting PBR materials.
  96011. */
  96012. specular: Color3;
  96013. /**
  96014. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96015. * falling off base on range or angle.
  96016. * This can be set to any values in Light.FALLOFF_x.
  96017. *
  96018. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96019. * other types of materials.
  96020. */
  96021. falloffType: number;
  96022. /**
  96023. * Strength of the light.
  96024. * Note: By default it is define in the framework own unit.
  96025. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96026. */
  96027. intensity: number;
  96028. private _range;
  96029. protected _inverseSquaredRange: number;
  96030. /**
  96031. * Defines how far from the source the light is impacting in scene units.
  96032. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96033. */
  96034. get range(): number;
  96035. /**
  96036. * Defines how far from the source the light is impacting in scene units.
  96037. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96038. */
  96039. set range(value: number);
  96040. /**
  96041. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96042. * of light.
  96043. */
  96044. private _photometricScale;
  96045. private _intensityMode;
  96046. /**
  96047. * Gets the photometric scale used to interpret the intensity.
  96048. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96049. */
  96050. get intensityMode(): number;
  96051. /**
  96052. * Sets the photometric scale used to interpret the intensity.
  96053. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96054. */
  96055. set intensityMode(value: number);
  96056. private _radius;
  96057. /**
  96058. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96059. */
  96060. get radius(): number;
  96061. /**
  96062. * sets the light radius used by PBR Materials to simulate soft area lights.
  96063. */
  96064. set radius(value: number);
  96065. private _renderPriority;
  96066. /**
  96067. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96068. * exceeding the number allowed of the materials.
  96069. */
  96070. renderPriority: number;
  96071. private _shadowEnabled;
  96072. /**
  96073. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96074. * the current shadow generator.
  96075. */
  96076. get shadowEnabled(): boolean;
  96077. /**
  96078. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96079. * the current shadow generator.
  96080. */
  96081. set shadowEnabled(value: boolean);
  96082. private _includedOnlyMeshes;
  96083. /**
  96084. * Gets the only meshes impacted by this light.
  96085. */
  96086. get includedOnlyMeshes(): AbstractMesh[];
  96087. /**
  96088. * Sets the only meshes impacted by this light.
  96089. */
  96090. set includedOnlyMeshes(value: AbstractMesh[]);
  96091. private _excludedMeshes;
  96092. /**
  96093. * Gets the meshes not impacted by this light.
  96094. */
  96095. get excludedMeshes(): AbstractMesh[];
  96096. /**
  96097. * Sets the meshes not impacted by this light.
  96098. */
  96099. set excludedMeshes(value: AbstractMesh[]);
  96100. private _excludeWithLayerMask;
  96101. /**
  96102. * Gets the layer id use to find what meshes are not impacted by the light.
  96103. * Inactive if 0
  96104. */
  96105. get excludeWithLayerMask(): number;
  96106. /**
  96107. * Sets the layer id use to find what meshes are not impacted by the light.
  96108. * Inactive if 0
  96109. */
  96110. set excludeWithLayerMask(value: number);
  96111. private _includeOnlyWithLayerMask;
  96112. /**
  96113. * Gets the layer id use to find what meshes are impacted by the light.
  96114. * Inactive if 0
  96115. */
  96116. get includeOnlyWithLayerMask(): number;
  96117. /**
  96118. * Sets the layer id use to find what meshes are impacted by the light.
  96119. * Inactive if 0
  96120. */
  96121. set includeOnlyWithLayerMask(value: number);
  96122. private _lightmapMode;
  96123. /**
  96124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96125. */
  96126. get lightmapMode(): number;
  96127. /**
  96128. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96129. */
  96130. set lightmapMode(value: number);
  96131. /**
  96132. * Shadow generator associted to the light.
  96133. * @hidden Internal use only.
  96134. */
  96135. _shadowGenerator: Nullable<IShadowGenerator>;
  96136. /**
  96137. * @hidden Internal use only.
  96138. */
  96139. _excludedMeshesIds: string[];
  96140. /**
  96141. * @hidden Internal use only.
  96142. */
  96143. _includedOnlyMeshesIds: string[];
  96144. /**
  96145. * The current light unifom buffer.
  96146. * @hidden Internal use only.
  96147. */
  96148. _uniformBuffer: UniformBuffer;
  96149. /** @hidden */
  96150. _renderId: number;
  96151. /**
  96152. * Creates a Light object in the scene.
  96153. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96154. * @param name The firendly name of the light
  96155. * @param scene The scene the light belongs too
  96156. */
  96157. constructor(name: string, scene: Scene);
  96158. protected abstract _buildUniformLayout(): void;
  96159. /**
  96160. * Sets the passed Effect "effect" with the Light information.
  96161. * @param effect The effect to update
  96162. * @param lightIndex The index of the light in the effect to update
  96163. * @returns The light
  96164. */
  96165. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96166. /**
  96167. * Sets the passed Effect "effect" with the Light textures.
  96168. * @param effect The effect to update
  96169. * @param lightIndex The index of the light in the effect to update
  96170. * @returns The light
  96171. */
  96172. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96173. /**
  96174. * Binds the lights information from the scene to the effect for the given mesh.
  96175. * @param lightIndex Light index
  96176. * @param scene The scene where the light belongs to
  96177. * @param effect The effect we are binding the data to
  96178. * @param useSpecular Defines if specular is supported
  96179. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96180. */
  96181. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96182. /**
  96183. * Sets the passed Effect "effect" with the Light information.
  96184. * @param effect The effect to update
  96185. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96186. * @returns The light
  96187. */
  96188. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96189. /**
  96190. * Returns the string "Light".
  96191. * @returns the class name
  96192. */
  96193. getClassName(): string;
  96194. /** @hidden */
  96195. readonly _isLight: boolean;
  96196. /**
  96197. * Converts the light information to a readable string for debug purpose.
  96198. * @param fullDetails Supports for multiple levels of logging within scene loading
  96199. * @returns the human readable light info
  96200. */
  96201. toString(fullDetails?: boolean): string;
  96202. /** @hidden */
  96203. protected _syncParentEnabledState(): void;
  96204. /**
  96205. * Set the enabled state of this node.
  96206. * @param value - the new enabled state
  96207. */
  96208. setEnabled(value: boolean): void;
  96209. /**
  96210. * Returns the Light associated shadow generator if any.
  96211. * @return the associated shadow generator.
  96212. */
  96213. getShadowGenerator(): Nullable<IShadowGenerator>;
  96214. /**
  96215. * Returns a Vector3, the absolute light position in the World.
  96216. * @returns the world space position of the light
  96217. */
  96218. getAbsolutePosition(): Vector3;
  96219. /**
  96220. * Specifies if the light will affect the passed mesh.
  96221. * @param mesh The mesh to test against the light
  96222. * @return true the mesh is affected otherwise, false.
  96223. */
  96224. canAffectMesh(mesh: AbstractMesh): boolean;
  96225. /**
  96226. * Sort function to order lights for rendering.
  96227. * @param a First Light object to compare to second.
  96228. * @param b Second Light object to compare first.
  96229. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96230. */
  96231. static CompareLightsPriority(a: Light, b: Light): number;
  96232. /**
  96233. * Releases resources associated with this node.
  96234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96236. */
  96237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96238. /**
  96239. * Returns the light type ID (integer).
  96240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96241. */
  96242. getTypeID(): number;
  96243. /**
  96244. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96245. * @returns the scaled intensity in intensity mode unit
  96246. */
  96247. getScaledIntensity(): number;
  96248. /**
  96249. * Returns a new Light object, named "name", from the current one.
  96250. * @param name The name of the cloned light
  96251. * @param newParent The parent of this light, if it has one
  96252. * @returns the new created light
  96253. */
  96254. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96255. /**
  96256. * Serializes the current light into a Serialization object.
  96257. * @returns the serialized object.
  96258. */
  96259. serialize(): any;
  96260. /**
  96261. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96262. * This new light is named "name" and added to the passed scene.
  96263. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96264. * @param name The friendly name of the light
  96265. * @param scene The scene the new light will belong to
  96266. * @returns the constructor function
  96267. */
  96268. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96269. /**
  96270. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96271. * @param parsedLight The JSON representation of the light
  96272. * @param scene The scene to create the parsed light in
  96273. * @returns the created light after parsing
  96274. */
  96275. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96276. private _hookArrayForExcluded;
  96277. private _hookArrayForIncludedOnly;
  96278. private _resyncMeshes;
  96279. /**
  96280. * Forces the meshes to update their light related information in their rendering used effects
  96281. * @hidden Internal Use Only
  96282. */
  96283. _markMeshesAsLightDirty(): void;
  96284. /**
  96285. * Recomputes the cached photometric scale if needed.
  96286. */
  96287. private _computePhotometricScale;
  96288. /**
  96289. * Returns the Photometric Scale according to the light type and intensity mode.
  96290. */
  96291. private _getPhotometricScale;
  96292. /**
  96293. * Reorder the light in the scene according to their defined priority.
  96294. * @hidden Internal Use Only
  96295. */
  96296. _reorderLightsInScene(): void;
  96297. /**
  96298. * Prepares the list of defines specific to the light type.
  96299. * @param defines the list of defines
  96300. * @param lightIndex defines the index of the light for the effect
  96301. */
  96302. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96303. }
  96304. }
  96305. declare module BABYLON {
  96306. /**
  96307. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96308. * This is the base of the follow, arc rotate cameras and Free camera
  96309. * @see https://doc.babylonjs.com/features/cameras
  96310. */
  96311. export class TargetCamera extends Camera {
  96312. private static _RigCamTransformMatrix;
  96313. private static _TargetTransformMatrix;
  96314. private static _TargetFocalPoint;
  96315. private _tmpUpVector;
  96316. private _tmpTargetVector;
  96317. /**
  96318. * Define the current direction the camera is moving to
  96319. */
  96320. cameraDirection: Vector3;
  96321. /**
  96322. * Define the current rotation the camera is rotating to
  96323. */
  96324. cameraRotation: Vector2;
  96325. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96326. ignoreParentScaling: boolean;
  96327. /**
  96328. * When set, the up vector of the camera will be updated by the rotation of the camera
  96329. */
  96330. updateUpVectorFromRotation: boolean;
  96331. private _tmpQuaternion;
  96332. /**
  96333. * Define the current rotation of the camera
  96334. */
  96335. rotation: Vector3;
  96336. /**
  96337. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96338. */
  96339. rotationQuaternion: Quaternion;
  96340. /**
  96341. * Define the current speed of the camera
  96342. */
  96343. speed: number;
  96344. /**
  96345. * Add constraint to the camera to prevent it to move freely in all directions and
  96346. * around all axis.
  96347. */
  96348. noRotationConstraint: boolean;
  96349. /**
  96350. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96351. * panning
  96352. */
  96353. invertRotation: boolean;
  96354. /**
  96355. * Speed multiplier for inverse camera panning
  96356. */
  96357. inverseRotationSpeed: number;
  96358. /**
  96359. * Define the current target of the camera as an object or a position.
  96360. */
  96361. lockedTarget: any;
  96362. /** @hidden */
  96363. _currentTarget: Vector3;
  96364. /** @hidden */
  96365. _initialFocalDistance: number;
  96366. /** @hidden */
  96367. _viewMatrix: Matrix;
  96368. /** @hidden */
  96369. _camMatrix: Matrix;
  96370. /** @hidden */
  96371. _cameraTransformMatrix: Matrix;
  96372. /** @hidden */
  96373. _cameraRotationMatrix: Matrix;
  96374. /** @hidden */
  96375. _referencePoint: Vector3;
  96376. /** @hidden */
  96377. _transformedReferencePoint: Vector3;
  96378. /** @hidden */
  96379. _reset: () => void;
  96380. private _defaultUp;
  96381. /**
  96382. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96383. * This is the base of the follow, arc rotate cameras and Free camera
  96384. * @see https://doc.babylonjs.com/features/cameras
  96385. * @param name Defines the name of the camera in the scene
  96386. * @param position Defines the start position of the camera in the scene
  96387. * @param scene Defines the scene the camera belongs to
  96388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96389. */
  96390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96391. /**
  96392. * Gets the position in front of the camera at a given distance.
  96393. * @param distance The distance from the camera we want the position to be
  96394. * @returns the position
  96395. */
  96396. getFrontPosition(distance: number): Vector3;
  96397. /** @hidden */
  96398. _getLockedTargetPosition(): Nullable<Vector3>;
  96399. private _storedPosition;
  96400. private _storedRotation;
  96401. private _storedRotationQuaternion;
  96402. /**
  96403. * Store current camera state of the camera (fov, position, rotation, etc..)
  96404. * @returns the camera
  96405. */
  96406. storeState(): Camera;
  96407. /**
  96408. * Restored camera state. You must call storeState() first
  96409. * @returns whether it was successful or not
  96410. * @hidden
  96411. */
  96412. _restoreStateValues(): boolean;
  96413. /** @hidden */
  96414. _initCache(): void;
  96415. /** @hidden */
  96416. _updateCache(ignoreParentClass?: boolean): void;
  96417. /** @hidden */
  96418. _isSynchronizedViewMatrix(): boolean;
  96419. /** @hidden */
  96420. _computeLocalCameraSpeed(): number;
  96421. /**
  96422. * Defines the target the camera should look at.
  96423. * @param target Defines the new target as a Vector or a mesh
  96424. */
  96425. setTarget(target: Vector3): void;
  96426. /**
  96427. * Return the current target position of the camera. This value is expressed in local space.
  96428. * @returns the target position
  96429. */
  96430. getTarget(): Vector3;
  96431. /** @hidden */
  96432. _decideIfNeedsToMove(): boolean;
  96433. /** @hidden */
  96434. _updatePosition(): void;
  96435. /** @hidden */
  96436. _checkInputs(): void;
  96437. protected _updateCameraRotationMatrix(): void;
  96438. /**
  96439. * 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)
  96440. * @returns the current camera
  96441. */
  96442. private _rotateUpVectorWithCameraRotationMatrix;
  96443. private _cachedRotationZ;
  96444. private _cachedQuaternionRotationZ;
  96445. /** @hidden */
  96446. _getViewMatrix(): Matrix;
  96447. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96448. /**
  96449. * @hidden
  96450. */
  96451. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96452. /**
  96453. * @hidden
  96454. */
  96455. _updateRigCameras(): void;
  96456. private _getRigCamPositionAndTarget;
  96457. /**
  96458. * Gets the current object class name.
  96459. * @return the class name
  96460. */
  96461. getClassName(): string;
  96462. }
  96463. }
  96464. declare module BABYLON {
  96465. /**
  96466. * Gather the list of keyboard event types as constants.
  96467. */
  96468. export class KeyboardEventTypes {
  96469. /**
  96470. * The keydown event is fired when a key becomes active (pressed).
  96471. */
  96472. static readonly KEYDOWN: number;
  96473. /**
  96474. * The keyup event is fired when a key has been released.
  96475. */
  96476. static readonly KEYUP: number;
  96477. }
  96478. /**
  96479. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96480. */
  96481. export class KeyboardInfo {
  96482. /**
  96483. * Defines the type of event (KeyboardEventTypes)
  96484. */
  96485. type: number;
  96486. /**
  96487. * Defines the related dom event
  96488. */
  96489. event: KeyboardEvent;
  96490. /**
  96491. * Instantiates a new keyboard info.
  96492. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96493. * @param type Defines the type of event (KeyboardEventTypes)
  96494. * @param event Defines the related dom event
  96495. */
  96496. constructor(
  96497. /**
  96498. * Defines the type of event (KeyboardEventTypes)
  96499. */
  96500. type: number,
  96501. /**
  96502. * Defines the related dom event
  96503. */
  96504. event: KeyboardEvent);
  96505. }
  96506. /**
  96507. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96508. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96509. */
  96510. export class KeyboardInfoPre extends KeyboardInfo {
  96511. /**
  96512. * Defines the type of event (KeyboardEventTypes)
  96513. */
  96514. type: number;
  96515. /**
  96516. * Defines the related dom event
  96517. */
  96518. event: KeyboardEvent;
  96519. /**
  96520. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96521. */
  96522. skipOnPointerObservable: boolean;
  96523. /**
  96524. * Instantiates a new keyboard pre info.
  96525. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96526. * @param type Defines the type of event (KeyboardEventTypes)
  96527. * @param event Defines the related dom event
  96528. */
  96529. constructor(
  96530. /**
  96531. * Defines the type of event (KeyboardEventTypes)
  96532. */
  96533. type: number,
  96534. /**
  96535. * Defines the related dom event
  96536. */
  96537. event: KeyboardEvent);
  96538. }
  96539. }
  96540. declare module BABYLON {
  96541. /**
  96542. * Manage the keyboard inputs to control the movement of a free camera.
  96543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96544. */
  96545. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96546. /**
  96547. * Defines the camera the input is attached to.
  96548. */
  96549. camera: FreeCamera;
  96550. /**
  96551. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96552. */
  96553. keysUp: number[];
  96554. /**
  96555. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96556. */
  96557. keysUpward: number[];
  96558. /**
  96559. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96560. */
  96561. keysDown: number[];
  96562. /**
  96563. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96564. */
  96565. keysDownward: number[];
  96566. /**
  96567. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96568. */
  96569. keysLeft: number[];
  96570. /**
  96571. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96572. */
  96573. keysRight: number[];
  96574. private _keys;
  96575. private _onCanvasBlurObserver;
  96576. private _onKeyboardObserver;
  96577. private _engine;
  96578. private _scene;
  96579. /**
  96580. * Attach the input controls to a specific dom element to get the input from.
  96581. * @param element Defines the element the controls should be listened from
  96582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96583. */
  96584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96585. /**
  96586. * Detach the current controls from the specified dom element.
  96587. * @param element Defines the element to stop listening the inputs from
  96588. */
  96589. detachControl(element: Nullable<HTMLElement>): void;
  96590. /**
  96591. * Update the current camera state depending on the inputs that have been used this frame.
  96592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96593. */
  96594. checkInputs(): void;
  96595. /**
  96596. * Gets the class name of the current intput.
  96597. * @returns the class name
  96598. */
  96599. getClassName(): string;
  96600. /** @hidden */
  96601. _onLostFocus(): void;
  96602. /**
  96603. * Get the friendly name associated with the input class.
  96604. * @returns the input friendly name
  96605. */
  96606. getSimpleName(): string;
  96607. }
  96608. }
  96609. declare module BABYLON {
  96610. /**
  96611. * Gather the list of pointer event types as constants.
  96612. */
  96613. export class PointerEventTypes {
  96614. /**
  96615. * 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.
  96616. */
  96617. static readonly POINTERDOWN: number;
  96618. /**
  96619. * The pointerup event is fired when a pointer is no longer active.
  96620. */
  96621. static readonly POINTERUP: number;
  96622. /**
  96623. * The pointermove event is fired when a pointer changes coordinates.
  96624. */
  96625. static readonly POINTERMOVE: number;
  96626. /**
  96627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96628. */
  96629. static readonly POINTERWHEEL: number;
  96630. /**
  96631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96632. */
  96633. static readonly POINTERPICK: number;
  96634. /**
  96635. * The pointertap event is fired when a the object has been touched and released without drag.
  96636. */
  96637. static readonly POINTERTAP: number;
  96638. /**
  96639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96640. */
  96641. static readonly POINTERDOUBLETAP: number;
  96642. }
  96643. /**
  96644. * Base class of pointer info types.
  96645. */
  96646. export class PointerInfoBase {
  96647. /**
  96648. * Defines the type of event (PointerEventTypes)
  96649. */
  96650. type: number;
  96651. /**
  96652. * Defines the related dom event
  96653. */
  96654. event: PointerEvent | MouseWheelEvent;
  96655. /**
  96656. * Instantiates the base class of pointers info.
  96657. * @param type Defines the type of event (PointerEventTypes)
  96658. * @param event Defines the related dom event
  96659. */
  96660. constructor(
  96661. /**
  96662. * Defines the type of event (PointerEventTypes)
  96663. */
  96664. type: number,
  96665. /**
  96666. * Defines the related dom event
  96667. */
  96668. event: PointerEvent | MouseWheelEvent);
  96669. }
  96670. /**
  96671. * This class is used to store pointer related info for the onPrePointerObservable event.
  96672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96673. */
  96674. export class PointerInfoPre extends PointerInfoBase {
  96675. /**
  96676. * Ray from a pointer if availible (eg. 6dof controller)
  96677. */
  96678. ray: Nullable<Ray>;
  96679. /**
  96680. * Defines the local position of the pointer on the canvas.
  96681. */
  96682. localPosition: Vector2;
  96683. /**
  96684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96685. */
  96686. skipOnPointerObservable: boolean;
  96687. /**
  96688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96689. * @param type Defines the type of event (PointerEventTypes)
  96690. * @param event Defines the related dom event
  96691. * @param localX Defines the local x coordinates of the pointer when the event occured
  96692. * @param localY Defines the local y coordinates of the pointer when the event occured
  96693. */
  96694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96695. }
  96696. /**
  96697. * This type contains all the data related to a pointer event in Babylon.js.
  96698. * 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.
  96699. */
  96700. export class PointerInfo extends PointerInfoBase {
  96701. /**
  96702. * Defines the picking info associated to the info (if any)\
  96703. */
  96704. pickInfo: Nullable<PickingInfo>;
  96705. /**
  96706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96707. * @param type Defines the type of event (PointerEventTypes)
  96708. * @param event Defines the related dom event
  96709. * @param pickInfo Defines the picking info associated to the info (if any)\
  96710. */
  96711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96712. /**
  96713. * Defines the picking info associated to the info (if any)\
  96714. */
  96715. pickInfo: Nullable<PickingInfo>);
  96716. }
  96717. /**
  96718. * Data relating to a touch event on the screen.
  96719. */
  96720. export interface PointerTouch {
  96721. /**
  96722. * X coordinate of touch.
  96723. */
  96724. x: number;
  96725. /**
  96726. * Y coordinate of touch.
  96727. */
  96728. y: number;
  96729. /**
  96730. * Id of touch. Unique for each finger.
  96731. */
  96732. pointerId: number;
  96733. /**
  96734. * Event type passed from DOM.
  96735. */
  96736. type: any;
  96737. }
  96738. }
  96739. declare module BABYLON {
  96740. /**
  96741. * Manage the mouse inputs to control the movement of a free camera.
  96742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96743. */
  96744. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96745. /**
  96746. * Define if touch is enabled in the mouse input
  96747. */
  96748. touchEnabled: boolean;
  96749. /**
  96750. * Defines the camera the input is attached to.
  96751. */
  96752. camera: FreeCamera;
  96753. /**
  96754. * Defines the buttons associated with the input to handle camera move.
  96755. */
  96756. buttons: number[];
  96757. /**
  96758. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96759. */
  96760. angularSensibility: number;
  96761. private _pointerInput;
  96762. private _onMouseMove;
  96763. private _observer;
  96764. private previousPosition;
  96765. /**
  96766. * Observable for when a pointer move event occurs containing the move offset
  96767. */
  96768. onPointerMovedObservable: Observable<{
  96769. offsetX: number;
  96770. offsetY: number;
  96771. }>;
  96772. /**
  96773. * @hidden
  96774. * If the camera should be rotated automatically based on pointer movement
  96775. */
  96776. _allowCameraRotation: boolean;
  96777. /**
  96778. * Manage the mouse inputs to control the movement of a free camera.
  96779. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96780. * @param touchEnabled Defines if touch is enabled or not
  96781. */
  96782. constructor(
  96783. /**
  96784. * Define if touch is enabled in the mouse input
  96785. */
  96786. touchEnabled?: boolean);
  96787. /**
  96788. * Attach the input controls to a specific dom element to get the input from.
  96789. * @param element Defines the element the controls should be listened from
  96790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96791. */
  96792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96793. /**
  96794. * Called on JS contextmenu event.
  96795. * Override this method to provide functionality.
  96796. */
  96797. protected onContextMenu(evt: PointerEvent): void;
  96798. /**
  96799. * Detach the current controls from the specified dom element.
  96800. * @param element Defines the element to stop listening the inputs from
  96801. */
  96802. detachControl(element: Nullable<HTMLElement>): void;
  96803. /**
  96804. * Gets the class name of the current intput.
  96805. * @returns the class name
  96806. */
  96807. getClassName(): string;
  96808. /**
  96809. * Get the friendly name associated with the input class.
  96810. * @returns the input friendly name
  96811. */
  96812. getSimpleName(): string;
  96813. }
  96814. }
  96815. declare module BABYLON {
  96816. /**
  96817. * Manage the touch inputs to control the movement of a free camera.
  96818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96819. */
  96820. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96821. /**
  96822. * Defines the camera the input is attached to.
  96823. */
  96824. camera: FreeCamera;
  96825. /**
  96826. * Defines the touch sensibility for rotation.
  96827. * The higher the faster.
  96828. */
  96829. touchAngularSensibility: number;
  96830. /**
  96831. * Defines the touch sensibility for move.
  96832. * The higher the faster.
  96833. */
  96834. touchMoveSensibility: number;
  96835. private _offsetX;
  96836. private _offsetY;
  96837. private _pointerPressed;
  96838. private _pointerInput;
  96839. private _observer;
  96840. private _onLostFocus;
  96841. /**
  96842. * Attach the input controls to a specific dom element to get the input from.
  96843. * @param element Defines the element the controls should be listened from
  96844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96845. */
  96846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96847. /**
  96848. * Detach the current controls from the specified dom element.
  96849. * @param element Defines the element to stop listening the inputs from
  96850. */
  96851. detachControl(element: Nullable<HTMLElement>): void;
  96852. /**
  96853. * Update the current camera state depending on the inputs that have been used this frame.
  96854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96855. */
  96856. checkInputs(): void;
  96857. /**
  96858. * Gets the class name of the current intput.
  96859. * @returns the class name
  96860. */
  96861. getClassName(): string;
  96862. /**
  96863. * Get the friendly name associated with the input class.
  96864. * @returns the input friendly name
  96865. */
  96866. getSimpleName(): string;
  96867. }
  96868. }
  96869. declare module BABYLON {
  96870. /**
  96871. * Default Inputs manager for the FreeCamera.
  96872. * It groups all the default supported inputs for ease of use.
  96873. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96874. */
  96875. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96876. /**
  96877. * @hidden
  96878. */
  96879. _mouseInput: Nullable<FreeCameraMouseInput>;
  96880. /**
  96881. * Instantiates a new FreeCameraInputsManager.
  96882. * @param camera Defines the camera the inputs belong to
  96883. */
  96884. constructor(camera: FreeCamera);
  96885. /**
  96886. * Add keyboard input support to the input manager.
  96887. * @returns the current input manager
  96888. */
  96889. addKeyboard(): FreeCameraInputsManager;
  96890. /**
  96891. * Add mouse input support to the input manager.
  96892. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96893. * @returns the current input manager
  96894. */
  96895. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96896. /**
  96897. * Removes the mouse input support from the manager
  96898. * @returns the current input manager
  96899. */
  96900. removeMouse(): FreeCameraInputsManager;
  96901. /**
  96902. * Add touch input support to the input manager.
  96903. * @returns the current input manager
  96904. */
  96905. addTouch(): FreeCameraInputsManager;
  96906. /**
  96907. * Remove all attached input methods from a camera
  96908. */
  96909. clear(): void;
  96910. }
  96911. }
  96912. declare module BABYLON {
  96913. /**
  96914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96916. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96917. */
  96918. export class FreeCamera extends TargetCamera {
  96919. /**
  96920. * Define the collision ellipsoid of the camera.
  96921. * This is helpful to simulate a camera body like the player body around the camera
  96922. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96923. */
  96924. ellipsoid: Vector3;
  96925. /**
  96926. * Define an offset for the position of the ellipsoid around the camera.
  96927. * This can be helpful to determine the center of the body near the gravity center of the body
  96928. * instead of its head.
  96929. */
  96930. ellipsoidOffset: Vector3;
  96931. /**
  96932. * Enable or disable collisions of the camera with the rest of the scene objects.
  96933. */
  96934. checkCollisions: boolean;
  96935. /**
  96936. * Enable or disable gravity on the camera.
  96937. */
  96938. applyGravity: boolean;
  96939. /**
  96940. * Define the input manager associated to the camera.
  96941. */
  96942. inputs: FreeCameraInputsManager;
  96943. /**
  96944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96945. * Higher values reduce sensitivity.
  96946. */
  96947. get angularSensibility(): number;
  96948. /**
  96949. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96950. * Higher values reduce sensitivity.
  96951. */
  96952. set angularSensibility(value: number);
  96953. /**
  96954. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96955. */
  96956. get keysUp(): number[];
  96957. set keysUp(value: number[]);
  96958. /**
  96959. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96960. */
  96961. get keysUpward(): number[];
  96962. set keysUpward(value: number[]);
  96963. /**
  96964. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96965. */
  96966. get keysDown(): number[];
  96967. set keysDown(value: number[]);
  96968. /**
  96969. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96970. */
  96971. get keysDownward(): number[];
  96972. set keysDownward(value: number[]);
  96973. /**
  96974. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96975. */
  96976. get keysLeft(): number[];
  96977. set keysLeft(value: number[]);
  96978. /**
  96979. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96980. */
  96981. get keysRight(): number[];
  96982. set keysRight(value: number[]);
  96983. /**
  96984. * Event raised when the camera collide with a mesh in the scene.
  96985. */
  96986. onCollide: (collidedMesh: AbstractMesh) => void;
  96987. private _collider;
  96988. private _needMoveForGravity;
  96989. private _oldPosition;
  96990. private _diffPosition;
  96991. private _newPosition;
  96992. /** @hidden */
  96993. _localDirection: Vector3;
  96994. /** @hidden */
  96995. _transformedDirection: Vector3;
  96996. /**
  96997. * Instantiates a Free Camera.
  96998. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96999. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97000. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97001. * @param name Define the name of the camera in the scene
  97002. * @param position Define the start position of the camera in the scene
  97003. * @param scene Define the scene the camera belongs to
  97004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97005. */
  97006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97007. /**
  97008. * Attached controls to the current camera.
  97009. * @param element Defines the element the controls should be listened from
  97010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97011. */
  97012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97013. /**
  97014. * Detach the current controls from the camera.
  97015. * The camera will stop reacting to inputs.
  97016. * @param element Defines the element to stop listening the inputs from
  97017. */
  97018. detachControl(element: HTMLElement): void;
  97019. private _collisionMask;
  97020. /**
  97021. * Define a collision mask to limit the list of object the camera can collide with
  97022. */
  97023. get collisionMask(): number;
  97024. set collisionMask(mask: number);
  97025. /** @hidden */
  97026. _collideWithWorld(displacement: Vector3): void;
  97027. private _onCollisionPositionChange;
  97028. /** @hidden */
  97029. _checkInputs(): void;
  97030. /** @hidden */
  97031. _decideIfNeedsToMove(): boolean;
  97032. /** @hidden */
  97033. _updatePosition(): void;
  97034. /**
  97035. * Destroy the camera and release the current resources hold by it.
  97036. */
  97037. dispose(): void;
  97038. /**
  97039. * Gets the current object class name.
  97040. * @return the class name
  97041. */
  97042. getClassName(): string;
  97043. }
  97044. }
  97045. declare module BABYLON {
  97046. /**
  97047. * Represents a gamepad control stick position
  97048. */
  97049. export class StickValues {
  97050. /**
  97051. * The x component of the control stick
  97052. */
  97053. x: number;
  97054. /**
  97055. * The y component of the control stick
  97056. */
  97057. y: number;
  97058. /**
  97059. * Initializes the gamepad x and y control stick values
  97060. * @param x The x component of the gamepad control stick value
  97061. * @param y The y component of the gamepad control stick value
  97062. */
  97063. constructor(
  97064. /**
  97065. * The x component of the control stick
  97066. */
  97067. x: number,
  97068. /**
  97069. * The y component of the control stick
  97070. */
  97071. y: number);
  97072. }
  97073. /**
  97074. * An interface which manages callbacks for gamepad button changes
  97075. */
  97076. export interface GamepadButtonChanges {
  97077. /**
  97078. * Called when a gamepad has been changed
  97079. */
  97080. changed: boolean;
  97081. /**
  97082. * Called when a gamepad press event has been triggered
  97083. */
  97084. pressChanged: boolean;
  97085. /**
  97086. * Called when a touch event has been triggered
  97087. */
  97088. touchChanged: boolean;
  97089. /**
  97090. * Called when a value has changed
  97091. */
  97092. valueChanged: boolean;
  97093. }
  97094. /**
  97095. * Represents a gamepad
  97096. */
  97097. export class Gamepad {
  97098. /**
  97099. * The id of the gamepad
  97100. */
  97101. id: string;
  97102. /**
  97103. * The index of the gamepad
  97104. */
  97105. index: number;
  97106. /**
  97107. * The browser gamepad
  97108. */
  97109. browserGamepad: any;
  97110. /**
  97111. * Specifies what type of gamepad this represents
  97112. */
  97113. type: number;
  97114. private _leftStick;
  97115. private _rightStick;
  97116. /** @hidden */
  97117. _isConnected: boolean;
  97118. private _leftStickAxisX;
  97119. private _leftStickAxisY;
  97120. private _rightStickAxisX;
  97121. private _rightStickAxisY;
  97122. /**
  97123. * Triggered when the left control stick has been changed
  97124. */
  97125. private _onleftstickchanged;
  97126. /**
  97127. * Triggered when the right control stick has been changed
  97128. */
  97129. private _onrightstickchanged;
  97130. /**
  97131. * Represents a gamepad controller
  97132. */
  97133. static GAMEPAD: number;
  97134. /**
  97135. * Represents a generic controller
  97136. */
  97137. static GENERIC: number;
  97138. /**
  97139. * Represents an XBox controller
  97140. */
  97141. static XBOX: number;
  97142. /**
  97143. * Represents a pose-enabled controller
  97144. */
  97145. static POSE_ENABLED: number;
  97146. /**
  97147. * Represents an Dual Shock controller
  97148. */
  97149. static DUALSHOCK: number;
  97150. /**
  97151. * Specifies whether the left control stick should be Y-inverted
  97152. */
  97153. protected _invertLeftStickY: boolean;
  97154. /**
  97155. * Specifies if the gamepad has been connected
  97156. */
  97157. get isConnected(): boolean;
  97158. /**
  97159. * Initializes the gamepad
  97160. * @param id The id of the gamepad
  97161. * @param index The index of the gamepad
  97162. * @param browserGamepad The browser gamepad
  97163. * @param leftStickX The x component of the left joystick
  97164. * @param leftStickY The y component of the left joystick
  97165. * @param rightStickX The x component of the right joystick
  97166. * @param rightStickY The y component of the right joystick
  97167. */
  97168. constructor(
  97169. /**
  97170. * The id of the gamepad
  97171. */
  97172. id: string,
  97173. /**
  97174. * The index of the gamepad
  97175. */
  97176. index: number,
  97177. /**
  97178. * The browser gamepad
  97179. */
  97180. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97181. /**
  97182. * Callback triggered when the left joystick has changed
  97183. * @param callback
  97184. */
  97185. onleftstickchanged(callback: (values: StickValues) => void): void;
  97186. /**
  97187. * Callback triggered when the right joystick has changed
  97188. * @param callback
  97189. */
  97190. onrightstickchanged(callback: (values: StickValues) => void): void;
  97191. /**
  97192. * Gets the left joystick
  97193. */
  97194. get leftStick(): StickValues;
  97195. /**
  97196. * Sets the left joystick values
  97197. */
  97198. set leftStick(newValues: StickValues);
  97199. /**
  97200. * Gets the right joystick
  97201. */
  97202. get rightStick(): StickValues;
  97203. /**
  97204. * Sets the right joystick value
  97205. */
  97206. set rightStick(newValues: StickValues);
  97207. /**
  97208. * Updates the gamepad joystick positions
  97209. */
  97210. update(): void;
  97211. /**
  97212. * Disposes the gamepad
  97213. */
  97214. dispose(): void;
  97215. }
  97216. /**
  97217. * Represents a generic gamepad
  97218. */
  97219. export class GenericPad extends Gamepad {
  97220. private _buttons;
  97221. private _onbuttondown;
  97222. private _onbuttonup;
  97223. /**
  97224. * Observable triggered when a button has been pressed
  97225. */
  97226. onButtonDownObservable: Observable<number>;
  97227. /**
  97228. * Observable triggered when a button has been released
  97229. */
  97230. onButtonUpObservable: Observable<number>;
  97231. /**
  97232. * Callback triggered when a button has been pressed
  97233. * @param callback Called when a button has been pressed
  97234. */
  97235. onbuttondown(callback: (buttonPressed: number) => void): void;
  97236. /**
  97237. * Callback triggered when a button has been released
  97238. * @param callback Called when a button has been released
  97239. */
  97240. onbuttonup(callback: (buttonReleased: number) => void): void;
  97241. /**
  97242. * Initializes the generic gamepad
  97243. * @param id The id of the generic gamepad
  97244. * @param index The index of the generic gamepad
  97245. * @param browserGamepad The browser gamepad
  97246. */
  97247. constructor(id: string, index: number, browserGamepad: any);
  97248. private _setButtonValue;
  97249. /**
  97250. * Updates the generic gamepad
  97251. */
  97252. update(): void;
  97253. /**
  97254. * Disposes the generic gamepad
  97255. */
  97256. dispose(): void;
  97257. }
  97258. }
  97259. declare module BABYLON {
  97260. /**
  97261. * Defines the types of pose enabled controllers that are supported
  97262. */
  97263. export enum PoseEnabledControllerType {
  97264. /**
  97265. * HTC Vive
  97266. */
  97267. VIVE = 0,
  97268. /**
  97269. * Oculus Rift
  97270. */
  97271. OCULUS = 1,
  97272. /**
  97273. * Windows mixed reality
  97274. */
  97275. WINDOWS = 2,
  97276. /**
  97277. * Samsung gear VR
  97278. */
  97279. GEAR_VR = 3,
  97280. /**
  97281. * Google Daydream
  97282. */
  97283. DAYDREAM = 4,
  97284. /**
  97285. * Generic
  97286. */
  97287. GENERIC = 5
  97288. }
  97289. /**
  97290. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97291. */
  97292. export interface MutableGamepadButton {
  97293. /**
  97294. * Value of the button/trigger
  97295. */
  97296. value: number;
  97297. /**
  97298. * If the button/trigger is currently touched
  97299. */
  97300. touched: boolean;
  97301. /**
  97302. * If the button/trigger is currently pressed
  97303. */
  97304. pressed: boolean;
  97305. }
  97306. /**
  97307. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97308. * @hidden
  97309. */
  97310. export interface ExtendedGamepadButton extends GamepadButton {
  97311. /**
  97312. * If the button/trigger is currently pressed
  97313. */
  97314. readonly pressed: boolean;
  97315. /**
  97316. * If the button/trigger is currently touched
  97317. */
  97318. readonly touched: boolean;
  97319. /**
  97320. * Value of the button/trigger
  97321. */
  97322. readonly value: number;
  97323. }
  97324. /** @hidden */
  97325. export interface _GamePadFactory {
  97326. /**
  97327. * Returns whether or not the current gamepad can be created for this type of controller.
  97328. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97329. * @returns true if it can be created, otherwise false
  97330. */
  97331. canCreate(gamepadInfo: any): boolean;
  97332. /**
  97333. * Creates a new instance of the Gamepad.
  97334. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97335. * @returns the new gamepad instance
  97336. */
  97337. create(gamepadInfo: any): Gamepad;
  97338. }
  97339. /**
  97340. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97341. */
  97342. export class PoseEnabledControllerHelper {
  97343. /** @hidden */
  97344. static _ControllerFactories: _GamePadFactory[];
  97345. /** @hidden */
  97346. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97347. /**
  97348. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97349. * @param vrGamepad the gamepad to initialized
  97350. * @returns a vr controller of the type the gamepad identified as
  97351. */
  97352. static InitiateController(vrGamepad: any): Gamepad;
  97353. }
  97354. /**
  97355. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97356. */
  97357. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97358. /**
  97359. * If the controller is used in a webXR session
  97360. */
  97361. isXR: boolean;
  97362. private _deviceRoomPosition;
  97363. private _deviceRoomRotationQuaternion;
  97364. /**
  97365. * The device position in babylon space
  97366. */
  97367. devicePosition: Vector3;
  97368. /**
  97369. * The device rotation in babylon space
  97370. */
  97371. deviceRotationQuaternion: Quaternion;
  97372. /**
  97373. * The scale factor of the device in babylon space
  97374. */
  97375. deviceScaleFactor: number;
  97376. /**
  97377. * (Likely devicePosition should be used instead) The device position in its room space
  97378. */
  97379. position: Vector3;
  97380. /**
  97381. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97382. */
  97383. rotationQuaternion: Quaternion;
  97384. /**
  97385. * The type of controller (Eg. Windows mixed reality)
  97386. */
  97387. controllerType: PoseEnabledControllerType;
  97388. protected _calculatedPosition: Vector3;
  97389. private _calculatedRotation;
  97390. /**
  97391. * The raw pose from the device
  97392. */
  97393. rawPose: DevicePose;
  97394. private _trackPosition;
  97395. private _maxRotationDistFromHeadset;
  97396. private _draggedRoomRotation;
  97397. /**
  97398. * @hidden
  97399. */
  97400. _disableTrackPosition(fixedPosition: Vector3): void;
  97401. /**
  97402. * Internal, the mesh attached to the controller
  97403. * @hidden
  97404. */
  97405. _mesh: Nullable<AbstractMesh>;
  97406. private _poseControlledCamera;
  97407. private _leftHandSystemQuaternion;
  97408. /**
  97409. * Internal, matrix used to convert room space to babylon space
  97410. * @hidden
  97411. */
  97412. _deviceToWorld: Matrix;
  97413. /**
  97414. * Node to be used when casting a ray from the controller
  97415. * @hidden
  97416. */
  97417. _pointingPoseNode: Nullable<TransformNode>;
  97418. /**
  97419. * Name of the child mesh that can be used to cast a ray from the controller
  97420. */
  97421. static readonly POINTING_POSE: string;
  97422. /**
  97423. * Creates a new PoseEnabledController from a gamepad
  97424. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97425. */
  97426. constructor(browserGamepad: any);
  97427. private _workingMatrix;
  97428. /**
  97429. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97430. */
  97431. update(): void;
  97432. /**
  97433. * Updates only the pose device and mesh without doing any button event checking
  97434. */
  97435. protected _updatePoseAndMesh(): void;
  97436. /**
  97437. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97438. * @param poseData raw pose fromthe device
  97439. */
  97440. updateFromDevice(poseData: DevicePose): void;
  97441. /**
  97442. * @hidden
  97443. */
  97444. _meshAttachedObservable: Observable<AbstractMesh>;
  97445. /**
  97446. * Attaches a mesh to the controller
  97447. * @param mesh the mesh to be attached
  97448. */
  97449. attachToMesh(mesh: AbstractMesh): void;
  97450. /**
  97451. * Attaches the controllers mesh to a camera
  97452. * @param camera the camera the mesh should be attached to
  97453. */
  97454. attachToPoseControlledCamera(camera: TargetCamera): void;
  97455. /**
  97456. * Disposes of the controller
  97457. */
  97458. dispose(): void;
  97459. /**
  97460. * The mesh that is attached to the controller
  97461. */
  97462. get mesh(): Nullable<AbstractMesh>;
  97463. /**
  97464. * Gets the ray of the controller in the direction the controller is pointing
  97465. * @param length the length the resulting ray should be
  97466. * @returns a ray in the direction the controller is pointing
  97467. */
  97468. getForwardRay(length?: number): Ray;
  97469. }
  97470. }
  97471. declare module BABYLON {
  97472. /**
  97473. * Defines the WebVRController object that represents controllers tracked in 3D space
  97474. */
  97475. export abstract class WebVRController extends PoseEnabledController {
  97476. /**
  97477. * Internal, the default controller model for the controller
  97478. */
  97479. protected _defaultModel: Nullable<AbstractMesh>;
  97480. /**
  97481. * Fired when the trigger state has changed
  97482. */
  97483. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97484. /**
  97485. * Fired when the main button state has changed
  97486. */
  97487. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97488. /**
  97489. * Fired when the secondary button state has changed
  97490. */
  97491. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97492. /**
  97493. * Fired when the pad state has changed
  97494. */
  97495. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97496. /**
  97497. * Fired when controllers stick values have changed
  97498. */
  97499. onPadValuesChangedObservable: Observable<StickValues>;
  97500. /**
  97501. * Array of button availible on the controller
  97502. */
  97503. protected _buttons: Array<MutableGamepadButton>;
  97504. private _onButtonStateChange;
  97505. /**
  97506. * Fired when a controller button's state has changed
  97507. * @param callback the callback containing the button that was modified
  97508. */
  97509. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97510. /**
  97511. * X and Y axis corresponding to the controllers joystick
  97512. */
  97513. pad: StickValues;
  97514. /**
  97515. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97516. */
  97517. hand: string;
  97518. /**
  97519. * The default controller model for the controller
  97520. */
  97521. get defaultModel(): Nullable<AbstractMesh>;
  97522. /**
  97523. * Creates a new WebVRController from a gamepad
  97524. * @param vrGamepad the gamepad that the WebVRController should be created from
  97525. */
  97526. constructor(vrGamepad: any);
  97527. /**
  97528. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97529. */
  97530. update(): void;
  97531. /**
  97532. * Function to be called when a button is modified
  97533. */
  97534. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97535. /**
  97536. * Loads a mesh and attaches it to the controller
  97537. * @param scene the scene the mesh should be added to
  97538. * @param meshLoaded callback for when the mesh has been loaded
  97539. */
  97540. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97541. private _setButtonValue;
  97542. private _changes;
  97543. private _checkChanges;
  97544. /**
  97545. * Disposes of th webVRCOntroller
  97546. */
  97547. dispose(): void;
  97548. }
  97549. }
  97550. declare module BABYLON {
  97551. /**
  97552. * The HemisphericLight simulates the ambient environment light,
  97553. * so the passed direction is the light reflection direction, not the incoming direction.
  97554. */
  97555. export class HemisphericLight extends Light {
  97556. /**
  97557. * The groundColor is the light in the opposite direction to the one specified during creation.
  97558. * 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.
  97559. */
  97560. groundColor: Color3;
  97561. /**
  97562. * The light reflection direction, not the incoming direction.
  97563. */
  97564. direction: Vector3;
  97565. /**
  97566. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97567. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97568. * The HemisphericLight can't cast shadows.
  97569. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97570. * @param name The friendly name of the light
  97571. * @param direction The direction of the light reflection
  97572. * @param scene The scene the light belongs to
  97573. */
  97574. constructor(name: string, direction: Vector3, scene: Scene);
  97575. protected _buildUniformLayout(): void;
  97576. /**
  97577. * Returns the string "HemisphericLight".
  97578. * @return The class name
  97579. */
  97580. getClassName(): string;
  97581. /**
  97582. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97583. * Returns the updated direction.
  97584. * @param target The target the direction should point to
  97585. * @return The computed direction
  97586. */
  97587. setDirectionToTarget(target: Vector3): Vector3;
  97588. /**
  97589. * Returns the shadow generator associated to the light.
  97590. * @returns Always null for hemispheric lights because it does not support shadows.
  97591. */
  97592. getShadowGenerator(): Nullable<IShadowGenerator>;
  97593. /**
  97594. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97595. * @param effect The effect to update
  97596. * @param lightIndex The index of the light in the effect to update
  97597. * @returns The hemispheric light
  97598. */
  97599. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97600. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97601. /**
  97602. * Computes the world matrix of the node
  97603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97604. * @param useWasUpdatedFlag defines a reserved property
  97605. * @returns the world matrix
  97606. */
  97607. computeWorldMatrix(): Matrix;
  97608. /**
  97609. * Returns the integer 3.
  97610. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97611. */
  97612. getTypeID(): number;
  97613. /**
  97614. * Prepares the list of defines specific to the light type.
  97615. * @param defines the list of defines
  97616. * @param lightIndex defines the index of the light for the effect
  97617. */
  97618. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97619. }
  97620. }
  97621. declare module BABYLON {
  97622. /** @hidden */
  97623. export var vrMultiviewToSingleviewPixelShader: {
  97624. name: string;
  97625. shader: string;
  97626. };
  97627. }
  97628. declare module BABYLON {
  97629. /**
  97630. * Renders to multiple views with a single draw call
  97631. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97632. */
  97633. export class MultiviewRenderTarget extends RenderTargetTexture {
  97634. /**
  97635. * Creates a multiview render target
  97636. * @param scene scene used with the render target
  97637. * @param size the size of the render target (used for each view)
  97638. */
  97639. constructor(scene: Scene, size?: number | {
  97640. width: number;
  97641. height: number;
  97642. } | {
  97643. ratio: number;
  97644. });
  97645. /**
  97646. * @hidden
  97647. * @param faceIndex the face index, if its a cube texture
  97648. */
  97649. _bindFrameBuffer(faceIndex?: number): void;
  97650. /**
  97651. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97652. * @returns the view count
  97653. */
  97654. getViewCount(): number;
  97655. }
  97656. }
  97657. declare module BABYLON {
  97658. interface Engine {
  97659. /**
  97660. * Creates a new multiview render target
  97661. * @param width defines the width of the texture
  97662. * @param height defines the height of the texture
  97663. * @returns the created multiview texture
  97664. */
  97665. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97666. /**
  97667. * Binds a multiview framebuffer to be drawn to
  97668. * @param multiviewTexture texture to bind
  97669. */
  97670. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97671. }
  97672. interface Camera {
  97673. /**
  97674. * @hidden
  97675. * 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)
  97676. */
  97677. _useMultiviewToSingleView: boolean;
  97678. /**
  97679. * @hidden
  97680. * 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)
  97681. */
  97682. _multiviewTexture: Nullable<RenderTargetTexture>;
  97683. /**
  97684. * @hidden
  97685. * ensures the multiview texture of the camera exists and has the specified width/height
  97686. * @param width height to set on the multiview texture
  97687. * @param height width to set on the multiview texture
  97688. */
  97689. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97690. }
  97691. interface Scene {
  97692. /** @hidden */
  97693. _transformMatrixR: Matrix;
  97694. /** @hidden */
  97695. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97696. /** @hidden */
  97697. _createMultiviewUbo(): void;
  97698. /** @hidden */
  97699. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97700. /** @hidden */
  97701. _renderMultiviewToSingleView(camera: Camera): void;
  97702. }
  97703. }
  97704. declare module BABYLON {
  97705. /**
  97706. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97707. * This will not be used for webXR as it supports displaying texture arrays directly
  97708. */
  97709. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97710. /**
  97711. * Initializes a VRMultiviewToSingleview
  97712. * @param name name of the post process
  97713. * @param camera camera to be applied to
  97714. * @param scaleFactor scaling factor to the size of the output texture
  97715. */
  97716. constructor(name: string, camera: Camera, scaleFactor: number);
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * Interface used to define additional presentation attributes
  97722. */
  97723. export interface IVRPresentationAttributes {
  97724. /**
  97725. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97726. */
  97727. highRefreshRate: boolean;
  97728. /**
  97729. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97730. */
  97731. foveationLevel: number;
  97732. }
  97733. interface Engine {
  97734. /** @hidden */
  97735. _vrDisplay: any;
  97736. /** @hidden */
  97737. _vrSupported: boolean;
  97738. /** @hidden */
  97739. _oldSize: Size;
  97740. /** @hidden */
  97741. _oldHardwareScaleFactor: number;
  97742. /** @hidden */
  97743. _vrExclusivePointerMode: boolean;
  97744. /** @hidden */
  97745. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97746. /** @hidden */
  97747. _onVRDisplayPointerRestricted: () => void;
  97748. /** @hidden */
  97749. _onVRDisplayPointerUnrestricted: () => void;
  97750. /** @hidden */
  97751. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97752. /** @hidden */
  97753. _onVrDisplayDisconnect: Nullable<() => void>;
  97754. /** @hidden */
  97755. _onVrDisplayPresentChange: Nullable<() => void>;
  97756. /**
  97757. * Observable signaled when VR display mode changes
  97758. */
  97759. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97760. /**
  97761. * Observable signaled when VR request present is complete
  97762. */
  97763. onVRRequestPresentComplete: Observable<boolean>;
  97764. /**
  97765. * Observable signaled when VR request present starts
  97766. */
  97767. onVRRequestPresentStart: Observable<Engine>;
  97768. /**
  97769. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97770. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97771. */
  97772. isInVRExclusivePointerMode: boolean;
  97773. /**
  97774. * Gets a boolean indicating if a webVR device was detected
  97775. * @returns true if a webVR device was detected
  97776. */
  97777. isVRDevicePresent(): boolean;
  97778. /**
  97779. * Gets the current webVR device
  97780. * @returns the current webVR device (or null)
  97781. */
  97782. getVRDevice(): any;
  97783. /**
  97784. * Initializes a webVR display and starts listening to display change events
  97785. * The onVRDisplayChangedObservable will be notified upon these changes
  97786. * @returns A promise containing a VRDisplay and if vr is supported
  97787. */
  97788. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97789. /** @hidden */
  97790. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97791. /**
  97792. * Gets or sets the presentation attributes used to configure VR rendering
  97793. */
  97794. vrPresentationAttributes?: IVRPresentationAttributes;
  97795. /**
  97796. * Call this function to switch to webVR mode
  97797. * Will do nothing if webVR is not supported or if there is no webVR device
  97798. * @param options the webvr options provided to the camera. mainly used for multiview
  97799. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97800. */
  97801. enableVR(options: WebVROptions): void;
  97802. /** @hidden */
  97803. _onVRFullScreenTriggered(): void;
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97809. * IMPORTANT!! The data is right-hand data.
  97810. * @export
  97811. * @interface DevicePose
  97812. */
  97813. export interface DevicePose {
  97814. /**
  97815. * The position of the device, values in array are [x,y,z].
  97816. */
  97817. readonly position: Nullable<Float32Array>;
  97818. /**
  97819. * The linearVelocity of the device, values in array are [x,y,z].
  97820. */
  97821. readonly linearVelocity: Nullable<Float32Array>;
  97822. /**
  97823. * The linearAcceleration of the device, values in array are [x,y,z].
  97824. */
  97825. readonly linearAcceleration: Nullable<Float32Array>;
  97826. /**
  97827. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97828. */
  97829. readonly orientation: Nullable<Float32Array>;
  97830. /**
  97831. * The angularVelocity of the device, values in array are [x,y,z].
  97832. */
  97833. readonly angularVelocity: Nullable<Float32Array>;
  97834. /**
  97835. * The angularAcceleration of the device, values in array are [x,y,z].
  97836. */
  97837. readonly angularAcceleration: Nullable<Float32Array>;
  97838. }
  97839. /**
  97840. * Interface representing a pose controlled object in Babylon.
  97841. * A pose controlled object has both regular pose values as well as pose values
  97842. * from an external device such as a VR head mounted display
  97843. */
  97844. export interface PoseControlled {
  97845. /**
  97846. * The position of the object in babylon space.
  97847. */
  97848. position: Vector3;
  97849. /**
  97850. * The rotation quaternion of the object in babylon space.
  97851. */
  97852. rotationQuaternion: Quaternion;
  97853. /**
  97854. * The position of the device in babylon space.
  97855. */
  97856. devicePosition?: Vector3;
  97857. /**
  97858. * The rotation quaternion of the device in babylon space.
  97859. */
  97860. deviceRotationQuaternion: Quaternion;
  97861. /**
  97862. * The raw pose coming from the device.
  97863. */
  97864. rawPose: Nullable<DevicePose>;
  97865. /**
  97866. * The scale of the device to be used when translating from device space to babylon space.
  97867. */
  97868. deviceScaleFactor: number;
  97869. /**
  97870. * Updates the poseControlled values based on the input device pose.
  97871. * @param poseData the pose data to update the object with
  97872. */
  97873. updateFromDevice(poseData: DevicePose): void;
  97874. }
  97875. /**
  97876. * Set of options to customize the webVRCamera
  97877. */
  97878. export interface WebVROptions {
  97879. /**
  97880. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97881. */
  97882. trackPosition?: boolean;
  97883. /**
  97884. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97885. */
  97886. positionScale?: number;
  97887. /**
  97888. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97889. */
  97890. displayName?: string;
  97891. /**
  97892. * Should the native controller meshes be initialized. (default: true)
  97893. */
  97894. controllerMeshes?: boolean;
  97895. /**
  97896. * Creating a default HemiLight only on controllers. (default: true)
  97897. */
  97898. defaultLightingOnControllers?: boolean;
  97899. /**
  97900. * If you don't want to use the default VR button of the helper. (default: false)
  97901. */
  97902. useCustomVRButton?: boolean;
  97903. /**
  97904. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97905. */
  97906. customVRButton?: HTMLButtonElement;
  97907. /**
  97908. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97909. */
  97910. rayLength?: number;
  97911. /**
  97912. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97913. */
  97914. defaultHeight?: number;
  97915. /**
  97916. * If multiview should be used if availible (default: false)
  97917. */
  97918. useMultiview?: boolean;
  97919. }
  97920. /**
  97921. * This represents a WebVR camera.
  97922. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97923. * @example https://doc.babylonjs.com/how_to/webvr_camera
  97924. */
  97925. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97926. private webVROptions;
  97927. /**
  97928. * @hidden
  97929. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97930. */
  97931. _vrDevice: any;
  97932. /**
  97933. * The rawPose of the vrDevice.
  97934. */
  97935. rawPose: Nullable<DevicePose>;
  97936. private _onVREnabled;
  97937. private _specsVersion;
  97938. private _attached;
  97939. private _frameData;
  97940. protected _descendants: Array<Node>;
  97941. private _deviceRoomPosition;
  97942. /** @hidden */
  97943. _deviceRoomRotationQuaternion: Quaternion;
  97944. private _standingMatrix;
  97945. /**
  97946. * Represents device position in babylon space.
  97947. */
  97948. devicePosition: Vector3;
  97949. /**
  97950. * Represents device rotation in babylon space.
  97951. */
  97952. deviceRotationQuaternion: Quaternion;
  97953. /**
  97954. * The scale of the device to be used when translating from device space to babylon space.
  97955. */
  97956. deviceScaleFactor: number;
  97957. private _deviceToWorld;
  97958. private _worldToDevice;
  97959. /**
  97960. * References to the webVR controllers for the vrDevice.
  97961. */
  97962. controllers: Array<WebVRController>;
  97963. /**
  97964. * Emits an event when a controller is attached.
  97965. */
  97966. onControllersAttachedObservable: Observable<WebVRController[]>;
  97967. /**
  97968. * Emits an event when a controller's mesh has been loaded;
  97969. */
  97970. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97971. /**
  97972. * Emits an event when the HMD's pose has been updated.
  97973. */
  97974. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97975. private _poseSet;
  97976. /**
  97977. * If the rig cameras be used as parent instead of this camera.
  97978. */
  97979. rigParenting: boolean;
  97980. private _lightOnControllers;
  97981. private _defaultHeight?;
  97982. /**
  97983. * Instantiates a WebVRFreeCamera.
  97984. * @param name The name of the WebVRFreeCamera
  97985. * @param position The starting anchor position for the camera
  97986. * @param scene The scene the camera belongs to
  97987. * @param webVROptions a set of customizable options for the webVRCamera
  97988. */
  97989. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97990. /**
  97991. * Gets the device distance from the ground in meters.
  97992. * @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.
  97993. */
  97994. deviceDistanceToRoomGround(): number;
  97995. /**
  97996. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97997. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97998. */
  97999. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98000. /**
  98001. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98002. * @returns A promise with a boolean set to if the standing matrix is supported.
  98003. */
  98004. useStandingMatrixAsync(): Promise<boolean>;
  98005. /**
  98006. * Disposes the camera
  98007. */
  98008. dispose(): void;
  98009. /**
  98010. * Gets a vrController by name.
  98011. * @param name The name of the controller to retreive
  98012. * @returns the controller matching the name specified or null if not found
  98013. */
  98014. getControllerByName(name: string): Nullable<WebVRController>;
  98015. private _leftController;
  98016. /**
  98017. * The controller corresponding to the users left hand.
  98018. */
  98019. get leftController(): Nullable<WebVRController>;
  98020. private _rightController;
  98021. /**
  98022. * The controller corresponding to the users right hand.
  98023. */
  98024. get rightController(): Nullable<WebVRController>;
  98025. /**
  98026. * Casts a ray forward from the vrCamera's gaze.
  98027. * @param length Length of the ray (default: 100)
  98028. * @returns the ray corresponding to the gaze
  98029. */
  98030. getForwardRay(length?: number): Ray;
  98031. /**
  98032. * @hidden
  98033. * Updates the camera based on device's frame data
  98034. */
  98035. _checkInputs(): void;
  98036. /**
  98037. * Updates the poseControlled values based on the input device pose.
  98038. * @param poseData Pose coming from the device
  98039. */
  98040. updateFromDevice(poseData: DevicePose): void;
  98041. private _htmlElementAttached;
  98042. private _detachIfAttached;
  98043. /**
  98044. * WebVR's attach control will start broadcasting frames to the device.
  98045. * Note that in certain browsers (chrome for example) this function must be called
  98046. * within a user-interaction callback. Example:
  98047. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98048. *
  98049. * @param element html element to attach the vrDevice to
  98050. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98051. */
  98052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98053. /**
  98054. * Detaches the camera from the html element and disables VR
  98055. *
  98056. * @param element html element to detach from
  98057. */
  98058. detachControl(element: HTMLElement): void;
  98059. /**
  98060. * @returns the name of this class
  98061. */
  98062. getClassName(): string;
  98063. /**
  98064. * Calls resetPose on the vrDisplay
  98065. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98066. */
  98067. resetToCurrentRotation(): void;
  98068. /**
  98069. * @hidden
  98070. * Updates the rig cameras (left and right eye)
  98071. */
  98072. _updateRigCameras(): void;
  98073. private _workingVector;
  98074. private _oneVector;
  98075. private _workingMatrix;
  98076. private updateCacheCalled;
  98077. private _correctPositionIfNotTrackPosition;
  98078. /**
  98079. * @hidden
  98080. * Updates the cached values of the camera
  98081. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98082. */
  98083. _updateCache(ignoreParentClass?: boolean): void;
  98084. /**
  98085. * @hidden
  98086. * Get current device position in babylon world
  98087. */
  98088. _computeDevicePosition(): void;
  98089. /**
  98090. * Updates the current device position and rotation in the babylon world
  98091. */
  98092. update(): void;
  98093. /**
  98094. * @hidden
  98095. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98096. * @returns an identity matrix
  98097. */
  98098. _getViewMatrix(): Matrix;
  98099. private _tmpMatrix;
  98100. /**
  98101. * This function is called by the two RIG cameras.
  98102. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98103. * @hidden
  98104. */
  98105. _getWebVRViewMatrix(): Matrix;
  98106. /** @hidden */
  98107. _getWebVRProjectionMatrix(): Matrix;
  98108. private _onGamepadConnectedObserver;
  98109. private _onGamepadDisconnectedObserver;
  98110. private _updateCacheWhenTrackingDisabledObserver;
  98111. /**
  98112. * Initializes the controllers and their meshes
  98113. */
  98114. initControllers(): void;
  98115. }
  98116. }
  98117. declare module BABYLON {
  98118. /**
  98119. * "Static Class" containing the most commonly used helper while dealing with material for
  98120. * rendering purpose.
  98121. *
  98122. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98123. *
  98124. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98125. */
  98126. export class MaterialHelper {
  98127. /**
  98128. * Bind the current view position to an effect.
  98129. * @param effect The effect to be bound
  98130. * @param scene The scene the eyes position is used from
  98131. * @param variableName name of the shader variable that will hold the eye position
  98132. */
  98133. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98134. /**
  98135. * Helps preparing the defines values about the UVs in used in the effect.
  98136. * UVs are shared as much as we can accross channels in the shaders.
  98137. * @param texture The texture we are preparing the UVs for
  98138. * @param defines The defines to update
  98139. * @param key The channel key "diffuse", "specular"... used in the shader
  98140. */
  98141. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98142. /**
  98143. * Binds a texture matrix value to its corrsponding uniform
  98144. * @param texture The texture to bind the matrix for
  98145. * @param uniformBuffer The uniform buffer receivin the data
  98146. * @param key The channel key "diffuse", "specular"... used in the shader
  98147. */
  98148. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98149. /**
  98150. * Gets the current status of the fog (should it be enabled?)
  98151. * @param mesh defines the mesh to evaluate for fog support
  98152. * @param scene defines the hosting scene
  98153. * @returns true if fog must be enabled
  98154. */
  98155. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98156. /**
  98157. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98158. * @param mesh defines the current mesh
  98159. * @param scene defines the current scene
  98160. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98161. * @param pointsCloud defines if point cloud rendering has to be turned on
  98162. * @param fogEnabled defines if fog has to be turned on
  98163. * @param alphaTest defines if alpha testing has to be turned on
  98164. * @param defines defines the current list of defines
  98165. */
  98166. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98167. /**
  98168. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98169. * @param scene defines the current scene
  98170. * @param engine defines the current engine
  98171. * @param defines specifies the list of active defines
  98172. * @param useInstances defines if instances have to be turned on
  98173. * @param useClipPlane defines if clip plane have to be turned on
  98174. * @param useInstances defines if instances have to be turned on
  98175. * @param useThinInstances defines if thin instances have to be turned on
  98176. */
  98177. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98178. /**
  98179. * Prepares the defines for bones
  98180. * @param mesh The mesh containing the geometry data we will draw
  98181. * @param defines The defines to update
  98182. */
  98183. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98184. /**
  98185. * Prepares the defines for morph targets
  98186. * @param mesh The mesh containing the geometry data we will draw
  98187. * @param defines The defines to update
  98188. */
  98189. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98190. /**
  98191. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98192. * @param mesh The mesh containing the geometry data we will draw
  98193. * @param defines The defines to update
  98194. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98195. * @param useBones Precise whether bones should be used or not (override mesh info)
  98196. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98197. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98198. * @returns false if defines are considered not dirty and have not been checked
  98199. */
  98200. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98201. /**
  98202. * Prepares the defines related to multiview
  98203. * @param scene The scene we are intending to draw
  98204. * @param defines The defines to update
  98205. */
  98206. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98207. /**
  98208. * Prepares the defines related to the prepass
  98209. * @param scene The scene we are intending to draw
  98210. * @param defines The defines to update
  98211. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98212. */
  98213. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98214. /**
  98215. * Prepares the defines related to the light information passed in parameter
  98216. * @param scene The scene we are intending to draw
  98217. * @param mesh The mesh the effect is compiling for
  98218. * @param light The light the effect is compiling for
  98219. * @param lightIndex The index of the light
  98220. * @param defines The defines to update
  98221. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98222. * @param state Defines the current state regarding what is needed (normals, etc...)
  98223. */
  98224. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98225. needNormals: boolean;
  98226. needRebuild: boolean;
  98227. shadowEnabled: boolean;
  98228. specularEnabled: boolean;
  98229. lightmapMode: boolean;
  98230. }): void;
  98231. /**
  98232. * Prepares the defines related to the light information passed in parameter
  98233. * @param scene The scene we are intending to draw
  98234. * @param mesh The mesh the effect is compiling for
  98235. * @param defines The defines to update
  98236. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98237. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98238. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98239. * @returns true if normals will be required for the rest of the effect
  98240. */
  98241. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98242. /**
  98243. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98244. * @param lightIndex defines the light index
  98245. * @param uniformsList The uniform list
  98246. * @param samplersList The sampler list
  98247. * @param projectedLightTexture defines if projected texture must be used
  98248. * @param uniformBuffersList defines an optional list of uniform buffers
  98249. */
  98250. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98251. /**
  98252. * Prepares the uniforms and samplers list to be used in the effect
  98253. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98254. * @param samplersList The sampler list
  98255. * @param defines The defines helping in the list generation
  98256. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98257. */
  98258. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98259. /**
  98260. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98261. * @param defines The defines to update while falling back
  98262. * @param fallbacks The authorized effect fallbacks
  98263. * @param maxSimultaneousLights The maximum number of lights allowed
  98264. * @param rank the current rank of the Effect
  98265. * @returns The newly affected rank
  98266. */
  98267. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98268. private static _TmpMorphInfluencers;
  98269. /**
  98270. * Prepares the list of attributes required for morph targets according to the effect defines.
  98271. * @param attribs The current list of supported attribs
  98272. * @param mesh The mesh to prepare the morph targets attributes for
  98273. * @param influencers The number of influencers
  98274. */
  98275. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98276. /**
  98277. * Prepares the list of attributes required for morph targets according to the effect defines.
  98278. * @param attribs The current list of supported attribs
  98279. * @param mesh The mesh to prepare the morph targets attributes for
  98280. * @param defines The current Defines of the effect
  98281. */
  98282. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98283. /**
  98284. * Prepares the list of attributes required for bones according to the effect defines.
  98285. * @param attribs The current list of supported attribs
  98286. * @param mesh The mesh to prepare the bones attributes for
  98287. * @param defines The current Defines of the effect
  98288. * @param fallbacks The current efffect fallback strategy
  98289. */
  98290. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98291. /**
  98292. * Check and prepare the list of attributes required for instances according to the effect defines.
  98293. * @param attribs The current list of supported attribs
  98294. * @param defines The current MaterialDefines of the effect
  98295. */
  98296. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98297. /**
  98298. * Add the list of attributes required for instances to the attribs array.
  98299. * @param attribs The current list of supported attribs
  98300. */
  98301. static PushAttributesForInstances(attribs: string[]): void;
  98302. /**
  98303. * Binds the light information to the effect.
  98304. * @param light The light containing the generator
  98305. * @param effect The effect we are binding the data to
  98306. * @param lightIndex The light index in the effect used to render
  98307. */
  98308. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98309. /**
  98310. * Binds the lights information from the scene to the effect for the given mesh.
  98311. * @param light Light to bind
  98312. * @param lightIndex Light index
  98313. * @param scene The scene where the light belongs to
  98314. * @param effect The effect we are binding the data to
  98315. * @param useSpecular Defines if specular is supported
  98316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98317. */
  98318. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98319. /**
  98320. * Binds the lights information from the scene to the effect for the given mesh.
  98321. * @param scene The scene the lights belongs to
  98322. * @param mesh The mesh we are binding the information to render
  98323. * @param effect The effect we are binding the data to
  98324. * @param defines The generated defines for the effect
  98325. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98326. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98327. */
  98328. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98329. private static _tempFogColor;
  98330. /**
  98331. * Binds the fog information from the scene to the effect for the given mesh.
  98332. * @param scene The scene the lights belongs to
  98333. * @param mesh The mesh we are binding the information to render
  98334. * @param effect The effect we are binding the data to
  98335. * @param linearSpace Defines if the fog effect is applied in linear space
  98336. */
  98337. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98338. /**
  98339. * Binds the bones information from the mesh to the effect.
  98340. * @param mesh The mesh we are binding the information to render
  98341. * @param effect The effect we are binding the data to
  98342. */
  98343. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98344. /**
  98345. * Binds the morph targets information from the mesh to the effect.
  98346. * @param abstractMesh The mesh we are binding the information to render
  98347. * @param effect The effect we are binding the data to
  98348. */
  98349. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98350. /**
  98351. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98352. * @param defines The generated defines used in the effect
  98353. * @param effect The effect we are binding the data to
  98354. * @param scene The scene we are willing to render with logarithmic scale for
  98355. */
  98356. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98357. /**
  98358. * Binds the clip plane information from the scene to the effect.
  98359. * @param scene The scene the clip plane information are extracted from
  98360. * @param effect The effect we are binding the data to
  98361. */
  98362. static BindClipPlane(effect: Effect, scene: Scene): void;
  98363. }
  98364. }
  98365. declare module BABYLON {
  98366. /**
  98367. * Block used to expose an input value
  98368. */
  98369. export class InputBlock extends NodeMaterialBlock {
  98370. private _mode;
  98371. private _associatedVariableName;
  98372. private _storedValue;
  98373. private _valueCallback;
  98374. private _type;
  98375. private _animationType;
  98376. /** Gets or set a value used to limit the range of float values */
  98377. min: number;
  98378. /** Gets or set a value used to limit the range of float values */
  98379. max: number;
  98380. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98381. isBoolean: boolean;
  98382. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98383. matrixMode: number;
  98384. /** @hidden */
  98385. _systemValue: Nullable<NodeMaterialSystemValues>;
  98386. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98387. visibleInInspector: boolean;
  98388. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98389. isConstant: boolean;
  98390. /** Gets or sets the group to use to display this block in the Inspector */
  98391. groupInInspector: string;
  98392. /** Gets an observable raised when the value is changed */
  98393. onValueChangedObservable: Observable<InputBlock>;
  98394. /**
  98395. * Gets or sets the connection point type (default is float)
  98396. */
  98397. get type(): NodeMaterialBlockConnectionPointTypes;
  98398. /**
  98399. * Creates a new InputBlock
  98400. * @param name defines the block name
  98401. * @param target defines the target of that block (Vertex by default)
  98402. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98403. */
  98404. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98405. /**
  98406. * Gets the output component
  98407. */
  98408. get output(): NodeMaterialConnectionPoint;
  98409. /**
  98410. * Set the source of this connection point to a vertex attribute
  98411. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98412. * @returns the current connection point
  98413. */
  98414. setAsAttribute(attributeName?: string): InputBlock;
  98415. /**
  98416. * Set the source of this connection point to a system value
  98417. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98418. * @returns the current connection point
  98419. */
  98420. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98421. /**
  98422. * Gets or sets the value of that point.
  98423. * Please note that this value will be ignored if valueCallback is defined
  98424. */
  98425. get value(): any;
  98426. set value(value: any);
  98427. /**
  98428. * Gets or sets a callback used to get the value of that point.
  98429. * Please note that setting this value will force the connection point to ignore the value property
  98430. */
  98431. get valueCallback(): () => any;
  98432. set valueCallback(value: () => any);
  98433. /**
  98434. * Gets or sets the associated variable name in the shader
  98435. */
  98436. get associatedVariableName(): string;
  98437. set associatedVariableName(value: string);
  98438. /** Gets or sets the type of animation applied to the input */
  98439. get animationType(): AnimatedInputBlockTypes;
  98440. set animationType(value: AnimatedInputBlockTypes);
  98441. /**
  98442. * Gets a boolean indicating that this connection point not defined yet
  98443. */
  98444. get isUndefined(): boolean;
  98445. /**
  98446. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98447. * In this case the connection point name must be the name of the uniform to use.
  98448. * Can only be set on inputs
  98449. */
  98450. get isUniform(): boolean;
  98451. set isUniform(value: boolean);
  98452. /**
  98453. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98454. * In this case the connection point name must be the name of the attribute to use
  98455. * Can only be set on inputs
  98456. */
  98457. get isAttribute(): boolean;
  98458. set isAttribute(value: boolean);
  98459. /**
  98460. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98461. * Can only be set on exit points
  98462. */
  98463. get isVarying(): boolean;
  98464. set isVarying(value: boolean);
  98465. /**
  98466. * Gets a boolean indicating that the current connection point is a system value
  98467. */
  98468. get isSystemValue(): boolean;
  98469. /**
  98470. * Gets or sets the current well known value or null if not defined as a system value
  98471. */
  98472. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98473. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98474. /**
  98475. * Gets the current class name
  98476. * @returns the class name
  98477. */
  98478. getClassName(): string;
  98479. /**
  98480. * Animate the input if animationType !== None
  98481. * @param scene defines the rendering scene
  98482. */
  98483. animate(scene: Scene): void;
  98484. private _emitDefine;
  98485. initialize(state: NodeMaterialBuildState): void;
  98486. /**
  98487. * Set the input block to its default value (based on its type)
  98488. */
  98489. setDefaultValue(): void;
  98490. private _emitConstant;
  98491. /** @hidden */
  98492. get _noContextSwitch(): boolean;
  98493. private _emit;
  98494. /** @hidden */
  98495. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98496. /** @hidden */
  98497. _transmit(effect: Effect, scene: Scene): void;
  98498. protected _buildBlock(state: NodeMaterialBuildState): void;
  98499. protected _dumpPropertiesCode(): string;
  98500. dispose(): void;
  98501. serialize(): any;
  98502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98503. }
  98504. }
  98505. declare module BABYLON {
  98506. /**
  98507. * Enum used to define the compatibility state between two connection points
  98508. */
  98509. export enum NodeMaterialConnectionPointCompatibilityStates {
  98510. /** Points are compatibles */
  98511. Compatible = 0,
  98512. /** Points are incompatible because of their types */
  98513. TypeIncompatible = 1,
  98514. /** Points are incompatible because of their targets (vertex vs fragment) */
  98515. TargetIncompatible = 2
  98516. }
  98517. /**
  98518. * Defines the direction of a connection point
  98519. */
  98520. export enum NodeMaterialConnectionPointDirection {
  98521. /** Input */
  98522. Input = 0,
  98523. /** Output */
  98524. Output = 1
  98525. }
  98526. /**
  98527. * Defines a connection point for a block
  98528. */
  98529. export class NodeMaterialConnectionPoint {
  98530. /** @hidden */
  98531. _ownerBlock: NodeMaterialBlock;
  98532. /** @hidden */
  98533. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98534. private _endpoints;
  98535. private _associatedVariableName;
  98536. private _direction;
  98537. /** @hidden */
  98538. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98539. /** @hidden */
  98540. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98541. private _type;
  98542. /** @hidden */
  98543. _enforceAssociatedVariableName: boolean;
  98544. /** Gets the direction of the point */
  98545. get direction(): NodeMaterialConnectionPointDirection;
  98546. /** Indicates that this connection point needs dual validation before being connected to another point */
  98547. needDualDirectionValidation: boolean;
  98548. /**
  98549. * Gets or sets the additional types supported by this connection point
  98550. */
  98551. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98552. /**
  98553. * Gets or sets the additional types excluded by this connection point
  98554. */
  98555. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98556. /**
  98557. * Observable triggered when this point is connected
  98558. */
  98559. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98560. /**
  98561. * Gets or sets the associated variable name in the shader
  98562. */
  98563. get associatedVariableName(): string;
  98564. set associatedVariableName(value: string);
  98565. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98566. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98567. /**
  98568. * Gets or sets the connection point type (default is float)
  98569. */
  98570. get type(): NodeMaterialBlockConnectionPointTypes;
  98571. set type(value: NodeMaterialBlockConnectionPointTypes);
  98572. /**
  98573. * Gets or sets the connection point name
  98574. */
  98575. name: string;
  98576. /**
  98577. * Gets or sets the connection point name
  98578. */
  98579. displayName: string;
  98580. /**
  98581. * Gets or sets a boolean indicating that this connection point can be omitted
  98582. */
  98583. isOptional: boolean;
  98584. /**
  98585. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98586. */
  98587. isExposedOnFrame: boolean;
  98588. /**
  98589. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98590. */
  98591. define: string;
  98592. /** @hidden */
  98593. _prioritizeVertex: boolean;
  98594. private _target;
  98595. /** Gets or sets the target of that connection point */
  98596. get target(): NodeMaterialBlockTargets;
  98597. set target(value: NodeMaterialBlockTargets);
  98598. /**
  98599. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98600. */
  98601. get isConnected(): boolean;
  98602. /**
  98603. * Gets a boolean indicating that the current point is connected to an input block
  98604. */
  98605. get isConnectedToInputBlock(): boolean;
  98606. /**
  98607. * Gets a the connected input block (if any)
  98608. */
  98609. get connectInputBlock(): Nullable<InputBlock>;
  98610. /** Get the other side of the connection (if any) */
  98611. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98612. /** Get the block that owns this connection point */
  98613. get ownerBlock(): NodeMaterialBlock;
  98614. /** Get the block connected on the other side of this connection (if any) */
  98615. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98616. /** Get the block connected on the endpoints of this connection (if any) */
  98617. get connectedBlocks(): Array<NodeMaterialBlock>;
  98618. /** Gets the list of connected endpoints */
  98619. get endpoints(): NodeMaterialConnectionPoint[];
  98620. /** Gets a boolean indicating if that output point is connected to at least one input */
  98621. get hasEndpoints(): boolean;
  98622. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98623. get isConnectedInVertexShader(): boolean;
  98624. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98625. get isConnectedInFragmentShader(): boolean;
  98626. /**
  98627. * Creates a block suitable to be used as an input for this input point.
  98628. * If null is returned, a block based on the point type will be created.
  98629. * @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
  98630. */
  98631. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98632. /**
  98633. * Creates a new connection point
  98634. * @param name defines the connection point name
  98635. * @param ownerBlock defines the block hosting this connection point
  98636. * @param direction defines the direction of the connection point
  98637. */
  98638. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98639. /**
  98640. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98641. * @returns the class name
  98642. */
  98643. getClassName(): string;
  98644. /**
  98645. * Gets a boolean indicating if the current point can be connected to another point
  98646. * @param connectionPoint defines the other connection point
  98647. * @returns a boolean
  98648. */
  98649. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98650. /**
  98651. * Gets a number indicating if the current point can be connected to another point
  98652. * @param connectionPoint defines the other connection point
  98653. * @returns a number defining the compatibility state
  98654. */
  98655. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98656. /**
  98657. * Connect this point to another connection point
  98658. * @param connectionPoint defines the other connection point
  98659. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98660. * @returns the current connection point
  98661. */
  98662. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98663. /**
  98664. * Disconnect this point from one of his endpoint
  98665. * @param endpoint defines the other connection point
  98666. * @returns the current connection point
  98667. */
  98668. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98669. /**
  98670. * Serializes this point in a JSON representation
  98671. * @param isInput defines if the connection point is an input (default is true)
  98672. * @returns the serialized point object
  98673. */
  98674. serialize(isInput?: boolean): any;
  98675. /**
  98676. * Release resources
  98677. */
  98678. dispose(): void;
  98679. }
  98680. }
  98681. declare module BABYLON {
  98682. /**
  98683. * Enum used to define the material modes
  98684. */
  98685. export enum NodeMaterialModes {
  98686. /** Regular material */
  98687. Material = 0,
  98688. /** For post process */
  98689. PostProcess = 1,
  98690. /** For particle system */
  98691. Particle = 2
  98692. }
  98693. }
  98694. declare module BABYLON {
  98695. /**
  98696. * Block used to read a texture from a sampler
  98697. */
  98698. export class TextureBlock extends NodeMaterialBlock {
  98699. private _defineName;
  98700. private _linearDefineName;
  98701. private _gammaDefineName;
  98702. private _tempTextureRead;
  98703. private _samplerName;
  98704. private _transformedUVName;
  98705. private _textureTransformName;
  98706. private _textureInfoName;
  98707. private _mainUVName;
  98708. private _mainUVDefineName;
  98709. private _fragmentOnly;
  98710. /**
  98711. * Gets or sets the texture associated with the node
  98712. */
  98713. texture: Nullable<Texture>;
  98714. /**
  98715. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98716. */
  98717. convertToGammaSpace: boolean;
  98718. /**
  98719. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98720. */
  98721. convertToLinearSpace: boolean;
  98722. /**
  98723. * Create a new TextureBlock
  98724. * @param name defines the block name
  98725. */
  98726. constructor(name: string, fragmentOnly?: boolean);
  98727. /**
  98728. * Gets the current class name
  98729. * @returns the class name
  98730. */
  98731. getClassName(): string;
  98732. /**
  98733. * Gets the uv input component
  98734. */
  98735. get uv(): NodeMaterialConnectionPoint;
  98736. /**
  98737. * Gets the rgba output component
  98738. */
  98739. get rgba(): NodeMaterialConnectionPoint;
  98740. /**
  98741. * Gets the rgb output component
  98742. */
  98743. get rgb(): NodeMaterialConnectionPoint;
  98744. /**
  98745. * Gets the r output component
  98746. */
  98747. get r(): NodeMaterialConnectionPoint;
  98748. /**
  98749. * Gets the g output component
  98750. */
  98751. get g(): NodeMaterialConnectionPoint;
  98752. /**
  98753. * Gets the b output component
  98754. */
  98755. get b(): NodeMaterialConnectionPoint;
  98756. /**
  98757. * Gets the a output component
  98758. */
  98759. get a(): NodeMaterialConnectionPoint;
  98760. get target(): NodeMaterialBlockTargets;
  98761. autoConfigure(material: NodeMaterial): void;
  98762. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98764. isReady(): boolean;
  98765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98766. private get _isMixed();
  98767. private _injectVertexCode;
  98768. private _writeTextureRead;
  98769. private _writeOutput;
  98770. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98771. protected _dumpPropertiesCode(): string;
  98772. serialize(): any;
  98773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98774. }
  98775. }
  98776. declare module BABYLON {
  98777. /** @hidden */
  98778. export var reflectionFunction: {
  98779. name: string;
  98780. shader: string;
  98781. };
  98782. }
  98783. declare module BABYLON {
  98784. /**
  98785. * Base block used to read a reflection texture from a sampler
  98786. */
  98787. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98788. /** @hidden */
  98789. _define3DName: string;
  98790. /** @hidden */
  98791. _defineCubicName: string;
  98792. /** @hidden */
  98793. _defineExplicitName: string;
  98794. /** @hidden */
  98795. _defineProjectionName: string;
  98796. /** @hidden */
  98797. _defineLocalCubicName: string;
  98798. /** @hidden */
  98799. _defineSphericalName: string;
  98800. /** @hidden */
  98801. _definePlanarName: string;
  98802. /** @hidden */
  98803. _defineEquirectangularName: string;
  98804. /** @hidden */
  98805. _defineMirroredEquirectangularFixedName: string;
  98806. /** @hidden */
  98807. _defineEquirectangularFixedName: string;
  98808. /** @hidden */
  98809. _defineSkyboxName: string;
  98810. /** @hidden */
  98811. _defineOppositeZ: string;
  98812. /** @hidden */
  98813. _cubeSamplerName: string;
  98814. /** @hidden */
  98815. _2DSamplerName: string;
  98816. protected _positionUVWName: string;
  98817. protected _directionWName: string;
  98818. protected _reflectionVectorName: string;
  98819. /** @hidden */
  98820. _reflectionCoordsName: string;
  98821. /** @hidden */
  98822. _reflectionMatrixName: string;
  98823. protected _reflectionColorName: string;
  98824. /**
  98825. * Gets or sets the texture associated with the node
  98826. */
  98827. texture: Nullable<BaseTexture>;
  98828. /**
  98829. * Create a new ReflectionTextureBaseBlock
  98830. * @param name defines the block name
  98831. */
  98832. constructor(name: string);
  98833. /**
  98834. * Gets the current class name
  98835. * @returns the class name
  98836. */
  98837. getClassName(): string;
  98838. /**
  98839. * Gets the world position input component
  98840. */
  98841. abstract get position(): NodeMaterialConnectionPoint;
  98842. /**
  98843. * Gets the world position input component
  98844. */
  98845. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98846. /**
  98847. * Gets the world normal input component
  98848. */
  98849. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98850. /**
  98851. * Gets the world input component
  98852. */
  98853. abstract get world(): NodeMaterialConnectionPoint;
  98854. /**
  98855. * Gets the camera (or eye) position component
  98856. */
  98857. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98858. /**
  98859. * Gets the view input component
  98860. */
  98861. abstract get view(): NodeMaterialConnectionPoint;
  98862. protected _getTexture(): Nullable<BaseTexture>;
  98863. autoConfigure(material: NodeMaterial): void;
  98864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98865. isReady(): boolean;
  98866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98867. /**
  98868. * Gets the code to inject in the vertex shader
  98869. * @param state current state of the node material building
  98870. * @returns the shader code
  98871. */
  98872. handleVertexSide(state: NodeMaterialBuildState): string;
  98873. /**
  98874. * Handles the inits for the fragment code path
  98875. * @param state node material build state
  98876. */
  98877. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98878. /**
  98879. * Generates the reflection coords code for the fragment code path
  98880. * @param worldNormalVarName name of the world normal variable
  98881. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98882. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98883. * @returns the shader code
  98884. */
  98885. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98886. /**
  98887. * Generates the reflection color code for the fragment code path
  98888. * @param lodVarName name of the lod variable
  98889. * @param swizzleLookupTexture swizzle to use for the final color variable
  98890. * @returns the shader code
  98891. */
  98892. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98893. /**
  98894. * Generates the code corresponding to the connected output points
  98895. * @param state node material build state
  98896. * @param varName name of the variable to output
  98897. * @returns the shader code
  98898. */
  98899. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98900. protected _buildBlock(state: NodeMaterialBuildState): this;
  98901. protected _dumpPropertiesCode(): string;
  98902. serialize(): any;
  98903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98904. }
  98905. }
  98906. declare module BABYLON {
  98907. /**
  98908. * Defines a connection point to be used for points with a custom object type
  98909. */
  98910. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98911. private _blockType;
  98912. private _blockName;
  98913. private _nameForCheking?;
  98914. /**
  98915. * Creates a new connection point
  98916. * @param name defines the connection point name
  98917. * @param ownerBlock defines the block hosting this connection point
  98918. * @param direction defines the direction of the connection point
  98919. */
  98920. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98921. /**
  98922. * Gets a number indicating if the current point can be connected to another point
  98923. * @param connectionPoint defines the other connection point
  98924. * @returns a number defining the compatibility state
  98925. */
  98926. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98927. /**
  98928. * Creates a block suitable to be used as an input for this input point.
  98929. * If null is returned, a block based on the point type will be created.
  98930. * @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
  98931. */
  98932. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98933. }
  98934. }
  98935. declare module BABYLON {
  98936. /**
  98937. * Enum defining the type of properties that can be edited in the property pages in the NME
  98938. */
  98939. export enum PropertyTypeForEdition {
  98940. /** property is a boolean */
  98941. Boolean = 0,
  98942. /** property is a float */
  98943. Float = 1,
  98944. /** property is a Vector2 */
  98945. Vector2 = 2,
  98946. /** property is a list of values */
  98947. List = 3
  98948. }
  98949. /**
  98950. * Interface that defines an option in a variable of type list
  98951. */
  98952. export interface IEditablePropertyListOption {
  98953. /** label of the option */
  98954. "label": string;
  98955. /** value of the option */
  98956. "value": number;
  98957. }
  98958. /**
  98959. * Interface that defines the options available for an editable property
  98960. */
  98961. export interface IEditablePropertyOption {
  98962. /** min value */
  98963. "min"?: number;
  98964. /** max value */
  98965. "max"?: number;
  98966. /** notifiers: indicates which actions to take when the property is changed */
  98967. "notifiers"?: {
  98968. /** the material should be rebuilt */
  98969. "rebuild"?: boolean;
  98970. /** the preview should be updated */
  98971. "update"?: boolean;
  98972. };
  98973. /** list of the options for a variable of type list */
  98974. "options"?: IEditablePropertyListOption[];
  98975. }
  98976. /**
  98977. * Interface that describes an editable property
  98978. */
  98979. export interface IPropertyDescriptionForEdition {
  98980. /** name of the property */
  98981. "propertyName": string;
  98982. /** display name of the property */
  98983. "displayName": string;
  98984. /** type of the property */
  98985. "type": PropertyTypeForEdition;
  98986. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98987. "groupName": string;
  98988. /** options for the property */
  98989. "options": IEditablePropertyOption;
  98990. }
  98991. /**
  98992. * Decorator that flags a property in a node material block as being editable
  98993. */
  98994. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98995. }
  98996. declare module BABYLON {
  98997. /**
  98998. * Block used to implement the refraction part of the sub surface module of the PBR material
  98999. */
  99000. export class RefractionBlock extends NodeMaterialBlock {
  99001. /** @hidden */
  99002. _define3DName: string;
  99003. /** @hidden */
  99004. _refractionMatrixName: string;
  99005. /** @hidden */
  99006. _defineLODRefractionAlpha: string;
  99007. /** @hidden */
  99008. _defineLinearSpecularRefraction: string;
  99009. /** @hidden */
  99010. _defineOppositeZ: string;
  99011. /** @hidden */
  99012. _cubeSamplerName: string;
  99013. /** @hidden */
  99014. _2DSamplerName: string;
  99015. /** @hidden */
  99016. _vRefractionMicrosurfaceInfosName: string;
  99017. /** @hidden */
  99018. _vRefractionInfosName: string;
  99019. private _scene;
  99020. /**
  99021. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99022. * Materials half opaque for instance using refraction could benefit from this control.
  99023. */
  99024. linkRefractionWithTransparency: boolean;
  99025. /**
  99026. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99027. */
  99028. invertRefractionY: boolean;
  99029. /**
  99030. * Gets or sets the texture associated with the node
  99031. */
  99032. texture: Nullable<BaseTexture>;
  99033. /**
  99034. * Create a new RefractionBlock
  99035. * @param name defines the block name
  99036. */
  99037. constructor(name: string);
  99038. /**
  99039. * Gets the current class name
  99040. * @returns the class name
  99041. */
  99042. getClassName(): string;
  99043. /**
  99044. * Gets the intensity input component
  99045. */
  99046. get intensity(): NodeMaterialConnectionPoint;
  99047. /**
  99048. * Gets the index of refraction input component
  99049. */
  99050. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99051. /**
  99052. * Gets the tint at distance input component
  99053. */
  99054. get tintAtDistance(): NodeMaterialConnectionPoint;
  99055. /**
  99056. * Gets the view input component
  99057. */
  99058. get view(): NodeMaterialConnectionPoint;
  99059. /**
  99060. * Gets the refraction object output component
  99061. */
  99062. get refraction(): NodeMaterialConnectionPoint;
  99063. /**
  99064. * Returns true if the block has a texture
  99065. */
  99066. get hasTexture(): boolean;
  99067. protected _getTexture(): Nullable<BaseTexture>;
  99068. autoConfigure(material: NodeMaterial): void;
  99069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99070. isReady(): boolean;
  99071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99072. /**
  99073. * Gets the main code of the block (fragment side)
  99074. * @param state current state of the node material building
  99075. * @returns the shader code
  99076. */
  99077. getCode(state: NodeMaterialBuildState): string;
  99078. protected _buildBlock(state: NodeMaterialBuildState): this;
  99079. protected _dumpPropertiesCode(): string;
  99080. serialize(): any;
  99081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99082. }
  99083. }
  99084. declare module BABYLON {
  99085. /**
  99086. * Base block used as input for post process
  99087. */
  99088. export class CurrentScreenBlock extends NodeMaterialBlock {
  99089. private _samplerName;
  99090. private _linearDefineName;
  99091. private _gammaDefineName;
  99092. private _mainUVName;
  99093. private _tempTextureRead;
  99094. /**
  99095. * Gets or sets the texture associated with the node
  99096. */
  99097. texture: Nullable<BaseTexture>;
  99098. /**
  99099. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99100. */
  99101. convertToGammaSpace: boolean;
  99102. /**
  99103. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99104. */
  99105. convertToLinearSpace: boolean;
  99106. /**
  99107. * Create a new CurrentScreenBlock
  99108. * @param name defines the block name
  99109. */
  99110. constructor(name: string);
  99111. /**
  99112. * Gets the current class name
  99113. * @returns the class name
  99114. */
  99115. getClassName(): string;
  99116. /**
  99117. * Gets the uv input component
  99118. */
  99119. get uv(): NodeMaterialConnectionPoint;
  99120. /**
  99121. * Gets the rgba output component
  99122. */
  99123. get rgba(): NodeMaterialConnectionPoint;
  99124. /**
  99125. * Gets the rgb output component
  99126. */
  99127. get rgb(): NodeMaterialConnectionPoint;
  99128. /**
  99129. * Gets the r output component
  99130. */
  99131. get r(): NodeMaterialConnectionPoint;
  99132. /**
  99133. * Gets the g output component
  99134. */
  99135. get g(): NodeMaterialConnectionPoint;
  99136. /**
  99137. * Gets the b output component
  99138. */
  99139. get b(): NodeMaterialConnectionPoint;
  99140. /**
  99141. * Gets the a output component
  99142. */
  99143. get a(): NodeMaterialConnectionPoint;
  99144. /**
  99145. * Initialize the block and prepare the context for build
  99146. * @param state defines the state that will be used for the build
  99147. */
  99148. initialize(state: NodeMaterialBuildState): void;
  99149. get target(): NodeMaterialBlockTargets;
  99150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99151. isReady(): boolean;
  99152. private _injectVertexCode;
  99153. private _writeTextureRead;
  99154. private _writeOutput;
  99155. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99156. serialize(): any;
  99157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99158. }
  99159. }
  99160. declare module BABYLON {
  99161. /**
  99162. * Base block used for the particle texture
  99163. */
  99164. export class ParticleTextureBlock extends NodeMaterialBlock {
  99165. private _samplerName;
  99166. private _linearDefineName;
  99167. private _gammaDefineName;
  99168. private _tempTextureRead;
  99169. /**
  99170. * Gets or sets the texture associated with the node
  99171. */
  99172. texture: Nullable<BaseTexture>;
  99173. /**
  99174. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99175. */
  99176. convertToGammaSpace: boolean;
  99177. /**
  99178. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99179. */
  99180. convertToLinearSpace: boolean;
  99181. /**
  99182. * Create a new ParticleTextureBlock
  99183. * @param name defines the block name
  99184. */
  99185. constructor(name: string);
  99186. /**
  99187. * Gets the current class name
  99188. * @returns the class name
  99189. */
  99190. getClassName(): string;
  99191. /**
  99192. * Gets the uv input component
  99193. */
  99194. get uv(): NodeMaterialConnectionPoint;
  99195. /**
  99196. * Gets the rgba output component
  99197. */
  99198. get rgba(): NodeMaterialConnectionPoint;
  99199. /**
  99200. * Gets the rgb output component
  99201. */
  99202. get rgb(): NodeMaterialConnectionPoint;
  99203. /**
  99204. * Gets the r output component
  99205. */
  99206. get r(): NodeMaterialConnectionPoint;
  99207. /**
  99208. * Gets the g output component
  99209. */
  99210. get g(): NodeMaterialConnectionPoint;
  99211. /**
  99212. * Gets the b output component
  99213. */
  99214. get b(): NodeMaterialConnectionPoint;
  99215. /**
  99216. * Gets the a output component
  99217. */
  99218. get a(): NodeMaterialConnectionPoint;
  99219. /**
  99220. * Initialize the block and prepare the context for build
  99221. * @param state defines the state that will be used for the build
  99222. */
  99223. initialize(state: NodeMaterialBuildState): void;
  99224. autoConfigure(material: NodeMaterial): void;
  99225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99226. isReady(): boolean;
  99227. private _writeOutput;
  99228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99229. serialize(): any;
  99230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99231. }
  99232. }
  99233. declare module BABYLON {
  99234. /**
  99235. * Class used to store shared data between 2 NodeMaterialBuildState
  99236. */
  99237. export class NodeMaterialBuildStateSharedData {
  99238. /**
  99239. * Gets the list of emitted varyings
  99240. */
  99241. temps: string[];
  99242. /**
  99243. * Gets the list of emitted varyings
  99244. */
  99245. varyings: string[];
  99246. /**
  99247. * Gets the varying declaration string
  99248. */
  99249. varyingDeclaration: string;
  99250. /**
  99251. * Input blocks
  99252. */
  99253. inputBlocks: InputBlock[];
  99254. /**
  99255. * Input blocks
  99256. */
  99257. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99258. /**
  99259. * Bindable blocks (Blocks that need to set data to the effect)
  99260. */
  99261. bindableBlocks: NodeMaterialBlock[];
  99262. /**
  99263. * List of blocks that can provide a compilation fallback
  99264. */
  99265. blocksWithFallbacks: NodeMaterialBlock[];
  99266. /**
  99267. * List of blocks that can provide a define update
  99268. */
  99269. blocksWithDefines: NodeMaterialBlock[];
  99270. /**
  99271. * List of blocks that can provide a repeatable content
  99272. */
  99273. repeatableContentBlocks: NodeMaterialBlock[];
  99274. /**
  99275. * List of blocks that can provide a dynamic list of uniforms
  99276. */
  99277. dynamicUniformBlocks: NodeMaterialBlock[];
  99278. /**
  99279. * List of blocks that can block the isReady function for the material
  99280. */
  99281. blockingBlocks: NodeMaterialBlock[];
  99282. /**
  99283. * Gets the list of animated inputs
  99284. */
  99285. animatedInputs: InputBlock[];
  99286. /**
  99287. * Build Id used to avoid multiple recompilations
  99288. */
  99289. buildId: number;
  99290. /** List of emitted variables */
  99291. variableNames: {
  99292. [key: string]: number;
  99293. };
  99294. /** List of emitted defines */
  99295. defineNames: {
  99296. [key: string]: number;
  99297. };
  99298. /** Should emit comments? */
  99299. emitComments: boolean;
  99300. /** Emit build activity */
  99301. verbose: boolean;
  99302. /** Gets or sets the hosting scene */
  99303. scene: Scene;
  99304. /**
  99305. * Gets the compilation hints emitted at compilation time
  99306. */
  99307. hints: {
  99308. needWorldViewMatrix: boolean;
  99309. needWorldViewProjectionMatrix: boolean;
  99310. needAlphaBlending: boolean;
  99311. needAlphaTesting: boolean;
  99312. };
  99313. /**
  99314. * List of compilation checks
  99315. */
  99316. checks: {
  99317. emitVertex: boolean;
  99318. emitFragment: boolean;
  99319. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99320. };
  99321. /**
  99322. * Is vertex program allowed to be empty?
  99323. */
  99324. allowEmptyVertexProgram: boolean;
  99325. /** Creates a new shared data */
  99326. constructor();
  99327. /**
  99328. * Emits console errors and exceptions if there is a failing check
  99329. */
  99330. emitErrors(): void;
  99331. }
  99332. }
  99333. declare module BABYLON {
  99334. /**
  99335. * Class used to store node based material build state
  99336. */
  99337. export class NodeMaterialBuildState {
  99338. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99339. supportUniformBuffers: boolean;
  99340. /**
  99341. * Gets the list of emitted attributes
  99342. */
  99343. attributes: string[];
  99344. /**
  99345. * Gets the list of emitted uniforms
  99346. */
  99347. uniforms: string[];
  99348. /**
  99349. * Gets the list of emitted constants
  99350. */
  99351. constants: string[];
  99352. /**
  99353. * Gets the list of emitted samplers
  99354. */
  99355. samplers: string[];
  99356. /**
  99357. * Gets the list of emitted functions
  99358. */
  99359. functions: {
  99360. [key: string]: string;
  99361. };
  99362. /**
  99363. * Gets the list of emitted extensions
  99364. */
  99365. extensions: {
  99366. [key: string]: string;
  99367. };
  99368. /**
  99369. * Gets the target of the compilation state
  99370. */
  99371. target: NodeMaterialBlockTargets;
  99372. /**
  99373. * Gets the list of emitted counters
  99374. */
  99375. counters: {
  99376. [key: string]: number;
  99377. };
  99378. /**
  99379. * Shared data between multiple NodeMaterialBuildState instances
  99380. */
  99381. sharedData: NodeMaterialBuildStateSharedData;
  99382. /** @hidden */
  99383. _vertexState: NodeMaterialBuildState;
  99384. /** @hidden */
  99385. _attributeDeclaration: string;
  99386. /** @hidden */
  99387. _uniformDeclaration: string;
  99388. /** @hidden */
  99389. _constantDeclaration: string;
  99390. /** @hidden */
  99391. _samplerDeclaration: string;
  99392. /** @hidden */
  99393. _varyingTransfer: string;
  99394. /** @hidden */
  99395. _injectAtEnd: string;
  99396. private _repeatableContentAnchorIndex;
  99397. /** @hidden */
  99398. _builtCompilationString: string;
  99399. /**
  99400. * Gets the emitted compilation strings
  99401. */
  99402. compilationString: string;
  99403. /**
  99404. * Finalize the compilation strings
  99405. * @param state defines the current compilation state
  99406. */
  99407. finalize(state: NodeMaterialBuildState): void;
  99408. /** @hidden */
  99409. get _repeatableContentAnchor(): string;
  99410. /** @hidden */
  99411. _getFreeVariableName(prefix: string): string;
  99412. /** @hidden */
  99413. _getFreeDefineName(prefix: string): string;
  99414. /** @hidden */
  99415. _excludeVariableName(name: string): void;
  99416. /** @hidden */
  99417. _emit2DSampler(name: string): void;
  99418. /** @hidden */
  99419. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99420. /** @hidden */
  99421. _emitExtension(name: string, extension: string, define?: string): void;
  99422. /** @hidden */
  99423. _emitFunction(name: string, code: string, comments: string): void;
  99424. /** @hidden */
  99425. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99426. replaceStrings?: {
  99427. search: RegExp;
  99428. replace: string;
  99429. }[];
  99430. repeatKey?: string;
  99431. }): string;
  99432. /** @hidden */
  99433. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99434. repeatKey?: string;
  99435. removeAttributes?: boolean;
  99436. removeUniforms?: boolean;
  99437. removeVaryings?: boolean;
  99438. removeIfDef?: boolean;
  99439. replaceStrings?: {
  99440. search: RegExp;
  99441. replace: string;
  99442. }[];
  99443. }, storeKey?: string): void;
  99444. /** @hidden */
  99445. _registerTempVariable(name: string): boolean;
  99446. /** @hidden */
  99447. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99448. /** @hidden */
  99449. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99450. /** @hidden */
  99451. _emitFloat(value: number): string;
  99452. }
  99453. }
  99454. declare module BABYLON {
  99455. /**
  99456. * Helper class used to generate session unique ID
  99457. */
  99458. export class UniqueIdGenerator {
  99459. private static _UniqueIdCounter;
  99460. /**
  99461. * Gets an unique (relatively to the current scene) Id
  99462. */
  99463. static get UniqueId(): number;
  99464. }
  99465. }
  99466. declare module BABYLON {
  99467. /**
  99468. * Defines a block that can be used inside a node based material
  99469. */
  99470. export class NodeMaterialBlock {
  99471. private _buildId;
  99472. private _buildTarget;
  99473. private _target;
  99474. private _isFinalMerger;
  99475. private _isInput;
  99476. protected _isUnique: boolean;
  99477. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99478. inputsAreExclusive: boolean;
  99479. /** @hidden */
  99480. _codeVariableName: string;
  99481. /** @hidden */
  99482. _inputs: NodeMaterialConnectionPoint[];
  99483. /** @hidden */
  99484. _outputs: NodeMaterialConnectionPoint[];
  99485. /** @hidden */
  99486. _preparationId: number;
  99487. /**
  99488. * Gets or sets the name of the block
  99489. */
  99490. name: string;
  99491. /**
  99492. * Gets or sets the unique id of the node
  99493. */
  99494. uniqueId: number;
  99495. /**
  99496. * Gets or sets the comments associated with this block
  99497. */
  99498. comments: string;
  99499. /**
  99500. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99501. */
  99502. get isUnique(): boolean;
  99503. /**
  99504. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99505. */
  99506. get isFinalMerger(): boolean;
  99507. /**
  99508. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99509. */
  99510. get isInput(): boolean;
  99511. /**
  99512. * Gets or sets the build Id
  99513. */
  99514. get buildId(): number;
  99515. set buildId(value: number);
  99516. /**
  99517. * Gets or sets the target of the block
  99518. */
  99519. get target(): NodeMaterialBlockTargets;
  99520. set target(value: NodeMaterialBlockTargets);
  99521. /**
  99522. * Gets the list of input points
  99523. */
  99524. get inputs(): NodeMaterialConnectionPoint[];
  99525. /** Gets the list of output points */
  99526. get outputs(): NodeMaterialConnectionPoint[];
  99527. /**
  99528. * Find an input by its name
  99529. * @param name defines the name of the input to look for
  99530. * @returns the input or null if not found
  99531. */
  99532. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99533. /**
  99534. * Find an output by its name
  99535. * @param name defines the name of the outputto look for
  99536. * @returns the output or null if not found
  99537. */
  99538. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99539. /**
  99540. * Creates a new NodeMaterialBlock
  99541. * @param name defines the block name
  99542. * @param target defines the target of that block (Vertex by default)
  99543. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99544. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99545. */
  99546. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99547. /**
  99548. * Initialize the block and prepare the context for build
  99549. * @param state defines the state that will be used for the build
  99550. */
  99551. initialize(state: NodeMaterialBuildState): void;
  99552. /**
  99553. * Bind data to effect. Will only be called for blocks with isBindable === true
  99554. * @param effect defines the effect to bind data to
  99555. * @param nodeMaterial defines the hosting NodeMaterial
  99556. * @param mesh defines the mesh that will be rendered
  99557. * @param subMesh defines the submesh that will be rendered
  99558. */
  99559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99560. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99561. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99562. protected _writeFloat(value: number): string;
  99563. /**
  99564. * Gets the current class name e.g. "NodeMaterialBlock"
  99565. * @returns the class name
  99566. */
  99567. getClassName(): string;
  99568. /**
  99569. * Register a new input. Must be called inside a block constructor
  99570. * @param name defines the connection point name
  99571. * @param type defines the connection point type
  99572. * @param isOptional defines a boolean indicating that this input can be omitted
  99573. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99574. * @param point an already created connection point. If not provided, create a new one
  99575. * @returns the current block
  99576. */
  99577. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99578. /**
  99579. * Register a new output. Must be called inside a block constructor
  99580. * @param name defines the connection point name
  99581. * @param type defines the connection point type
  99582. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99583. * @param point an already created connection point. If not provided, create a new one
  99584. * @returns the current block
  99585. */
  99586. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99587. /**
  99588. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99589. * @param forOutput defines an optional connection point to check compatibility with
  99590. * @returns the first available input or null
  99591. */
  99592. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99593. /**
  99594. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99595. * @param forBlock defines an optional block to check compatibility with
  99596. * @returns the first available input or null
  99597. */
  99598. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99599. /**
  99600. * Gets the sibling of the given output
  99601. * @param current defines the current output
  99602. * @returns the next output in the list or null
  99603. */
  99604. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99605. /**
  99606. * Connect current block with another block
  99607. * @param other defines the block to connect with
  99608. * @param options define the various options to help pick the right connections
  99609. * @returns the current block
  99610. */
  99611. connectTo(other: NodeMaterialBlock, options?: {
  99612. input?: string;
  99613. output?: string;
  99614. outputSwizzle?: string;
  99615. }): this | undefined;
  99616. protected _buildBlock(state: NodeMaterialBuildState): void;
  99617. /**
  99618. * Add uniforms, samplers and uniform buffers at compilation time
  99619. * @param state defines the state to update
  99620. * @param nodeMaterial defines the node material requesting the update
  99621. * @param defines defines the material defines to update
  99622. * @param uniformBuffers defines the list of uniform buffer names
  99623. */
  99624. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99625. /**
  99626. * Add potential fallbacks if shader compilation fails
  99627. * @param mesh defines the mesh to be rendered
  99628. * @param fallbacks defines the current prioritized list of fallbacks
  99629. */
  99630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99631. /**
  99632. * Initialize defines for shader compilation
  99633. * @param mesh defines the mesh to be rendered
  99634. * @param nodeMaterial defines the node material requesting the update
  99635. * @param defines defines the material defines to update
  99636. * @param useInstances specifies that instances should be used
  99637. */
  99638. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99639. /**
  99640. * Update defines for shader compilation
  99641. * @param mesh defines the mesh to be rendered
  99642. * @param nodeMaterial defines the node material requesting the update
  99643. * @param defines defines the material defines to update
  99644. * @param useInstances specifies that instances should be used
  99645. * @param subMesh defines which submesh to render
  99646. */
  99647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99648. /**
  99649. * Lets the block try to connect some inputs automatically
  99650. * @param material defines the hosting NodeMaterial
  99651. */
  99652. autoConfigure(material: NodeMaterial): void;
  99653. /**
  99654. * Function called when a block is declared as repeatable content generator
  99655. * @param vertexShaderState defines the current compilation state for the vertex shader
  99656. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99657. * @param mesh defines the mesh to be rendered
  99658. * @param defines defines the material defines to update
  99659. */
  99660. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99661. /**
  99662. * Checks if the block is ready
  99663. * @param mesh defines the mesh to be rendered
  99664. * @param nodeMaterial defines the node material requesting the update
  99665. * @param defines defines the material defines to update
  99666. * @param useInstances specifies that instances should be used
  99667. * @returns true if the block is ready
  99668. */
  99669. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99670. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99671. private _processBuild;
  99672. /**
  99673. * Compile the current node and generate the shader code
  99674. * @param state defines the current compilation state (uniforms, samplers, current string)
  99675. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99676. * @returns true if already built
  99677. */
  99678. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99679. protected _inputRename(name: string): string;
  99680. protected _outputRename(name: string): string;
  99681. protected _dumpPropertiesCode(): string;
  99682. /** @hidden */
  99683. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99684. /** @hidden */
  99685. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99686. /**
  99687. * Clone the current block to a new identical block
  99688. * @param scene defines the hosting scene
  99689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99690. * @returns a copy of the current block
  99691. */
  99692. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99693. /**
  99694. * Serializes this block in a JSON representation
  99695. * @returns the serialized block object
  99696. */
  99697. serialize(): any;
  99698. /** @hidden */
  99699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99700. private _deserializePortDisplayNamesAndExposedOnFrame;
  99701. /**
  99702. * Release resources
  99703. */
  99704. dispose(): void;
  99705. }
  99706. }
  99707. declare module BABYLON {
  99708. /**
  99709. * Base class of materials working in push mode in babylon JS
  99710. * @hidden
  99711. */
  99712. export class PushMaterial extends Material {
  99713. protected _activeEffect: Effect;
  99714. protected _normalMatrix: Matrix;
  99715. constructor(name: string, scene: Scene);
  99716. getEffect(): Effect;
  99717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99718. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99719. /**
  99720. * Binds the given world matrix to the active effect
  99721. *
  99722. * @param world the matrix to bind
  99723. */
  99724. bindOnlyWorldMatrix(world: Matrix): void;
  99725. /**
  99726. * Binds the given normal matrix to the active effect
  99727. *
  99728. * @param normalMatrix the matrix to bind
  99729. */
  99730. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99731. bind(world: Matrix, mesh?: Mesh): void;
  99732. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99733. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99734. }
  99735. }
  99736. declare module BABYLON {
  99737. /**
  99738. * Root class for all node material optimizers
  99739. */
  99740. export class NodeMaterialOptimizer {
  99741. /**
  99742. * Function used to optimize a NodeMaterial graph
  99743. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99744. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99745. */
  99746. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99747. }
  99748. }
  99749. declare module BABYLON {
  99750. /**
  99751. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99752. */
  99753. export class TransformBlock extends NodeMaterialBlock {
  99754. /**
  99755. * Defines the value to use to complement W value to transform it to a Vector4
  99756. */
  99757. complementW: number;
  99758. /**
  99759. * Defines the value to use to complement z value to transform it to a Vector4
  99760. */
  99761. complementZ: number;
  99762. /**
  99763. * Creates a new TransformBlock
  99764. * @param name defines the block name
  99765. */
  99766. constructor(name: string);
  99767. /**
  99768. * Gets the current class name
  99769. * @returns the class name
  99770. */
  99771. getClassName(): string;
  99772. /**
  99773. * Gets the vector input
  99774. */
  99775. get vector(): NodeMaterialConnectionPoint;
  99776. /**
  99777. * Gets the output component
  99778. */
  99779. get output(): NodeMaterialConnectionPoint;
  99780. /**
  99781. * Gets the xyz output component
  99782. */
  99783. get xyz(): NodeMaterialConnectionPoint;
  99784. /**
  99785. * Gets the matrix transform input
  99786. */
  99787. get transform(): NodeMaterialConnectionPoint;
  99788. protected _buildBlock(state: NodeMaterialBuildState): this;
  99789. /**
  99790. * Update defines for shader compilation
  99791. * @param mesh defines the mesh to be rendered
  99792. * @param nodeMaterial defines the node material requesting the update
  99793. * @param defines defines the material defines to update
  99794. * @param useInstances specifies that instances should be used
  99795. * @param subMesh defines which submesh to render
  99796. */
  99797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99798. serialize(): any;
  99799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99800. protected _dumpPropertiesCode(): string;
  99801. }
  99802. }
  99803. declare module BABYLON {
  99804. /**
  99805. * Block used to output the vertex position
  99806. */
  99807. export class VertexOutputBlock extends NodeMaterialBlock {
  99808. /**
  99809. * Creates a new VertexOutputBlock
  99810. * @param name defines the block name
  99811. */
  99812. constructor(name: string);
  99813. /**
  99814. * Gets the current class name
  99815. * @returns the class name
  99816. */
  99817. getClassName(): string;
  99818. /**
  99819. * Gets the vector input component
  99820. */
  99821. get vector(): NodeMaterialConnectionPoint;
  99822. protected _buildBlock(state: NodeMaterialBuildState): this;
  99823. }
  99824. }
  99825. declare module BABYLON {
  99826. /**
  99827. * Block used to output the final color
  99828. */
  99829. export class FragmentOutputBlock extends NodeMaterialBlock {
  99830. /**
  99831. * Create a new FragmentOutputBlock
  99832. * @param name defines the block name
  99833. */
  99834. constructor(name: string);
  99835. /**
  99836. * Gets the current class name
  99837. * @returns the class name
  99838. */
  99839. getClassName(): string;
  99840. /**
  99841. * Gets the rgba input component
  99842. */
  99843. get rgba(): NodeMaterialConnectionPoint;
  99844. /**
  99845. * Gets the rgb input component
  99846. */
  99847. get rgb(): NodeMaterialConnectionPoint;
  99848. /**
  99849. * Gets the a input component
  99850. */
  99851. get a(): NodeMaterialConnectionPoint;
  99852. protected _buildBlock(state: NodeMaterialBuildState): this;
  99853. }
  99854. }
  99855. declare module BABYLON {
  99856. /**
  99857. * Block used for the particle ramp gradient section
  99858. */
  99859. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99860. /**
  99861. * Create a new ParticleRampGradientBlock
  99862. * @param name defines the block name
  99863. */
  99864. constructor(name: string);
  99865. /**
  99866. * Gets the current class name
  99867. * @returns the class name
  99868. */
  99869. getClassName(): string;
  99870. /**
  99871. * Gets the color input component
  99872. */
  99873. get color(): NodeMaterialConnectionPoint;
  99874. /**
  99875. * Gets the rampColor output component
  99876. */
  99877. get rampColor(): NodeMaterialConnectionPoint;
  99878. /**
  99879. * Initialize the block and prepare the context for build
  99880. * @param state defines the state that will be used for the build
  99881. */
  99882. initialize(state: NodeMaterialBuildState): void;
  99883. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99884. }
  99885. }
  99886. declare module BABYLON {
  99887. /**
  99888. * Block used for the particle blend multiply section
  99889. */
  99890. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99891. /**
  99892. * Create a new ParticleBlendMultiplyBlock
  99893. * @param name defines the block name
  99894. */
  99895. constructor(name: string);
  99896. /**
  99897. * Gets the current class name
  99898. * @returns the class name
  99899. */
  99900. getClassName(): string;
  99901. /**
  99902. * Gets the color input component
  99903. */
  99904. get color(): NodeMaterialConnectionPoint;
  99905. /**
  99906. * Gets the alphaTexture input component
  99907. */
  99908. get alphaTexture(): NodeMaterialConnectionPoint;
  99909. /**
  99910. * Gets the alphaColor input component
  99911. */
  99912. get alphaColor(): NodeMaterialConnectionPoint;
  99913. /**
  99914. * Gets the blendColor output component
  99915. */
  99916. get blendColor(): NodeMaterialConnectionPoint;
  99917. /**
  99918. * Initialize the block and prepare the context for build
  99919. * @param state defines the state that will be used for the build
  99920. */
  99921. initialize(state: NodeMaterialBuildState): void;
  99922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99923. }
  99924. }
  99925. declare module BABYLON {
  99926. /**
  99927. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99928. */
  99929. export class VectorMergerBlock extends NodeMaterialBlock {
  99930. /**
  99931. * Create a new VectorMergerBlock
  99932. * @param name defines the block name
  99933. */
  99934. constructor(name: string);
  99935. /**
  99936. * Gets the current class name
  99937. * @returns the class name
  99938. */
  99939. getClassName(): string;
  99940. /**
  99941. * Gets the xyz component (input)
  99942. */
  99943. get xyzIn(): NodeMaterialConnectionPoint;
  99944. /**
  99945. * Gets the xy component (input)
  99946. */
  99947. get xyIn(): NodeMaterialConnectionPoint;
  99948. /**
  99949. * Gets the x component (input)
  99950. */
  99951. get x(): NodeMaterialConnectionPoint;
  99952. /**
  99953. * Gets the y component (input)
  99954. */
  99955. get y(): NodeMaterialConnectionPoint;
  99956. /**
  99957. * Gets the z component (input)
  99958. */
  99959. get z(): NodeMaterialConnectionPoint;
  99960. /**
  99961. * Gets the w component (input)
  99962. */
  99963. get w(): NodeMaterialConnectionPoint;
  99964. /**
  99965. * Gets the xyzw component (output)
  99966. */
  99967. get xyzw(): NodeMaterialConnectionPoint;
  99968. /**
  99969. * Gets the xyz component (output)
  99970. */
  99971. get xyzOut(): NodeMaterialConnectionPoint;
  99972. /**
  99973. * Gets the xy component (output)
  99974. */
  99975. get xyOut(): NodeMaterialConnectionPoint;
  99976. /**
  99977. * Gets the xy component (output)
  99978. * @deprecated Please use xyOut instead.
  99979. */
  99980. get xy(): NodeMaterialConnectionPoint;
  99981. /**
  99982. * Gets the xyz component (output)
  99983. * @deprecated Please use xyzOut instead.
  99984. */
  99985. get xyz(): NodeMaterialConnectionPoint;
  99986. protected _buildBlock(state: NodeMaterialBuildState): this;
  99987. }
  99988. }
  99989. declare module BABYLON {
  99990. /**
  99991. * Block used to remap a float from a range to a new one
  99992. */
  99993. export class RemapBlock extends NodeMaterialBlock {
  99994. /**
  99995. * Gets or sets the source range
  99996. */
  99997. sourceRange: Vector2;
  99998. /**
  99999. * Gets or sets the target range
  100000. */
  100001. targetRange: Vector2;
  100002. /**
  100003. * Creates a new RemapBlock
  100004. * @param name defines the block name
  100005. */
  100006. constructor(name: string);
  100007. /**
  100008. * Gets the current class name
  100009. * @returns the class name
  100010. */
  100011. getClassName(): string;
  100012. /**
  100013. * Gets the input component
  100014. */
  100015. get input(): NodeMaterialConnectionPoint;
  100016. /**
  100017. * Gets the source min input component
  100018. */
  100019. get sourceMin(): NodeMaterialConnectionPoint;
  100020. /**
  100021. * Gets the source max input component
  100022. */
  100023. get sourceMax(): NodeMaterialConnectionPoint;
  100024. /**
  100025. * Gets the target min input component
  100026. */
  100027. get targetMin(): NodeMaterialConnectionPoint;
  100028. /**
  100029. * Gets the target max input component
  100030. */
  100031. get targetMax(): NodeMaterialConnectionPoint;
  100032. /**
  100033. * Gets the output component
  100034. */
  100035. get output(): NodeMaterialConnectionPoint;
  100036. protected _buildBlock(state: NodeMaterialBuildState): this;
  100037. protected _dumpPropertiesCode(): string;
  100038. serialize(): any;
  100039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100040. }
  100041. }
  100042. declare module BABYLON {
  100043. /**
  100044. * Block used to multiply 2 values
  100045. */
  100046. export class MultiplyBlock extends NodeMaterialBlock {
  100047. /**
  100048. * Creates a new MultiplyBlock
  100049. * @param name defines the block name
  100050. */
  100051. constructor(name: string);
  100052. /**
  100053. * Gets the current class name
  100054. * @returns the class name
  100055. */
  100056. getClassName(): string;
  100057. /**
  100058. * Gets the left operand input component
  100059. */
  100060. get left(): NodeMaterialConnectionPoint;
  100061. /**
  100062. * Gets the right operand input component
  100063. */
  100064. get right(): NodeMaterialConnectionPoint;
  100065. /**
  100066. * Gets the output component
  100067. */
  100068. get output(): NodeMaterialConnectionPoint;
  100069. protected _buildBlock(state: NodeMaterialBuildState): this;
  100070. }
  100071. }
  100072. declare module BABYLON {
  100073. /**
  100074. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100075. */
  100076. export class ColorSplitterBlock extends NodeMaterialBlock {
  100077. /**
  100078. * Create a new ColorSplitterBlock
  100079. * @param name defines the block name
  100080. */
  100081. constructor(name: string);
  100082. /**
  100083. * Gets the current class name
  100084. * @returns the class name
  100085. */
  100086. getClassName(): string;
  100087. /**
  100088. * Gets the rgba component (input)
  100089. */
  100090. get rgba(): NodeMaterialConnectionPoint;
  100091. /**
  100092. * Gets the rgb component (input)
  100093. */
  100094. get rgbIn(): NodeMaterialConnectionPoint;
  100095. /**
  100096. * Gets the rgb component (output)
  100097. */
  100098. get rgbOut(): NodeMaterialConnectionPoint;
  100099. /**
  100100. * Gets the r component (output)
  100101. */
  100102. get r(): NodeMaterialConnectionPoint;
  100103. /**
  100104. * Gets the g component (output)
  100105. */
  100106. get g(): NodeMaterialConnectionPoint;
  100107. /**
  100108. * Gets the b component (output)
  100109. */
  100110. get b(): NodeMaterialConnectionPoint;
  100111. /**
  100112. * Gets the a component (output)
  100113. */
  100114. get a(): NodeMaterialConnectionPoint;
  100115. protected _inputRename(name: string): string;
  100116. protected _outputRename(name: string): string;
  100117. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100118. }
  100119. }
  100120. declare module BABYLON {
  100121. /**
  100122. * Interface used to configure the node material editor
  100123. */
  100124. export interface INodeMaterialEditorOptions {
  100125. /** Define the URl to load node editor script */
  100126. editorURL?: string;
  100127. }
  100128. /** @hidden */
  100129. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100130. NORMAL: boolean;
  100131. TANGENT: boolean;
  100132. UV1: boolean;
  100133. /** BONES */
  100134. NUM_BONE_INFLUENCERS: number;
  100135. BonesPerMesh: number;
  100136. BONETEXTURE: boolean;
  100137. /** MORPH TARGETS */
  100138. MORPHTARGETS: boolean;
  100139. MORPHTARGETS_NORMAL: boolean;
  100140. MORPHTARGETS_TANGENT: boolean;
  100141. MORPHTARGETS_UV: boolean;
  100142. NUM_MORPH_INFLUENCERS: number;
  100143. /** IMAGE PROCESSING */
  100144. IMAGEPROCESSING: boolean;
  100145. VIGNETTE: boolean;
  100146. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100147. VIGNETTEBLENDMODEOPAQUE: boolean;
  100148. TONEMAPPING: boolean;
  100149. TONEMAPPING_ACES: boolean;
  100150. CONTRAST: boolean;
  100151. EXPOSURE: boolean;
  100152. COLORCURVES: boolean;
  100153. COLORGRADING: boolean;
  100154. COLORGRADING3D: boolean;
  100155. SAMPLER3DGREENDEPTH: boolean;
  100156. SAMPLER3DBGRMAP: boolean;
  100157. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100158. /** MISC. */
  100159. BUMPDIRECTUV: number;
  100160. constructor();
  100161. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100162. }
  100163. /**
  100164. * Class used to configure NodeMaterial
  100165. */
  100166. export interface INodeMaterialOptions {
  100167. /**
  100168. * Defines if blocks should emit comments
  100169. */
  100170. emitComments: boolean;
  100171. }
  100172. /**
  100173. * Class used to create a node based material built by assembling shader blocks
  100174. */
  100175. export class NodeMaterial extends PushMaterial {
  100176. private static _BuildIdGenerator;
  100177. private _options;
  100178. private _vertexCompilationState;
  100179. private _fragmentCompilationState;
  100180. private _sharedData;
  100181. private _buildId;
  100182. private _buildWasSuccessful;
  100183. private _cachedWorldViewMatrix;
  100184. private _cachedWorldViewProjectionMatrix;
  100185. private _optimizers;
  100186. private _animationFrame;
  100187. /** Define the Url to load node editor script */
  100188. static EditorURL: string;
  100189. /** Define the Url to load snippets */
  100190. static SnippetUrl: string;
  100191. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100192. static IgnoreTexturesAtLoadTime: boolean;
  100193. private BJSNODEMATERIALEDITOR;
  100194. /** Get the inspector from bundle or global */
  100195. private _getGlobalNodeMaterialEditor;
  100196. /**
  100197. * Snippet ID if the material was created from the snippet server
  100198. */
  100199. snippetId: string;
  100200. /**
  100201. * Gets or sets data used by visual editor
  100202. * @see https://nme.babylonjs.com
  100203. */
  100204. editorData: any;
  100205. /**
  100206. * 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)
  100207. */
  100208. ignoreAlpha: boolean;
  100209. /**
  100210. * Defines the maximum number of lights that can be used in the material
  100211. */
  100212. maxSimultaneousLights: number;
  100213. /**
  100214. * Observable raised when the material is built
  100215. */
  100216. onBuildObservable: Observable<NodeMaterial>;
  100217. /**
  100218. * Gets or sets the root nodes of the material vertex shader
  100219. */
  100220. _vertexOutputNodes: NodeMaterialBlock[];
  100221. /**
  100222. * Gets or sets the root nodes of the material fragment (pixel) shader
  100223. */
  100224. _fragmentOutputNodes: NodeMaterialBlock[];
  100225. /** Gets or sets options to control the node material overall behavior */
  100226. get options(): INodeMaterialOptions;
  100227. set options(options: INodeMaterialOptions);
  100228. /**
  100229. * Default configuration related to image processing available in the standard Material.
  100230. */
  100231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100232. /**
  100233. * Gets the image processing configuration used either in this material.
  100234. */
  100235. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100236. /**
  100237. * Sets the Default image processing configuration used either in the this material.
  100238. *
  100239. * If sets to null, the scene one is in use.
  100240. */
  100241. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100242. /**
  100243. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100244. */
  100245. attachedBlocks: NodeMaterialBlock[];
  100246. /**
  100247. * Specifies the mode of the node material
  100248. * @hidden
  100249. */
  100250. _mode: NodeMaterialModes;
  100251. /**
  100252. * Gets the mode property
  100253. */
  100254. get mode(): NodeMaterialModes;
  100255. /**
  100256. * Create a new node based material
  100257. * @param name defines the material name
  100258. * @param scene defines the hosting scene
  100259. * @param options defines creation option
  100260. */
  100261. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100262. /**
  100263. * Gets the current class name of the material e.g. "NodeMaterial"
  100264. * @returns the class name
  100265. */
  100266. getClassName(): string;
  100267. /**
  100268. * Keep track of the image processing observer to allow dispose and replace.
  100269. */
  100270. private _imageProcessingObserver;
  100271. /**
  100272. * Attaches a new image processing configuration to the Standard Material.
  100273. * @param configuration
  100274. */
  100275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100276. /**
  100277. * Get a block by its name
  100278. * @param name defines the name of the block to retrieve
  100279. * @returns the required block or null if not found
  100280. */
  100281. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100282. /**
  100283. * Get a block by its name
  100284. * @param predicate defines the predicate used to find the good candidate
  100285. * @returns the required block or null if not found
  100286. */
  100287. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100288. /**
  100289. * Get an input block by its name
  100290. * @param predicate defines the predicate used to find the good candidate
  100291. * @returns the required input block or null if not found
  100292. */
  100293. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100294. /**
  100295. * Gets the list of input blocks attached to this material
  100296. * @returns an array of InputBlocks
  100297. */
  100298. getInputBlocks(): InputBlock[];
  100299. /**
  100300. * Adds a new optimizer to the list of optimizers
  100301. * @param optimizer defines the optimizers to add
  100302. * @returns the current material
  100303. */
  100304. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100305. /**
  100306. * Remove an optimizer from the list of optimizers
  100307. * @param optimizer defines the optimizers to remove
  100308. * @returns the current material
  100309. */
  100310. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100311. /**
  100312. * Add a new block to the list of output nodes
  100313. * @param node defines the node to add
  100314. * @returns the current material
  100315. */
  100316. addOutputNode(node: NodeMaterialBlock): this;
  100317. /**
  100318. * Remove a block from the list of root nodes
  100319. * @param node defines the node to remove
  100320. * @returns the current material
  100321. */
  100322. removeOutputNode(node: NodeMaterialBlock): this;
  100323. private _addVertexOutputNode;
  100324. private _removeVertexOutputNode;
  100325. private _addFragmentOutputNode;
  100326. private _removeFragmentOutputNode;
  100327. /**
  100328. * Specifies if the material will require alpha blending
  100329. * @returns a boolean specifying if alpha blending is needed
  100330. */
  100331. needAlphaBlending(): boolean;
  100332. /**
  100333. * Specifies if this material should be rendered in alpha test mode
  100334. * @returns a boolean specifying if an alpha test is needed.
  100335. */
  100336. needAlphaTesting(): boolean;
  100337. private _initializeBlock;
  100338. private _resetDualBlocks;
  100339. /**
  100340. * Remove a block from the current node material
  100341. * @param block defines the block to remove
  100342. */
  100343. removeBlock(block: NodeMaterialBlock): void;
  100344. /**
  100345. * Build the material and generates the inner effect
  100346. * @param verbose defines if the build should log activity
  100347. */
  100348. build(verbose?: boolean): void;
  100349. /**
  100350. * Runs an otpimization phase to try to improve the shader code
  100351. */
  100352. optimize(): void;
  100353. private _prepareDefinesForAttributes;
  100354. /**
  100355. * Create a post process from the material
  100356. * @param camera The camera to apply the render pass to.
  100357. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100359. * @param engine The engine which the post process will be applied. (default: current engine)
  100360. * @param reusable If the post process can be reused on the same frame. (default: false)
  100361. * @param textureType Type of textures used when performing the post process. (default: 0)
  100362. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100363. * @returns the post process created
  100364. */
  100365. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100366. /**
  100367. * Create the post process effect from the material
  100368. * @param postProcess The post process to create the effect for
  100369. */
  100370. createEffectForPostProcess(postProcess: PostProcess): void;
  100371. private _createEffectOrPostProcess;
  100372. private _createEffectForParticles;
  100373. /**
  100374. * Create the effect to be used as the custom effect for a particle system
  100375. * @param particleSystem Particle system to create the effect for
  100376. * @param onCompiled defines a function to call when the effect creation is successful
  100377. * @param onError defines a function to call when the effect creation has failed
  100378. */
  100379. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100380. private _processDefines;
  100381. /**
  100382. * Get if the submesh is ready to be used and all its information available.
  100383. * Child classes can use it to update shaders
  100384. * @param mesh defines the mesh to check
  100385. * @param subMesh defines which submesh to check
  100386. * @param useInstances specifies that instances should be used
  100387. * @returns a boolean indicating that the submesh is ready or not
  100388. */
  100389. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100390. /**
  100391. * Get a string representing the shaders built by the current node graph
  100392. */
  100393. get compiledShaders(): string;
  100394. /**
  100395. * Binds the world matrix to the material
  100396. * @param world defines the world transformation matrix
  100397. */
  100398. bindOnlyWorldMatrix(world: Matrix): void;
  100399. /**
  100400. * Binds the submesh to this material by preparing the effect and shader to draw
  100401. * @param world defines the world transformation matrix
  100402. * @param mesh defines the mesh containing the submesh
  100403. * @param subMesh defines the submesh to bind the material to
  100404. */
  100405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100406. /**
  100407. * Gets the active textures from the material
  100408. * @returns an array of textures
  100409. */
  100410. getActiveTextures(): BaseTexture[];
  100411. /**
  100412. * Gets the list of texture blocks
  100413. * @returns an array of texture blocks
  100414. */
  100415. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100416. /**
  100417. * Specifies if the material uses a texture
  100418. * @param texture defines the texture to check against the material
  100419. * @returns a boolean specifying if the material uses the texture
  100420. */
  100421. hasTexture(texture: BaseTexture): boolean;
  100422. /**
  100423. * Disposes the material
  100424. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100425. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100426. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100427. */
  100428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100429. /** Creates the node editor window. */
  100430. private _createNodeEditor;
  100431. /**
  100432. * Launch the node material editor
  100433. * @param config Define the configuration of the editor
  100434. * @return a promise fulfilled when the node editor is visible
  100435. */
  100436. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100437. /**
  100438. * Clear the current material
  100439. */
  100440. clear(): void;
  100441. /**
  100442. * Clear the current material and set it to a default state
  100443. */
  100444. setToDefault(): void;
  100445. /**
  100446. * Clear the current material and set it to a default state for post process
  100447. */
  100448. setToDefaultPostProcess(): void;
  100449. /**
  100450. * Clear the current material and set it to a default state for particle
  100451. */
  100452. setToDefaultParticle(): void;
  100453. /**
  100454. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100455. * @param url defines the url to load from
  100456. * @returns a promise that will fullfil when the material is fully loaded
  100457. */
  100458. loadAsync(url: string): Promise<void>;
  100459. private _gatherBlocks;
  100460. /**
  100461. * Generate a string containing the code declaration required to create an equivalent of this material
  100462. * @returns a string
  100463. */
  100464. generateCode(): string;
  100465. /**
  100466. * Serializes this material in a JSON representation
  100467. * @returns the serialized material object
  100468. */
  100469. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100470. private _restoreConnections;
  100471. /**
  100472. * Clear the current graph and load a new one from a serialization object
  100473. * @param source defines the JSON representation of the material
  100474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100475. * @param merge defines whether or not the source must be merged or replace the current content
  100476. */
  100477. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100478. /**
  100479. * Makes a duplicate of the current material.
  100480. * @param name - name to use for the new material.
  100481. */
  100482. clone(name: string): NodeMaterial;
  100483. /**
  100484. * Creates a node material from parsed material data
  100485. * @param source defines the JSON representation of the material
  100486. * @param scene defines the hosting scene
  100487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100488. * @returns a new node material
  100489. */
  100490. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100491. /**
  100492. * Creates a node material from a snippet saved in a remote file
  100493. * @param name defines the name of the material to create
  100494. * @param url defines the url to load from
  100495. * @param scene defines the hosting scene
  100496. * @returns a promise that will resolve to the new node material
  100497. */
  100498. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100499. /**
  100500. * Creates a node material from a snippet saved by the node material editor
  100501. * @param snippetId defines the snippet to load
  100502. * @param scene defines the hosting scene
  100503. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100504. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100505. * @returns a promise that will resolve to the new node material
  100506. */
  100507. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100508. /**
  100509. * Creates a new node material set to default basic configuration
  100510. * @param name defines the name of the material
  100511. * @param scene defines the hosting scene
  100512. * @returns a new NodeMaterial
  100513. */
  100514. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /**
  100519. * Size options for a post process
  100520. */
  100521. export type PostProcessOptions = {
  100522. width: number;
  100523. height: number;
  100524. };
  100525. /**
  100526. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100527. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100528. */
  100529. export class PostProcess {
  100530. /** Name of the PostProcess. */
  100531. name: string;
  100532. /**
  100533. * Gets or sets the unique id of the post process
  100534. */
  100535. uniqueId: number;
  100536. /**
  100537. * Width of the texture to apply the post process on
  100538. */
  100539. width: number;
  100540. /**
  100541. * Height of the texture to apply the post process on
  100542. */
  100543. height: number;
  100544. /**
  100545. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100546. */
  100547. nodeMaterialSource: Nullable<NodeMaterial>;
  100548. /**
  100549. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100550. * @hidden
  100551. */
  100552. _outputTexture: Nullable<InternalTexture>;
  100553. /**
  100554. * Sampling mode used by the shader
  100555. * See https://doc.babylonjs.com/classes/3.1/texture
  100556. */
  100557. renderTargetSamplingMode: number;
  100558. /**
  100559. * Clear color to use when screen clearing
  100560. */
  100561. clearColor: Color4;
  100562. /**
  100563. * If the buffer needs to be cleared before applying the post process. (default: true)
  100564. * Should be set to false if shader will overwrite all previous pixels.
  100565. */
  100566. autoClear: boolean;
  100567. /**
  100568. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100569. */
  100570. alphaMode: number;
  100571. /**
  100572. * Sets the setAlphaBlendConstants of the babylon engine
  100573. */
  100574. alphaConstants: Color4;
  100575. /**
  100576. * Animations to be used for the post processing
  100577. */
  100578. animations: Animation[];
  100579. /**
  100580. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100581. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100582. */
  100583. enablePixelPerfectMode: boolean;
  100584. /**
  100585. * Force the postprocess to be applied without taking in account viewport
  100586. */
  100587. forceFullscreenViewport: boolean;
  100588. /**
  100589. * List of inspectable custom properties (used by the Inspector)
  100590. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100591. */
  100592. inspectableCustomProperties: IInspectable[];
  100593. /**
  100594. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100595. *
  100596. * | Value | Type | Description |
  100597. * | ----- | ----------------------------------- | ----------- |
  100598. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100599. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100600. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100601. *
  100602. */
  100603. scaleMode: number;
  100604. /**
  100605. * Force textures to be a power of two (default: false)
  100606. */
  100607. alwaysForcePOT: boolean;
  100608. private _samples;
  100609. /**
  100610. * Number of sample textures (default: 1)
  100611. */
  100612. get samples(): number;
  100613. set samples(n: number);
  100614. /**
  100615. * Modify the scale of the post process to be the same as the viewport (default: false)
  100616. */
  100617. adaptScaleToCurrentViewport: boolean;
  100618. private _camera;
  100619. protected _scene: Scene;
  100620. private _engine;
  100621. private _options;
  100622. private _reusable;
  100623. private _textureType;
  100624. private _textureFormat;
  100625. /**
  100626. * Smart array of input and output textures for the post process.
  100627. * @hidden
  100628. */
  100629. _textures: SmartArray<InternalTexture>;
  100630. /**
  100631. * The index in _textures that corresponds to the output texture.
  100632. * @hidden
  100633. */
  100634. _currentRenderTextureInd: number;
  100635. private _effect;
  100636. private _samplers;
  100637. private _fragmentUrl;
  100638. private _vertexUrl;
  100639. private _parameters;
  100640. private _scaleRatio;
  100641. protected _indexParameters: any;
  100642. private _shareOutputWithPostProcess;
  100643. private _texelSize;
  100644. private _forcedOutputTexture;
  100645. /**
  100646. * Returns the fragment url or shader name used in the post process.
  100647. * @returns the fragment url or name in the shader store.
  100648. */
  100649. getEffectName(): string;
  100650. /**
  100651. * An event triggered when the postprocess is activated.
  100652. */
  100653. onActivateObservable: Observable<Camera>;
  100654. private _onActivateObserver;
  100655. /**
  100656. * A function that is added to the onActivateObservable
  100657. */
  100658. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100659. /**
  100660. * An event triggered when the postprocess changes its size.
  100661. */
  100662. onSizeChangedObservable: Observable<PostProcess>;
  100663. private _onSizeChangedObserver;
  100664. /**
  100665. * A function that is added to the onSizeChangedObservable
  100666. */
  100667. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100668. /**
  100669. * An event triggered when the postprocess applies its effect.
  100670. */
  100671. onApplyObservable: Observable<Effect>;
  100672. private _onApplyObserver;
  100673. /**
  100674. * A function that is added to the onApplyObservable
  100675. */
  100676. set onApply(callback: (effect: Effect) => void);
  100677. /**
  100678. * An event triggered before rendering the postprocess
  100679. */
  100680. onBeforeRenderObservable: Observable<Effect>;
  100681. private _onBeforeRenderObserver;
  100682. /**
  100683. * A function that is added to the onBeforeRenderObservable
  100684. */
  100685. set onBeforeRender(callback: (effect: Effect) => void);
  100686. /**
  100687. * An event triggered after rendering the postprocess
  100688. */
  100689. onAfterRenderObservable: Observable<Effect>;
  100690. private _onAfterRenderObserver;
  100691. /**
  100692. * A function that is added to the onAfterRenderObservable
  100693. */
  100694. set onAfterRender(callback: (efect: Effect) => void);
  100695. /**
  100696. * 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
  100697. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100698. */
  100699. get inputTexture(): InternalTexture;
  100700. set inputTexture(value: InternalTexture);
  100701. /**
  100702. * Gets the camera which post process is applied to.
  100703. * @returns The camera the post process is applied to.
  100704. */
  100705. getCamera(): Camera;
  100706. /**
  100707. * Gets the texel size of the postprocess.
  100708. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100709. */
  100710. get texelSize(): Vector2;
  100711. /**
  100712. * Creates a new instance PostProcess
  100713. * @param name The name of the PostProcess.
  100714. * @param fragmentUrl The url of the fragment shader to be used.
  100715. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100716. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100718. * @param camera The camera to apply the render pass to.
  100719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100720. * @param engine The engine which the post process will be applied. (default: current engine)
  100721. * @param reusable If the post process can be reused on the same frame. (default: false)
  100722. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100723. * @param textureType Type of textures used when performing the post process. (default: 0)
  100724. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100725. * @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
  100726. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100727. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100728. */
  100729. constructor(
  100730. /** Name of the PostProcess. */
  100731. 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);
  100732. /**
  100733. * Gets a string idenfifying the name of the class
  100734. * @returns "PostProcess" string
  100735. */
  100736. getClassName(): string;
  100737. /**
  100738. * Gets the engine which this post process belongs to.
  100739. * @returns The engine the post process was enabled with.
  100740. */
  100741. getEngine(): Engine;
  100742. /**
  100743. * The effect that is created when initializing the post process.
  100744. * @returns The created effect corresponding the the postprocess.
  100745. */
  100746. getEffect(): Effect;
  100747. /**
  100748. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100749. * @param postProcess The post process to share the output with.
  100750. * @returns This post process.
  100751. */
  100752. shareOutputWith(postProcess: PostProcess): PostProcess;
  100753. /**
  100754. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100755. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100756. */
  100757. useOwnOutput(): void;
  100758. /**
  100759. * Updates the effect with the current post process compile time values and recompiles the shader.
  100760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100763. * @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
  100764. * @param onCompiled Called when the shader has been compiled.
  100765. * @param onError Called if there is an error when compiling a shader.
  100766. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100767. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100768. */
  100769. 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;
  100770. /**
  100771. * The post process is reusable if it can be used multiple times within one frame.
  100772. * @returns If the post process is reusable
  100773. */
  100774. isReusable(): boolean;
  100775. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100776. markTextureDirty(): void;
  100777. /**
  100778. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100779. * 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.
  100780. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100781. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100782. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100783. * @returns The target texture that was bound to be written to.
  100784. */
  100785. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100786. /**
  100787. * If the post process is supported.
  100788. */
  100789. get isSupported(): boolean;
  100790. /**
  100791. * The aspect ratio of the output texture.
  100792. */
  100793. get aspectRatio(): number;
  100794. /**
  100795. * Get a value indicating if the post-process is ready to be used
  100796. * @returns true if the post-process is ready (shader is compiled)
  100797. */
  100798. isReady(): boolean;
  100799. /**
  100800. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100801. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100802. */
  100803. apply(): Nullable<Effect>;
  100804. private _disposeTextures;
  100805. /**
  100806. * Disposes the post process.
  100807. * @param camera The camera to dispose the post process on.
  100808. */
  100809. dispose(camera?: Camera): void;
  100810. }
  100811. }
  100812. declare module BABYLON {
  100813. /** @hidden */
  100814. export var kernelBlurVaryingDeclaration: {
  100815. name: string;
  100816. shader: string;
  100817. };
  100818. }
  100819. declare module BABYLON {
  100820. /** @hidden */
  100821. export var kernelBlurFragment: {
  100822. name: string;
  100823. shader: string;
  100824. };
  100825. }
  100826. declare module BABYLON {
  100827. /** @hidden */
  100828. export var kernelBlurFragment2: {
  100829. name: string;
  100830. shader: string;
  100831. };
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var kernelBlurPixelShader: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /** @hidden */
  100842. export var kernelBlurVertex: {
  100843. name: string;
  100844. shader: string;
  100845. };
  100846. }
  100847. declare module BABYLON {
  100848. /** @hidden */
  100849. export var kernelBlurVertexShader: {
  100850. name: string;
  100851. shader: string;
  100852. };
  100853. }
  100854. declare module BABYLON {
  100855. /**
  100856. * The Blur Post Process which blurs an image based on a kernel and direction.
  100857. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100858. */
  100859. export class BlurPostProcess extends PostProcess {
  100860. /** The direction in which to blur the image. */
  100861. direction: Vector2;
  100862. private blockCompilation;
  100863. protected _kernel: number;
  100864. protected _idealKernel: number;
  100865. protected _packedFloat: boolean;
  100866. private _staticDefines;
  100867. /**
  100868. * Sets the length in pixels of the blur sample region
  100869. */
  100870. set kernel(v: number);
  100871. /**
  100872. * Gets the length in pixels of the blur sample region
  100873. */
  100874. get kernel(): number;
  100875. /**
  100876. * Sets wether or not the blur needs to unpack/repack floats
  100877. */
  100878. set packedFloat(v: boolean);
  100879. /**
  100880. * Gets wether or not the blur is unpacking/repacking floats
  100881. */
  100882. get packedFloat(): boolean;
  100883. /**
  100884. * Creates a new instance BlurPostProcess
  100885. * @param name The name of the effect.
  100886. * @param direction The direction in which to blur the image.
  100887. * @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.
  100888. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100889. * @param camera The camera to apply the render pass to.
  100890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100891. * @param engine The engine which the post process will be applied. (default: current engine)
  100892. * @param reusable If the post process can be reused on the same frame. (default: false)
  100893. * @param textureType Type of textures used when performing the post process. (default: 0)
  100894. * @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)
  100895. */
  100896. constructor(name: string,
  100897. /** The direction in which to blur the image. */
  100898. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100899. /**
  100900. * Updates the effect with the current post process compile time values and recompiles the shader.
  100901. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100902. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100903. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100904. * @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
  100905. * @param onCompiled Called when the shader has been compiled.
  100906. * @param onError Called if there is an error when compiling a shader.
  100907. */
  100908. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100909. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100910. /**
  100911. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100912. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100913. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100914. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100915. * The gaps between physical kernels are compensated for in the weighting of the samples
  100916. * @param idealKernel Ideal blur kernel.
  100917. * @return Nearest best kernel.
  100918. */
  100919. protected _nearestBestKernel(idealKernel: number): number;
  100920. /**
  100921. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100922. * @param x The point on the Gaussian distribution to sample.
  100923. * @return the value of the Gaussian function at x.
  100924. */
  100925. protected _gaussianWeight(x: number): number;
  100926. /**
  100927. * Generates a string that can be used as a floating point number in GLSL.
  100928. * @param x Value to print.
  100929. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100930. * @return GLSL float string.
  100931. */
  100932. protected _glslFloat(x: number, decimalFigures?: number): string;
  100933. }
  100934. }
  100935. declare module BABYLON {
  100936. /**
  100937. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100938. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100939. * You can then easily use it as a reflectionTexture on a flat surface.
  100940. * In case the surface is not a plane, please consider relying on reflection probes.
  100941. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100942. */
  100943. export class MirrorTexture extends RenderTargetTexture {
  100944. private scene;
  100945. /**
  100946. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100947. * 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.
  100948. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100949. */
  100950. mirrorPlane: Plane;
  100951. /**
  100952. * Define the blur ratio used to blur the reflection if needed.
  100953. */
  100954. set blurRatio(value: number);
  100955. get blurRatio(): number;
  100956. /**
  100957. * Define the adaptive blur kernel used to blur the reflection if needed.
  100958. * This will autocompute the closest best match for the `blurKernel`
  100959. */
  100960. set adaptiveBlurKernel(value: number);
  100961. /**
  100962. * Define the blur kernel used to blur the reflection if needed.
  100963. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100964. */
  100965. set blurKernel(value: number);
  100966. /**
  100967. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100968. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100969. */
  100970. set blurKernelX(value: number);
  100971. get blurKernelX(): number;
  100972. /**
  100973. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100974. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100975. */
  100976. set blurKernelY(value: number);
  100977. get blurKernelY(): number;
  100978. private _autoComputeBlurKernel;
  100979. protected _onRatioRescale(): void;
  100980. private _updateGammaSpace;
  100981. private _imageProcessingConfigChangeObserver;
  100982. private _transformMatrix;
  100983. private _mirrorMatrix;
  100984. private _savedViewMatrix;
  100985. private _blurX;
  100986. private _blurY;
  100987. private _adaptiveBlurKernel;
  100988. private _blurKernelX;
  100989. private _blurKernelY;
  100990. private _blurRatio;
  100991. /**
  100992. * Instantiates a Mirror Texture.
  100993. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100994. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100995. * You can then easily use it as a reflectionTexture on a flat surface.
  100996. * In case the surface is not a plane, please consider relying on reflection probes.
  100997. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100998. * @param name
  100999. * @param size
  101000. * @param scene
  101001. * @param generateMipMaps
  101002. * @param type
  101003. * @param samplingMode
  101004. * @param generateDepthBuffer
  101005. */
  101006. constructor(name: string, size: number | {
  101007. width: number;
  101008. height: number;
  101009. } | {
  101010. ratio: number;
  101011. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101012. private _preparePostProcesses;
  101013. /**
  101014. * Clone the mirror texture.
  101015. * @returns the cloned texture
  101016. */
  101017. clone(): MirrorTexture;
  101018. /**
  101019. * Serialize the texture to a JSON representation you could use in Parse later on
  101020. * @returns the serialized JSON representation
  101021. */
  101022. serialize(): any;
  101023. /**
  101024. * Dispose the texture and release its associated resources.
  101025. */
  101026. dispose(): void;
  101027. }
  101028. }
  101029. declare module BABYLON {
  101030. /**
  101031. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101032. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101033. */
  101034. export class Texture extends BaseTexture {
  101035. /**
  101036. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101037. */
  101038. static SerializeBuffers: boolean;
  101039. /** @hidden */
  101040. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101041. /** @hidden */
  101042. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101043. /** @hidden */
  101044. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101045. /** nearest is mag = nearest and min = nearest and mip = linear */
  101046. static readonly NEAREST_SAMPLINGMODE: number;
  101047. /** nearest is mag = nearest and min = nearest and mip = linear */
  101048. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101049. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101050. static readonly BILINEAR_SAMPLINGMODE: number;
  101051. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101052. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101053. /** Trilinear is mag = linear and min = linear and mip = linear */
  101054. static readonly TRILINEAR_SAMPLINGMODE: number;
  101055. /** Trilinear is mag = linear and min = linear and mip = linear */
  101056. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101057. /** mag = nearest and min = nearest and mip = nearest */
  101058. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101059. /** mag = nearest and min = linear and mip = nearest */
  101060. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101061. /** mag = nearest and min = linear and mip = linear */
  101062. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101063. /** mag = nearest and min = linear and mip = none */
  101064. static readonly NEAREST_LINEAR: number;
  101065. /** mag = nearest and min = nearest and mip = none */
  101066. static readonly NEAREST_NEAREST: number;
  101067. /** mag = linear and min = nearest and mip = nearest */
  101068. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101069. /** mag = linear and min = nearest and mip = linear */
  101070. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101071. /** mag = linear and min = linear and mip = none */
  101072. static readonly LINEAR_LINEAR: number;
  101073. /** mag = linear and min = nearest and mip = none */
  101074. static readonly LINEAR_NEAREST: number;
  101075. /** Explicit coordinates mode */
  101076. static readonly EXPLICIT_MODE: number;
  101077. /** Spherical coordinates mode */
  101078. static readonly SPHERICAL_MODE: number;
  101079. /** Planar coordinates mode */
  101080. static readonly PLANAR_MODE: number;
  101081. /** Cubic coordinates mode */
  101082. static readonly CUBIC_MODE: number;
  101083. /** Projection coordinates mode */
  101084. static readonly PROJECTION_MODE: number;
  101085. /** Inverse Cubic coordinates mode */
  101086. static readonly SKYBOX_MODE: number;
  101087. /** Inverse Cubic coordinates mode */
  101088. static readonly INVCUBIC_MODE: number;
  101089. /** Equirectangular coordinates mode */
  101090. static readonly EQUIRECTANGULAR_MODE: number;
  101091. /** Equirectangular Fixed coordinates mode */
  101092. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101093. /** Equirectangular Fixed Mirrored coordinates mode */
  101094. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101095. /** Texture is not repeating outside of 0..1 UVs */
  101096. static readonly CLAMP_ADDRESSMODE: number;
  101097. /** Texture is repeating outside of 0..1 UVs */
  101098. static readonly WRAP_ADDRESSMODE: number;
  101099. /** Texture is repeating and mirrored */
  101100. static readonly MIRROR_ADDRESSMODE: number;
  101101. /**
  101102. * 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
  101103. */
  101104. static UseSerializedUrlIfAny: boolean;
  101105. /**
  101106. * Define the url of the texture.
  101107. */
  101108. url: Nullable<string>;
  101109. /**
  101110. * Define an offset on the texture to offset the u coordinates of the UVs
  101111. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101112. */
  101113. uOffset: number;
  101114. /**
  101115. * Define an offset on the texture to offset the v coordinates of the UVs
  101116. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101117. */
  101118. vOffset: number;
  101119. /**
  101120. * Define an offset on the texture to scale the u coordinates of the UVs
  101121. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101122. */
  101123. uScale: number;
  101124. /**
  101125. * Define an offset on the texture to scale the v coordinates of the UVs
  101126. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101127. */
  101128. vScale: number;
  101129. /**
  101130. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101131. * @see https://doc.babylonjs.com/how_to/more_materials
  101132. */
  101133. uAng: number;
  101134. /**
  101135. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101136. * @see https://doc.babylonjs.com/how_to/more_materials
  101137. */
  101138. vAng: number;
  101139. /**
  101140. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101141. * @see https://doc.babylonjs.com/how_to/more_materials
  101142. */
  101143. wAng: number;
  101144. /**
  101145. * Defines the center of rotation (U)
  101146. */
  101147. uRotationCenter: number;
  101148. /**
  101149. * Defines the center of rotation (V)
  101150. */
  101151. vRotationCenter: number;
  101152. /**
  101153. * Defines the center of rotation (W)
  101154. */
  101155. wRotationCenter: number;
  101156. /**
  101157. * Are mip maps generated for this texture or not.
  101158. */
  101159. get noMipmap(): boolean;
  101160. /**
  101161. * List of inspectable custom properties (used by the Inspector)
  101162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101163. */
  101164. inspectableCustomProperties: Nullable<IInspectable[]>;
  101165. private _noMipmap;
  101166. /** @hidden */
  101167. _invertY: boolean;
  101168. private _rowGenerationMatrix;
  101169. private _cachedTextureMatrix;
  101170. private _projectionModeMatrix;
  101171. private _t0;
  101172. private _t1;
  101173. private _t2;
  101174. private _cachedUOffset;
  101175. private _cachedVOffset;
  101176. private _cachedUScale;
  101177. private _cachedVScale;
  101178. private _cachedUAng;
  101179. private _cachedVAng;
  101180. private _cachedWAng;
  101181. private _cachedProjectionMatrixId;
  101182. private _cachedCoordinatesMode;
  101183. /** @hidden */
  101184. protected _initialSamplingMode: number;
  101185. /** @hidden */
  101186. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101187. private _deleteBuffer;
  101188. protected _format: Nullable<number>;
  101189. private _delayedOnLoad;
  101190. private _delayedOnError;
  101191. private _mimeType?;
  101192. /**
  101193. * Observable triggered once the texture has been loaded.
  101194. */
  101195. onLoadObservable: Observable<Texture>;
  101196. protected _isBlocking: boolean;
  101197. /**
  101198. * Is the texture preventing material to render while loading.
  101199. * If false, a default texture will be used instead of the loading one during the preparation step.
  101200. */
  101201. set isBlocking(value: boolean);
  101202. get isBlocking(): boolean;
  101203. /**
  101204. * Get the current sampling mode associated with the texture.
  101205. */
  101206. get samplingMode(): number;
  101207. /**
  101208. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101209. */
  101210. get invertY(): boolean;
  101211. /**
  101212. * Instantiates a new texture.
  101213. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101214. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101215. * @param url defines the url of the picture to load as a texture
  101216. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101217. * @param noMipmap defines if the texture will require mip maps or not
  101218. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101219. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101220. * @param onLoad defines a callback triggered when the texture has been loaded
  101221. * @param onError defines a callback triggered when an error occurred during the loading session
  101222. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101223. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101224. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101225. * @param mimeType defines an optional mime type information
  101226. */
  101227. 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);
  101228. /**
  101229. * Update the url (and optional buffer) of this texture if url was null during construction.
  101230. * @param url the url of the texture
  101231. * @param buffer the buffer of the texture (defaults to null)
  101232. * @param onLoad callback called when the texture is loaded (defaults to null)
  101233. */
  101234. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101235. /**
  101236. * Finish the loading sequence of a texture flagged as delayed load.
  101237. * @hidden
  101238. */
  101239. delayLoad(): void;
  101240. private _prepareRowForTextureGeneration;
  101241. /**
  101242. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101243. * @returns the transform matrix of the texture.
  101244. */
  101245. getTextureMatrix(uBase?: number): Matrix;
  101246. /**
  101247. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101248. * @returns The reflection texture transform
  101249. */
  101250. getReflectionTextureMatrix(): Matrix;
  101251. /**
  101252. * Clones the texture.
  101253. * @returns the cloned texture
  101254. */
  101255. clone(): Texture;
  101256. /**
  101257. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101258. * @returns The JSON representation of the texture
  101259. */
  101260. serialize(): any;
  101261. /**
  101262. * Get the current class name of the texture useful for serialization or dynamic coding.
  101263. * @returns "Texture"
  101264. */
  101265. getClassName(): string;
  101266. /**
  101267. * Dispose the texture and release its associated resources.
  101268. */
  101269. dispose(): void;
  101270. /**
  101271. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101272. * @param parsedTexture Define the JSON representation of the texture
  101273. * @param scene Define the scene the parsed texture should be instantiated in
  101274. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101275. * @returns The parsed texture if successful
  101276. */
  101277. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101278. /**
  101279. * Creates a texture from its base 64 representation.
  101280. * @param data Define the base64 payload without the data: prefix
  101281. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101282. * @param scene Define the scene the texture should belong to
  101283. * @param noMipmap Forces the texture to not create mip map information if true
  101284. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101285. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101286. * @param onLoad define a callback triggered when the texture has been loaded
  101287. * @param onError define a callback triggered when an error occurred during the loading session
  101288. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101289. * @returns the created texture
  101290. */
  101291. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101292. /**
  101293. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101294. * @param data Define the base64 payload without the data: prefix
  101295. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101296. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101297. * @param scene Define the scene the texture should belong to
  101298. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101299. * @param noMipmap Forces the texture to not create mip map information if true
  101300. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101301. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101302. * @param onLoad define a callback triggered when the texture has been loaded
  101303. * @param onError define a callback triggered when an error occurred during the loading session
  101304. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101305. * @returns the created texture
  101306. */
  101307. 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;
  101308. }
  101309. }
  101310. declare module BABYLON {
  101311. /**
  101312. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101313. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101314. */
  101315. export class PostProcessManager {
  101316. private _scene;
  101317. private _indexBuffer;
  101318. private _vertexBuffers;
  101319. /**
  101320. * Creates a new instance PostProcess
  101321. * @param scene The scene that the post process is associated with.
  101322. */
  101323. constructor(scene: Scene);
  101324. private _prepareBuffers;
  101325. private _buildIndexBuffer;
  101326. /**
  101327. * Rebuilds the vertex buffers of the manager.
  101328. * @hidden
  101329. */
  101330. _rebuild(): void;
  101331. /**
  101332. * Prepares a frame to be run through a post process.
  101333. * @param sourceTexture The input texture to the post procesess. (default: null)
  101334. * @param postProcesses An array of post processes to be run. (default: null)
  101335. * @returns True if the post processes were able to be run.
  101336. * @hidden
  101337. */
  101338. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101339. /**
  101340. * Manually render a set of post processes to a texture.
  101341. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101342. * @param postProcesses An array of post processes to be run.
  101343. * @param targetTexture The target texture to render to.
  101344. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101345. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101346. * @param lodLevel defines which lod of the texture to render to
  101347. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101348. */
  101349. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101350. /**
  101351. * Finalize the result of the output of the postprocesses.
  101352. * @param doNotPresent If true the result will not be displayed to the screen.
  101353. * @param targetTexture The target texture to render to.
  101354. * @param faceIndex The index of the face to bind the target texture to.
  101355. * @param postProcesses The array of post processes to render.
  101356. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101357. * @hidden
  101358. */
  101359. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101360. /**
  101361. * Disposes of the post process manager.
  101362. */
  101363. dispose(): void;
  101364. }
  101365. }
  101366. declare module BABYLON {
  101367. /**
  101368. * This Helps creating a texture that will be created from a camera in your scene.
  101369. * It is basically a dynamic texture that could be used to create special effects for instance.
  101370. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101371. */
  101372. export class RenderTargetTexture extends Texture {
  101373. isCube: boolean;
  101374. /**
  101375. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101376. */
  101377. static readonly REFRESHRATE_RENDER_ONCE: number;
  101378. /**
  101379. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101380. */
  101381. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101382. /**
  101383. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101384. * the central point of your effect and can save a lot of performances.
  101385. */
  101386. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101387. /**
  101388. * Use this predicate to dynamically define the list of mesh you want to render.
  101389. * If set, the renderList property will be overwritten.
  101390. */
  101391. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101392. private _renderList;
  101393. /**
  101394. * Use this list to define the list of mesh you want to render.
  101395. */
  101396. get renderList(): Nullable<Array<AbstractMesh>>;
  101397. set renderList(value: Nullable<Array<AbstractMesh>>);
  101398. /**
  101399. * Use this function to overload the renderList array at rendering time.
  101400. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101401. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101402. * the cube (if the RTT is a cube, else layerOrFace=0).
  101403. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101404. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101405. * hold dummy elements!
  101406. */
  101407. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101408. private _hookArray;
  101409. /**
  101410. * Define if particles should be rendered in your texture.
  101411. */
  101412. renderParticles: boolean;
  101413. /**
  101414. * Define if sprites should be rendered in your texture.
  101415. */
  101416. renderSprites: boolean;
  101417. /**
  101418. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101419. */
  101420. coordinatesMode: number;
  101421. /**
  101422. * Define the camera used to render the texture.
  101423. */
  101424. activeCamera: Nullable<Camera>;
  101425. /**
  101426. * Override the mesh isReady function with your own one.
  101427. */
  101428. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101429. /**
  101430. * Override the render function of the texture with your own one.
  101431. */
  101432. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101433. /**
  101434. * Define if camera post processes should be use while rendering the texture.
  101435. */
  101436. useCameraPostProcesses: boolean;
  101437. /**
  101438. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101439. */
  101440. ignoreCameraViewport: boolean;
  101441. private _postProcessManager;
  101442. private _postProcesses;
  101443. private _resizeObserver;
  101444. /**
  101445. * An event triggered when the texture is unbind.
  101446. */
  101447. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101448. /**
  101449. * An event triggered when the texture is unbind.
  101450. */
  101451. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101452. private _onAfterUnbindObserver;
  101453. /**
  101454. * Set a after unbind callback in the texture.
  101455. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101456. */
  101457. set onAfterUnbind(callback: () => void);
  101458. /**
  101459. * An event triggered before rendering the texture
  101460. */
  101461. onBeforeRenderObservable: Observable<number>;
  101462. private _onBeforeRenderObserver;
  101463. /**
  101464. * Set a before render callback in the texture.
  101465. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101466. */
  101467. set onBeforeRender(callback: (faceIndex: number) => void);
  101468. /**
  101469. * An event triggered after rendering the texture
  101470. */
  101471. onAfterRenderObservable: Observable<number>;
  101472. private _onAfterRenderObserver;
  101473. /**
  101474. * Set a after render callback in the texture.
  101475. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101476. */
  101477. set onAfterRender(callback: (faceIndex: number) => void);
  101478. /**
  101479. * An event triggered after the texture clear
  101480. */
  101481. onClearObservable: Observable<Engine>;
  101482. private _onClearObserver;
  101483. /**
  101484. * Set a clear callback in the texture.
  101485. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101486. */
  101487. set onClear(callback: (Engine: Engine) => void);
  101488. /**
  101489. * An event triggered when the texture is resized.
  101490. */
  101491. onResizeObservable: Observable<RenderTargetTexture>;
  101492. /**
  101493. * Define the clear color of the Render Target if it should be different from the scene.
  101494. */
  101495. clearColor: Color4;
  101496. protected _size: number | {
  101497. width: number;
  101498. height: number;
  101499. layers?: number;
  101500. };
  101501. protected _initialSizeParameter: number | {
  101502. width: number;
  101503. height: number;
  101504. } | {
  101505. ratio: number;
  101506. };
  101507. protected _sizeRatio: Nullable<number>;
  101508. /** @hidden */
  101509. _generateMipMaps: boolean;
  101510. protected _renderingManager: RenderingManager;
  101511. /** @hidden */
  101512. _waitingRenderList: string[];
  101513. protected _doNotChangeAspectRatio: boolean;
  101514. protected _currentRefreshId: number;
  101515. protected _refreshRate: number;
  101516. protected _textureMatrix: Matrix;
  101517. protected _samples: number;
  101518. protected _renderTargetOptions: RenderTargetCreationOptions;
  101519. /**
  101520. * Gets render target creation options that were used.
  101521. */
  101522. get renderTargetOptions(): RenderTargetCreationOptions;
  101523. protected _onRatioRescale(): void;
  101524. /**
  101525. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101526. * It must define where the camera used to render the texture is set
  101527. */
  101528. boundingBoxPosition: Vector3;
  101529. private _boundingBoxSize;
  101530. /**
  101531. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101532. * When defined, the cubemap will switch to local mode
  101533. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101534. * @example https://www.babylonjs-playground.com/#RNASML
  101535. */
  101536. set boundingBoxSize(value: Vector3);
  101537. get boundingBoxSize(): Vector3;
  101538. /**
  101539. * In case the RTT has been created with a depth texture, get the associated
  101540. * depth texture.
  101541. * Otherwise, return null.
  101542. */
  101543. get depthStencilTexture(): Nullable<InternalTexture>;
  101544. /**
  101545. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101546. * or used a shadow, depth texture...
  101547. * @param name The friendly name of the texture
  101548. * @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)
  101549. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101550. * @param generateMipMaps True if mip maps need to be generated after render.
  101551. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101552. * @param type The type of the buffer in the RTT (int, half float, float...)
  101553. * @param isCube True if a cube texture needs to be created
  101554. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101555. * @param generateDepthBuffer True to generate a depth buffer
  101556. * @param generateStencilBuffer True to generate a stencil buffer
  101557. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101558. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101559. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101560. */
  101561. constructor(name: string, size: number | {
  101562. width: number;
  101563. height: number;
  101564. layers?: number;
  101565. } | {
  101566. ratio: number;
  101567. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101568. /**
  101569. * Creates a depth stencil texture.
  101570. * This is only available in WebGL 2 or with the depth texture extension available.
  101571. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101572. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101573. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101574. */
  101575. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101576. private _processSizeParameter;
  101577. /**
  101578. * Define the number of samples to use in case of MSAA.
  101579. * It defaults to one meaning no MSAA has been enabled.
  101580. */
  101581. get samples(): number;
  101582. set samples(value: number);
  101583. /**
  101584. * Resets the refresh counter of the texture and start bak from scratch.
  101585. * Could be useful to regenerate the texture if it is setup to render only once.
  101586. */
  101587. resetRefreshCounter(): void;
  101588. /**
  101589. * Define the refresh rate of the texture or the rendering frequency.
  101590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101591. */
  101592. get refreshRate(): number;
  101593. set refreshRate(value: number);
  101594. /**
  101595. * Adds a post process to the render target rendering passes.
  101596. * @param postProcess define the post process to add
  101597. */
  101598. addPostProcess(postProcess: PostProcess): void;
  101599. /**
  101600. * Clear all the post processes attached to the render target
  101601. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101602. */
  101603. clearPostProcesses(dispose?: boolean): void;
  101604. /**
  101605. * Remove one of the post process from the list of attached post processes to the texture
  101606. * @param postProcess define the post process to remove from the list
  101607. */
  101608. removePostProcess(postProcess: PostProcess): void;
  101609. /** @hidden */
  101610. _shouldRender(): boolean;
  101611. /**
  101612. * Gets the actual render size of the texture.
  101613. * @returns the width of the render size
  101614. */
  101615. getRenderSize(): number;
  101616. /**
  101617. * Gets the actual render width of the texture.
  101618. * @returns the width of the render size
  101619. */
  101620. getRenderWidth(): number;
  101621. /**
  101622. * Gets the actual render height of the texture.
  101623. * @returns the height of the render size
  101624. */
  101625. getRenderHeight(): number;
  101626. /**
  101627. * Gets the actual number of layers of the texture.
  101628. * @returns the number of layers
  101629. */
  101630. getRenderLayers(): number;
  101631. /**
  101632. * Get if the texture can be rescaled or not.
  101633. */
  101634. get canRescale(): boolean;
  101635. /**
  101636. * Resize the texture using a ratio.
  101637. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101638. */
  101639. scale(ratio: number): void;
  101640. /**
  101641. * Get the texture reflection matrix used to rotate/transform the reflection.
  101642. * @returns the reflection matrix
  101643. */
  101644. getReflectionTextureMatrix(): Matrix;
  101645. /**
  101646. * Resize the texture to a new desired size.
  101647. * Be carrefull as it will recreate all the data in the new texture.
  101648. * @param size Define the new size. It can be:
  101649. * - a number for squared texture,
  101650. * - an object containing { width: number, height: number }
  101651. * - or an object containing a ratio { ratio: number }
  101652. */
  101653. resize(size: number | {
  101654. width: number;
  101655. height: number;
  101656. } | {
  101657. ratio: number;
  101658. }): void;
  101659. private _defaultRenderListPrepared;
  101660. /**
  101661. * Renders all the objects from the render list into the texture.
  101662. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101663. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101664. */
  101665. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101666. private _bestReflectionRenderTargetDimension;
  101667. private _prepareRenderingManager;
  101668. /**
  101669. * @hidden
  101670. * @param faceIndex face index to bind to if this is a cubetexture
  101671. * @param layer defines the index of the texture to bind in the array
  101672. */
  101673. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101674. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101675. private renderToTarget;
  101676. /**
  101677. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101678. * This allowed control for front to back rendering or reversly depending of the special needs.
  101679. *
  101680. * @param renderingGroupId The rendering group id corresponding to its index
  101681. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101682. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101683. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101684. */
  101685. 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;
  101686. /**
  101687. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101688. *
  101689. * @param renderingGroupId The rendering group id corresponding to its index
  101690. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101691. */
  101692. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101693. /**
  101694. * Clones the texture.
  101695. * @returns the cloned texture
  101696. */
  101697. clone(): RenderTargetTexture;
  101698. /**
  101699. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101700. * @returns The JSON representation of the texture
  101701. */
  101702. serialize(): any;
  101703. /**
  101704. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101705. */
  101706. disposeFramebufferObjects(): void;
  101707. /**
  101708. * Dispose the texture and release its associated resources.
  101709. */
  101710. dispose(): void;
  101711. /** @hidden */
  101712. _rebuild(): void;
  101713. /**
  101714. * Clear the info related to rendering groups preventing retention point in material dispose.
  101715. */
  101716. freeRenderingGroups(): void;
  101717. /**
  101718. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101719. * @returns the view count
  101720. */
  101721. getViewCount(): number;
  101722. }
  101723. }
  101724. declare module BABYLON {
  101725. /**
  101726. * Class used to manipulate GUIDs
  101727. */
  101728. export class GUID {
  101729. /**
  101730. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101731. * Be aware Math.random() could cause collisions, but:
  101732. * "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"
  101733. * @returns a pseudo random id
  101734. */
  101735. static RandomId(): string;
  101736. }
  101737. }
  101738. declare module BABYLON {
  101739. /**
  101740. * Options to be used when creating a shadow depth material
  101741. */
  101742. export interface IIOptionShadowDepthMaterial {
  101743. /** Variables in the vertex shader code that need to have their names remapped.
  101744. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101745. * "var_name" should be either: worldPos or vNormalW
  101746. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101747. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101748. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101749. */
  101750. remappedVariables?: string[];
  101751. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101752. standalone?: boolean;
  101753. }
  101754. /**
  101755. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101756. */
  101757. export class ShadowDepthWrapper {
  101758. private _scene;
  101759. private _options?;
  101760. private _baseMaterial;
  101761. private _onEffectCreatedObserver;
  101762. private _subMeshToEffect;
  101763. private _subMeshToDepthEffect;
  101764. private _meshes;
  101765. /** @hidden */
  101766. _matriceNames: any;
  101767. /** Gets the standalone status of the wrapper */
  101768. get standalone(): boolean;
  101769. /** Gets the base material the wrapper is built upon */
  101770. get baseMaterial(): Material;
  101771. /**
  101772. * Instantiate a new shadow depth wrapper.
  101773. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101774. * generate the shadow depth map. For more information, please refer to the documentation:
  101775. * https://doc.babylonjs.com/babylon101/shadows
  101776. * @param baseMaterial Material to wrap
  101777. * @param scene Define the scene the material belongs to
  101778. * @param options Options used to create the wrapper
  101779. */
  101780. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101781. /**
  101782. * Gets the effect to use to generate the depth map
  101783. * @param subMesh subMesh to get the effect for
  101784. * @param shadowGenerator shadow generator to get the effect for
  101785. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101786. */
  101787. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101788. /**
  101789. * Specifies that the submesh is ready to be used for depth rendering
  101790. * @param subMesh submesh to check
  101791. * @param defines the list of defines to take into account when checking the effect
  101792. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101793. * @param useInstances specifies that instances should be used
  101794. * @returns a boolean indicating that the submesh is ready or not
  101795. */
  101796. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101797. /**
  101798. * Disposes the resources
  101799. */
  101800. dispose(): void;
  101801. private _makeEffect;
  101802. }
  101803. }
  101804. declare module BABYLON {
  101805. /**
  101806. * Options for compiling materials.
  101807. */
  101808. export interface IMaterialCompilationOptions {
  101809. /**
  101810. * Defines whether clip planes are enabled.
  101811. */
  101812. clipPlane: boolean;
  101813. /**
  101814. * Defines whether instances are enabled.
  101815. */
  101816. useInstances: boolean;
  101817. }
  101818. /**
  101819. * Options passed when calling customShaderNameResolve
  101820. */
  101821. export interface ICustomShaderNameResolveOptions {
  101822. /**
  101823. * 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
  101824. */
  101825. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101826. }
  101827. /**
  101828. * Base class for the main features of a material in Babylon.js
  101829. */
  101830. export class Material implements IAnimatable {
  101831. /**
  101832. * Returns the triangle fill mode
  101833. */
  101834. static readonly TriangleFillMode: number;
  101835. /**
  101836. * Returns the wireframe mode
  101837. */
  101838. static readonly WireFrameFillMode: number;
  101839. /**
  101840. * Returns the point fill mode
  101841. */
  101842. static readonly PointFillMode: number;
  101843. /**
  101844. * Returns the point list draw mode
  101845. */
  101846. static readonly PointListDrawMode: number;
  101847. /**
  101848. * Returns the line list draw mode
  101849. */
  101850. static readonly LineListDrawMode: number;
  101851. /**
  101852. * Returns the line loop draw mode
  101853. */
  101854. static readonly LineLoopDrawMode: number;
  101855. /**
  101856. * Returns the line strip draw mode
  101857. */
  101858. static readonly LineStripDrawMode: number;
  101859. /**
  101860. * Returns the triangle strip draw mode
  101861. */
  101862. static readonly TriangleStripDrawMode: number;
  101863. /**
  101864. * Returns the triangle fan draw mode
  101865. */
  101866. static readonly TriangleFanDrawMode: number;
  101867. /**
  101868. * Stores the clock-wise side orientation
  101869. */
  101870. static readonly ClockWiseSideOrientation: number;
  101871. /**
  101872. * Stores the counter clock-wise side orientation
  101873. */
  101874. static readonly CounterClockWiseSideOrientation: number;
  101875. /**
  101876. * The dirty texture flag value
  101877. */
  101878. static readonly TextureDirtyFlag: number;
  101879. /**
  101880. * The dirty light flag value
  101881. */
  101882. static readonly LightDirtyFlag: number;
  101883. /**
  101884. * The dirty fresnel flag value
  101885. */
  101886. static readonly FresnelDirtyFlag: number;
  101887. /**
  101888. * The dirty attribute flag value
  101889. */
  101890. static readonly AttributesDirtyFlag: number;
  101891. /**
  101892. * The dirty misc flag value
  101893. */
  101894. static readonly MiscDirtyFlag: number;
  101895. /**
  101896. * The all dirty flag value
  101897. */
  101898. static readonly AllDirtyFlag: number;
  101899. /**
  101900. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101901. */
  101902. static readonly MATERIAL_OPAQUE: number;
  101903. /**
  101904. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101905. */
  101906. static readonly MATERIAL_ALPHATEST: number;
  101907. /**
  101908. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101909. */
  101910. static readonly MATERIAL_ALPHABLEND: number;
  101911. /**
  101912. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101913. * They are also discarded below the alpha cutoff threshold to improve performances.
  101914. */
  101915. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101916. /**
  101917. * The Whiteout method is used to blend normals.
  101918. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101919. */
  101920. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101921. /**
  101922. * The Reoriented Normal Mapping method is used to blend normals.
  101923. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101924. */
  101925. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101926. /**
  101927. * Custom callback helping to override the default shader used in the material.
  101928. */
  101929. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101930. /**
  101931. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101932. */
  101933. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101934. /**
  101935. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101936. * This means that the material can keep using a previous shader while a new one is being compiled.
  101937. * This is mostly used when shader parallel compilation is supported (true by default)
  101938. */
  101939. allowShaderHotSwapping: boolean;
  101940. /**
  101941. * The ID of the material
  101942. */
  101943. id: string;
  101944. /**
  101945. * Gets or sets the unique id of the material
  101946. */
  101947. uniqueId: number;
  101948. /**
  101949. * The name of the material
  101950. */
  101951. name: string;
  101952. /**
  101953. * Gets or sets user defined metadata
  101954. */
  101955. metadata: any;
  101956. /**
  101957. * For internal use only. Please do not use.
  101958. */
  101959. reservedDataStore: any;
  101960. /**
  101961. * Specifies if the ready state should be checked on each call
  101962. */
  101963. checkReadyOnEveryCall: boolean;
  101964. /**
  101965. * Specifies if the ready state should be checked once
  101966. */
  101967. checkReadyOnlyOnce: boolean;
  101968. /**
  101969. * The state of the material
  101970. */
  101971. state: string;
  101972. /**
  101973. * If the material should be rendered to several textures with MRT extension
  101974. */
  101975. get shouldRenderToMRT(): boolean;
  101976. /**
  101977. * The alpha value of the material
  101978. */
  101979. protected _alpha: number;
  101980. /**
  101981. * List of inspectable custom properties (used by the Inspector)
  101982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101983. */
  101984. inspectableCustomProperties: IInspectable[];
  101985. /**
  101986. * Sets the alpha value of the material
  101987. */
  101988. set alpha(value: number);
  101989. /**
  101990. * Gets the alpha value of the material
  101991. */
  101992. get alpha(): number;
  101993. /**
  101994. * Specifies if back face culling is enabled
  101995. */
  101996. protected _backFaceCulling: boolean;
  101997. /**
  101998. * Sets the back-face culling state
  101999. */
  102000. set backFaceCulling(value: boolean);
  102001. /**
  102002. * Gets the back-face culling state
  102003. */
  102004. get backFaceCulling(): boolean;
  102005. /**
  102006. * Stores the value for side orientation
  102007. */
  102008. sideOrientation: number;
  102009. /**
  102010. * Callback triggered when the material is compiled
  102011. */
  102012. onCompiled: Nullable<(effect: Effect) => void>;
  102013. /**
  102014. * Callback triggered when an error occurs
  102015. */
  102016. onError: Nullable<(effect: Effect, errors: string) => void>;
  102017. /**
  102018. * Callback triggered to get the render target textures
  102019. */
  102020. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102021. /**
  102022. * Gets a boolean indicating that current material needs to register RTT
  102023. */
  102024. get hasRenderTargetTextures(): boolean;
  102025. /**
  102026. * Specifies if the material should be serialized
  102027. */
  102028. doNotSerialize: boolean;
  102029. /**
  102030. * @hidden
  102031. */
  102032. _storeEffectOnSubMeshes: boolean;
  102033. /**
  102034. * Stores the animations for the material
  102035. */
  102036. animations: Nullable<Array<Animation>>;
  102037. /**
  102038. * An event triggered when the material is disposed
  102039. */
  102040. onDisposeObservable: Observable<Material>;
  102041. /**
  102042. * An observer which watches for dispose events
  102043. */
  102044. private _onDisposeObserver;
  102045. private _onUnBindObservable;
  102046. /**
  102047. * Called during a dispose event
  102048. */
  102049. set onDispose(callback: () => void);
  102050. private _onBindObservable;
  102051. /**
  102052. * An event triggered when the material is bound
  102053. */
  102054. get onBindObservable(): Observable<AbstractMesh>;
  102055. /**
  102056. * An observer which watches for bind events
  102057. */
  102058. private _onBindObserver;
  102059. /**
  102060. * Called during a bind event
  102061. */
  102062. set onBind(callback: (Mesh: AbstractMesh) => void);
  102063. /**
  102064. * An event triggered when the material is unbound
  102065. */
  102066. get onUnBindObservable(): Observable<Material>;
  102067. protected _onEffectCreatedObservable: Nullable<Observable<{
  102068. effect: Effect;
  102069. subMesh: Nullable<SubMesh>;
  102070. }>>;
  102071. /**
  102072. * An event triggered when the effect is (re)created
  102073. */
  102074. get onEffectCreatedObservable(): Observable<{
  102075. effect: Effect;
  102076. subMesh: Nullable<SubMesh>;
  102077. }>;
  102078. /**
  102079. * Stores the value of the alpha mode
  102080. */
  102081. private _alphaMode;
  102082. /**
  102083. * Sets the value of the alpha mode.
  102084. *
  102085. * | Value | Type | Description |
  102086. * | --- | --- | --- |
  102087. * | 0 | ALPHA_DISABLE | |
  102088. * | 1 | ALPHA_ADD | |
  102089. * | 2 | ALPHA_COMBINE | |
  102090. * | 3 | ALPHA_SUBTRACT | |
  102091. * | 4 | ALPHA_MULTIPLY | |
  102092. * | 5 | ALPHA_MAXIMIZED | |
  102093. * | 6 | ALPHA_ONEONE | |
  102094. * | 7 | ALPHA_PREMULTIPLIED | |
  102095. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102096. * | 9 | ALPHA_INTERPOLATE | |
  102097. * | 10 | ALPHA_SCREENMODE | |
  102098. *
  102099. */
  102100. set alphaMode(value: number);
  102101. /**
  102102. * Gets the value of the alpha mode
  102103. */
  102104. get alphaMode(): number;
  102105. /**
  102106. * Stores the state of the need depth pre-pass value
  102107. */
  102108. private _needDepthPrePass;
  102109. /**
  102110. * Sets the need depth pre-pass value
  102111. */
  102112. set needDepthPrePass(value: boolean);
  102113. /**
  102114. * Gets the depth pre-pass value
  102115. */
  102116. get needDepthPrePass(): boolean;
  102117. /**
  102118. * Specifies if depth writing should be disabled
  102119. */
  102120. disableDepthWrite: boolean;
  102121. /**
  102122. * Specifies if color writing should be disabled
  102123. */
  102124. disableColorWrite: boolean;
  102125. /**
  102126. * Specifies if depth writing should be forced
  102127. */
  102128. forceDepthWrite: boolean;
  102129. /**
  102130. * Specifies the depth function that should be used. 0 means the default engine function
  102131. */
  102132. depthFunction: number;
  102133. /**
  102134. * Specifies if there should be a separate pass for culling
  102135. */
  102136. separateCullingPass: boolean;
  102137. /**
  102138. * Stores the state specifing if fog should be enabled
  102139. */
  102140. private _fogEnabled;
  102141. /**
  102142. * Sets the state for enabling fog
  102143. */
  102144. set fogEnabled(value: boolean);
  102145. /**
  102146. * Gets the value of the fog enabled state
  102147. */
  102148. get fogEnabled(): boolean;
  102149. /**
  102150. * Stores the size of points
  102151. */
  102152. pointSize: number;
  102153. /**
  102154. * Stores the z offset value
  102155. */
  102156. zOffset: number;
  102157. get wireframe(): boolean;
  102158. /**
  102159. * Sets the state of wireframe mode
  102160. */
  102161. set wireframe(value: boolean);
  102162. /**
  102163. * Gets the value specifying if point clouds are enabled
  102164. */
  102165. get pointsCloud(): boolean;
  102166. /**
  102167. * Sets the state of point cloud mode
  102168. */
  102169. set pointsCloud(value: boolean);
  102170. /**
  102171. * Gets the material fill mode
  102172. */
  102173. get fillMode(): number;
  102174. /**
  102175. * Sets the material fill mode
  102176. */
  102177. set fillMode(value: number);
  102178. /**
  102179. * @hidden
  102180. * Stores the effects for the material
  102181. */
  102182. _effect: Nullable<Effect>;
  102183. /**
  102184. * Specifies if uniform buffers should be used
  102185. */
  102186. private _useUBO;
  102187. /**
  102188. * Stores a reference to the scene
  102189. */
  102190. private _scene;
  102191. /**
  102192. * Stores the fill mode state
  102193. */
  102194. private _fillMode;
  102195. /**
  102196. * Specifies if the depth write state should be cached
  102197. */
  102198. private _cachedDepthWriteState;
  102199. /**
  102200. * Specifies if the color write state should be cached
  102201. */
  102202. private _cachedColorWriteState;
  102203. /**
  102204. * Specifies if the depth function state should be cached
  102205. */
  102206. private _cachedDepthFunctionState;
  102207. /**
  102208. * Stores the uniform buffer
  102209. */
  102210. protected _uniformBuffer: UniformBuffer;
  102211. /** @hidden */
  102212. _indexInSceneMaterialArray: number;
  102213. /** @hidden */
  102214. meshMap: Nullable<{
  102215. [id: string]: AbstractMesh | undefined;
  102216. }>;
  102217. /**
  102218. * Creates a material instance
  102219. * @param name defines the name of the material
  102220. * @param scene defines the scene to reference
  102221. * @param doNotAdd specifies if the material should be added to the scene
  102222. */
  102223. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102224. /**
  102225. * Returns a string representation of the current material
  102226. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102227. * @returns a string with material information
  102228. */
  102229. toString(fullDetails?: boolean): string;
  102230. /**
  102231. * Gets the class name of the material
  102232. * @returns a string with the class name of the material
  102233. */
  102234. getClassName(): string;
  102235. /**
  102236. * Specifies if updates for the material been locked
  102237. */
  102238. get isFrozen(): boolean;
  102239. /**
  102240. * Locks updates for the material
  102241. */
  102242. freeze(): void;
  102243. /**
  102244. * Unlocks updates for the material
  102245. */
  102246. unfreeze(): void;
  102247. /**
  102248. * Specifies if the material is ready to be used
  102249. * @param mesh defines the mesh to check
  102250. * @param useInstances specifies if instances should be used
  102251. * @returns a boolean indicating if the material is ready to be used
  102252. */
  102253. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102254. /**
  102255. * Specifies that the submesh is ready to be used
  102256. * @param mesh defines the mesh to check
  102257. * @param subMesh defines which submesh to check
  102258. * @param useInstances specifies that instances should be used
  102259. * @returns a boolean indicating that the submesh is ready or not
  102260. */
  102261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102262. /**
  102263. * Returns the material effect
  102264. * @returns the effect associated with the material
  102265. */
  102266. getEffect(): Nullable<Effect>;
  102267. /**
  102268. * Returns the current scene
  102269. * @returns a Scene
  102270. */
  102271. getScene(): Scene;
  102272. /**
  102273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102274. */
  102275. protected _forceAlphaTest: boolean;
  102276. /**
  102277. * The transparency mode of the material.
  102278. */
  102279. protected _transparencyMode: Nullable<number>;
  102280. /**
  102281. * Gets the current transparency mode.
  102282. */
  102283. get transparencyMode(): Nullable<number>;
  102284. /**
  102285. * Sets the transparency mode of the material.
  102286. *
  102287. * | Value | Type | Description |
  102288. * | ----- | ----------------------------------- | ----------- |
  102289. * | 0 | OPAQUE | |
  102290. * | 1 | ALPHATEST | |
  102291. * | 2 | ALPHABLEND | |
  102292. * | 3 | ALPHATESTANDBLEND | |
  102293. *
  102294. */
  102295. set transparencyMode(value: Nullable<number>);
  102296. /**
  102297. * Returns true if alpha blending should be disabled.
  102298. */
  102299. protected get _disableAlphaBlending(): boolean;
  102300. /**
  102301. * Specifies whether or not this material should be rendered in alpha blend mode.
  102302. * @returns a boolean specifying if alpha blending is needed
  102303. */
  102304. needAlphaBlending(): boolean;
  102305. /**
  102306. * Specifies if the mesh will require alpha blending
  102307. * @param mesh defines the mesh to check
  102308. * @returns a boolean specifying if alpha blending is needed for the mesh
  102309. */
  102310. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102311. /**
  102312. * Specifies whether or not this material should be rendered in alpha test mode.
  102313. * @returns a boolean specifying if an alpha test is needed.
  102314. */
  102315. needAlphaTesting(): boolean;
  102316. /**
  102317. * Specifies if material alpha testing should be turned on for the mesh
  102318. * @param mesh defines the mesh to check
  102319. */
  102320. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102321. /**
  102322. * Gets the texture used for the alpha test
  102323. * @returns the texture to use for alpha testing
  102324. */
  102325. getAlphaTestTexture(): Nullable<BaseTexture>;
  102326. /**
  102327. * Marks the material to indicate that it needs to be re-calculated
  102328. */
  102329. markDirty(): void;
  102330. /** @hidden */
  102331. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102332. /**
  102333. * Binds the material to the mesh
  102334. * @param world defines the world transformation matrix
  102335. * @param mesh defines the mesh to bind the material to
  102336. */
  102337. bind(world: Matrix, mesh?: Mesh): void;
  102338. /**
  102339. * Binds the submesh to the material
  102340. * @param world defines the world transformation matrix
  102341. * @param mesh defines the mesh containing the submesh
  102342. * @param subMesh defines the submesh to bind the material to
  102343. */
  102344. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102345. /**
  102346. * Binds the world matrix to the material
  102347. * @param world defines the world transformation matrix
  102348. */
  102349. bindOnlyWorldMatrix(world: Matrix): void;
  102350. /**
  102351. * Binds the scene's uniform buffer to the effect.
  102352. * @param effect defines the effect to bind to the scene uniform buffer
  102353. * @param sceneUbo defines the uniform buffer storing scene data
  102354. */
  102355. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102356. /**
  102357. * Binds the view matrix to the effect
  102358. * @param effect defines the effect to bind the view matrix to
  102359. */
  102360. bindView(effect: Effect): void;
  102361. /**
  102362. * Binds the view projection matrix to the effect
  102363. * @param effect defines the effect to bind the view projection matrix to
  102364. */
  102365. bindViewProjection(effect: Effect): void;
  102366. /**
  102367. * Processes to execute after binding the material to a mesh
  102368. * @param mesh defines the rendered mesh
  102369. */
  102370. protected _afterBind(mesh?: Mesh): void;
  102371. /**
  102372. * Unbinds the material from the mesh
  102373. */
  102374. unbind(): void;
  102375. /**
  102376. * Gets the active textures from the material
  102377. * @returns an array of textures
  102378. */
  102379. getActiveTextures(): BaseTexture[];
  102380. /**
  102381. * Specifies if the material uses a texture
  102382. * @param texture defines the texture to check against the material
  102383. * @returns a boolean specifying if the material uses the texture
  102384. */
  102385. hasTexture(texture: BaseTexture): boolean;
  102386. /**
  102387. * Makes a duplicate of the material, and gives it a new name
  102388. * @param name defines the new name for the duplicated material
  102389. * @returns the cloned material
  102390. */
  102391. clone(name: string): Nullable<Material>;
  102392. /**
  102393. * Gets the meshes bound to the material
  102394. * @returns an array of meshes bound to the material
  102395. */
  102396. getBindedMeshes(): AbstractMesh[];
  102397. /**
  102398. * Force shader compilation
  102399. * @param mesh defines the mesh associated with this material
  102400. * @param onCompiled defines a function to execute once the material is compiled
  102401. * @param options defines the options to configure the compilation
  102402. * @param onError defines a function to execute if the material fails compiling
  102403. */
  102404. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102405. /**
  102406. * Force shader compilation
  102407. * @param mesh defines the mesh that will use this material
  102408. * @param options defines additional options for compiling the shaders
  102409. * @returns a promise that resolves when the compilation completes
  102410. */
  102411. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102412. private static readonly _AllDirtyCallBack;
  102413. private static readonly _ImageProcessingDirtyCallBack;
  102414. private static readonly _TextureDirtyCallBack;
  102415. private static readonly _FresnelDirtyCallBack;
  102416. private static readonly _MiscDirtyCallBack;
  102417. private static readonly _LightsDirtyCallBack;
  102418. private static readonly _AttributeDirtyCallBack;
  102419. private static _FresnelAndMiscDirtyCallBack;
  102420. private static _TextureAndMiscDirtyCallBack;
  102421. private static readonly _DirtyCallbackArray;
  102422. private static readonly _RunDirtyCallBacks;
  102423. /**
  102424. * Marks a define in the material to indicate that it needs to be re-computed
  102425. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102426. */
  102427. markAsDirty(flag: number): void;
  102428. /**
  102429. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102430. * @param func defines a function which checks material defines against the submeshes
  102431. */
  102432. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102433. /**
  102434. * Indicates that the scene should check if the rendering now needs a prepass
  102435. */
  102436. protected _markScenePrePassDirty(): void;
  102437. /**
  102438. * Indicates that we need to re-calculated for all submeshes
  102439. */
  102440. protected _markAllSubMeshesAsAllDirty(): void;
  102441. /**
  102442. * Indicates that image processing needs to be re-calculated for all submeshes
  102443. */
  102444. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102445. /**
  102446. * Indicates that textures need to be re-calculated for all submeshes
  102447. */
  102448. protected _markAllSubMeshesAsTexturesDirty(): void;
  102449. /**
  102450. * Indicates that fresnel needs to be re-calculated for all submeshes
  102451. */
  102452. protected _markAllSubMeshesAsFresnelDirty(): void;
  102453. /**
  102454. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102455. */
  102456. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102457. /**
  102458. * Indicates that lights need to be re-calculated for all submeshes
  102459. */
  102460. protected _markAllSubMeshesAsLightsDirty(): void;
  102461. /**
  102462. * Indicates that attributes need to be re-calculated for all submeshes
  102463. */
  102464. protected _markAllSubMeshesAsAttributesDirty(): void;
  102465. /**
  102466. * Indicates that misc needs to be re-calculated for all submeshes
  102467. */
  102468. protected _markAllSubMeshesAsMiscDirty(): void;
  102469. /**
  102470. * Indicates that textures and misc need to be re-calculated for all submeshes
  102471. */
  102472. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102473. /**
  102474. * Disposes the material
  102475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102478. */
  102479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102480. /** @hidden */
  102481. private releaseVertexArrayObject;
  102482. /**
  102483. * Serializes this material
  102484. * @returns the serialized material object
  102485. */
  102486. serialize(): any;
  102487. /**
  102488. * Creates a material from parsed material data
  102489. * @param parsedMaterial defines parsed material data
  102490. * @param scene defines the hosting scene
  102491. * @param rootUrl defines the root URL to use to load textures
  102492. * @returns a new material
  102493. */
  102494. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102495. }
  102496. }
  102497. declare module BABYLON {
  102498. /**
  102499. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102500. * separate meshes. This can be use to improve performances.
  102501. * @see https://doc.babylonjs.com/how_to/multi_materials
  102502. */
  102503. export class MultiMaterial extends Material {
  102504. private _subMaterials;
  102505. /**
  102506. * Gets or Sets the list of Materials used within the multi material.
  102507. * They need to be ordered according to the submeshes order in the associated mesh
  102508. */
  102509. get subMaterials(): Nullable<Material>[];
  102510. set subMaterials(value: Nullable<Material>[]);
  102511. /**
  102512. * Function used to align with Node.getChildren()
  102513. * @returns the list of Materials used within the multi material
  102514. */
  102515. getChildren(): Nullable<Material>[];
  102516. /**
  102517. * Instantiates a new Multi Material
  102518. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102519. * separate meshes. This can be use to improve performances.
  102520. * @see https://doc.babylonjs.com/how_to/multi_materials
  102521. * @param name Define the name in the scene
  102522. * @param scene Define the scene the material belongs to
  102523. */
  102524. constructor(name: string, scene: Scene);
  102525. private _hookArray;
  102526. /**
  102527. * Get one of the submaterial by its index in the submaterials array
  102528. * @param index The index to look the sub material at
  102529. * @returns The Material if the index has been defined
  102530. */
  102531. getSubMaterial(index: number): Nullable<Material>;
  102532. /**
  102533. * Get the list of active textures for the whole sub materials list.
  102534. * @returns All the textures that will be used during the rendering
  102535. */
  102536. getActiveTextures(): BaseTexture[];
  102537. /**
  102538. * Gets the current class name of the material e.g. "MultiMaterial"
  102539. * Mainly use in serialization.
  102540. * @returns the class name
  102541. */
  102542. getClassName(): string;
  102543. /**
  102544. * Checks if the material is ready to render the requested sub mesh
  102545. * @param mesh Define the mesh the submesh belongs to
  102546. * @param subMesh Define the sub mesh to look readyness for
  102547. * @param useInstances Define whether or not the material is used with instances
  102548. * @returns true if ready, otherwise false
  102549. */
  102550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102551. /**
  102552. * Clones the current material and its related sub materials
  102553. * @param name Define the name of the newly cloned material
  102554. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102555. * @returns the cloned material
  102556. */
  102557. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102558. /**
  102559. * Serializes the materials into a JSON representation.
  102560. * @returns the JSON representation
  102561. */
  102562. serialize(): any;
  102563. /**
  102564. * Dispose the material and release its associated resources
  102565. * @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)
  102566. * @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)
  102567. * @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)
  102568. */
  102569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102570. /**
  102571. * Creates a MultiMaterial from parsed MultiMaterial data.
  102572. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102573. * @param scene defines the hosting scene
  102574. * @returns a new MultiMaterial
  102575. */
  102576. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102577. }
  102578. }
  102579. declare module BABYLON {
  102580. /**
  102581. * Defines a subdivision inside a mesh
  102582. */
  102583. export class SubMesh implements ICullable {
  102584. /** the material index to use */
  102585. materialIndex: number;
  102586. /** vertex index start */
  102587. verticesStart: number;
  102588. /** vertices count */
  102589. verticesCount: number;
  102590. /** index start */
  102591. indexStart: number;
  102592. /** indices count */
  102593. indexCount: number;
  102594. /** @hidden */
  102595. _materialDefines: Nullable<MaterialDefines>;
  102596. /** @hidden */
  102597. _materialEffect: Nullable<Effect>;
  102598. /** @hidden */
  102599. _effectOverride: Nullable<Effect>;
  102600. /**
  102601. * Gets material defines used by the effect associated to the sub mesh
  102602. */
  102603. get materialDefines(): Nullable<MaterialDefines>;
  102604. /**
  102605. * Sets material defines used by the effect associated to the sub mesh
  102606. */
  102607. set materialDefines(defines: Nullable<MaterialDefines>);
  102608. /**
  102609. * Gets associated effect
  102610. */
  102611. get effect(): Nullable<Effect>;
  102612. /**
  102613. * Sets associated effect (effect used to render this submesh)
  102614. * @param effect defines the effect to associate with
  102615. * @param defines defines the set of defines used to compile this effect
  102616. */
  102617. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102618. /** @hidden */
  102619. _linesIndexCount: number;
  102620. private _mesh;
  102621. private _renderingMesh;
  102622. private _boundingInfo;
  102623. private _linesIndexBuffer;
  102624. /** @hidden */
  102625. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102626. /** @hidden */
  102627. _trianglePlanes: Plane[];
  102628. /** @hidden */
  102629. _lastColliderTransformMatrix: Nullable<Matrix>;
  102630. /** @hidden */
  102631. _renderId: number;
  102632. /** @hidden */
  102633. _alphaIndex: number;
  102634. /** @hidden */
  102635. _distanceToCamera: number;
  102636. /** @hidden */
  102637. _id: number;
  102638. private _currentMaterial;
  102639. /**
  102640. * Add a new submesh to a mesh
  102641. * @param materialIndex defines the material index to use
  102642. * @param verticesStart defines vertex index start
  102643. * @param verticesCount defines vertices count
  102644. * @param indexStart defines index start
  102645. * @param indexCount defines indices count
  102646. * @param mesh defines the parent mesh
  102647. * @param renderingMesh defines an optional rendering mesh
  102648. * @param createBoundingBox defines if bounding box should be created for this submesh
  102649. * @returns the new submesh
  102650. */
  102651. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102652. /**
  102653. * Creates a new submesh
  102654. * @param materialIndex defines the material index to use
  102655. * @param verticesStart defines vertex index start
  102656. * @param verticesCount defines vertices count
  102657. * @param indexStart defines index start
  102658. * @param indexCount defines indices count
  102659. * @param mesh defines the parent mesh
  102660. * @param renderingMesh defines an optional rendering mesh
  102661. * @param createBoundingBox defines if bounding box should be created for this submesh
  102662. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102663. */
  102664. constructor(
  102665. /** the material index to use */
  102666. materialIndex: number,
  102667. /** vertex index start */
  102668. verticesStart: number,
  102669. /** vertices count */
  102670. verticesCount: number,
  102671. /** index start */
  102672. indexStart: number,
  102673. /** indices count */
  102674. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102675. /**
  102676. * Returns true if this submesh covers the entire parent mesh
  102677. * @ignorenaming
  102678. */
  102679. get IsGlobal(): boolean;
  102680. /**
  102681. * Returns the submesh BoudingInfo object
  102682. * @returns current bounding info (or mesh's one if the submesh is global)
  102683. */
  102684. getBoundingInfo(): BoundingInfo;
  102685. /**
  102686. * Sets the submesh BoundingInfo
  102687. * @param boundingInfo defines the new bounding info to use
  102688. * @returns the SubMesh
  102689. */
  102690. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102691. /**
  102692. * Returns the mesh of the current submesh
  102693. * @return the parent mesh
  102694. */
  102695. getMesh(): AbstractMesh;
  102696. /**
  102697. * Returns the rendering mesh of the submesh
  102698. * @returns the rendering mesh (could be different from parent mesh)
  102699. */
  102700. getRenderingMesh(): Mesh;
  102701. /**
  102702. * Returns the replacement mesh of the submesh
  102703. * @returns the replacement mesh (could be different from parent mesh)
  102704. */
  102705. getReplacementMesh(): Nullable<AbstractMesh>;
  102706. /**
  102707. * Returns the effective mesh of the submesh
  102708. * @returns the effective mesh (could be different from parent mesh)
  102709. */
  102710. getEffectiveMesh(): AbstractMesh;
  102711. /**
  102712. * Returns the submesh material
  102713. * @returns null or the current material
  102714. */
  102715. getMaterial(): Nullable<Material>;
  102716. private _IsMultiMaterial;
  102717. /**
  102718. * Sets a new updated BoundingInfo object to the submesh
  102719. * @param data defines an optional position array to use to determine the bounding info
  102720. * @returns the SubMesh
  102721. */
  102722. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102723. /** @hidden */
  102724. _checkCollision(collider: Collider): boolean;
  102725. /**
  102726. * Updates the submesh BoundingInfo
  102727. * @param world defines the world matrix to use to update the bounding info
  102728. * @returns the submesh
  102729. */
  102730. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102731. /**
  102732. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102733. * @param frustumPlanes defines the frustum planes
  102734. * @returns true if the submesh is intersecting with the frustum
  102735. */
  102736. isInFrustum(frustumPlanes: Plane[]): boolean;
  102737. /**
  102738. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102739. * @param frustumPlanes defines the frustum planes
  102740. * @returns true if the submesh is inside the frustum
  102741. */
  102742. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102743. /**
  102744. * Renders the submesh
  102745. * @param enableAlphaMode defines if alpha needs to be used
  102746. * @returns the submesh
  102747. */
  102748. render(enableAlphaMode: boolean): SubMesh;
  102749. /**
  102750. * @hidden
  102751. */
  102752. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102753. /**
  102754. * Checks if the submesh intersects with a ray
  102755. * @param ray defines the ray to test
  102756. * @returns true is the passed ray intersects the submesh bounding box
  102757. */
  102758. canIntersects(ray: Ray): boolean;
  102759. /**
  102760. * Intersects current submesh with a ray
  102761. * @param ray defines the ray to test
  102762. * @param positions defines mesh's positions array
  102763. * @param indices defines mesh's indices array
  102764. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102766. * @returns intersection info or null if no intersection
  102767. */
  102768. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102769. /** @hidden */
  102770. private _intersectLines;
  102771. /** @hidden */
  102772. private _intersectUnIndexedLines;
  102773. /** @hidden */
  102774. private _intersectTriangles;
  102775. /** @hidden */
  102776. private _intersectUnIndexedTriangles;
  102777. /** @hidden */
  102778. _rebuild(): void;
  102779. /**
  102780. * Creates a new submesh from the passed mesh
  102781. * @param newMesh defines the new hosting mesh
  102782. * @param newRenderingMesh defines an optional rendering mesh
  102783. * @returns the new submesh
  102784. */
  102785. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102786. /**
  102787. * Release associated resources
  102788. */
  102789. dispose(): void;
  102790. /**
  102791. * Gets the class name
  102792. * @returns the string "SubMesh".
  102793. */
  102794. getClassName(): string;
  102795. /**
  102796. * Creates a new submesh from indices data
  102797. * @param materialIndex the index of the main mesh material
  102798. * @param startIndex the index where to start the copy in the mesh indices array
  102799. * @param indexCount the number of indices to copy then from the startIndex
  102800. * @param mesh the main mesh to create the submesh from
  102801. * @param renderingMesh the optional rendering mesh
  102802. * @returns a new submesh
  102803. */
  102804. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102805. }
  102806. }
  102807. declare module BABYLON {
  102808. /**
  102809. * Class used to represent data loading progression
  102810. */
  102811. export class SceneLoaderFlags {
  102812. private static _ForceFullSceneLoadingForIncremental;
  102813. private static _ShowLoadingScreen;
  102814. private static _CleanBoneMatrixWeights;
  102815. private static _loggingLevel;
  102816. /**
  102817. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102818. */
  102819. static get ForceFullSceneLoadingForIncremental(): boolean;
  102820. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102821. /**
  102822. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102823. */
  102824. static get ShowLoadingScreen(): boolean;
  102825. static set ShowLoadingScreen(value: boolean);
  102826. /**
  102827. * Defines the current logging level (while loading the scene)
  102828. * @ignorenaming
  102829. */
  102830. static get loggingLevel(): number;
  102831. static set loggingLevel(value: number);
  102832. /**
  102833. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102834. */
  102835. static get CleanBoneMatrixWeights(): boolean;
  102836. static set CleanBoneMatrixWeights(value: boolean);
  102837. }
  102838. }
  102839. declare module BABYLON {
  102840. /**
  102841. * Class used to store geometry data (vertex buffers + index buffer)
  102842. */
  102843. export class Geometry implements IGetSetVerticesData {
  102844. /**
  102845. * Gets or sets the ID of the geometry
  102846. */
  102847. id: string;
  102848. /**
  102849. * Gets or sets the unique ID of the geometry
  102850. */
  102851. uniqueId: number;
  102852. /**
  102853. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102854. */
  102855. delayLoadState: number;
  102856. /**
  102857. * Gets the file containing the data to load when running in delay load state
  102858. */
  102859. delayLoadingFile: Nullable<string>;
  102860. /**
  102861. * Callback called when the geometry is updated
  102862. */
  102863. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102864. private _scene;
  102865. private _engine;
  102866. private _meshes;
  102867. private _totalVertices;
  102868. /** @hidden */
  102869. _indices: IndicesArray;
  102870. /** @hidden */
  102871. _vertexBuffers: {
  102872. [key: string]: VertexBuffer;
  102873. };
  102874. private _isDisposed;
  102875. private _extend;
  102876. private _boundingBias;
  102877. /** @hidden */
  102878. _delayInfo: Array<string>;
  102879. private _indexBuffer;
  102880. private _indexBufferIsUpdatable;
  102881. /** @hidden */
  102882. _boundingInfo: Nullable<BoundingInfo>;
  102883. /** @hidden */
  102884. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102885. /** @hidden */
  102886. _softwareSkinningFrameId: number;
  102887. private _vertexArrayObjects;
  102888. private _updatable;
  102889. /** @hidden */
  102890. _positions: Nullable<Vector3[]>;
  102891. /**
  102892. * 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
  102893. */
  102894. get boundingBias(): Vector2;
  102895. /**
  102896. * 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
  102897. */
  102898. set boundingBias(value: Vector2);
  102899. /**
  102900. * Static function used to attach a new empty geometry to a mesh
  102901. * @param mesh defines the mesh to attach the geometry to
  102902. * @returns the new Geometry
  102903. */
  102904. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102905. /** Get the list of meshes using this geometry */
  102906. get meshes(): Mesh[];
  102907. /**
  102908. * 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
  102909. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  102910. */
  102911. useBoundingInfoFromGeometry: boolean;
  102912. /**
  102913. * Creates a new geometry
  102914. * @param id defines the unique ID
  102915. * @param scene defines the hosting scene
  102916. * @param vertexData defines the VertexData used to get geometry data
  102917. * @param updatable defines if geometry must be updatable (false by default)
  102918. * @param mesh defines the mesh that will be associated with the geometry
  102919. */
  102920. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102921. /**
  102922. * Gets the current extend of the geometry
  102923. */
  102924. get extend(): {
  102925. minimum: Vector3;
  102926. maximum: Vector3;
  102927. };
  102928. /**
  102929. * Gets the hosting scene
  102930. * @returns the hosting Scene
  102931. */
  102932. getScene(): Scene;
  102933. /**
  102934. * Gets the hosting engine
  102935. * @returns the hosting Engine
  102936. */
  102937. getEngine(): Engine;
  102938. /**
  102939. * Defines if the geometry is ready to use
  102940. * @returns true if the geometry is ready to be used
  102941. */
  102942. isReady(): boolean;
  102943. /**
  102944. * Gets a value indicating that the geometry should not be serialized
  102945. */
  102946. get doNotSerialize(): boolean;
  102947. /** @hidden */
  102948. _rebuild(): void;
  102949. /**
  102950. * Affects all geometry data in one call
  102951. * @param vertexData defines the geometry data
  102952. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102953. */
  102954. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102955. /**
  102956. * Set specific vertex data
  102957. * @param kind defines the data kind (Position, normal, etc...)
  102958. * @param data defines the vertex data to use
  102959. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102960. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102961. */
  102962. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102963. /**
  102964. * Removes a specific vertex data
  102965. * @param kind defines the data kind (Position, normal, etc...)
  102966. */
  102967. removeVerticesData(kind: string): void;
  102968. /**
  102969. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102970. * @param buffer defines the vertex buffer to use
  102971. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102972. */
  102973. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102974. /**
  102975. * Update a specific vertex buffer
  102976. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102977. * It will do nothing if the buffer is not updatable
  102978. * @param kind defines the data kind (Position, normal, etc...)
  102979. * @param data defines the data to use
  102980. * @param offset defines the offset in the target buffer where to store the data
  102981. * @param useBytes set to true if the offset is in bytes
  102982. */
  102983. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102984. /**
  102985. * Update a specific vertex buffer
  102986. * This function will create a new buffer if the current one is not updatable
  102987. * @param kind defines the data kind (Position, normal, etc...)
  102988. * @param data defines the data to use
  102989. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102990. */
  102991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102992. private _updateBoundingInfo;
  102993. /** @hidden */
  102994. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102995. /**
  102996. * Gets total number of vertices
  102997. * @returns the total number of vertices
  102998. */
  102999. getTotalVertices(): number;
  103000. /**
  103001. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103002. * @param kind defines the data kind (Position, normal, etc...)
  103003. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103004. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103005. * @returns a float array containing vertex data
  103006. */
  103007. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103008. /**
  103009. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103010. * @param kind defines the data kind (Position, normal, etc...)
  103011. * @returns true if the vertex buffer with the specified kind is updatable
  103012. */
  103013. isVertexBufferUpdatable(kind: string): boolean;
  103014. /**
  103015. * Gets a specific vertex buffer
  103016. * @param kind defines the data kind (Position, normal, etc...)
  103017. * @returns a VertexBuffer
  103018. */
  103019. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103020. /**
  103021. * Returns all vertex buffers
  103022. * @return an object holding all vertex buffers indexed by kind
  103023. */
  103024. getVertexBuffers(): Nullable<{
  103025. [key: string]: VertexBuffer;
  103026. }>;
  103027. /**
  103028. * Gets a boolean indicating if specific vertex buffer is present
  103029. * @param kind defines the data kind (Position, normal, etc...)
  103030. * @returns true if data is present
  103031. */
  103032. isVerticesDataPresent(kind: string): boolean;
  103033. /**
  103034. * Gets a list of all attached data kinds (Position, normal, etc...)
  103035. * @returns a list of string containing all kinds
  103036. */
  103037. getVerticesDataKinds(): string[];
  103038. /**
  103039. * Update index buffer
  103040. * @param indices defines the indices to store in the index buffer
  103041. * @param offset defines the offset in the target buffer where to store the data
  103042. * @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)
  103043. */
  103044. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103045. /**
  103046. * Creates a new index buffer
  103047. * @param indices defines the indices to store in the index buffer
  103048. * @param totalVertices defines the total number of vertices (could be null)
  103049. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103050. */
  103051. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103052. /**
  103053. * Return the total number of indices
  103054. * @returns the total number of indices
  103055. */
  103056. getTotalIndices(): number;
  103057. /**
  103058. * Gets the index buffer array
  103059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103061. * @returns the index buffer array
  103062. */
  103063. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103064. /**
  103065. * Gets the index buffer
  103066. * @return the index buffer
  103067. */
  103068. getIndexBuffer(): Nullable<DataBuffer>;
  103069. /** @hidden */
  103070. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103071. /**
  103072. * Release the associated resources for a specific mesh
  103073. * @param mesh defines the source mesh
  103074. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103075. */
  103076. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103077. /**
  103078. * Apply current geometry to a given mesh
  103079. * @param mesh defines the mesh to apply geometry to
  103080. */
  103081. applyToMesh(mesh: Mesh): void;
  103082. private _updateExtend;
  103083. private _applyToMesh;
  103084. private notifyUpdate;
  103085. /**
  103086. * Load the geometry if it was flagged as delay loaded
  103087. * @param scene defines the hosting scene
  103088. * @param onLoaded defines a callback called when the geometry is loaded
  103089. */
  103090. load(scene: Scene, onLoaded?: () => void): void;
  103091. private _queueLoad;
  103092. /**
  103093. * Invert the geometry to move from a right handed system to a left handed one.
  103094. */
  103095. toLeftHanded(): void;
  103096. /** @hidden */
  103097. _resetPointsArrayCache(): void;
  103098. /** @hidden */
  103099. _generatePointsArray(): boolean;
  103100. /**
  103101. * Gets a value indicating if the geometry is disposed
  103102. * @returns true if the geometry was disposed
  103103. */
  103104. isDisposed(): boolean;
  103105. private _disposeVertexArrayObjects;
  103106. /**
  103107. * Free all associated resources
  103108. */
  103109. dispose(): void;
  103110. /**
  103111. * Clone the current geometry into a new geometry
  103112. * @param id defines the unique ID of the new geometry
  103113. * @returns a new geometry object
  103114. */
  103115. copy(id: string): Geometry;
  103116. /**
  103117. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103118. * @return a JSON representation of the current geometry data (without the vertices data)
  103119. */
  103120. serialize(): any;
  103121. private toNumberArray;
  103122. /**
  103123. * Serialize all vertices data into a JSON oject
  103124. * @returns a JSON representation of the current geometry data
  103125. */
  103126. serializeVerticeData(): any;
  103127. /**
  103128. * Extracts a clone of a mesh geometry
  103129. * @param mesh defines the source mesh
  103130. * @param id defines the unique ID of the new geometry object
  103131. * @returns the new geometry object
  103132. */
  103133. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103134. /**
  103135. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103136. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103137. * Be aware Math.random() could cause collisions, but:
  103138. * "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"
  103139. * @returns a string containing a new GUID
  103140. */
  103141. static RandomId(): string;
  103142. /** @hidden */
  103143. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103144. private static _CleanMatricesWeights;
  103145. /**
  103146. * Create a new geometry from persisted data (Using .babylon file format)
  103147. * @param parsedVertexData defines the persisted data
  103148. * @param scene defines the hosting scene
  103149. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103150. * @returns the new geometry object
  103151. */
  103152. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103153. }
  103154. }
  103155. declare module BABYLON {
  103156. /**
  103157. * Define an interface for all classes that will get and set the data on vertices
  103158. */
  103159. export interface IGetSetVerticesData {
  103160. /**
  103161. * Gets a boolean indicating if specific vertex data is present
  103162. * @param kind defines the vertex data kind to use
  103163. * @returns true is data kind is present
  103164. */
  103165. isVerticesDataPresent(kind: string): boolean;
  103166. /**
  103167. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103168. * @param kind defines the data kind (Position, normal, etc...)
  103169. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103170. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103171. * @returns a float array containing vertex data
  103172. */
  103173. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103174. /**
  103175. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103176. * @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.
  103177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103178. * @returns the indices array or an empty array if the mesh has no geometry
  103179. */
  103180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103181. /**
  103182. * Set specific vertex data
  103183. * @param kind defines the data kind (Position, normal, etc...)
  103184. * @param data defines the vertex data to use
  103185. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103186. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103187. */
  103188. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103189. /**
  103190. * Update a specific associated vertex buffer
  103191. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103192. * - VertexBuffer.PositionKind
  103193. * - VertexBuffer.UVKind
  103194. * - VertexBuffer.UV2Kind
  103195. * - VertexBuffer.UV3Kind
  103196. * - VertexBuffer.UV4Kind
  103197. * - VertexBuffer.UV5Kind
  103198. * - VertexBuffer.UV6Kind
  103199. * - VertexBuffer.ColorKind
  103200. * - VertexBuffer.MatricesIndicesKind
  103201. * - VertexBuffer.MatricesIndicesExtraKind
  103202. * - VertexBuffer.MatricesWeightsKind
  103203. * - VertexBuffer.MatricesWeightsExtraKind
  103204. * @param data defines the data source
  103205. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103206. * @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)
  103207. */
  103208. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103209. /**
  103210. * Creates a new index buffer
  103211. * @param indices defines the indices to store in the index buffer
  103212. * @param totalVertices defines the total number of vertices (could be null)
  103213. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103214. */
  103215. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103216. }
  103217. /**
  103218. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103219. */
  103220. export class VertexData {
  103221. /**
  103222. * Mesh side orientation : usually the external or front surface
  103223. */
  103224. static readonly FRONTSIDE: number;
  103225. /**
  103226. * Mesh side orientation : usually the internal or back surface
  103227. */
  103228. static readonly BACKSIDE: number;
  103229. /**
  103230. * Mesh side orientation : both internal and external or front and back surfaces
  103231. */
  103232. static readonly DOUBLESIDE: number;
  103233. /**
  103234. * Mesh side orientation : by default, `FRONTSIDE`
  103235. */
  103236. static readonly DEFAULTSIDE: number;
  103237. /**
  103238. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103239. */
  103240. positions: Nullable<FloatArray>;
  103241. /**
  103242. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103243. */
  103244. normals: Nullable<FloatArray>;
  103245. /**
  103246. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103247. */
  103248. tangents: Nullable<FloatArray>;
  103249. /**
  103250. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103251. */
  103252. uvs: Nullable<FloatArray>;
  103253. /**
  103254. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103255. */
  103256. uvs2: Nullable<FloatArray>;
  103257. /**
  103258. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103259. */
  103260. uvs3: Nullable<FloatArray>;
  103261. /**
  103262. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103263. */
  103264. uvs4: Nullable<FloatArray>;
  103265. /**
  103266. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103267. */
  103268. uvs5: Nullable<FloatArray>;
  103269. /**
  103270. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103271. */
  103272. uvs6: Nullable<FloatArray>;
  103273. /**
  103274. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103275. */
  103276. colors: Nullable<FloatArray>;
  103277. /**
  103278. * 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).
  103279. */
  103280. matricesIndices: Nullable<FloatArray>;
  103281. /**
  103282. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103283. */
  103284. matricesWeights: Nullable<FloatArray>;
  103285. /**
  103286. * An array extending the number of possible indices
  103287. */
  103288. matricesIndicesExtra: Nullable<FloatArray>;
  103289. /**
  103290. * An array extending the number of possible weights when the number of indices is extended
  103291. */
  103292. matricesWeightsExtra: Nullable<FloatArray>;
  103293. /**
  103294. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103295. */
  103296. indices: Nullable<IndicesArray>;
  103297. /**
  103298. * Uses the passed data array to set the set the values for the specified kind of data
  103299. * @param data a linear array of floating numbers
  103300. * @param kind the type of data that is being set, eg positions, colors etc
  103301. */
  103302. set(data: FloatArray, kind: string): void;
  103303. /**
  103304. * Associates the vertexData to the passed Mesh.
  103305. * Sets it as updatable or not (default `false`)
  103306. * @param mesh the mesh the vertexData is applied to
  103307. * @param updatable when used and having the value true allows new data to update the vertexData
  103308. * @returns the VertexData
  103309. */
  103310. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103311. /**
  103312. * Associates the vertexData to the passed Geometry.
  103313. * Sets it as updatable or not (default `false`)
  103314. * @param geometry the geometry the vertexData is applied to
  103315. * @param updatable when used and having the value true allows new data to update the vertexData
  103316. * @returns VertexData
  103317. */
  103318. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103319. /**
  103320. * Updates the associated mesh
  103321. * @param mesh the mesh to be updated
  103322. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103323. * @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
  103324. * @returns VertexData
  103325. */
  103326. updateMesh(mesh: Mesh): VertexData;
  103327. /**
  103328. * Updates the associated geometry
  103329. * @param geometry the geometry to be updated
  103330. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103331. * @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
  103332. * @returns VertexData.
  103333. */
  103334. updateGeometry(geometry: Geometry): VertexData;
  103335. private _applyTo;
  103336. private _update;
  103337. /**
  103338. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103339. * @param matrix the transforming matrix
  103340. * @returns the VertexData
  103341. */
  103342. transform(matrix: Matrix): VertexData;
  103343. /**
  103344. * Merges the passed VertexData into the current one
  103345. * @param other the VertexData to be merged into the current one
  103346. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103347. * @returns the modified VertexData
  103348. */
  103349. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103350. private _mergeElement;
  103351. private _validate;
  103352. /**
  103353. * Serializes the VertexData
  103354. * @returns a serialized object
  103355. */
  103356. serialize(): any;
  103357. /**
  103358. * Extracts the vertexData from a mesh
  103359. * @param mesh the mesh from which to extract the VertexData
  103360. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103361. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103362. * @returns the object VertexData associated to the passed mesh
  103363. */
  103364. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103365. /**
  103366. * Extracts the vertexData from the geometry
  103367. * @param geometry the geometry from which to extract the VertexData
  103368. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103369. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103370. * @returns the object VertexData associated to the passed mesh
  103371. */
  103372. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103373. private static _ExtractFrom;
  103374. /**
  103375. * Creates the VertexData for a Ribbon
  103376. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103377. * * pathArray array of paths, each of which an array of successive Vector3
  103378. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103379. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103380. * * 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
  103381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103382. * * 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)
  103383. * * 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)
  103384. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103385. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103386. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103387. * @returns the VertexData of the ribbon
  103388. */
  103389. static CreateRibbon(options: {
  103390. pathArray: Vector3[][];
  103391. closeArray?: boolean;
  103392. closePath?: boolean;
  103393. offset?: number;
  103394. sideOrientation?: number;
  103395. frontUVs?: Vector4;
  103396. backUVs?: Vector4;
  103397. invertUV?: boolean;
  103398. uvs?: Vector2[];
  103399. colors?: Color4[];
  103400. }): VertexData;
  103401. /**
  103402. * Creates the VertexData for a box
  103403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103404. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103405. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103406. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103407. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103408. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103409. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103410. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103411. * * 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)
  103412. * * 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)
  103413. * @returns the VertexData of the box
  103414. */
  103415. static CreateBox(options: {
  103416. size?: number;
  103417. width?: number;
  103418. height?: number;
  103419. depth?: number;
  103420. faceUV?: Vector4[];
  103421. faceColors?: Color4[];
  103422. sideOrientation?: number;
  103423. frontUVs?: Vector4;
  103424. backUVs?: Vector4;
  103425. }): VertexData;
  103426. /**
  103427. * Creates the VertexData for a tiled box
  103428. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103429. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103430. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103431. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103433. * @returns the VertexData of the box
  103434. */
  103435. static CreateTiledBox(options: {
  103436. pattern?: number;
  103437. width?: number;
  103438. height?: number;
  103439. depth?: number;
  103440. tileSize?: number;
  103441. tileWidth?: number;
  103442. tileHeight?: number;
  103443. alignHorizontal?: number;
  103444. alignVertical?: number;
  103445. faceUV?: Vector4[];
  103446. faceColors?: Color4[];
  103447. sideOrientation?: number;
  103448. }): VertexData;
  103449. /**
  103450. * Creates the VertexData for a tiled plane
  103451. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103452. * * pattern a limited pattern arrangement depending on the number
  103453. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103454. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103455. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103457. * * 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)
  103458. * * 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)
  103459. * @returns the VertexData of the tiled plane
  103460. */
  103461. static CreateTiledPlane(options: {
  103462. pattern?: number;
  103463. tileSize?: number;
  103464. tileWidth?: number;
  103465. tileHeight?: number;
  103466. size?: number;
  103467. width?: number;
  103468. height?: number;
  103469. alignHorizontal?: number;
  103470. alignVertical?: number;
  103471. sideOrientation?: number;
  103472. frontUVs?: Vector4;
  103473. backUVs?: Vector4;
  103474. }): VertexData;
  103475. /**
  103476. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103478. * * segments sets the number of horizontal strips optional, default 32
  103479. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103480. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103481. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103482. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103483. * * 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
  103484. * * 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
  103485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103486. * * 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)
  103487. * * 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)
  103488. * @returns the VertexData of the ellipsoid
  103489. */
  103490. static CreateSphere(options: {
  103491. segments?: number;
  103492. diameter?: number;
  103493. diameterX?: number;
  103494. diameterY?: number;
  103495. diameterZ?: number;
  103496. arc?: number;
  103497. slice?: number;
  103498. sideOrientation?: number;
  103499. frontUVs?: Vector4;
  103500. backUVs?: Vector4;
  103501. }): VertexData;
  103502. /**
  103503. * Creates the VertexData for a cylinder, cone or prism
  103504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103505. * * height sets the height (y direction) of the cylinder, optional, default 2
  103506. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103507. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103508. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103509. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103510. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103511. * * 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
  103512. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103513. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103514. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103515. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103517. * * 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)
  103518. * * 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)
  103519. * @returns the VertexData of the cylinder, cone or prism
  103520. */
  103521. static CreateCylinder(options: {
  103522. height?: number;
  103523. diameterTop?: number;
  103524. diameterBottom?: number;
  103525. diameter?: number;
  103526. tessellation?: number;
  103527. subdivisions?: number;
  103528. arc?: number;
  103529. faceColors?: Color4[];
  103530. faceUV?: Vector4[];
  103531. hasRings?: boolean;
  103532. enclose?: boolean;
  103533. sideOrientation?: number;
  103534. frontUVs?: Vector4;
  103535. backUVs?: Vector4;
  103536. }): VertexData;
  103537. /**
  103538. * Creates the VertexData for a torus
  103539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103540. * * diameter the diameter of the torus, optional default 1
  103541. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103542. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103543. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103544. * * 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)
  103545. * * 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)
  103546. * @returns the VertexData of the torus
  103547. */
  103548. static CreateTorus(options: {
  103549. diameter?: number;
  103550. thickness?: number;
  103551. tessellation?: number;
  103552. sideOrientation?: number;
  103553. frontUVs?: Vector4;
  103554. backUVs?: Vector4;
  103555. }): VertexData;
  103556. /**
  103557. * Creates the VertexData of the LineSystem
  103558. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103559. * - lines an array of lines, each line being an array of successive Vector3
  103560. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103561. * @returns the VertexData of the LineSystem
  103562. */
  103563. static CreateLineSystem(options: {
  103564. lines: Vector3[][];
  103565. colors?: Nullable<Color4[][]>;
  103566. }): VertexData;
  103567. /**
  103568. * Create the VertexData for a DashedLines
  103569. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103570. * - points an array successive Vector3
  103571. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103572. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103573. * - dashNb the intended total number of dashes, optional, default 200
  103574. * @returns the VertexData for the DashedLines
  103575. */
  103576. static CreateDashedLines(options: {
  103577. points: Vector3[];
  103578. dashSize?: number;
  103579. gapSize?: number;
  103580. dashNb?: number;
  103581. }): VertexData;
  103582. /**
  103583. * Creates the VertexData for a Ground
  103584. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103585. * - width the width (x direction) of the ground, optional, default 1
  103586. * - height the height (z direction) of the ground, optional, default 1
  103587. * - subdivisions the number of subdivisions per side, optional, default 1
  103588. * @returns the VertexData of the Ground
  103589. */
  103590. static CreateGround(options: {
  103591. width?: number;
  103592. height?: number;
  103593. subdivisions?: number;
  103594. subdivisionsX?: number;
  103595. subdivisionsY?: number;
  103596. }): VertexData;
  103597. /**
  103598. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103599. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103600. * * xmin the ground minimum X coordinate, optional, default -1
  103601. * * zmin the ground minimum Z coordinate, optional, default -1
  103602. * * xmax the ground maximum X coordinate, optional, default 1
  103603. * * zmax the ground maximum Z coordinate, optional, default 1
  103604. * * 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}
  103605. * * 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}
  103606. * @returns the VertexData of the TiledGround
  103607. */
  103608. static CreateTiledGround(options: {
  103609. xmin: number;
  103610. zmin: number;
  103611. xmax: number;
  103612. zmax: number;
  103613. subdivisions?: {
  103614. w: number;
  103615. h: number;
  103616. };
  103617. precision?: {
  103618. w: number;
  103619. h: number;
  103620. };
  103621. }): VertexData;
  103622. /**
  103623. * Creates the VertexData of the Ground designed from a heightmap
  103624. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103625. * * width the width (x direction) of the ground
  103626. * * height the height (z direction) of the ground
  103627. * * subdivisions the number of subdivisions per side
  103628. * * minHeight the minimum altitude on the ground, optional, default 0
  103629. * * maxHeight the maximum altitude on the ground, optional default 1
  103630. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103631. * * buffer the array holding the image color data
  103632. * * bufferWidth the width of image
  103633. * * bufferHeight the height of image
  103634. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103635. * @returns the VertexData of the Ground designed from a heightmap
  103636. */
  103637. static CreateGroundFromHeightMap(options: {
  103638. width: number;
  103639. height: number;
  103640. subdivisions: number;
  103641. minHeight: number;
  103642. maxHeight: number;
  103643. colorFilter: Color3;
  103644. buffer: Uint8Array;
  103645. bufferWidth: number;
  103646. bufferHeight: number;
  103647. alphaFilter: number;
  103648. }): VertexData;
  103649. /**
  103650. * Creates the VertexData for a Plane
  103651. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103652. * * size sets the width and height of the plane to the value of size, optional default 1
  103653. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103654. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103656. * * 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)
  103657. * * 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)
  103658. * @returns the VertexData of the box
  103659. */
  103660. static CreatePlane(options: {
  103661. size?: number;
  103662. width?: number;
  103663. height?: number;
  103664. sideOrientation?: number;
  103665. frontUVs?: Vector4;
  103666. backUVs?: Vector4;
  103667. }): VertexData;
  103668. /**
  103669. * Creates the VertexData of the Disc or regular Polygon
  103670. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103671. * * radius the radius of the disc, optional default 0.5
  103672. * * tessellation the number of polygon sides, optional, default 64
  103673. * * 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
  103674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103675. * * 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)
  103676. * * 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)
  103677. * @returns the VertexData of the box
  103678. */
  103679. static CreateDisc(options: {
  103680. radius?: number;
  103681. tessellation?: number;
  103682. arc?: number;
  103683. sideOrientation?: number;
  103684. frontUVs?: Vector4;
  103685. backUVs?: Vector4;
  103686. }): VertexData;
  103687. /**
  103688. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103689. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103690. * @param polygon a mesh built from polygonTriangulation.build()
  103691. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103692. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103693. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103694. * @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)
  103695. * @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)
  103696. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103697. * @returns the VertexData of the Polygon
  103698. */
  103699. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103700. /**
  103701. * Creates the VertexData of the IcoSphere
  103702. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103703. * * radius the radius of the IcoSphere, optional default 1
  103704. * * radiusX allows stretching in the x direction, optional, default radius
  103705. * * radiusY allows stretching in the y direction, optional, default radius
  103706. * * radiusZ allows stretching in the z direction, optional, default radius
  103707. * * flat when true creates a flat shaded mesh, optional, default true
  103708. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103710. * * 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)
  103711. * * 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)
  103712. * @returns the VertexData of the IcoSphere
  103713. */
  103714. static CreateIcoSphere(options: {
  103715. radius?: number;
  103716. radiusX?: number;
  103717. radiusY?: number;
  103718. radiusZ?: number;
  103719. flat?: boolean;
  103720. subdivisions?: number;
  103721. sideOrientation?: number;
  103722. frontUVs?: Vector4;
  103723. backUVs?: Vector4;
  103724. }): VertexData;
  103725. /**
  103726. * Creates the VertexData for a Polyhedron
  103727. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103728. * * type provided types are:
  103729. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103730. * * 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)
  103731. * * size the size of the IcoSphere, optional default 1
  103732. * * sizeX allows stretching in the x direction, optional, default size
  103733. * * sizeY allows stretching in the y direction, optional, default size
  103734. * * sizeZ allows stretching in the z direction, optional, default size
  103735. * * 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
  103736. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103737. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103738. * * flat when true creates a flat shaded mesh, optional, default true
  103739. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103741. * * 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)
  103742. * * 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)
  103743. * @returns the VertexData of the Polyhedron
  103744. */
  103745. static CreatePolyhedron(options: {
  103746. type?: number;
  103747. size?: number;
  103748. sizeX?: number;
  103749. sizeY?: number;
  103750. sizeZ?: number;
  103751. custom?: any;
  103752. faceUV?: Vector4[];
  103753. faceColors?: Color4[];
  103754. flat?: boolean;
  103755. sideOrientation?: number;
  103756. frontUVs?: Vector4;
  103757. backUVs?: Vector4;
  103758. }): VertexData;
  103759. /**
  103760. * Creates the VertexData for a TorusKnot
  103761. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103762. * * radius the radius of the torus knot, optional, default 2
  103763. * * tube the thickness of the tube, optional, default 0.5
  103764. * * radialSegments the number of sides on each tube segments, optional, default 32
  103765. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103766. * * p the number of windings around the z axis, optional, default 2
  103767. * * q the number of windings around the x axis, optional, default 3
  103768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103769. * * 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)
  103770. * * 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)
  103771. * @returns the VertexData of the Torus Knot
  103772. */
  103773. static CreateTorusKnot(options: {
  103774. radius?: number;
  103775. tube?: number;
  103776. radialSegments?: number;
  103777. tubularSegments?: number;
  103778. p?: number;
  103779. q?: number;
  103780. sideOrientation?: number;
  103781. frontUVs?: Vector4;
  103782. backUVs?: Vector4;
  103783. }): VertexData;
  103784. /**
  103785. * Compute normals for given positions and indices
  103786. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103787. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103788. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103789. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103790. * * facetNormals : optional array of facet normals (vector3)
  103791. * * facetPositions : optional array of facet positions (vector3)
  103792. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103793. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103794. * * bInfo : optional bounding info, required for facetPartitioning computation
  103795. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103796. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103797. * * useRightHandedSystem: optional boolean to for right handed system computation
  103798. * * depthSort : optional boolean to enable the facet depth sort computation
  103799. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103800. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103801. */
  103802. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103803. facetNormals?: any;
  103804. facetPositions?: any;
  103805. facetPartitioning?: any;
  103806. ratio?: number;
  103807. bInfo?: any;
  103808. bbSize?: Vector3;
  103809. subDiv?: any;
  103810. useRightHandedSystem?: boolean;
  103811. depthSort?: boolean;
  103812. distanceTo?: Vector3;
  103813. depthSortedFacets?: any;
  103814. }): void;
  103815. /** @hidden */
  103816. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103817. /**
  103818. * Applies VertexData created from the imported parameters to the geometry
  103819. * @param parsedVertexData the parsed data from an imported file
  103820. * @param geometry the geometry to apply the VertexData to
  103821. */
  103822. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103823. }
  103824. }
  103825. declare module BABYLON {
  103826. /**
  103827. * Defines a target to use with MorphTargetManager
  103828. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103829. */
  103830. export class MorphTarget implements IAnimatable {
  103831. /** defines the name of the target */
  103832. name: string;
  103833. /**
  103834. * Gets or sets the list of animations
  103835. */
  103836. animations: Animation[];
  103837. private _scene;
  103838. private _positions;
  103839. private _normals;
  103840. private _tangents;
  103841. private _uvs;
  103842. private _influence;
  103843. private _uniqueId;
  103844. /**
  103845. * Observable raised when the influence changes
  103846. */
  103847. onInfluenceChanged: Observable<boolean>;
  103848. /** @hidden */
  103849. _onDataLayoutChanged: Observable<void>;
  103850. /**
  103851. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103852. */
  103853. get influence(): number;
  103854. set influence(influence: number);
  103855. /**
  103856. * Gets or sets the id of the morph Target
  103857. */
  103858. id: string;
  103859. private _animationPropertiesOverride;
  103860. /**
  103861. * Gets or sets the animation properties override
  103862. */
  103863. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103864. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103865. /**
  103866. * Creates a new MorphTarget
  103867. * @param name defines the name of the target
  103868. * @param influence defines the influence to use
  103869. * @param scene defines the scene the morphtarget belongs to
  103870. */
  103871. constructor(
  103872. /** defines the name of the target */
  103873. name: string, influence?: number, scene?: Nullable<Scene>);
  103874. /**
  103875. * Gets the unique ID of this manager
  103876. */
  103877. get uniqueId(): number;
  103878. /**
  103879. * Gets a boolean defining if the target contains position data
  103880. */
  103881. get hasPositions(): boolean;
  103882. /**
  103883. * Gets a boolean defining if the target contains normal data
  103884. */
  103885. get hasNormals(): boolean;
  103886. /**
  103887. * Gets a boolean defining if the target contains tangent data
  103888. */
  103889. get hasTangents(): boolean;
  103890. /**
  103891. * Gets a boolean defining if the target contains texture coordinates data
  103892. */
  103893. get hasUVs(): boolean;
  103894. /**
  103895. * Affects position data to this target
  103896. * @param data defines the position data to use
  103897. */
  103898. setPositions(data: Nullable<FloatArray>): void;
  103899. /**
  103900. * Gets the position data stored in this target
  103901. * @returns a FloatArray containing the position data (or null if not present)
  103902. */
  103903. getPositions(): Nullable<FloatArray>;
  103904. /**
  103905. * Affects normal data to this target
  103906. * @param data defines the normal data to use
  103907. */
  103908. setNormals(data: Nullable<FloatArray>): void;
  103909. /**
  103910. * Gets the normal data stored in this target
  103911. * @returns a FloatArray containing the normal data (or null if not present)
  103912. */
  103913. getNormals(): Nullable<FloatArray>;
  103914. /**
  103915. * Affects tangent data to this target
  103916. * @param data defines the tangent data to use
  103917. */
  103918. setTangents(data: Nullable<FloatArray>): void;
  103919. /**
  103920. * Gets the tangent data stored in this target
  103921. * @returns a FloatArray containing the tangent data (or null if not present)
  103922. */
  103923. getTangents(): Nullable<FloatArray>;
  103924. /**
  103925. * Affects texture coordinates data to this target
  103926. * @param data defines the texture coordinates data to use
  103927. */
  103928. setUVs(data: Nullable<FloatArray>): void;
  103929. /**
  103930. * Gets the texture coordinates data stored in this target
  103931. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103932. */
  103933. getUVs(): Nullable<FloatArray>;
  103934. /**
  103935. * Clone the current target
  103936. * @returns a new MorphTarget
  103937. */
  103938. clone(): MorphTarget;
  103939. /**
  103940. * Serializes the current target into a Serialization object
  103941. * @returns the serialized object
  103942. */
  103943. serialize(): any;
  103944. /**
  103945. * Returns the string "MorphTarget"
  103946. * @returns "MorphTarget"
  103947. */
  103948. getClassName(): string;
  103949. /**
  103950. * Creates a new target from serialized data
  103951. * @param serializationObject defines the serialized data to use
  103952. * @returns a new MorphTarget
  103953. */
  103954. static Parse(serializationObject: any): MorphTarget;
  103955. /**
  103956. * Creates a MorphTarget from mesh data
  103957. * @param mesh defines the source mesh
  103958. * @param name defines the name to use for the new target
  103959. * @param influence defines the influence to attach to the target
  103960. * @returns a new MorphTarget
  103961. */
  103962. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103963. }
  103964. }
  103965. declare module BABYLON {
  103966. /**
  103967. * This class is used to deform meshes using morphing between different targets
  103968. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103969. */
  103970. export class MorphTargetManager {
  103971. private _targets;
  103972. private _targetInfluenceChangedObservers;
  103973. private _targetDataLayoutChangedObservers;
  103974. private _activeTargets;
  103975. private _scene;
  103976. private _influences;
  103977. private _supportsNormals;
  103978. private _supportsTangents;
  103979. private _supportsUVs;
  103980. private _vertexCount;
  103981. private _uniqueId;
  103982. private _tempInfluences;
  103983. /**
  103984. * Gets or sets a boolean indicating if normals must be morphed
  103985. */
  103986. enableNormalMorphing: boolean;
  103987. /**
  103988. * Gets or sets a boolean indicating if tangents must be morphed
  103989. */
  103990. enableTangentMorphing: boolean;
  103991. /**
  103992. * Gets or sets a boolean indicating if UV must be morphed
  103993. */
  103994. enableUVMorphing: boolean;
  103995. /**
  103996. * Creates a new MorphTargetManager
  103997. * @param scene defines the current scene
  103998. */
  103999. constructor(scene?: Nullable<Scene>);
  104000. /**
  104001. * Gets the unique ID of this manager
  104002. */
  104003. get uniqueId(): number;
  104004. /**
  104005. * Gets the number of vertices handled by this manager
  104006. */
  104007. get vertexCount(): number;
  104008. /**
  104009. * Gets a boolean indicating if this manager supports morphing of normals
  104010. */
  104011. get supportsNormals(): boolean;
  104012. /**
  104013. * Gets a boolean indicating if this manager supports morphing of tangents
  104014. */
  104015. get supportsTangents(): boolean;
  104016. /**
  104017. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104018. */
  104019. get supportsUVs(): boolean;
  104020. /**
  104021. * Gets the number of targets stored in this manager
  104022. */
  104023. get numTargets(): number;
  104024. /**
  104025. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104026. */
  104027. get numInfluencers(): number;
  104028. /**
  104029. * Gets the list of influences (one per target)
  104030. */
  104031. get influences(): Float32Array;
  104032. /**
  104033. * Gets the active target at specified index. An active target is a target with an influence > 0
  104034. * @param index defines the index to check
  104035. * @returns the requested target
  104036. */
  104037. getActiveTarget(index: number): MorphTarget;
  104038. /**
  104039. * Gets the target at specified index
  104040. * @param index defines the index to check
  104041. * @returns the requested target
  104042. */
  104043. getTarget(index: number): MorphTarget;
  104044. /**
  104045. * Add a new target to this manager
  104046. * @param target defines the target to add
  104047. */
  104048. addTarget(target: MorphTarget): void;
  104049. /**
  104050. * Removes a target from the manager
  104051. * @param target defines the target to remove
  104052. */
  104053. removeTarget(target: MorphTarget): void;
  104054. /**
  104055. * Clone the current manager
  104056. * @returns a new MorphTargetManager
  104057. */
  104058. clone(): MorphTargetManager;
  104059. /**
  104060. * Serializes the current manager into a Serialization object
  104061. * @returns the serialized object
  104062. */
  104063. serialize(): any;
  104064. private _syncActiveTargets;
  104065. /**
  104066. * Syncrhonize the targets with all the meshes using this morph target manager
  104067. */
  104068. synchronize(): void;
  104069. /**
  104070. * Creates a new MorphTargetManager from serialized data
  104071. * @param serializationObject defines the serialized data
  104072. * @param scene defines the hosting scene
  104073. * @returns the new MorphTargetManager
  104074. */
  104075. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104076. }
  104077. }
  104078. declare module BABYLON {
  104079. /**
  104080. * Class used to represent a specific level of detail of a mesh
  104081. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104082. */
  104083. export class MeshLODLevel {
  104084. /** Defines the distance where this level should start being displayed */
  104085. distance: number;
  104086. /** Defines the mesh to use to render this level */
  104087. mesh: Nullable<Mesh>;
  104088. /**
  104089. * Creates a new LOD level
  104090. * @param distance defines the distance where this level should star being displayed
  104091. * @param mesh defines the mesh to use to render this level
  104092. */
  104093. constructor(
  104094. /** Defines the distance where this level should start being displayed */
  104095. distance: number,
  104096. /** Defines the mesh to use to render this level */
  104097. mesh: Nullable<Mesh>);
  104098. }
  104099. }
  104100. declare module BABYLON {
  104101. /**
  104102. * Helper class used to generate a canvas to manipulate images
  104103. */
  104104. export class CanvasGenerator {
  104105. /**
  104106. * Create a new canvas (or offscreen canvas depending on the context)
  104107. * @param width defines the expected width
  104108. * @param height defines the expected height
  104109. * @return a new canvas or offscreen canvas
  104110. */
  104111. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104112. }
  104113. }
  104114. declare module BABYLON {
  104115. /**
  104116. * Mesh representing the gorund
  104117. */
  104118. export class GroundMesh extends Mesh {
  104119. /** If octree should be generated */
  104120. generateOctree: boolean;
  104121. private _heightQuads;
  104122. /** @hidden */
  104123. _subdivisionsX: number;
  104124. /** @hidden */
  104125. _subdivisionsY: number;
  104126. /** @hidden */
  104127. _width: number;
  104128. /** @hidden */
  104129. _height: number;
  104130. /** @hidden */
  104131. _minX: number;
  104132. /** @hidden */
  104133. _maxX: number;
  104134. /** @hidden */
  104135. _minZ: number;
  104136. /** @hidden */
  104137. _maxZ: number;
  104138. constructor(name: string, scene: Scene);
  104139. /**
  104140. * "GroundMesh"
  104141. * @returns "GroundMesh"
  104142. */
  104143. getClassName(): string;
  104144. /**
  104145. * The minimum of x and y subdivisions
  104146. */
  104147. get subdivisions(): number;
  104148. /**
  104149. * X subdivisions
  104150. */
  104151. get subdivisionsX(): number;
  104152. /**
  104153. * Y subdivisions
  104154. */
  104155. get subdivisionsY(): number;
  104156. /**
  104157. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104158. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104159. * @param chunksCount the number of subdivisions for x and y
  104160. * @param octreeBlocksSize (Default: 32)
  104161. */
  104162. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104163. /**
  104164. * Returns a height (y) value in the Worl system :
  104165. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104166. * @param x x coordinate
  104167. * @param z z coordinate
  104168. * @returns the ground y position if (x, z) are outside the ground surface.
  104169. */
  104170. getHeightAtCoordinates(x: number, z: number): number;
  104171. /**
  104172. * Returns a normalized vector (Vector3) orthogonal to the ground
  104173. * at the ground coordinates (x, z) expressed in the World system.
  104174. * @param x x coordinate
  104175. * @param z z coordinate
  104176. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104177. */
  104178. getNormalAtCoordinates(x: number, z: number): Vector3;
  104179. /**
  104180. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104181. * at the ground coordinates (x, z) expressed in the World system.
  104182. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104183. * @param x x coordinate
  104184. * @param z z coordinate
  104185. * @param ref vector to store the result
  104186. * @returns the GroundMesh.
  104187. */
  104188. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104189. /**
  104190. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104191. * if the ground has been updated.
  104192. * This can be used in the render loop.
  104193. * @returns the GroundMesh.
  104194. */
  104195. updateCoordinateHeights(): GroundMesh;
  104196. private _getFacetAt;
  104197. private _initHeightQuads;
  104198. private _computeHeightQuads;
  104199. /**
  104200. * Serializes this ground mesh
  104201. * @param serializationObject object to write serialization to
  104202. */
  104203. serialize(serializationObject: any): void;
  104204. /**
  104205. * Parses a serialized ground mesh
  104206. * @param parsedMesh the serialized mesh
  104207. * @param scene the scene to create the ground mesh in
  104208. * @returns the created ground mesh
  104209. */
  104210. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Interface for Physics-Joint data
  104216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104217. */
  104218. export interface PhysicsJointData {
  104219. /**
  104220. * The main pivot of the joint
  104221. */
  104222. mainPivot?: Vector3;
  104223. /**
  104224. * The connected pivot of the joint
  104225. */
  104226. connectedPivot?: Vector3;
  104227. /**
  104228. * The main axis of the joint
  104229. */
  104230. mainAxis?: Vector3;
  104231. /**
  104232. * The connected axis of the joint
  104233. */
  104234. connectedAxis?: Vector3;
  104235. /**
  104236. * The collision of the joint
  104237. */
  104238. collision?: boolean;
  104239. /**
  104240. * Native Oimo/Cannon/Energy data
  104241. */
  104242. nativeParams?: any;
  104243. }
  104244. /**
  104245. * This is a holder class for the physics joint created by the physics plugin
  104246. * It holds a set of functions to control the underlying joint
  104247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104248. */
  104249. export class PhysicsJoint {
  104250. /**
  104251. * The type of the physics joint
  104252. */
  104253. type: number;
  104254. /**
  104255. * The data for the physics joint
  104256. */
  104257. jointData: PhysicsJointData;
  104258. private _physicsJoint;
  104259. protected _physicsPlugin: IPhysicsEnginePlugin;
  104260. /**
  104261. * Initializes the physics joint
  104262. * @param type The type of the physics joint
  104263. * @param jointData The data for the physics joint
  104264. */
  104265. constructor(
  104266. /**
  104267. * The type of the physics joint
  104268. */
  104269. type: number,
  104270. /**
  104271. * The data for the physics joint
  104272. */
  104273. jointData: PhysicsJointData);
  104274. /**
  104275. * Gets the physics joint
  104276. */
  104277. get physicsJoint(): any;
  104278. /**
  104279. * Sets the physics joint
  104280. */
  104281. set physicsJoint(newJoint: any);
  104282. /**
  104283. * Sets the physics plugin
  104284. */
  104285. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104286. /**
  104287. * Execute a function that is physics-plugin specific.
  104288. * @param {Function} func the function that will be executed.
  104289. * It accepts two parameters: the physics world and the physics joint
  104290. */
  104291. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104292. /**
  104293. * Distance-Joint type
  104294. */
  104295. static DistanceJoint: number;
  104296. /**
  104297. * Hinge-Joint type
  104298. */
  104299. static HingeJoint: number;
  104300. /**
  104301. * Ball-and-Socket joint type
  104302. */
  104303. static BallAndSocketJoint: number;
  104304. /**
  104305. * Wheel-Joint type
  104306. */
  104307. static WheelJoint: number;
  104308. /**
  104309. * Slider-Joint type
  104310. */
  104311. static SliderJoint: number;
  104312. /**
  104313. * Prismatic-Joint type
  104314. */
  104315. static PrismaticJoint: number;
  104316. /**
  104317. * Universal-Joint type
  104318. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104319. */
  104320. static UniversalJoint: number;
  104321. /**
  104322. * Hinge-Joint 2 type
  104323. */
  104324. static Hinge2Joint: number;
  104325. /**
  104326. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104327. */
  104328. static PointToPointJoint: number;
  104329. /**
  104330. * Spring-Joint type
  104331. */
  104332. static SpringJoint: number;
  104333. /**
  104334. * Lock-Joint type
  104335. */
  104336. static LockJoint: number;
  104337. }
  104338. /**
  104339. * A class representing a physics distance joint
  104340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104341. */
  104342. export class DistanceJoint extends PhysicsJoint {
  104343. /**
  104344. *
  104345. * @param jointData The data for the Distance-Joint
  104346. */
  104347. constructor(jointData: DistanceJointData);
  104348. /**
  104349. * Update the predefined distance.
  104350. * @param maxDistance The maximum preferred distance
  104351. * @param minDistance The minimum preferred distance
  104352. */
  104353. updateDistance(maxDistance: number, minDistance?: number): void;
  104354. }
  104355. /**
  104356. * Represents a Motor-Enabled Joint
  104357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104358. */
  104359. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104360. /**
  104361. * Initializes the Motor-Enabled Joint
  104362. * @param type The type of the joint
  104363. * @param jointData The physica joint data for the joint
  104364. */
  104365. constructor(type: number, jointData: PhysicsJointData);
  104366. /**
  104367. * Set the motor values.
  104368. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104369. * @param force the force to apply
  104370. * @param maxForce max force for this motor.
  104371. */
  104372. setMotor(force?: number, maxForce?: number): void;
  104373. /**
  104374. * Set the motor's limits.
  104375. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104376. * @param upperLimit The upper limit of the motor
  104377. * @param lowerLimit The lower limit of the motor
  104378. */
  104379. setLimit(upperLimit: number, lowerLimit?: number): void;
  104380. }
  104381. /**
  104382. * This class represents a single physics Hinge-Joint
  104383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104384. */
  104385. export class HingeJoint extends MotorEnabledJoint {
  104386. /**
  104387. * Initializes the Hinge-Joint
  104388. * @param jointData The joint data for the Hinge-Joint
  104389. */
  104390. constructor(jointData: PhysicsJointData);
  104391. /**
  104392. * Set the motor values.
  104393. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104394. * @param {number} force the force to apply
  104395. * @param {number} maxForce max force for this motor.
  104396. */
  104397. setMotor(force?: number, maxForce?: number): void;
  104398. /**
  104399. * Set the motor's limits.
  104400. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104401. * @param upperLimit The upper limit of the motor
  104402. * @param lowerLimit The lower limit of the motor
  104403. */
  104404. setLimit(upperLimit: number, lowerLimit?: number): void;
  104405. }
  104406. /**
  104407. * This class represents a dual hinge physics joint (same as wheel joint)
  104408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104409. */
  104410. export class Hinge2Joint extends MotorEnabledJoint {
  104411. /**
  104412. * Initializes the Hinge2-Joint
  104413. * @param jointData The joint data for the Hinge2-Joint
  104414. */
  104415. constructor(jointData: PhysicsJointData);
  104416. /**
  104417. * Set the motor values.
  104418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104419. * @param {number} targetSpeed the speed the motor is to reach
  104420. * @param {number} maxForce max force for this motor.
  104421. * @param {motorIndex} the motor's index, 0 or 1.
  104422. */
  104423. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104424. /**
  104425. * Set the motor limits.
  104426. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104427. * @param {number} upperLimit the upper limit
  104428. * @param {number} lowerLimit lower limit
  104429. * @param {motorIndex} the motor's index, 0 or 1.
  104430. */
  104431. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104432. }
  104433. /**
  104434. * Interface for a motor enabled joint
  104435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104436. */
  104437. export interface IMotorEnabledJoint {
  104438. /**
  104439. * Physics joint
  104440. */
  104441. physicsJoint: any;
  104442. /**
  104443. * Sets the motor of the motor-enabled joint
  104444. * @param force The force of the motor
  104445. * @param maxForce The maximum force of the motor
  104446. * @param motorIndex The index of the motor
  104447. */
  104448. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104449. /**
  104450. * Sets the limit of the motor
  104451. * @param upperLimit The upper limit of the motor
  104452. * @param lowerLimit The lower limit of the motor
  104453. * @param motorIndex The index of the motor
  104454. */
  104455. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104456. }
  104457. /**
  104458. * Joint data for a Distance-Joint
  104459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104460. */
  104461. export interface DistanceJointData extends PhysicsJointData {
  104462. /**
  104463. * Max distance the 2 joint objects can be apart
  104464. */
  104465. maxDistance: number;
  104466. }
  104467. /**
  104468. * Joint data from a spring joint
  104469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104470. */
  104471. export interface SpringJointData extends PhysicsJointData {
  104472. /**
  104473. * Length of the spring
  104474. */
  104475. length: number;
  104476. /**
  104477. * Stiffness of the spring
  104478. */
  104479. stiffness: number;
  104480. /**
  104481. * Damping of the spring
  104482. */
  104483. damping: number;
  104484. /** this callback will be called when applying the force to the impostors. */
  104485. forceApplicationCallback: () => void;
  104486. }
  104487. }
  104488. declare module BABYLON {
  104489. /**
  104490. * Holds the data for the raycast result
  104491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104492. */
  104493. export class PhysicsRaycastResult {
  104494. private _hasHit;
  104495. private _hitDistance;
  104496. private _hitNormalWorld;
  104497. private _hitPointWorld;
  104498. private _rayFromWorld;
  104499. private _rayToWorld;
  104500. /**
  104501. * Gets if there was a hit
  104502. */
  104503. get hasHit(): boolean;
  104504. /**
  104505. * Gets the distance from the hit
  104506. */
  104507. get hitDistance(): number;
  104508. /**
  104509. * Gets the hit normal/direction in the world
  104510. */
  104511. get hitNormalWorld(): Vector3;
  104512. /**
  104513. * Gets the hit point in the world
  104514. */
  104515. get hitPointWorld(): Vector3;
  104516. /**
  104517. * Gets the ray "start point" of the ray in the world
  104518. */
  104519. get rayFromWorld(): Vector3;
  104520. /**
  104521. * Gets the ray "end point" of the ray in the world
  104522. */
  104523. get rayToWorld(): Vector3;
  104524. /**
  104525. * Sets the hit data (normal & point in world space)
  104526. * @param hitNormalWorld defines the normal in world space
  104527. * @param hitPointWorld defines the point in world space
  104528. */
  104529. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104530. /**
  104531. * Sets the distance from the start point to the hit point
  104532. * @param distance
  104533. */
  104534. setHitDistance(distance: number): void;
  104535. /**
  104536. * Calculates the distance manually
  104537. */
  104538. calculateHitDistance(): void;
  104539. /**
  104540. * Resets all the values to default
  104541. * @param from The from point on world space
  104542. * @param to The to point on world space
  104543. */
  104544. reset(from?: Vector3, to?: Vector3): void;
  104545. }
  104546. /**
  104547. * Interface for the size containing width and height
  104548. */
  104549. interface IXYZ {
  104550. /**
  104551. * X
  104552. */
  104553. x: number;
  104554. /**
  104555. * Y
  104556. */
  104557. y: number;
  104558. /**
  104559. * Z
  104560. */
  104561. z: number;
  104562. }
  104563. }
  104564. declare module BABYLON {
  104565. /**
  104566. * Interface used to describe a physics joint
  104567. */
  104568. export interface PhysicsImpostorJoint {
  104569. /** Defines the main impostor to which the joint is linked */
  104570. mainImpostor: PhysicsImpostor;
  104571. /** Defines the impostor that is connected to the main impostor using this joint */
  104572. connectedImpostor: PhysicsImpostor;
  104573. /** Defines the joint itself */
  104574. joint: PhysicsJoint;
  104575. }
  104576. /** @hidden */
  104577. export interface IPhysicsEnginePlugin {
  104578. world: any;
  104579. name: string;
  104580. setGravity(gravity: Vector3): void;
  104581. setTimeStep(timeStep: number): void;
  104582. getTimeStep(): number;
  104583. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104584. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104585. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104586. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104587. removePhysicsBody(impostor: PhysicsImpostor): void;
  104588. generateJoint(joint: PhysicsImpostorJoint): void;
  104589. removeJoint(joint: PhysicsImpostorJoint): void;
  104590. isSupported(): boolean;
  104591. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104592. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104593. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104594. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104595. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104596. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104597. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104598. getBodyMass(impostor: PhysicsImpostor): number;
  104599. getBodyFriction(impostor: PhysicsImpostor): number;
  104600. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104601. getBodyRestitution(impostor: PhysicsImpostor): number;
  104602. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104603. getBodyPressure?(impostor: PhysicsImpostor): number;
  104604. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104605. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104606. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104607. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104608. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104609. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104610. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104611. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104612. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104613. sleepBody(impostor: PhysicsImpostor): void;
  104614. wakeUpBody(impostor: PhysicsImpostor): void;
  104615. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104616. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104617. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104618. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104619. getRadius(impostor: PhysicsImpostor): number;
  104620. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104621. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104622. dispose(): void;
  104623. }
  104624. /**
  104625. * Interface used to define a physics engine
  104626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104627. */
  104628. export interface IPhysicsEngine {
  104629. /**
  104630. * Gets the gravity vector used by the simulation
  104631. */
  104632. gravity: Vector3;
  104633. /**
  104634. * Sets the gravity vector used by the simulation
  104635. * @param gravity defines the gravity vector to use
  104636. */
  104637. setGravity(gravity: Vector3): void;
  104638. /**
  104639. * Set the time step of the physics engine.
  104640. * Default is 1/60.
  104641. * To slow it down, enter 1/600 for example.
  104642. * To speed it up, 1/30
  104643. * @param newTimeStep the new timestep to apply to this world.
  104644. */
  104645. setTimeStep(newTimeStep: number): void;
  104646. /**
  104647. * Get the time step of the physics engine.
  104648. * @returns the current time step
  104649. */
  104650. getTimeStep(): number;
  104651. /**
  104652. * Set the sub time step of the physics engine.
  104653. * Default is 0 meaning there is no sub steps
  104654. * To increase physics resolution precision, set a small value (like 1 ms)
  104655. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104656. */
  104657. setSubTimeStep(subTimeStep: number): void;
  104658. /**
  104659. * Get the sub time step of the physics engine.
  104660. * @returns the current sub time step
  104661. */
  104662. getSubTimeStep(): number;
  104663. /**
  104664. * Release all resources
  104665. */
  104666. dispose(): void;
  104667. /**
  104668. * Gets the name of the current physics plugin
  104669. * @returns the name of the plugin
  104670. */
  104671. getPhysicsPluginName(): string;
  104672. /**
  104673. * Adding a new impostor for the impostor tracking.
  104674. * This will be done by the impostor itself.
  104675. * @param impostor the impostor to add
  104676. */
  104677. addImpostor(impostor: PhysicsImpostor): void;
  104678. /**
  104679. * Remove an impostor from the engine.
  104680. * This impostor and its mesh will not longer be updated by the physics engine.
  104681. * @param impostor the impostor to remove
  104682. */
  104683. removeImpostor(impostor: PhysicsImpostor): void;
  104684. /**
  104685. * Add a joint to the physics engine
  104686. * @param mainImpostor defines the main impostor to which the joint is added.
  104687. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104688. * @param joint defines the joint that will connect both impostors.
  104689. */
  104690. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104691. /**
  104692. * Removes a joint from the simulation
  104693. * @param mainImpostor defines the impostor used with the joint
  104694. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104695. * @param joint defines the joint to remove
  104696. */
  104697. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104698. /**
  104699. * Gets the current plugin used to run the simulation
  104700. * @returns current plugin
  104701. */
  104702. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104703. /**
  104704. * Gets the list of physic impostors
  104705. * @returns an array of PhysicsImpostor
  104706. */
  104707. getImpostors(): Array<PhysicsImpostor>;
  104708. /**
  104709. * Gets the impostor for a physics enabled object
  104710. * @param object defines the object impersonated by the impostor
  104711. * @returns the PhysicsImpostor or null if not found
  104712. */
  104713. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104714. /**
  104715. * Gets the impostor for a physics body object
  104716. * @param body defines physics body used by the impostor
  104717. * @returns the PhysicsImpostor or null if not found
  104718. */
  104719. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104720. /**
  104721. * Does a raycast in the physics world
  104722. * @param from when should the ray start?
  104723. * @param to when should the ray end?
  104724. * @returns PhysicsRaycastResult
  104725. */
  104726. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104727. /**
  104728. * Called by the scene. No need to call it.
  104729. * @param delta defines the timespam between frames
  104730. */
  104731. _step(delta: number): void;
  104732. }
  104733. }
  104734. declare module BABYLON {
  104735. /**
  104736. * The interface for the physics imposter parameters
  104737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104738. */
  104739. export interface PhysicsImpostorParameters {
  104740. /**
  104741. * The mass of the physics imposter
  104742. */
  104743. mass: number;
  104744. /**
  104745. * The friction of the physics imposter
  104746. */
  104747. friction?: number;
  104748. /**
  104749. * The coefficient of restitution of the physics imposter
  104750. */
  104751. restitution?: number;
  104752. /**
  104753. * The native options of the physics imposter
  104754. */
  104755. nativeOptions?: any;
  104756. /**
  104757. * Specifies if the parent should be ignored
  104758. */
  104759. ignoreParent?: boolean;
  104760. /**
  104761. * Specifies if bi-directional transformations should be disabled
  104762. */
  104763. disableBidirectionalTransformation?: boolean;
  104764. /**
  104765. * The pressure inside the physics imposter, soft object only
  104766. */
  104767. pressure?: number;
  104768. /**
  104769. * The stiffness the physics imposter, soft object only
  104770. */
  104771. stiffness?: number;
  104772. /**
  104773. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104774. */
  104775. velocityIterations?: number;
  104776. /**
  104777. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104778. */
  104779. positionIterations?: number;
  104780. /**
  104781. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104782. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104783. * Add to fix multiple points
  104784. */
  104785. fixedPoints?: number;
  104786. /**
  104787. * The collision margin around a soft object
  104788. */
  104789. margin?: number;
  104790. /**
  104791. * The collision margin around a soft object
  104792. */
  104793. damping?: number;
  104794. /**
  104795. * The path for a rope based on an extrusion
  104796. */
  104797. path?: any;
  104798. /**
  104799. * The shape of an extrusion used for a rope based on an extrusion
  104800. */
  104801. shape?: any;
  104802. }
  104803. /**
  104804. * Interface for a physics-enabled object
  104805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104806. */
  104807. export interface IPhysicsEnabledObject {
  104808. /**
  104809. * The position of the physics-enabled object
  104810. */
  104811. position: Vector3;
  104812. /**
  104813. * The rotation of the physics-enabled object
  104814. */
  104815. rotationQuaternion: Nullable<Quaternion>;
  104816. /**
  104817. * The scale of the physics-enabled object
  104818. */
  104819. scaling: Vector3;
  104820. /**
  104821. * The rotation of the physics-enabled object
  104822. */
  104823. rotation?: Vector3;
  104824. /**
  104825. * The parent of the physics-enabled object
  104826. */
  104827. parent?: any;
  104828. /**
  104829. * The bounding info of the physics-enabled object
  104830. * @returns The bounding info of the physics-enabled object
  104831. */
  104832. getBoundingInfo(): BoundingInfo;
  104833. /**
  104834. * Computes the world matrix
  104835. * @param force Specifies if the world matrix should be computed by force
  104836. * @returns A world matrix
  104837. */
  104838. computeWorldMatrix(force: boolean): Matrix;
  104839. /**
  104840. * Gets the world matrix
  104841. * @returns A world matrix
  104842. */
  104843. getWorldMatrix?(): Matrix;
  104844. /**
  104845. * Gets the child meshes
  104846. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104847. * @returns An array of abstract meshes
  104848. */
  104849. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104850. /**
  104851. * Gets the vertex data
  104852. * @param kind The type of vertex data
  104853. * @returns A nullable array of numbers, or a float32 array
  104854. */
  104855. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104856. /**
  104857. * Gets the indices from the mesh
  104858. * @returns A nullable array of index arrays
  104859. */
  104860. getIndices?(): Nullable<IndicesArray>;
  104861. /**
  104862. * Gets the scene from the mesh
  104863. * @returns the indices array or null
  104864. */
  104865. getScene?(): Scene;
  104866. /**
  104867. * Gets the absolute position from the mesh
  104868. * @returns the absolute position
  104869. */
  104870. getAbsolutePosition(): Vector3;
  104871. /**
  104872. * Gets the absolute pivot point from the mesh
  104873. * @returns the absolute pivot point
  104874. */
  104875. getAbsolutePivotPoint(): Vector3;
  104876. /**
  104877. * Rotates the mesh
  104878. * @param axis The axis of rotation
  104879. * @param amount The amount of rotation
  104880. * @param space The space of the rotation
  104881. * @returns The rotation transform node
  104882. */
  104883. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104884. /**
  104885. * Translates the mesh
  104886. * @param axis The axis of translation
  104887. * @param distance The distance of translation
  104888. * @param space The space of the translation
  104889. * @returns The transform node
  104890. */
  104891. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104892. /**
  104893. * Sets the absolute position of the mesh
  104894. * @param absolutePosition The absolute position of the mesh
  104895. * @returns The transform node
  104896. */
  104897. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104898. /**
  104899. * Gets the class name of the mesh
  104900. * @returns The class name
  104901. */
  104902. getClassName(): string;
  104903. }
  104904. /**
  104905. * Represents a physics imposter
  104906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104907. */
  104908. export class PhysicsImpostor {
  104909. /**
  104910. * The physics-enabled object used as the physics imposter
  104911. */
  104912. object: IPhysicsEnabledObject;
  104913. /**
  104914. * The type of the physics imposter
  104915. */
  104916. type: number;
  104917. private _options;
  104918. private _scene?;
  104919. /**
  104920. * The default object size of the imposter
  104921. */
  104922. static DEFAULT_OBJECT_SIZE: Vector3;
  104923. /**
  104924. * The identity quaternion of the imposter
  104925. */
  104926. static IDENTITY_QUATERNION: Quaternion;
  104927. /** @hidden */
  104928. _pluginData: any;
  104929. private _physicsEngine;
  104930. private _physicsBody;
  104931. private _bodyUpdateRequired;
  104932. private _onBeforePhysicsStepCallbacks;
  104933. private _onAfterPhysicsStepCallbacks;
  104934. /** @hidden */
  104935. _onPhysicsCollideCallbacks: Array<{
  104936. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104937. otherImpostors: Array<PhysicsImpostor>;
  104938. }>;
  104939. private _deltaPosition;
  104940. private _deltaRotation;
  104941. private _deltaRotationConjugated;
  104942. /** @hidden */
  104943. _isFromLine: boolean;
  104944. private _parent;
  104945. private _isDisposed;
  104946. private static _tmpVecs;
  104947. private static _tmpQuat;
  104948. /**
  104949. * Specifies if the physics imposter is disposed
  104950. */
  104951. get isDisposed(): boolean;
  104952. /**
  104953. * Gets the mass of the physics imposter
  104954. */
  104955. get mass(): number;
  104956. set mass(value: number);
  104957. /**
  104958. * Gets the coefficient of friction
  104959. */
  104960. get friction(): number;
  104961. /**
  104962. * Sets the coefficient of friction
  104963. */
  104964. set friction(value: number);
  104965. /**
  104966. * Gets the coefficient of restitution
  104967. */
  104968. get restitution(): number;
  104969. /**
  104970. * Sets the coefficient of restitution
  104971. */
  104972. set restitution(value: number);
  104973. /**
  104974. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104975. */
  104976. get pressure(): number;
  104977. /**
  104978. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104979. */
  104980. set pressure(value: number);
  104981. /**
  104982. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104983. */
  104984. get stiffness(): number;
  104985. /**
  104986. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104987. */
  104988. set stiffness(value: number);
  104989. /**
  104990. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104991. */
  104992. get velocityIterations(): number;
  104993. /**
  104994. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104995. */
  104996. set velocityIterations(value: number);
  104997. /**
  104998. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104999. */
  105000. get positionIterations(): number;
  105001. /**
  105002. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105003. */
  105004. set positionIterations(value: number);
  105005. /**
  105006. * The unique id of the physics imposter
  105007. * set by the physics engine when adding this impostor to the array
  105008. */
  105009. uniqueId: number;
  105010. /**
  105011. * @hidden
  105012. */
  105013. soft: boolean;
  105014. /**
  105015. * @hidden
  105016. */
  105017. segments: number;
  105018. private _joints;
  105019. /**
  105020. * Initializes the physics imposter
  105021. * @param object The physics-enabled object used as the physics imposter
  105022. * @param type The type of the physics imposter
  105023. * @param _options The options for the physics imposter
  105024. * @param _scene The Babylon scene
  105025. */
  105026. constructor(
  105027. /**
  105028. * The physics-enabled object used as the physics imposter
  105029. */
  105030. object: IPhysicsEnabledObject,
  105031. /**
  105032. * The type of the physics imposter
  105033. */
  105034. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105035. /**
  105036. * This function will completly initialize this impostor.
  105037. * It will create a new body - but only if this mesh has no parent.
  105038. * If it has, this impostor will not be used other than to define the impostor
  105039. * of the child mesh.
  105040. * @hidden
  105041. */
  105042. _init(): void;
  105043. private _getPhysicsParent;
  105044. /**
  105045. * Should a new body be generated.
  105046. * @returns boolean specifying if body initialization is required
  105047. */
  105048. isBodyInitRequired(): boolean;
  105049. /**
  105050. * Sets the updated scaling
  105051. * @param updated Specifies if the scaling is updated
  105052. */
  105053. setScalingUpdated(): void;
  105054. /**
  105055. * Force a regeneration of this or the parent's impostor's body.
  105056. * Use under cautious - This will remove all joints already implemented.
  105057. */
  105058. forceUpdate(): void;
  105059. /**
  105060. * Gets the body that holds this impostor. Either its own, or its parent.
  105061. */
  105062. get physicsBody(): any;
  105063. /**
  105064. * Get the parent of the physics imposter
  105065. * @returns Physics imposter or null
  105066. */
  105067. get parent(): Nullable<PhysicsImpostor>;
  105068. /**
  105069. * Sets the parent of the physics imposter
  105070. */
  105071. set parent(value: Nullable<PhysicsImpostor>);
  105072. /**
  105073. * Set the physics body. Used mainly by the physics engine/plugin
  105074. */
  105075. set physicsBody(physicsBody: any);
  105076. /**
  105077. * Resets the update flags
  105078. */
  105079. resetUpdateFlags(): void;
  105080. /**
  105081. * Gets the object extend size
  105082. * @returns the object extend size
  105083. */
  105084. getObjectExtendSize(): Vector3;
  105085. /**
  105086. * Gets the object center
  105087. * @returns The object center
  105088. */
  105089. getObjectCenter(): Vector3;
  105090. /**
  105091. * Get a specific parameter from the options parameters
  105092. * @param paramName The object parameter name
  105093. * @returns The object parameter
  105094. */
  105095. getParam(paramName: string): any;
  105096. /**
  105097. * Sets a specific parameter in the options given to the physics plugin
  105098. * @param paramName The parameter name
  105099. * @param value The value of the parameter
  105100. */
  105101. setParam(paramName: string, value: number): void;
  105102. /**
  105103. * Specifically change the body's mass option. Won't recreate the physics body object
  105104. * @param mass The mass of the physics imposter
  105105. */
  105106. setMass(mass: number): void;
  105107. /**
  105108. * Gets the linear velocity
  105109. * @returns linear velocity or null
  105110. */
  105111. getLinearVelocity(): Nullable<Vector3>;
  105112. /**
  105113. * Sets the linear velocity
  105114. * @param velocity linear velocity or null
  105115. */
  105116. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105117. /**
  105118. * Gets the angular velocity
  105119. * @returns angular velocity or null
  105120. */
  105121. getAngularVelocity(): Nullable<Vector3>;
  105122. /**
  105123. * Sets the angular velocity
  105124. * @param velocity The velocity or null
  105125. */
  105126. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105127. /**
  105128. * Execute a function with the physics plugin native code
  105129. * Provide a function the will have two variables - the world object and the physics body object
  105130. * @param func The function to execute with the physics plugin native code
  105131. */
  105132. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105133. /**
  105134. * Register a function that will be executed before the physics world is stepping forward
  105135. * @param func The function to execute before the physics world is stepped forward
  105136. */
  105137. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105138. /**
  105139. * Unregister a function that will be executed before the physics world is stepping forward
  105140. * @param func The function to execute before the physics world is stepped forward
  105141. */
  105142. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105143. /**
  105144. * Register a function that will be executed after the physics step
  105145. * @param func The function to execute after physics step
  105146. */
  105147. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105148. /**
  105149. * Unregisters a function that will be executed after the physics step
  105150. * @param func The function to execute after physics step
  105151. */
  105152. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105153. /**
  105154. * register a function that will be executed when this impostor collides against a different body
  105155. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105156. * @param func Callback that is executed on collision
  105157. */
  105158. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105159. /**
  105160. * Unregisters the physics imposter on contact
  105161. * @param collideAgainst The physics object to collide against
  105162. * @param func Callback to execute on collision
  105163. */
  105164. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105165. private _tmpQuat;
  105166. private _tmpQuat2;
  105167. /**
  105168. * Get the parent rotation
  105169. * @returns The parent rotation
  105170. */
  105171. getParentsRotation(): Quaternion;
  105172. /**
  105173. * this function is executed by the physics engine.
  105174. */
  105175. beforeStep: () => void;
  105176. /**
  105177. * this function is executed by the physics engine
  105178. */
  105179. afterStep: () => void;
  105180. /**
  105181. * Legacy collision detection event support
  105182. */
  105183. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105184. /**
  105185. * event and body object due to cannon's event-based architecture.
  105186. */
  105187. onCollide: (e: {
  105188. body: any;
  105189. }) => void;
  105190. /**
  105191. * Apply a force
  105192. * @param force The force to apply
  105193. * @param contactPoint The contact point for the force
  105194. * @returns The physics imposter
  105195. */
  105196. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105197. /**
  105198. * Apply an impulse
  105199. * @param force The impulse force
  105200. * @param contactPoint The contact point for the impulse force
  105201. * @returns The physics imposter
  105202. */
  105203. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105204. /**
  105205. * A help function to create a joint
  105206. * @param otherImpostor A physics imposter used to create a joint
  105207. * @param jointType The type of joint
  105208. * @param jointData The data for the joint
  105209. * @returns The physics imposter
  105210. */
  105211. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105212. /**
  105213. * Add a joint to this impostor with a different impostor
  105214. * @param otherImpostor A physics imposter used to add a joint
  105215. * @param joint The joint to add
  105216. * @returns The physics imposter
  105217. */
  105218. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105219. /**
  105220. * Add an anchor to a cloth impostor
  105221. * @param otherImpostor rigid impostor to anchor to
  105222. * @param width ratio across width from 0 to 1
  105223. * @param height ratio up height from 0 to 1
  105224. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105225. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105226. * @returns impostor the soft imposter
  105227. */
  105228. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105229. /**
  105230. * Add a hook to a rope impostor
  105231. * @param otherImpostor rigid impostor to anchor to
  105232. * @param length ratio across rope from 0 to 1
  105233. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105234. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105235. * @returns impostor the rope imposter
  105236. */
  105237. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105238. /**
  105239. * Will keep this body still, in a sleep mode.
  105240. * @returns the physics imposter
  105241. */
  105242. sleep(): PhysicsImpostor;
  105243. /**
  105244. * Wake the body up.
  105245. * @returns The physics imposter
  105246. */
  105247. wakeUp(): PhysicsImpostor;
  105248. /**
  105249. * Clones the physics imposter
  105250. * @param newObject The physics imposter clones to this physics-enabled object
  105251. * @returns A nullable physics imposter
  105252. */
  105253. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105254. /**
  105255. * Disposes the physics imposter
  105256. */
  105257. dispose(): void;
  105258. /**
  105259. * Sets the delta position
  105260. * @param position The delta position amount
  105261. */
  105262. setDeltaPosition(position: Vector3): void;
  105263. /**
  105264. * Sets the delta rotation
  105265. * @param rotation The delta rotation amount
  105266. */
  105267. setDeltaRotation(rotation: Quaternion): void;
  105268. /**
  105269. * Gets the box size of the physics imposter and stores the result in the input parameter
  105270. * @param result Stores the box size
  105271. * @returns The physics imposter
  105272. */
  105273. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105274. /**
  105275. * Gets the radius of the physics imposter
  105276. * @returns Radius of the physics imposter
  105277. */
  105278. getRadius(): number;
  105279. /**
  105280. * Sync a bone with this impostor
  105281. * @param bone The bone to sync to the impostor.
  105282. * @param boneMesh The mesh that the bone is influencing.
  105283. * @param jointPivot The pivot of the joint / bone in local space.
  105284. * @param distToJoint Optional distance from the impostor to the joint.
  105285. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105286. */
  105287. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105288. /**
  105289. * Sync impostor to a bone
  105290. * @param bone The bone that the impostor will be synced to.
  105291. * @param boneMesh The mesh that the bone is influencing.
  105292. * @param jointPivot The pivot of the joint / bone in local space.
  105293. * @param distToJoint Optional distance from the impostor to the joint.
  105294. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105295. * @param boneAxis Optional vector3 axis the bone is aligned with
  105296. */
  105297. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105298. /**
  105299. * No-Imposter type
  105300. */
  105301. static NoImpostor: number;
  105302. /**
  105303. * Sphere-Imposter type
  105304. */
  105305. static SphereImpostor: number;
  105306. /**
  105307. * Box-Imposter type
  105308. */
  105309. static BoxImpostor: number;
  105310. /**
  105311. * Plane-Imposter type
  105312. */
  105313. static PlaneImpostor: number;
  105314. /**
  105315. * Mesh-imposter type
  105316. */
  105317. static MeshImpostor: number;
  105318. /**
  105319. * Capsule-Impostor type (Ammo.js plugin only)
  105320. */
  105321. static CapsuleImpostor: number;
  105322. /**
  105323. * Cylinder-Imposter type
  105324. */
  105325. static CylinderImpostor: number;
  105326. /**
  105327. * Particle-Imposter type
  105328. */
  105329. static ParticleImpostor: number;
  105330. /**
  105331. * Heightmap-Imposter type
  105332. */
  105333. static HeightmapImpostor: number;
  105334. /**
  105335. * ConvexHull-Impostor type (Ammo.js plugin only)
  105336. */
  105337. static ConvexHullImpostor: number;
  105338. /**
  105339. * Custom-Imposter type (Ammo.js plugin only)
  105340. */
  105341. static CustomImpostor: number;
  105342. /**
  105343. * Rope-Imposter type
  105344. */
  105345. static RopeImpostor: number;
  105346. /**
  105347. * Cloth-Imposter type
  105348. */
  105349. static ClothImpostor: number;
  105350. /**
  105351. * Softbody-Imposter type
  105352. */
  105353. static SoftbodyImpostor: number;
  105354. }
  105355. }
  105356. declare module BABYLON {
  105357. /**
  105358. * @hidden
  105359. **/
  105360. export class _CreationDataStorage {
  105361. closePath?: boolean;
  105362. closeArray?: boolean;
  105363. idx: number[];
  105364. dashSize: number;
  105365. gapSize: number;
  105366. path3D: Path3D;
  105367. pathArray: Vector3[][];
  105368. arc: number;
  105369. radius: number;
  105370. cap: number;
  105371. tessellation: number;
  105372. }
  105373. /**
  105374. * @hidden
  105375. **/
  105376. class _InstanceDataStorage {
  105377. visibleInstances: any;
  105378. batchCache: _InstancesBatch;
  105379. instancesBufferSize: number;
  105380. instancesBuffer: Nullable<Buffer>;
  105381. instancesData: Float32Array;
  105382. overridenInstanceCount: number;
  105383. isFrozen: boolean;
  105384. previousBatch: Nullable<_InstancesBatch>;
  105385. hardwareInstancedRendering: boolean;
  105386. sideOrientation: number;
  105387. manualUpdate: boolean;
  105388. }
  105389. /**
  105390. * @hidden
  105391. **/
  105392. export class _InstancesBatch {
  105393. mustReturn: boolean;
  105394. visibleInstances: Nullable<InstancedMesh[]>[];
  105395. renderSelf: boolean[];
  105396. hardwareInstancedRendering: boolean[];
  105397. }
  105398. /**
  105399. * @hidden
  105400. **/
  105401. class _ThinInstanceDataStorage {
  105402. instancesCount: number;
  105403. matrixBuffer: Nullable<Buffer>;
  105404. matrixBufferSize: number;
  105405. matrixData: Nullable<Float32Array>;
  105406. boundingVectors: Array<Vector3>;
  105407. }
  105408. /**
  105409. * Class used to represent renderable models
  105410. */
  105411. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105412. /**
  105413. * Mesh side orientation : usually the external or front surface
  105414. */
  105415. static readonly FRONTSIDE: number;
  105416. /**
  105417. * Mesh side orientation : usually the internal or back surface
  105418. */
  105419. static readonly BACKSIDE: number;
  105420. /**
  105421. * Mesh side orientation : both internal and external or front and back surfaces
  105422. */
  105423. static readonly DOUBLESIDE: number;
  105424. /**
  105425. * Mesh side orientation : by default, `FRONTSIDE`
  105426. */
  105427. static readonly DEFAULTSIDE: number;
  105428. /**
  105429. * Mesh cap setting : no cap
  105430. */
  105431. static readonly NO_CAP: number;
  105432. /**
  105433. * Mesh cap setting : one cap at the beginning of the mesh
  105434. */
  105435. static readonly CAP_START: number;
  105436. /**
  105437. * Mesh cap setting : one cap at the end of the mesh
  105438. */
  105439. static readonly CAP_END: number;
  105440. /**
  105441. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105442. */
  105443. static readonly CAP_ALL: number;
  105444. /**
  105445. * Mesh pattern setting : no flip or rotate
  105446. */
  105447. static readonly NO_FLIP: number;
  105448. /**
  105449. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105450. */
  105451. static readonly FLIP_TILE: number;
  105452. /**
  105453. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105454. */
  105455. static readonly ROTATE_TILE: number;
  105456. /**
  105457. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105458. */
  105459. static readonly FLIP_ROW: number;
  105460. /**
  105461. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105462. */
  105463. static readonly ROTATE_ROW: number;
  105464. /**
  105465. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105466. */
  105467. static readonly FLIP_N_ROTATE_TILE: number;
  105468. /**
  105469. * Mesh pattern setting : rotate pattern and rotate
  105470. */
  105471. static readonly FLIP_N_ROTATE_ROW: number;
  105472. /**
  105473. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105474. */
  105475. static readonly CENTER: number;
  105476. /**
  105477. * Mesh tile positioning : part tiles on left
  105478. */
  105479. static readonly LEFT: number;
  105480. /**
  105481. * Mesh tile positioning : part tiles on right
  105482. */
  105483. static readonly RIGHT: number;
  105484. /**
  105485. * Mesh tile positioning : part tiles on top
  105486. */
  105487. static readonly TOP: number;
  105488. /**
  105489. * Mesh tile positioning : part tiles on bottom
  105490. */
  105491. static readonly BOTTOM: number;
  105492. /**
  105493. * Gets the default side orientation.
  105494. * @param orientation the orientation to value to attempt to get
  105495. * @returns the default orientation
  105496. * @hidden
  105497. */
  105498. static _GetDefaultSideOrientation(orientation?: number): number;
  105499. private _internalMeshDataInfo;
  105500. /**
  105501. * An event triggered before rendering the mesh
  105502. */
  105503. get onBeforeRenderObservable(): Observable<Mesh>;
  105504. /**
  105505. * An event triggered before binding the mesh
  105506. */
  105507. get onBeforeBindObservable(): Observable<Mesh>;
  105508. /**
  105509. * An event triggered after rendering the mesh
  105510. */
  105511. get onAfterRenderObservable(): Observable<Mesh>;
  105512. /**
  105513. * An event triggered before drawing the mesh
  105514. */
  105515. get onBeforeDrawObservable(): Observable<Mesh>;
  105516. private _onBeforeDrawObserver;
  105517. /**
  105518. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105519. */
  105520. set onBeforeDraw(callback: () => void);
  105521. get hasInstances(): boolean;
  105522. get hasThinInstances(): boolean;
  105523. /**
  105524. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105525. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105526. */
  105527. delayLoadState: number;
  105528. /**
  105529. * Gets the list of instances created from this mesh
  105530. * it is not supposed to be modified manually.
  105531. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105532. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105533. */
  105534. instances: InstancedMesh[];
  105535. /**
  105536. * Gets the file containing delay loading data for this mesh
  105537. */
  105538. delayLoadingFile: string;
  105539. /** @hidden */
  105540. _binaryInfo: any;
  105541. /**
  105542. * User defined function used to change how LOD level selection is done
  105543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105544. */
  105545. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105546. /**
  105547. * Gets or sets the morph target manager
  105548. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105549. */
  105550. get morphTargetManager(): Nullable<MorphTargetManager>;
  105551. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105552. /** @hidden */
  105553. _creationDataStorage: Nullable<_CreationDataStorage>;
  105554. /** @hidden */
  105555. _geometry: Nullable<Geometry>;
  105556. /** @hidden */
  105557. _delayInfo: Array<string>;
  105558. /** @hidden */
  105559. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105560. /** @hidden */
  105561. _instanceDataStorage: _InstanceDataStorage;
  105562. /** @hidden */
  105563. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105564. private _effectiveMaterial;
  105565. /** @hidden */
  105566. _shouldGenerateFlatShading: boolean;
  105567. /** @hidden */
  105568. _originalBuilderSideOrientation: number;
  105569. /**
  105570. * Use this property to change the original side orientation defined at construction time
  105571. */
  105572. overrideMaterialSideOrientation: Nullable<number>;
  105573. /**
  105574. * Gets the source mesh (the one used to clone this one from)
  105575. */
  105576. get source(): Nullable<Mesh>;
  105577. /**
  105578. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105579. */
  105580. get isUnIndexed(): boolean;
  105581. set isUnIndexed(value: boolean);
  105582. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105583. get worldMatrixInstancedBuffer(): Float32Array;
  105584. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105585. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105586. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105587. /**
  105588. * @constructor
  105589. * @param name The value used by scene.getMeshByName() to do a lookup.
  105590. * @param scene The scene to add this mesh to.
  105591. * @param parent The parent of this mesh, if it has one
  105592. * @param source An optional Mesh from which geometry is shared, cloned.
  105593. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105594. * When false, achieved by calling a clone(), also passing False.
  105595. * This will make creation of children, recursive.
  105596. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105597. */
  105598. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105599. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105600. doNotInstantiate: boolean;
  105601. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105602. /**
  105603. * Gets the class name
  105604. * @returns the string "Mesh".
  105605. */
  105606. getClassName(): string;
  105607. /** @hidden */
  105608. get _isMesh(): boolean;
  105609. /**
  105610. * Returns a description of this mesh
  105611. * @param fullDetails define if full details about this mesh must be used
  105612. * @returns a descriptive string representing this mesh
  105613. */
  105614. toString(fullDetails?: boolean): string;
  105615. /** @hidden */
  105616. _unBindEffect(): void;
  105617. /**
  105618. * Gets a boolean indicating if this mesh has LOD
  105619. */
  105620. get hasLODLevels(): boolean;
  105621. /**
  105622. * Gets the list of MeshLODLevel associated with the current mesh
  105623. * @returns an array of MeshLODLevel
  105624. */
  105625. getLODLevels(): MeshLODLevel[];
  105626. private _sortLODLevels;
  105627. /**
  105628. * Add a mesh as LOD level triggered at the given distance.
  105629. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105630. * @param distance The distance from the center of the object to show this level
  105631. * @param mesh The mesh to be added as LOD level (can be null)
  105632. * @return This mesh (for chaining)
  105633. */
  105634. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105635. /**
  105636. * Returns the LOD level mesh at the passed distance or null if not found.
  105637. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105638. * @param distance The distance from the center of the object to show this level
  105639. * @returns a Mesh or `null`
  105640. */
  105641. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105642. /**
  105643. * Remove a mesh from the LOD array
  105644. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105645. * @param mesh defines the mesh to be removed
  105646. * @return This mesh (for chaining)
  105647. */
  105648. removeLODLevel(mesh: Mesh): Mesh;
  105649. /**
  105650. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105651. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105652. * @param camera defines the camera to use to compute distance
  105653. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105654. * @return This mesh (for chaining)
  105655. */
  105656. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105657. /**
  105658. * Gets the mesh internal Geometry object
  105659. */
  105660. get geometry(): Nullable<Geometry>;
  105661. /**
  105662. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105663. * @returns the total number of vertices
  105664. */
  105665. getTotalVertices(): number;
  105666. /**
  105667. * Returns the content of an associated vertex buffer
  105668. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105669. * - VertexBuffer.PositionKind
  105670. * - VertexBuffer.UVKind
  105671. * - VertexBuffer.UV2Kind
  105672. * - VertexBuffer.UV3Kind
  105673. * - VertexBuffer.UV4Kind
  105674. * - VertexBuffer.UV5Kind
  105675. * - VertexBuffer.UV6Kind
  105676. * - VertexBuffer.ColorKind
  105677. * - VertexBuffer.MatricesIndicesKind
  105678. * - VertexBuffer.MatricesIndicesExtraKind
  105679. * - VertexBuffer.MatricesWeightsKind
  105680. * - VertexBuffer.MatricesWeightsExtraKind
  105681. * @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
  105682. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105683. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105684. */
  105685. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105686. /**
  105687. * Returns the mesh VertexBuffer object from the requested `kind`
  105688. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105689. * - VertexBuffer.PositionKind
  105690. * - VertexBuffer.NormalKind
  105691. * - VertexBuffer.UVKind
  105692. * - VertexBuffer.UV2Kind
  105693. * - VertexBuffer.UV3Kind
  105694. * - VertexBuffer.UV4Kind
  105695. * - VertexBuffer.UV5Kind
  105696. * - VertexBuffer.UV6Kind
  105697. * - VertexBuffer.ColorKind
  105698. * - VertexBuffer.MatricesIndicesKind
  105699. * - VertexBuffer.MatricesIndicesExtraKind
  105700. * - VertexBuffer.MatricesWeightsKind
  105701. * - VertexBuffer.MatricesWeightsExtraKind
  105702. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105703. */
  105704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105705. /**
  105706. * Tests if a specific vertex buffer is associated with this mesh
  105707. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105708. * - VertexBuffer.PositionKind
  105709. * - VertexBuffer.NormalKind
  105710. * - VertexBuffer.UVKind
  105711. * - VertexBuffer.UV2Kind
  105712. * - VertexBuffer.UV3Kind
  105713. * - VertexBuffer.UV4Kind
  105714. * - VertexBuffer.UV5Kind
  105715. * - VertexBuffer.UV6Kind
  105716. * - VertexBuffer.ColorKind
  105717. * - VertexBuffer.MatricesIndicesKind
  105718. * - VertexBuffer.MatricesIndicesExtraKind
  105719. * - VertexBuffer.MatricesWeightsKind
  105720. * - VertexBuffer.MatricesWeightsExtraKind
  105721. * @returns a boolean
  105722. */
  105723. isVerticesDataPresent(kind: string): boolean;
  105724. /**
  105725. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105726. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105727. * - VertexBuffer.PositionKind
  105728. * - VertexBuffer.UVKind
  105729. * - VertexBuffer.UV2Kind
  105730. * - VertexBuffer.UV3Kind
  105731. * - VertexBuffer.UV4Kind
  105732. * - VertexBuffer.UV5Kind
  105733. * - VertexBuffer.UV6Kind
  105734. * - VertexBuffer.ColorKind
  105735. * - VertexBuffer.MatricesIndicesKind
  105736. * - VertexBuffer.MatricesIndicesExtraKind
  105737. * - VertexBuffer.MatricesWeightsKind
  105738. * - VertexBuffer.MatricesWeightsExtraKind
  105739. * @returns a boolean
  105740. */
  105741. isVertexBufferUpdatable(kind: string): boolean;
  105742. /**
  105743. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105744. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105745. * - VertexBuffer.PositionKind
  105746. * - VertexBuffer.NormalKind
  105747. * - VertexBuffer.UVKind
  105748. * - VertexBuffer.UV2Kind
  105749. * - VertexBuffer.UV3Kind
  105750. * - VertexBuffer.UV4Kind
  105751. * - VertexBuffer.UV5Kind
  105752. * - VertexBuffer.UV6Kind
  105753. * - VertexBuffer.ColorKind
  105754. * - VertexBuffer.MatricesIndicesKind
  105755. * - VertexBuffer.MatricesIndicesExtraKind
  105756. * - VertexBuffer.MatricesWeightsKind
  105757. * - VertexBuffer.MatricesWeightsExtraKind
  105758. * @returns an array of strings
  105759. */
  105760. getVerticesDataKinds(): string[];
  105761. /**
  105762. * Returns a positive integer : the total number of indices in this mesh geometry.
  105763. * @returns the numner of indices or zero if the mesh has no geometry.
  105764. */
  105765. getTotalIndices(): number;
  105766. /**
  105767. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105768. * @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.
  105769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105770. * @returns the indices array or an empty array if the mesh has no geometry
  105771. */
  105772. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105773. get isBlocked(): boolean;
  105774. /**
  105775. * Determine if the current mesh is ready to be rendered
  105776. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105777. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105778. * @returns true if all associated assets are ready (material, textures, shaders)
  105779. */
  105780. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105781. /**
  105782. * 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.
  105783. */
  105784. get areNormalsFrozen(): boolean;
  105785. /**
  105786. * 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.
  105787. * @returns the current mesh
  105788. */
  105789. freezeNormals(): Mesh;
  105790. /**
  105791. * 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
  105792. * @returns the current mesh
  105793. */
  105794. unfreezeNormals(): Mesh;
  105795. /**
  105796. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105797. */
  105798. set overridenInstanceCount(count: number);
  105799. /** @hidden */
  105800. _preActivate(): Mesh;
  105801. /** @hidden */
  105802. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105803. /** @hidden */
  105804. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105805. protected _afterComputeWorldMatrix(): void;
  105806. /** @hidden */
  105807. _postActivate(): void;
  105808. /**
  105809. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105810. * This means the mesh underlying bounding box and sphere are recomputed.
  105811. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105812. * @returns the current mesh
  105813. */
  105814. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105815. /** @hidden */
  105816. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105817. /**
  105818. * This function will subdivide the mesh into multiple submeshes
  105819. * @param count defines the expected number of submeshes
  105820. */
  105821. subdivide(count: number): void;
  105822. /**
  105823. * Copy a FloatArray into a specific associated vertex buffer
  105824. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105825. * - VertexBuffer.PositionKind
  105826. * - VertexBuffer.UVKind
  105827. * - VertexBuffer.UV2Kind
  105828. * - VertexBuffer.UV3Kind
  105829. * - VertexBuffer.UV4Kind
  105830. * - VertexBuffer.UV5Kind
  105831. * - VertexBuffer.UV6Kind
  105832. * - VertexBuffer.ColorKind
  105833. * - VertexBuffer.MatricesIndicesKind
  105834. * - VertexBuffer.MatricesIndicesExtraKind
  105835. * - VertexBuffer.MatricesWeightsKind
  105836. * - VertexBuffer.MatricesWeightsExtraKind
  105837. * @param data defines the data source
  105838. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105839. * @param stride defines the data stride size (can be null)
  105840. * @returns the current mesh
  105841. */
  105842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105843. /**
  105844. * Delete a vertex buffer associated with this mesh
  105845. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105846. * - VertexBuffer.PositionKind
  105847. * - VertexBuffer.UVKind
  105848. * - VertexBuffer.UV2Kind
  105849. * - VertexBuffer.UV3Kind
  105850. * - VertexBuffer.UV4Kind
  105851. * - VertexBuffer.UV5Kind
  105852. * - VertexBuffer.UV6Kind
  105853. * - VertexBuffer.ColorKind
  105854. * - VertexBuffer.MatricesIndicesKind
  105855. * - VertexBuffer.MatricesIndicesExtraKind
  105856. * - VertexBuffer.MatricesWeightsKind
  105857. * - VertexBuffer.MatricesWeightsExtraKind
  105858. */
  105859. removeVerticesData(kind: string): void;
  105860. /**
  105861. * Flags an associated vertex buffer as updatable
  105862. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105863. * - VertexBuffer.PositionKind
  105864. * - VertexBuffer.UVKind
  105865. * - VertexBuffer.UV2Kind
  105866. * - VertexBuffer.UV3Kind
  105867. * - VertexBuffer.UV4Kind
  105868. * - VertexBuffer.UV5Kind
  105869. * - VertexBuffer.UV6Kind
  105870. * - VertexBuffer.ColorKind
  105871. * - VertexBuffer.MatricesIndicesKind
  105872. * - VertexBuffer.MatricesIndicesExtraKind
  105873. * - VertexBuffer.MatricesWeightsKind
  105874. * - VertexBuffer.MatricesWeightsExtraKind
  105875. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105876. */
  105877. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105878. /**
  105879. * Sets the mesh global Vertex Buffer
  105880. * @param buffer defines the buffer to use
  105881. * @returns the current mesh
  105882. */
  105883. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105884. /**
  105885. * Update a specific associated vertex buffer
  105886. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105887. * - VertexBuffer.PositionKind
  105888. * - VertexBuffer.UVKind
  105889. * - VertexBuffer.UV2Kind
  105890. * - VertexBuffer.UV3Kind
  105891. * - VertexBuffer.UV4Kind
  105892. * - VertexBuffer.UV5Kind
  105893. * - VertexBuffer.UV6Kind
  105894. * - VertexBuffer.ColorKind
  105895. * - VertexBuffer.MatricesIndicesKind
  105896. * - VertexBuffer.MatricesIndicesExtraKind
  105897. * - VertexBuffer.MatricesWeightsKind
  105898. * - VertexBuffer.MatricesWeightsExtraKind
  105899. * @param data defines the data source
  105900. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105901. * @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)
  105902. * @returns the current mesh
  105903. */
  105904. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105905. /**
  105906. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105907. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105908. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105909. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105910. * @returns the current mesh
  105911. */
  105912. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105913. /**
  105914. * Creates a un-shared specific occurence of the geometry for the mesh.
  105915. * @returns the current mesh
  105916. */
  105917. makeGeometryUnique(): Mesh;
  105918. /**
  105919. * Set the index buffer of this mesh
  105920. * @param indices defines the source data
  105921. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105922. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105923. * @returns the current mesh
  105924. */
  105925. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105926. /**
  105927. * Update the current index buffer
  105928. * @param indices defines the source data
  105929. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105930. * @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)
  105931. * @returns the current mesh
  105932. */
  105933. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105934. /**
  105935. * Invert the geometry to move from a right handed system to a left handed one.
  105936. * @returns the current mesh
  105937. */
  105938. toLeftHanded(): Mesh;
  105939. /** @hidden */
  105940. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105941. /** @hidden */
  105942. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105943. /**
  105944. * Registers for this mesh a javascript function called just before the rendering process
  105945. * @param func defines the function to call before rendering this mesh
  105946. * @returns the current mesh
  105947. */
  105948. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105949. /**
  105950. * Disposes a previously registered javascript function called before the rendering
  105951. * @param func defines the function to remove
  105952. * @returns the current mesh
  105953. */
  105954. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105955. /**
  105956. * Registers for this mesh a javascript function called just after the rendering is complete
  105957. * @param func defines the function to call after rendering this mesh
  105958. * @returns the current mesh
  105959. */
  105960. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105961. /**
  105962. * Disposes a previously registered javascript function called after the rendering.
  105963. * @param func defines the function to remove
  105964. * @returns the current mesh
  105965. */
  105966. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105967. /** @hidden */
  105968. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105969. /** @hidden */
  105970. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105971. /** @hidden */
  105972. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105973. /** @hidden */
  105974. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105975. /** @hidden */
  105976. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105977. /** @hidden */
  105978. _rebuild(): void;
  105979. /** @hidden */
  105980. _freeze(): void;
  105981. /** @hidden */
  105982. _unFreeze(): void;
  105983. /**
  105984. * 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
  105985. * @param subMesh defines the subMesh to render
  105986. * @param enableAlphaMode defines if alpha mode can be changed
  105987. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105988. * @returns the current mesh
  105989. */
  105990. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105991. private _onBeforeDraw;
  105992. /**
  105993. * Renormalize the mesh and patch it up if there are no weights
  105994. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105995. * However in the case of zero weights then we set just a single influence to 1.
  105996. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105997. */
  105998. cleanMatrixWeights(): void;
  105999. private normalizeSkinFourWeights;
  106000. private normalizeSkinWeightsAndExtra;
  106001. /**
  106002. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106003. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106004. * the user know there was an issue with importing the mesh
  106005. * @returns a validation object with skinned, valid and report string
  106006. */
  106007. validateSkinning(): {
  106008. skinned: boolean;
  106009. valid: boolean;
  106010. report: string;
  106011. };
  106012. /** @hidden */
  106013. _checkDelayState(): Mesh;
  106014. private _queueLoad;
  106015. /**
  106016. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106017. * A mesh is in the frustum if its bounding box intersects the frustum
  106018. * @param frustumPlanes defines the frustum to test
  106019. * @returns true if the mesh is in the frustum planes
  106020. */
  106021. isInFrustum(frustumPlanes: Plane[]): boolean;
  106022. /**
  106023. * Sets the mesh material by the material or multiMaterial `id` property
  106024. * @param id is a string identifying the material or the multiMaterial
  106025. * @returns the current mesh
  106026. */
  106027. setMaterialByID(id: string): Mesh;
  106028. /**
  106029. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106030. * @returns an array of IAnimatable
  106031. */
  106032. getAnimatables(): IAnimatable[];
  106033. /**
  106034. * Modifies the mesh geometry according to the passed transformation matrix.
  106035. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106036. * The mesh normals are modified using the same transformation.
  106037. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106038. * @param transform defines the transform matrix to use
  106039. * @see https://doc.babylonjs.com/resources/baking_transformations
  106040. * @returns the current mesh
  106041. */
  106042. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106043. /**
  106044. * Modifies the mesh geometry according to its own current World Matrix.
  106045. * The mesh World Matrix is then reset.
  106046. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106047. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106048. * @see https://doc.babylonjs.com/resources/baking_transformations
  106049. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106050. * @returns the current mesh
  106051. */
  106052. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106053. /** @hidden */
  106054. get _positions(): Nullable<Vector3[]>;
  106055. /** @hidden */
  106056. _resetPointsArrayCache(): Mesh;
  106057. /** @hidden */
  106058. _generatePointsArray(): boolean;
  106059. /**
  106060. * Returns a new Mesh object generated from the current mesh properties.
  106061. * This method must not get confused with createInstance()
  106062. * @param name is a string, the name given to the new mesh
  106063. * @param newParent can be any Node object (default `null`)
  106064. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106065. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106066. * @returns a new mesh
  106067. */
  106068. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106069. /**
  106070. * Releases resources associated with this mesh.
  106071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106073. */
  106074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106075. /** @hidden */
  106076. _disposeInstanceSpecificData(): void;
  106077. /** @hidden */
  106078. _disposeThinInstanceSpecificData(): void;
  106079. /**
  106080. * Modifies the mesh geometry according to a displacement map.
  106081. * 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.
  106082. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106083. * @param url is a string, the URL from the image file is to be downloaded.
  106084. * @param minHeight is the lower limit of the displacement.
  106085. * @param maxHeight is the upper limit of the displacement.
  106086. * @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.
  106087. * @param uvOffset is an optional vector2 used to offset UV.
  106088. * @param uvScale is an optional vector2 used to scale UV.
  106089. * @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.
  106090. * @returns the Mesh.
  106091. */
  106092. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106093. /**
  106094. * Modifies the mesh geometry according to a displacementMap buffer.
  106095. * 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.
  106096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106097. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106098. * @param heightMapWidth is the width of the buffer image.
  106099. * @param heightMapHeight is the height of the buffer image.
  106100. * @param minHeight is the lower limit of the displacement.
  106101. * @param maxHeight is the upper limit of the displacement.
  106102. * @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.
  106103. * @param uvOffset is an optional vector2 used to offset UV.
  106104. * @param uvScale is an optional vector2 used to scale UV.
  106105. * @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.
  106106. * @returns the Mesh.
  106107. */
  106108. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106109. /**
  106110. * Modify the mesh to get a flat shading rendering.
  106111. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106112. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106113. * @returns current mesh
  106114. */
  106115. convertToFlatShadedMesh(): Mesh;
  106116. /**
  106117. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106118. * In other words, more vertices, no more indices and a single bigger VBO.
  106119. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106120. * @returns current mesh
  106121. */
  106122. convertToUnIndexedMesh(): Mesh;
  106123. /**
  106124. * Inverses facet orientations.
  106125. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106126. * @param flipNormals will also inverts the normals
  106127. * @returns current mesh
  106128. */
  106129. flipFaces(flipNormals?: boolean): Mesh;
  106130. /**
  106131. * Increase the number of facets and hence vertices in a mesh
  106132. * Vertex normals are interpolated from existing vertex normals
  106133. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106134. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106135. */
  106136. increaseVertices(numberPerEdge: number): void;
  106137. /**
  106138. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106139. * This will undo any application of covertToFlatShadedMesh
  106140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106141. */
  106142. forceSharedVertices(): void;
  106143. /** @hidden */
  106144. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106145. /** @hidden */
  106146. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106147. /**
  106148. * Creates a new InstancedMesh object from the mesh model.
  106149. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106150. * @param name defines the name of the new instance
  106151. * @returns a new InstancedMesh
  106152. */
  106153. createInstance(name: string): InstancedMesh;
  106154. /**
  106155. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106156. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106157. * @returns the current mesh
  106158. */
  106159. synchronizeInstances(): Mesh;
  106160. /**
  106161. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106162. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106163. * This should be used together with the simplification to avoid disappearing triangles.
  106164. * @param successCallback an optional success callback to be called after the optimization finished.
  106165. * @returns the current mesh
  106166. */
  106167. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106168. /**
  106169. * Serialize current mesh
  106170. * @param serializationObject defines the object which will receive the serialization data
  106171. */
  106172. serialize(serializationObject: any): void;
  106173. /** @hidden */
  106174. _syncGeometryWithMorphTargetManager(): void;
  106175. /** @hidden */
  106176. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106177. /**
  106178. * Returns a new Mesh object parsed from the source provided.
  106179. * @param parsedMesh is the source
  106180. * @param scene defines the hosting scene
  106181. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106182. * @returns a new Mesh
  106183. */
  106184. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106185. /**
  106186. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106188. * @param name defines the name of the mesh to create
  106189. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106190. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106191. * @param closePath creates a seam between the first and the last points of each path of the path array
  106192. * @param offset is taken in account only if the `pathArray` is containing a single path
  106193. * @param scene defines the hosting scene
  106194. * @param updatable defines if the mesh must be flagged as updatable
  106195. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106196. * @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)
  106197. * @returns a new Mesh
  106198. */
  106199. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106200. /**
  106201. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106202. * @param name defines the name of the mesh to create
  106203. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106204. * @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
  106205. * @param scene defines the hosting scene
  106206. * @param updatable defines if the mesh must be flagged as updatable
  106207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106208. * @returns a new Mesh
  106209. */
  106210. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106211. /**
  106212. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106213. * @param name defines the name of the mesh to create
  106214. * @param size sets the size (float) of each box side (default 1)
  106215. * @param scene defines the hosting scene
  106216. * @param updatable defines if the mesh must be flagged as updatable
  106217. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106218. * @returns a new Mesh
  106219. */
  106220. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106221. /**
  106222. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106223. * @param name defines the name of the mesh to create
  106224. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106225. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106226. * @param scene defines the hosting scene
  106227. * @param updatable defines if the mesh must be flagged as updatable
  106228. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106229. * @returns a new Mesh
  106230. */
  106231. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106232. /**
  106233. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106234. * @param name defines the name of the mesh to create
  106235. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106236. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106237. * @param scene defines the hosting scene
  106238. * @returns a new Mesh
  106239. */
  106240. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106241. /**
  106242. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106243. * @param name defines the name of the mesh to create
  106244. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106245. * @param diameterTop set the top cap diameter (floats, default 1)
  106246. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106247. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106248. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106249. * @param scene defines the hosting scene
  106250. * @param updatable defines if the mesh must be flagged as updatable
  106251. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106252. * @returns a new Mesh
  106253. */
  106254. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106255. /**
  106256. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106257. * @param name defines the name of the mesh to create
  106258. * @param diameter sets the diameter size (float) of the torus (default 1)
  106259. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106260. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106261. * @param scene defines the hosting scene
  106262. * @param updatable defines if the mesh must be flagged as updatable
  106263. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106264. * @returns a new Mesh
  106265. */
  106266. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106267. /**
  106268. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106269. * @param name defines the name of the mesh to create
  106270. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106271. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106272. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106273. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106274. * @param p the number of windings on X axis (positive integers, default 2)
  106275. * @param q the number of windings on Y axis (positive integers, default 3)
  106276. * @param scene defines the hosting scene
  106277. * @param updatable defines if the mesh must be flagged as updatable
  106278. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106279. * @returns a new Mesh
  106280. */
  106281. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106282. /**
  106283. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106284. * @param name defines the name of the mesh to create
  106285. * @param points is an array successive Vector3
  106286. * @param scene defines the hosting scene
  106287. * @param updatable defines if the mesh must be flagged as updatable
  106288. * @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).
  106289. * @returns a new Mesh
  106290. */
  106291. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106292. /**
  106293. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106294. * @param name defines the name of the mesh to create
  106295. * @param points is an array successive Vector3
  106296. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106297. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106298. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106299. * @param scene defines the hosting scene
  106300. * @param updatable defines if the mesh must be flagged as updatable
  106301. * @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)
  106302. * @returns a new Mesh
  106303. */
  106304. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106305. /**
  106306. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106307. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106308. * 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.
  106309. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106310. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106311. * Remember you can only change the shape positions, not their number when updating a polygon.
  106312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106313. * @param name defines the name of the mesh to create
  106314. * @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
  106315. * @param scene defines the hosting scene
  106316. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106317. * @param updatable defines if the mesh must be flagged as updatable
  106318. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106319. * @param earcutInjection can be used to inject your own earcut reference
  106320. * @returns a new Mesh
  106321. */
  106322. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106323. /**
  106324. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106326. * @param name defines the name of the mesh to create
  106327. * @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
  106328. * @param depth defines the height of extrusion
  106329. * @param scene defines the hosting scene
  106330. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106331. * @param updatable defines if the mesh must be flagged as updatable
  106332. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106333. * @param earcutInjection can be used to inject your own earcut reference
  106334. * @returns a new Mesh
  106335. */
  106336. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106337. /**
  106338. * Creates an extruded shape mesh.
  106339. * 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
  106340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106342. * @param name defines the name of the mesh to create
  106343. * @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
  106344. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106345. * @param scale is the value to scale the shape
  106346. * @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
  106347. * @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
  106348. * @param scene defines the hosting scene
  106349. * @param updatable defines if the mesh must be flagged as updatable
  106350. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106351. * @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)
  106352. * @returns a new Mesh
  106353. */
  106354. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106355. /**
  106356. * Creates an custom extruded shape mesh.
  106357. * The custom extrusion is a parametric shape.
  106358. * It has no predefined shape. Its final shape will depend on the input parameters.
  106359. * Please consider using the same method from the MeshBuilder class instead
  106360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106361. * @param name defines the name of the mesh to create
  106362. * @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
  106363. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106364. * @param scaleFunction is a custom Javascript function called on each path point
  106365. * @param rotationFunction is a custom Javascript function called on each path point
  106366. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106367. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106368. * @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
  106369. * @param scene defines the hosting scene
  106370. * @param updatable defines if the mesh must be flagged as updatable
  106371. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106372. * @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)
  106373. * @returns a new Mesh
  106374. */
  106375. 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;
  106376. /**
  106377. * Creates lathe mesh.
  106378. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106379. * Please consider using the same method from the MeshBuilder class instead
  106380. * @param name defines the name of the mesh to create
  106381. * @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
  106382. * @param radius is the radius value of the lathe
  106383. * @param tessellation is the side number of the lathe.
  106384. * @param scene defines the hosting scene
  106385. * @param updatable defines if the mesh must be flagged as updatable
  106386. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106387. * @returns a new Mesh
  106388. */
  106389. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106390. /**
  106391. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106392. * @param name defines the name of the mesh to create
  106393. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106394. * @param scene defines the hosting scene
  106395. * @param updatable defines if the mesh must be flagged as updatable
  106396. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106397. * @returns a new Mesh
  106398. */
  106399. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106400. /**
  106401. * Creates a ground mesh.
  106402. * Please consider using the same method from the MeshBuilder class instead
  106403. * @param name defines the name of the mesh to create
  106404. * @param width set the width of the ground
  106405. * @param height set the height of the ground
  106406. * @param subdivisions sets the number of subdivisions per side
  106407. * @param scene defines the hosting scene
  106408. * @param updatable defines if the mesh must be flagged as updatable
  106409. * @returns a new Mesh
  106410. */
  106411. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106412. /**
  106413. * Creates a tiled ground mesh.
  106414. * Please consider using the same method from the MeshBuilder class instead
  106415. * @param name defines the name of the mesh to create
  106416. * @param xmin set the ground minimum X coordinate
  106417. * @param zmin set the ground minimum Y coordinate
  106418. * @param xmax set the ground maximum X coordinate
  106419. * @param zmax set the ground maximum Z coordinate
  106420. * @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
  106421. * @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
  106422. * @param scene defines the hosting scene
  106423. * @param updatable defines if the mesh must be flagged as updatable
  106424. * @returns a new Mesh
  106425. */
  106426. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106427. w: number;
  106428. h: number;
  106429. }, precision: {
  106430. w: number;
  106431. h: number;
  106432. }, scene: Scene, updatable?: boolean): Mesh;
  106433. /**
  106434. * Creates a ground mesh from a height map.
  106435. * Please consider using the same method from the MeshBuilder class instead
  106436. * @see https://doc.babylonjs.com/babylon101/height_map
  106437. * @param name defines the name of the mesh to create
  106438. * @param url sets the URL of the height map image resource
  106439. * @param width set the ground width size
  106440. * @param height set the ground height size
  106441. * @param subdivisions sets the number of subdivision per side
  106442. * @param minHeight is the minimum altitude on the ground
  106443. * @param maxHeight is the maximum altitude on the ground
  106444. * @param scene defines the hosting scene
  106445. * @param updatable defines if the mesh must be flagged as updatable
  106446. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106447. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106448. * @returns a new Mesh
  106449. */
  106450. 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;
  106451. /**
  106452. * Creates a tube mesh.
  106453. * The tube is a parametric shape.
  106454. * It has no predefined shape. Its final shape will depend on the input parameters.
  106455. * Please consider using the same method from the MeshBuilder class instead
  106456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106457. * @param name defines the name of the mesh to create
  106458. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106459. * @param radius sets the tube radius size
  106460. * @param tessellation is the number of sides on the tubular surface
  106461. * @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
  106462. * @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
  106463. * @param scene defines the hosting scene
  106464. * @param updatable defines if the mesh must be flagged as updatable
  106465. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106466. * @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)
  106467. * @returns a new Mesh
  106468. */
  106469. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106470. (i: number, distance: number): number;
  106471. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106472. /**
  106473. * Creates a polyhedron mesh.
  106474. * Please consider using the same method from the MeshBuilder class instead.
  106475. * * 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
  106476. * * The parameter `size` (positive float, default 1) sets the polygon size
  106477. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106478. * * 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`
  106479. * * 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
  106480. * * 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)`)
  106481. * * 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
  106482. * * 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
  106483. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106486. * @param name defines the name of the mesh to create
  106487. * @param options defines the options used to create the mesh
  106488. * @param scene defines the hosting scene
  106489. * @returns a new Mesh
  106490. */
  106491. static CreatePolyhedron(name: string, options: {
  106492. type?: number;
  106493. size?: number;
  106494. sizeX?: number;
  106495. sizeY?: number;
  106496. sizeZ?: number;
  106497. custom?: any;
  106498. faceUV?: Vector4[];
  106499. faceColors?: Color4[];
  106500. updatable?: boolean;
  106501. sideOrientation?: number;
  106502. }, scene: Scene): Mesh;
  106503. /**
  106504. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106505. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106506. * * 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`)
  106507. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106508. * * 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
  106509. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106512. * @param name defines the name of the mesh
  106513. * @param options defines the options used to create the mesh
  106514. * @param scene defines the hosting scene
  106515. * @returns a new Mesh
  106516. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106517. */
  106518. static CreateIcoSphere(name: string, options: {
  106519. radius?: number;
  106520. flat?: boolean;
  106521. subdivisions?: number;
  106522. sideOrientation?: number;
  106523. updatable?: boolean;
  106524. }, scene: Scene): Mesh;
  106525. /**
  106526. * Creates a decal mesh.
  106527. * Please consider using the same method from the MeshBuilder class instead.
  106528. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106529. * @param name defines the name of the mesh
  106530. * @param sourceMesh defines the mesh receiving the decal
  106531. * @param position sets the position of the decal in world coordinates
  106532. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106533. * @param size sets the decal scaling
  106534. * @param angle sets the angle to rotate the decal
  106535. * @returns a new Mesh
  106536. */
  106537. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106538. /**
  106539. * Prepare internal position array for software CPU skinning
  106540. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106541. */
  106542. setPositionsForCPUSkinning(): Float32Array;
  106543. /**
  106544. * Prepare internal normal array for software CPU skinning
  106545. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106546. */
  106547. setNormalsForCPUSkinning(): Float32Array;
  106548. /**
  106549. * Updates the vertex buffer by applying transformation from the bones
  106550. * @param skeleton defines the skeleton to apply to current mesh
  106551. * @returns the current mesh
  106552. */
  106553. applySkeleton(skeleton: Skeleton): Mesh;
  106554. /**
  106555. * 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
  106556. * @param meshes defines the list of meshes to scan
  106557. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106558. */
  106559. static MinMax(meshes: AbstractMesh[]): {
  106560. min: Vector3;
  106561. max: Vector3;
  106562. };
  106563. /**
  106564. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106565. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106566. * @returns a vector3
  106567. */
  106568. static Center(meshesOrMinMaxVector: {
  106569. min: Vector3;
  106570. max: Vector3;
  106571. } | AbstractMesh[]): Vector3;
  106572. /**
  106573. * Merge the array of meshes into a single mesh for performance reasons.
  106574. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106575. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106576. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106577. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106578. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106579. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106580. * @returns a new mesh
  106581. */
  106582. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106583. /** @hidden */
  106584. addInstance(instance: InstancedMesh): void;
  106585. /** @hidden */
  106586. removeInstance(instance: InstancedMesh): void;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * This is the base class of all the camera used in the application.
  106592. * @see https://doc.babylonjs.com/features/cameras
  106593. */
  106594. export class Camera extends Node {
  106595. /** @hidden */
  106596. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106597. /**
  106598. * This is the default projection mode used by the cameras.
  106599. * It helps recreating a feeling of perspective and better appreciate depth.
  106600. * This is the best way to simulate real life cameras.
  106601. */
  106602. static readonly PERSPECTIVE_CAMERA: number;
  106603. /**
  106604. * This helps creating camera with an orthographic mode.
  106605. * 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.
  106606. */
  106607. static readonly ORTHOGRAPHIC_CAMERA: number;
  106608. /**
  106609. * This is the default FOV mode for perspective cameras.
  106610. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106611. */
  106612. static readonly FOVMODE_VERTICAL_FIXED: number;
  106613. /**
  106614. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106615. */
  106616. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106617. /**
  106618. * This specifies ther is no need for a camera rig.
  106619. * Basically only one eye is rendered corresponding to the camera.
  106620. */
  106621. static readonly RIG_MODE_NONE: number;
  106622. /**
  106623. * Simulates a camera Rig with one blue eye and one red eye.
  106624. * This can be use with 3d blue and red glasses.
  106625. */
  106626. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106627. /**
  106628. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106629. */
  106630. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106631. /**
  106632. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106633. */
  106634. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106635. /**
  106636. * Defines that both eyes of the camera will be rendered over under each other.
  106637. */
  106638. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106639. /**
  106640. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106641. */
  106642. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106643. /**
  106644. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106645. */
  106646. static readonly RIG_MODE_VR: number;
  106647. /**
  106648. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106649. */
  106650. static readonly RIG_MODE_WEBVR: number;
  106651. /**
  106652. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106653. */
  106654. static readonly RIG_MODE_CUSTOM: number;
  106655. /**
  106656. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106657. */
  106658. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106659. /**
  106660. * Define the input manager associated with the camera.
  106661. */
  106662. inputs: CameraInputsManager<Camera>;
  106663. /** @hidden */
  106664. _position: Vector3;
  106665. /**
  106666. * Define the current local position of the camera in the scene
  106667. */
  106668. get position(): Vector3;
  106669. set position(newPosition: Vector3);
  106670. /**
  106671. * The vector the camera should consider as up.
  106672. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106673. */
  106674. upVector: Vector3;
  106675. /**
  106676. * Define the current limit on the left side for an orthographic camera
  106677. * In scene unit
  106678. */
  106679. orthoLeft: Nullable<number>;
  106680. /**
  106681. * Define the current limit on the right side for an orthographic camera
  106682. * In scene unit
  106683. */
  106684. orthoRight: Nullable<number>;
  106685. /**
  106686. * Define the current limit on the bottom side for an orthographic camera
  106687. * In scene unit
  106688. */
  106689. orthoBottom: Nullable<number>;
  106690. /**
  106691. * Define the current limit on the top side for an orthographic camera
  106692. * In scene unit
  106693. */
  106694. orthoTop: Nullable<number>;
  106695. /**
  106696. * Field Of View is set in Radians. (default is 0.8)
  106697. */
  106698. fov: number;
  106699. /**
  106700. * Define the minimum distance the camera can see from.
  106701. * This is important to note that the depth buffer are not infinite and the closer it starts
  106702. * the more your scene might encounter depth fighting issue.
  106703. */
  106704. minZ: number;
  106705. /**
  106706. * Define the maximum distance the camera can see to.
  106707. * This is important to note that the depth buffer are not infinite and the further it end
  106708. * the more your scene might encounter depth fighting issue.
  106709. */
  106710. maxZ: number;
  106711. /**
  106712. * Define the default inertia of the camera.
  106713. * This helps giving a smooth feeling to the camera movement.
  106714. */
  106715. inertia: number;
  106716. /**
  106717. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106718. */
  106719. mode: number;
  106720. /**
  106721. * Define whether the camera is intermediate.
  106722. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106723. */
  106724. isIntermediate: boolean;
  106725. /**
  106726. * Define the viewport of the camera.
  106727. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106728. */
  106729. viewport: Viewport;
  106730. /**
  106731. * Restricts the camera to viewing objects with the same layerMask.
  106732. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106733. */
  106734. layerMask: number;
  106735. /**
  106736. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106737. */
  106738. fovMode: number;
  106739. /**
  106740. * Rig mode of the camera.
  106741. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106742. * This is normally controlled byt the camera themselves as internal use.
  106743. */
  106744. cameraRigMode: number;
  106745. /**
  106746. * Defines the distance between both "eyes" in case of a RIG
  106747. */
  106748. interaxialDistance: number;
  106749. /**
  106750. * Defines if stereoscopic rendering is done side by side or over under.
  106751. */
  106752. isStereoscopicSideBySide: boolean;
  106753. /**
  106754. * 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
  106755. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106756. * else in the scene. (Eg. security camera)
  106757. *
  106758. * 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)
  106759. */
  106760. customRenderTargets: RenderTargetTexture[];
  106761. /**
  106762. * When set, the camera will render to this render target instead of the default canvas
  106763. *
  106764. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106765. */
  106766. outputRenderTarget: Nullable<RenderTargetTexture>;
  106767. /**
  106768. * Observable triggered when the camera view matrix has changed.
  106769. */
  106770. onViewMatrixChangedObservable: Observable<Camera>;
  106771. /**
  106772. * Observable triggered when the camera Projection matrix has changed.
  106773. */
  106774. onProjectionMatrixChangedObservable: Observable<Camera>;
  106775. /**
  106776. * Observable triggered when the inputs have been processed.
  106777. */
  106778. onAfterCheckInputsObservable: Observable<Camera>;
  106779. /**
  106780. * Observable triggered when reset has been called and applied to the camera.
  106781. */
  106782. onRestoreStateObservable: Observable<Camera>;
  106783. /**
  106784. * Is this camera a part of a rig system?
  106785. */
  106786. isRigCamera: boolean;
  106787. /**
  106788. * If isRigCamera set to true this will be set with the parent camera.
  106789. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106790. */
  106791. rigParent?: Camera;
  106792. /** @hidden */
  106793. _cameraRigParams: any;
  106794. /** @hidden */
  106795. _rigCameras: Camera[];
  106796. /** @hidden */
  106797. _rigPostProcess: Nullable<PostProcess>;
  106798. protected _webvrViewMatrix: Matrix;
  106799. /** @hidden */
  106800. _skipRendering: boolean;
  106801. /** @hidden */
  106802. _projectionMatrix: Matrix;
  106803. /** @hidden */
  106804. _postProcesses: Nullable<PostProcess>[];
  106805. /** @hidden */
  106806. _activeMeshes: SmartArray<AbstractMesh>;
  106807. protected _globalPosition: Vector3;
  106808. /** @hidden */
  106809. _computedViewMatrix: Matrix;
  106810. private _doNotComputeProjectionMatrix;
  106811. private _transformMatrix;
  106812. private _frustumPlanes;
  106813. private _refreshFrustumPlanes;
  106814. private _storedFov;
  106815. private _stateStored;
  106816. /**
  106817. * Instantiates a new camera object.
  106818. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106819. * @see https://doc.babylonjs.com/features/cameras
  106820. * @param name Defines the name of the camera in the scene
  106821. * @param position Defines the position of the camera
  106822. * @param scene Defines the scene the camera belongs too
  106823. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106824. */
  106825. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106826. /**
  106827. * Store current camera state (fov, position, etc..)
  106828. * @returns the camera
  106829. */
  106830. storeState(): Camera;
  106831. /**
  106832. * Restores the camera state values if it has been stored. You must call storeState() first
  106833. */
  106834. protected _restoreStateValues(): boolean;
  106835. /**
  106836. * Restored camera state. You must call storeState() first.
  106837. * @returns true if restored and false otherwise
  106838. */
  106839. restoreState(): boolean;
  106840. /**
  106841. * Gets the class name of the camera.
  106842. * @returns the class name
  106843. */
  106844. getClassName(): string;
  106845. /** @hidden */
  106846. readonly _isCamera: boolean;
  106847. /**
  106848. * Gets a string representation of the camera useful for debug purpose.
  106849. * @param fullDetails Defines that a more verboe level of logging is required
  106850. * @returns the string representation
  106851. */
  106852. toString(fullDetails?: boolean): string;
  106853. /**
  106854. * Gets the current world space position of the camera.
  106855. */
  106856. get globalPosition(): Vector3;
  106857. /**
  106858. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106859. * @returns the active meshe list
  106860. */
  106861. getActiveMeshes(): SmartArray<AbstractMesh>;
  106862. /**
  106863. * Check whether a mesh is part of the current active mesh list of the camera
  106864. * @param mesh Defines the mesh to check
  106865. * @returns true if active, false otherwise
  106866. */
  106867. isActiveMesh(mesh: Mesh): boolean;
  106868. /**
  106869. * Is this camera ready to be used/rendered
  106870. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106871. * @return true if the camera is ready
  106872. */
  106873. isReady(completeCheck?: boolean): boolean;
  106874. /** @hidden */
  106875. _initCache(): void;
  106876. /** @hidden */
  106877. _updateCache(ignoreParentClass?: boolean): void;
  106878. /** @hidden */
  106879. _isSynchronized(): boolean;
  106880. /** @hidden */
  106881. _isSynchronizedViewMatrix(): boolean;
  106882. /** @hidden */
  106883. _isSynchronizedProjectionMatrix(): boolean;
  106884. /**
  106885. * Attach the input controls to a specific dom element to get the input from.
  106886. * @param element Defines the element the controls should be listened from
  106887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106888. */
  106889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106890. /**
  106891. * Detach the current controls from the specified dom element.
  106892. * @param element Defines the element to stop listening the inputs from
  106893. */
  106894. detachControl(element: HTMLElement): void;
  106895. /**
  106896. * Update the camera state according to the different inputs gathered during the frame.
  106897. */
  106898. update(): void;
  106899. /** @hidden */
  106900. _checkInputs(): void;
  106901. /** @hidden */
  106902. get rigCameras(): Camera[];
  106903. /**
  106904. * Gets the post process used by the rig cameras
  106905. */
  106906. get rigPostProcess(): Nullable<PostProcess>;
  106907. /**
  106908. * Internal, gets the first post proces.
  106909. * @returns the first post process to be run on this camera.
  106910. */
  106911. _getFirstPostProcess(): Nullable<PostProcess>;
  106912. private _cascadePostProcessesToRigCams;
  106913. /**
  106914. * Attach a post process to the camera.
  106915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106916. * @param postProcess The post process to attach to the camera
  106917. * @param insertAt The position of the post process in case several of them are in use in the scene
  106918. * @returns the position the post process has been inserted at
  106919. */
  106920. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106921. /**
  106922. * Detach a post process to the camera.
  106923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106924. * @param postProcess The post process to detach from the camera
  106925. */
  106926. detachPostProcess(postProcess: PostProcess): void;
  106927. /**
  106928. * Gets the current world matrix of the camera
  106929. */
  106930. getWorldMatrix(): Matrix;
  106931. /** @hidden */
  106932. _getViewMatrix(): Matrix;
  106933. /**
  106934. * Gets the current view matrix of the camera.
  106935. * @param force forces the camera to recompute the matrix without looking at the cached state
  106936. * @returns the view matrix
  106937. */
  106938. getViewMatrix(force?: boolean): Matrix;
  106939. /**
  106940. * Freeze the projection matrix.
  106941. * It will prevent the cache check of the camera projection compute and can speed up perf
  106942. * if no parameter of the camera are meant to change
  106943. * @param projection Defines manually a projection if necessary
  106944. */
  106945. freezeProjectionMatrix(projection?: Matrix): void;
  106946. /**
  106947. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106948. */
  106949. unfreezeProjectionMatrix(): void;
  106950. /**
  106951. * Gets the current projection matrix of the camera.
  106952. * @param force forces the camera to recompute the matrix without looking at the cached state
  106953. * @returns the projection matrix
  106954. */
  106955. getProjectionMatrix(force?: boolean): Matrix;
  106956. /**
  106957. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106958. * @returns a Matrix
  106959. */
  106960. getTransformationMatrix(): Matrix;
  106961. private _updateFrustumPlanes;
  106962. /**
  106963. * Checks if a cullable object (mesh...) is in the camera frustum
  106964. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106965. * @param target The object to check
  106966. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106967. * @returns true if the object is in frustum otherwise false
  106968. */
  106969. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106970. /**
  106971. * Checks if a cullable object (mesh...) is in the camera frustum
  106972. * Unlike isInFrustum this cheks the full bounding box
  106973. * @param target The object to check
  106974. * @returns true if the object is in frustum otherwise false
  106975. */
  106976. isCompletelyInFrustum(target: ICullable): boolean;
  106977. /**
  106978. * Gets a ray in the forward direction from the camera.
  106979. * @param length Defines the length of the ray to create
  106980. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106981. * @param origin Defines the start point of the ray which defaults to the camera position
  106982. * @returns the forward ray
  106983. */
  106984. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106985. /**
  106986. * Releases resources associated with this node.
  106987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106989. */
  106990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106991. /** @hidden */
  106992. _isLeftCamera: boolean;
  106993. /**
  106994. * Gets the left camera of a rig setup in case of Rigged Camera
  106995. */
  106996. get isLeftCamera(): boolean;
  106997. /** @hidden */
  106998. _isRightCamera: boolean;
  106999. /**
  107000. * Gets the right camera of a rig setup in case of Rigged Camera
  107001. */
  107002. get isRightCamera(): boolean;
  107003. /**
  107004. * Gets the left camera of a rig setup in case of Rigged Camera
  107005. */
  107006. get leftCamera(): Nullable<FreeCamera>;
  107007. /**
  107008. * Gets the right camera of a rig setup in case of Rigged Camera
  107009. */
  107010. get rightCamera(): Nullable<FreeCamera>;
  107011. /**
  107012. * Gets the left camera target of a rig setup in case of Rigged Camera
  107013. * @returns the target position
  107014. */
  107015. getLeftTarget(): Nullable<Vector3>;
  107016. /**
  107017. * Gets the right camera target of a rig setup in case of Rigged Camera
  107018. * @returns the target position
  107019. */
  107020. getRightTarget(): Nullable<Vector3>;
  107021. /**
  107022. * @hidden
  107023. */
  107024. setCameraRigMode(mode: number, rigParams: any): void;
  107025. /** @hidden */
  107026. static _setStereoscopicRigMode(camera: Camera): void;
  107027. /** @hidden */
  107028. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107029. /** @hidden */
  107030. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107031. /** @hidden */
  107032. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107033. /** @hidden */
  107034. _getVRProjectionMatrix(): Matrix;
  107035. protected _updateCameraRotationMatrix(): void;
  107036. protected _updateWebVRCameraRotationMatrix(): void;
  107037. /**
  107038. * This function MUST be overwritten by the different WebVR cameras available.
  107039. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107040. * @hidden
  107041. */
  107042. _getWebVRProjectionMatrix(): Matrix;
  107043. /**
  107044. * This function MUST be overwritten by the different WebVR cameras available.
  107045. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107046. * @hidden
  107047. */
  107048. _getWebVRViewMatrix(): Matrix;
  107049. /** @hidden */
  107050. setCameraRigParameter(name: string, value: any): void;
  107051. /**
  107052. * needs to be overridden by children so sub has required properties to be copied
  107053. * @hidden
  107054. */
  107055. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107056. /**
  107057. * May need to be overridden by children
  107058. * @hidden
  107059. */
  107060. _updateRigCameras(): void;
  107061. /** @hidden */
  107062. _setupInputs(): void;
  107063. /**
  107064. * Serialiaze the camera setup to a json represention
  107065. * @returns the JSON representation
  107066. */
  107067. serialize(): any;
  107068. /**
  107069. * Clones the current camera.
  107070. * @param name The cloned camera name
  107071. * @returns the cloned camera
  107072. */
  107073. clone(name: string): Camera;
  107074. /**
  107075. * Gets the direction of the camera relative to a given local axis.
  107076. * @param localAxis Defines the reference axis to provide a relative direction.
  107077. * @return the direction
  107078. */
  107079. getDirection(localAxis: Vector3): Vector3;
  107080. /**
  107081. * Returns the current camera absolute rotation
  107082. */
  107083. get absoluteRotation(): Quaternion;
  107084. /**
  107085. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107086. * @param localAxis Defines the reference axis to provide a relative direction.
  107087. * @param result Defines the vector to store the result in
  107088. */
  107089. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107090. /**
  107091. * Gets a camera constructor for a given camera type
  107092. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107093. * @param name The name of the camera the result will be able to instantiate
  107094. * @param scene The scene the result will construct the camera in
  107095. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107096. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107097. * @returns a factory method to construc the camera
  107098. */
  107099. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107100. /**
  107101. * Compute the world matrix of the camera.
  107102. * @returns the camera world matrix
  107103. */
  107104. computeWorldMatrix(): Matrix;
  107105. /**
  107106. * Parse a JSON and creates the camera from the parsed information
  107107. * @param parsedCamera The JSON to parse
  107108. * @param scene The scene to instantiate the camera in
  107109. * @returns the newly constructed camera
  107110. */
  107111. static Parse(parsedCamera: any, scene: Scene): Camera;
  107112. }
  107113. }
  107114. declare module BABYLON {
  107115. /**
  107116. * Class containing static functions to help procedurally build meshes
  107117. */
  107118. export class DiscBuilder {
  107119. /**
  107120. * Creates a plane polygonal mesh. By default, this is a disc
  107121. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107122. * * 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
  107123. * * 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
  107124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107127. * @param name defines the name of the mesh
  107128. * @param options defines the options used to create the mesh
  107129. * @param scene defines the hosting scene
  107130. * @returns the plane polygonal mesh
  107131. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107132. */
  107133. static CreateDisc(name: string, options: {
  107134. radius?: number;
  107135. tessellation?: number;
  107136. arc?: number;
  107137. updatable?: boolean;
  107138. sideOrientation?: number;
  107139. frontUVs?: Vector4;
  107140. backUVs?: Vector4;
  107141. }, scene?: Nullable<Scene>): Mesh;
  107142. }
  107143. }
  107144. declare module BABYLON {
  107145. /**
  107146. * Options to be used when creating a FresnelParameters.
  107147. */
  107148. export type IFresnelParametersCreationOptions = {
  107149. /**
  107150. * Define the color used on edges (grazing angle)
  107151. */
  107152. leftColor?: Color3;
  107153. /**
  107154. * Define the color used on center
  107155. */
  107156. rightColor?: Color3;
  107157. /**
  107158. * Define bias applied to computed fresnel term
  107159. */
  107160. bias?: number;
  107161. /**
  107162. * Defined the power exponent applied to fresnel term
  107163. */
  107164. power?: number;
  107165. /**
  107166. * Define if the fresnel effect is enable or not.
  107167. */
  107168. isEnabled?: boolean;
  107169. };
  107170. /**
  107171. * Serialized format for FresnelParameters.
  107172. */
  107173. export type IFresnelParametersSerialized = {
  107174. /**
  107175. * Define the color used on edges (grazing angle) [as an array]
  107176. */
  107177. leftColor: number[];
  107178. /**
  107179. * Define the color used on center [as an array]
  107180. */
  107181. rightColor: number[];
  107182. /**
  107183. * Define bias applied to computed fresnel term
  107184. */
  107185. bias: number;
  107186. /**
  107187. * Defined the power exponent applied to fresnel term
  107188. */
  107189. power?: number;
  107190. /**
  107191. * Define if the fresnel effect is enable or not.
  107192. */
  107193. isEnabled: boolean;
  107194. };
  107195. /**
  107196. * This represents all the required information to add a fresnel effect on a material:
  107197. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107198. */
  107199. export class FresnelParameters {
  107200. private _isEnabled;
  107201. /**
  107202. * Define if the fresnel effect is enable or not.
  107203. */
  107204. get isEnabled(): boolean;
  107205. set isEnabled(value: boolean);
  107206. /**
  107207. * Define the color used on edges (grazing angle)
  107208. */
  107209. leftColor: Color3;
  107210. /**
  107211. * Define the color used on center
  107212. */
  107213. rightColor: Color3;
  107214. /**
  107215. * Define bias applied to computed fresnel term
  107216. */
  107217. bias: number;
  107218. /**
  107219. * Defined the power exponent applied to fresnel term
  107220. */
  107221. power: number;
  107222. /**
  107223. * Creates a new FresnelParameters object.
  107224. *
  107225. * @param options provide your own settings to optionally to override defaults
  107226. */
  107227. constructor(options?: IFresnelParametersCreationOptions);
  107228. /**
  107229. * Clones the current fresnel and its valuues
  107230. * @returns a clone fresnel configuration
  107231. */
  107232. clone(): FresnelParameters;
  107233. /**
  107234. * Determines equality between FresnelParameters objects
  107235. * @param otherFresnelParameters defines the second operand
  107236. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107237. */
  107238. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107239. /**
  107240. * Serializes the current fresnel parameters to a JSON representation.
  107241. * @return the JSON serialization
  107242. */
  107243. serialize(): IFresnelParametersSerialized;
  107244. /**
  107245. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107246. * @param parsedFresnelParameters Define the JSON representation
  107247. * @returns the parsed parameters
  107248. */
  107249. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107250. }
  107251. }
  107252. declare module BABYLON {
  107253. /**
  107254. * This groups all the flags used to control the materials channel.
  107255. */
  107256. export class MaterialFlags {
  107257. private static _DiffuseTextureEnabled;
  107258. /**
  107259. * Are diffuse textures enabled in the application.
  107260. */
  107261. static get DiffuseTextureEnabled(): boolean;
  107262. static set DiffuseTextureEnabled(value: boolean);
  107263. private static _DetailTextureEnabled;
  107264. /**
  107265. * Are detail textures enabled in the application.
  107266. */
  107267. static get DetailTextureEnabled(): boolean;
  107268. static set DetailTextureEnabled(value: boolean);
  107269. private static _AmbientTextureEnabled;
  107270. /**
  107271. * Are ambient textures enabled in the application.
  107272. */
  107273. static get AmbientTextureEnabled(): boolean;
  107274. static set AmbientTextureEnabled(value: boolean);
  107275. private static _OpacityTextureEnabled;
  107276. /**
  107277. * Are opacity textures enabled in the application.
  107278. */
  107279. static get OpacityTextureEnabled(): boolean;
  107280. static set OpacityTextureEnabled(value: boolean);
  107281. private static _ReflectionTextureEnabled;
  107282. /**
  107283. * Are reflection textures enabled in the application.
  107284. */
  107285. static get ReflectionTextureEnabled(): boolean;
  107286. static set ReflectionTextureEnabled(value: boolean);
  107287. private static _EmissiveTextureEnabled;
  107288. /**
  107289. * Are emissive textures enabled in the application.
  107290. */
  107291. static get EmissiveTextureEnabled(): boolean;
  107292. static set EmissiveTextureEnabled(value: boolean);
  107293. private static _SpecularTextureEnabled;
  107294. /**
  107295. * Are specular textures enabled in the application.
  107296. */
  107297. static get SpecularTextureEnabled(): boolean;
  107298. static set SpecularTextureEnabled(value: boolean);
  107299. private static _BumpTextureEnabled;
  107300. /**
  107301. * Are bump textures enabled in the application.
  107302. */
  107303. static get BumpTextureEnabled(): boolean;
  107304. static set BumpTextureEnabled(value: boolean);
  107305. private static _LightmapTextureEnabled;
  107306. /**
  107307. * Are lightmap textures enabled in the application.
  107308. */
  107309. static get LightmapTextureEnabled(): boolean;
  107310. static set LightmapTextureEnabled(value: boolean);
  107311. private static _RefractionTextureEnabled;
  107312. /**
  107313. * Are refraction textures enabled in the application.
  107314. */
  107315. static get RefractionTextureEnabled(): boolean;
  107316. static set RefractionTextureEnabled(value: boolean);
  107317. private static _ColorGradingTextureEnabled;
  107318. /**
  107319. * Are color grading textures enabled in the application.
  107320. */
  107321. static get ColorGradingTextureEnabled(): boolean;
  107322. static set ColorGradingTextureEnabled(value: boolean);
  107323. private static _FresnelEnabled;
  107324. /**
  107325. * Are fresnels enabled in the application.
  107326. */
  107327. static get FresnelEnabled(): boolean;
  107328. static set FresnelEnabled(value: boolean);
  107329. private static _ClearCoatTextureEnabled;
  107330. /**
  107331. * Are clear coat textures enabled in the application.
  107332. */
  107333. static get ClearCoatTextureEnabled(): boolean;
  107334. static set ClearCoatTextureEnabled(value: boolean);
  107335. private static _ClearCoatBumpTextureEnabled;
  107336. /**
  107337. * Are clear coat bump textures enabled in the application.
  107338. */
  107339. static get ClearCoatBumpTextureEnabled(): boolean;
  107340. static set ClearCoatBumpTextureEnabled(value: boolean);
  107341. private static _ClearCoatTintTextureEnabled;
  107342. /**
  107343. * Are clear coat tint textures enabled in the application.
  107344. */
  107345. static get ClearCoatTintTextureEnabled(): boolean;
  107346. static set ClearCoatTintTextureEnabled(value: boolean);
  107347. private static _SheenTextureEnabled;
  107348. /**
  107349. * Are sheen textures enabled in the application.
  107350. */
  107351. static get SheenTextureEnabled(): boolean;
  107352. static set SheenTextureEnabled(value: boolean);
  107353. private static _AnisotropicTextureEnabled;
  107354. /**
  107355. * Are anisotropic textures enabled in the application.
  107356. */
  107357. static get AnisotropicTextureEnabled(): boolean;
  107358. static set AnisotropicTextureEnabled(value: boolean);
  107359. private static _ThicknessTextureEnabled;
  107360. /**
  107361. * Are thickness textures enabled in the application.
  107362. */
  107363. static get ThicknessTextureEnabled(): boolean;
  107364. static set ThicknessTextureEnabled(value: boolean);
  107365. }
  107366. }
  107367. declare module BABYLON {
  107368. /** @hidden */
  107369. export var defaultFragmentDeclaration: {
  107370. name: string;
  107371. shader: string;
  107372. };
  107373. }
  107374. declare module BABYLON {
  107375. /** @hidden */
  107376. export var defaultUboDeclaration: {
  107377. name: string;
  107378. shader: string;
  107379. };
  107380. }
  107381. declare module BABYLON {
  107382. /** @hidden */
  107383. export var lightFragmentDeclaration: {
  107384. name: string;
  107385. shader: string;
  107386. };
  107387. }
  107388. declare module BABYLON {
  107389. /** @hidden */
  107390. export var lightUboDeclaration: {
  107391. name: string;
  107392. shader: string;
  107393. };
  107394. }
  107395. declare module BABYLON {
  107396. /** @hidden */
  107397. export var lightsFragmentFunctions: {
  107398. name: string;
  107399. shader: string;
  107400. };
  107401. }
  107402. declare module BABYLON {
  107403. /** @hidden */
  107404. export var shadowsFragmentFunctions: {
  107405. name: string;
  107406. shader: string;
  107407. };
  107408. }
  107409. declare module BABYLON {
  107410. /** @hidden */
  107411. export var fresnelFunction: {
  107412. name: string;
  107413. shader: string;
  107414. };
  107415. }
  107416. declare module BABYLON {
  107417. /** @hidden */
  107418. export var bumpFragmentMainFunctions: {
  107419. name: string;
  107420. shader: string;
  107421. };
  107422. }
  107423. declare module BABYLON {
  107424. /** @hidden */
  107425. export var bumpFragmentFunctions: {
  107426. name: string;
  107427. shader: string;
  107428. };
  107429. }
  107430. declare module BABYLON {
  107431. /** @hidden */
  107432. export var logDepthDeclaration: {
  107433. name: string;
  107434. shader: string;
  107435. };
  107436. }
  107437. declare module BABYLON {
  107438. /** @hidden */
  107439. export var bumpFragment: {
  107440. name: string;
  107441. shader: string;
  107442. };
  107443. }
  107444. declare module BABYLON {
  107445. /** @hidden */
  107446. export var depthPrePass: {
  107447. name: string;
  107448. shader: string;
  107449. };
  107450. }
  107451. declare module BABYLON {
  107452. /** @hidden */
  107453. export var lightFragment: {
  107454. name: string;
  107455. shader: string;
  107456. };
  107457. }
  107458. declare module BABYLON {
  107459. /** @hidden */
  107460. export var logDepthFragment: {
  107461. name: string;
  107462. shader: string;
  107463. };
  107464. }
  107465. declare module BABYLON {
  107466. /** @hidden */
  107467. export var defaultPixelShader: {
  107468. name: string;
  107469. shader: string;
  107470. };
  107471. }
  107472. declare module BABYLON {
  107473. /** @hidden */
  107474. export var defaultVertexDeclaration: {
  107475. name: string;
  107476. shader: string;
  107477. };
  107478. }
  107479. declare module BABYLON {
  107480. /** @hidden */
  107481. export var bumpVertexDeclaration: {
  107482. name: string;
  107483. shader: string;
  107484. };
  107485. }
  107486. declare module BABYLON {
  107487. /** @hidden */
  107488. export var bumpVertex: {
  107489. name: string;
  107490. shader: string;
  107491. };
  107492. }
  107493. declare module BABYLON {
  107494. /** @hidden */
  107495. export var fogVertex: {
  107496. name: string;
  107497. shader: string;
  107498. };
  107499. }
  107500. declare module BABYLON {
  107501. /** @hidden */
  107502. export var shadowsVertex: {
  107503. name: string;
  107504. shader: string;
  107505. };
  107506. }
  107507. declare module BABYLON {
  107508. /** @hidden */
  107509. export var pointCloudVertex: {
  107510. name: string;
  107511. shader: string;
  107512. };
  107513. }
  107514. declare module BABYLON {
  107515. /** @hidden */
  107516. export var logDepthVertex: {
  107517. name: string;
  107518. shader: string;
  107519. };
  107520. }
  107521. declare module BABYLON {
  107522. /** @hidden */
  107523. export var defaultVertexShader: {
  107524. name: string;
  107525. shader: string;
  107526. };
  107527. }
  107528. declare module BABYLON {
  107529. /**
  107530. * @hidden
  107531. */
  107532. export interface IMaterialDetailMapDefines {
  107533. DETAIL: boolean;
  107534. DETAILDIRECTUV: number;
  107535. DETAIL_NORMALBLENDMETHOD: number;
  107536. /** @hidden */
  107537. _areTexturesDirty: boolean;
  107538. }
  107539. /**
  107540. * Define the code related to the detail map parameters of a material
  107541. *
  107542. * Inspired from:
  107543. * 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
  107544. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107545. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107546. */
  107547. export class DetailMapConfiguration {
  107548. private _texture;
  107549. /**
  107550. * The detail texture of the material.
  107551. */
  107552. texture: Nullable<BaseTexture>;
  107553. /**
  107554. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107555. * Bigger values mean stronger blending
  107556. */
  107557. diffuseBlendLevel: number;
  107558. /**
  107559. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107560. * Bigger values mean stronger blending. Only used with PBR materials
  107561. */
  107562. roughnessBlendLevel: number;
  107563. /**
  107564. * Defines how strong the bump effect from the detail map is
  107565. * Bigger values mean stronger effect
  107566. */
  107567. bumpLevel: number;
  107568. private _normalBlendMethod;
  107569. /**
  107570. * The method used to blend the bump and detail normals together
  107571. */
  107572. normalBlendMethod: number;
  107573. private _isEnabled;
  107574. /**
  107575. * Enable or disable the detail map on this material
  107576. */
  107577. isEnabled: boolean;
  107578. /** @hidden */
  107579. private _internalMarkAllSubMeshesAsTexturesDirty;
  107580. /** @hidden */
  107581. _markAllSubMeshesAsTexturesDirty(): void;
  107582. /**
  107583. * Instantiate a new detail map
  107584. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107585. */
  107586. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107587. /**
  107588. * Gets whether the submesh is ready to be used or not.
  107589. * @param defines the list of "defines" to update.
  107590. * @param scene defines the scene the material belongs to.
  107591. * @returns - boolean indicating that the submesh is ready or not.
  107592. */
  107593. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107594. /**
  107595. * Update the defines for detail map usage
  107596. * @param defines the list of "defines" to update.
  107597. * @param scene defines the scene the material belongs to.
  107598. */
  107599. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107600. /**
  107601. * Binds the material data.
  107602. * @param uniformBuffer defines the Uniform buffer to fill in.
  107603. * @param scene defines the scene the material belongs to.
  107604. * @param isFrozen defines whether the material is frozen or not.
  107605. */
  107606. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107607. /**
  107608. * Checks to see if a texture is used in the material.
  107609. * @param texture - Base texture to use.
  107610. * @returns - Boolean specifying if a texture is used in the material.
  107611. */
  107612. hasTexture(texture: BaseTexture): boolean;
  107613. /**
  107614. * Returns an array of the actively used textures.
  107615. * @param activeTextures Array of BaseTextures
  107616. */
  107617. getActiveTextures(activeTextures: BaseTexture[]): void;
  107618. /**
  107619. * Returns the animatable textures.
  107620. * @param animatables Array of animatable textures.
  107621. */
  107622. getAnimatables(animatables: IAnimatable[]): void;
  107623. /**
  107624. * Disposes the resources of the material.
  107625. * @param forceDisposeTextures - Forces the disposal of all textures.
  107626. */
  107627. dispose(forceDisposeTextures?: boolean): void;
  107628. /**
  107629. * Get the current class name useful for serialization or dynamic coding.
  107630. * @returns "DetailMap"
  107631. */
  107632. getClassName(): string;
  107633. /**
  107634. * Add the required uniforms to the current list.
  107635. * @param uniforms defines the current uniform list.
  107636. */
  107637. static AddUniforms(uniforms: string[]): void;
  107638. /**
  107639. * Add the required samplers to the current list.
  107640. * @param samplers defines the current sampler list.
  107641. */
  107642. static AddSamplers(samplers: string[]): void;
  107643. /**
  107644. * Add the required uniforms to the current buffer.
  107645. * @param uniformBuffer defines the current uniform buffer.
  107646. */
  107647. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107648. /**
  107649. * Makes a duplicate of the current instance into another one.
  107650. * @param detailMap define the instance where to copy the info
  107651. */
  107652. copyTo(detailMap: DetailMapConfiguration): void;
  107653. /**
  107654. * Serializes this detail map instance
  107655. * @returns - An object with the serialized instance.
  107656. */
  107657. serialize(): any;
  107658. /**
  107659. * Parses a detail map setting from a serialized object.
  107660. * @param source - Serialized object.
  107661. * @param scene Defines the scene we are parsing for
  107662. * @param rootUrl Defines the rootUrl to load from
  107663. */
  107664. parse(source: any, scene: Scene, rootUrl: string): void;
  107665. }
  107666. }
  107667. declare module BABYLON {
  107668. /** @hidden */
  107669. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107670. MAINUV1: boolean;
  107671. MAINUV2: boolean;
  107672. DIFFUSE: boolean;
  107673. DIFFUSEDIRECTUV: number;
  107674. DETAIL: boolean;
  107675. DETAILDIRECTUV: number;
  107676. DETAIL_NORMALBLENDMETHOD: number;
  107677. AMBIENT: boolean;
  107678. AMBIENTDIRECTUV: number;
  107679. OPACITY: boolean;
  107680. OPACITYDIRECTUV: number;
  107681. OPACITYRGB: boolean;
  107682. REFLECTION: boolean;
  107683. EMISSIVE: boolean;
  107684. EMISSIVEDIRECTUV: number;
  107685. SPECULAR: boolean;
  107686. SPECULARDIRECTUV: number;
  107687. BUMP: boolean;
  107688. BUMPDIRECTUV: number;
  107689. PARALLAX: boolean;
  107690. PARALLAXOCCLUSION: boolean;
  107691. SPECULAROVERALPHA: boolean;
  107692. CLIPPLANE: boolean;
  107693. CLIPPLANE2: boolean;
  107694. CLIPPLANE3: boolean;
  107695. CLIPPLANE4: boolean;
  107696. CLIPPLANE5: boolean;
  107697. CLIPPLANE6: boolean;
  107698. ALPHATEST: boolean;
  107699. DEPTHPREPASS: boolean;
  107700. ALPHAFROMDIFFUSE: boolean;
  107701. POINTSIZE: boolean;
  107702. FOG: boolean;
  107703. SPECULARTERM: boolean;
  107704. DIFFUSEFRESNEL: boolean;
  107705. OPACITYFRESNEL: boolean;
  107706. REFLECTIONFRESNEL: boolean;
  107707. REFRACTIONFRESNEL: boolean;
  107708. EMISSIVEFRESNEL: boolean;
  107709. FRESNEL: boolean;
  107710. NORMAL: boolean;
  107711. UV1: boolean;
  107712. UV2: boolean;
  107713. VERTEXCOLOR: boolean;
  107714. VERTEXALPHA: boolean;
  107715. NUM_BONE_INFLUENCERS: number;
  107716. BonesPerMesh: number;
  107717. BONETEXTURE: boolean;
  107718. INSTANCES: boolean;
  107719. THIN_INSTANCES: boolean;
  107720. GLOSSINESS: boolean;
  107721. ROUGHNESS: boolean;
  107722. EMISSIVEASILLUMINATION: boolean;
  107723. LINKEMISSIVEWITHDIFFUSE: boolean;
  107724. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107725. LIGHTMAP: boolean;
  107726. LIGHTMAPDIRECTUV: number;
  107727. OBJECTSPACE_NORMALMAP: boolean;
  107728. USELIGHTMAPASSHADOWMAP: boolean;
  107729. REFLECTIONMAP_3D: boolean;
  107730. REFLECTIONMAP_SPHERICAL: boolean;
  107731. REFLECTIONMAP_PLANAR: boolean;
  107732. REFLECTIONMAP_CUBIC: boolean;
  107733. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107734. REFLECTIONMAP_PROJECTION: boolean;
  107735. REFLECTIONMAP_SKYBOX: boolean;
  107736. REFLECTIONMAP_EXPLICIT: boolean;
  107737. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107738. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107739. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107740. INVERTCUBICMAP: boolean;
  107741. LOGARITHMICDEPTH: boolean;
  107742. REFRACTION: boolean;
  107743. REFRACTIONMAP_3D: boolean;
  107744. REFLECTIONOVERALPHA: boolean;
  107745. TWOSIDEDLIGHTING: boolean;
  107746. SHADOWFLOAT: boolean;
  107747. MORPHTARGETS: boolean;
  107748. MORPHTARGETS_NORMAL: boolean;
  107749. MORPHTARGETS_TANGENT: boolean;
  107750. MORPHTARGETS_UV: boolean;
  107751. NUM_MORPH_INFLUENCERS: number;
  107752. NONUNIFORMSCALING: boolean;
  107753. PREMULTIPLYALPHA: boolean;
  107754. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107755. ALPHABLEND: boolean;
  107756. PREPASS: boolean;
  107757. SCENE_MRT_COUNT: number;
  107758. RGBDLIGHTMAP: boolean;
  107759. RGBDREFLECTION: boolean;
  107760. RGBDREFRACTION: boolean;
  107761. IMAGEPROCESSING: boolean;
  107762. VIGNETTE: boolean;
  107763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107764. VIGNETTEBLENDMODEOPAQUE: boolean;
  107765. TONEMAPPING: boolean;
  107766. TONEMAPPING_ACES: boolean;
  107767. CONTRAST: boolean;
  107768. COLORCURVES: boolean;
  107769. COLORGRADING: boolean;
  107770. COLORGRADING3D: boolean;
  107771. SAMPLER3DGREENDEPTH: boolean;
  107772. SAMPLER3DBGRMAP: boolean;
  107773. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107774. MULTIVIEW: boolean;
  107775. /**
  107776. * If the reflection texture on this material is in linear color space
  107777. * @hidden
  107778. */
  107779. IS_REFLECTION_LINEAR: boolean;
  107780. /**
  107781. * If the refraction texture on this material is in linear color space
  107782. * @hidden
  107783. */
  107784. IS_REFRACTION_LINEAR: boolean;
  107785. EXPOSURE: boolean;
  107786. constructor();
  107787. setReflectionMode(modeToEnable: string): void;
  107788. }
  107789. /**
  107790. * This is the default material used in Babylon. It is the best trade off between quality
  107791. * and performances.
  107792. * @see https://doc.babylonjs.com/babylon101/materials
  107793. */
  107794. export class StandardMaterial extends PushMaterial {
  107795. private _diffuseTexture;
  107796. /**
  107797. * The basic texture of the material as viewed under a light.
  107798. */
  107799. diffuseTexture: Nullable<BaseTexture>;
  107800. private _ambientTexture;
  107801. /**
  107802. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107803. */
  107804. ambientTexture: Nullable<BaseTexture>;
  107805. private _opacityTexture;
  107806. /**
  107807. * Define the transparency of the material from a texture.
  107808. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107809. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107810. */
  107811. opacityTexture: Nullable<BaseTexture>;
  107812. private _reflectionTexture;
  107813. /**
  107814. * Define the texture used to display the reflection.
  107815. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107816. */
  107817. reflectionTexture: Nullable<BaseTexture>;
  107818. private _emissiveTexture;
  107819. /**
  107820. * Define texture of the material as if self lit.
  107821. * This will be mixed in the final result even in the absence of light.
  107822. */
  107823. emissiveTexture: Nullable<BaseTexture>;
  107824. private _specularTexture;
  107825. /**
  107826. * Define how the color and intensity of the highlight given by the light in the material.
  107827. */
  107828. specularTexture: Nullable<BaseTexture>;
  107829. private _bumpTexture;
  107830. /**
  107831. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107832. * 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.
  107833. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  107834. */
  107835. bumpTexture: Nullable<BaseTexture>;
  107836. private _lightmapTexture;
  107837. /**
  107838. * Complex lighting can be computationally expensive to compute at runtime.
  107839. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107840. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  107841. */
  107842. lightmapTexture: Nullable<BaseTexture>;
  107843. private _refractionTexture;
  107844. /**
  107845. * Define the texture used to display the refraction.
  107846. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107847. */
  107848. refractionTexture: Nullable<BaseTexture>;
  107849. /**
  107850. * The color of the material lit by the environmental background lighting.
  107851. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107852. */
  107853. ambientColor: Color3;
  107854. /**
  107855. * The basic color of the material as viewed under a light.
  107856. */
  107857. diffuseColor: Color3;
  107858. /**
  107859. * Define how the color and intensity of the highlight given by the light in the material.
  107860. */
  107861. specularColor: Color3;
  107862. /**
  107863. * Define the color of the material as if self lit.
  107864. * This will be mixed in the final result even in the absence of light.
  107865. */
  107866. emissiveColor: Color3;
  107867. /**
  107868. * Defines how sharp are the highlights in the material.
  107869. * The bigger the value the sharper giving a more glossy feeling to the result.
  107870. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107871. */
  107872. specularPower: number;
  107873. private _useAlphaFromDiffuseTexture;
  107874. /**
  107875. * Does the transparency come from the diffuse texture alpha channel.
  107876. */
  107877. useAlphaFromDiffuseTexture: boolean;
  107878. private _useEmissiveAsIllumination;
  107879. /**
  107880. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107881. */
  107882. useEmissiveAsIllumination: boolean;
  107883. private _linkEmissiveWithDiffuse;
  107884. /**
  107885. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107886. * the emissive level when the final color is close to one.
  107887. */
  107888. linkEmissiveWithDiffuse: boolean;
  107889. private _useSpecularOverAlpha;
  107890. /**
  107891. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107892. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107893. */
  107894. useSpecularOverAlpha: boolean;
  107895. private _useReflectionOverAlpha;
  107896. /**
  107897. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107898. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107899. */
  107900. useReflectionOverAlpha: boolean;
  107901. private _disableLighting;
  107902. /**
  107903. * Does lights from the scene impacts this material.
  107904. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107905. */
  107906. disableLighting: boolean;
  107907. private _useObjectSpaceNormalMap;
  107908. /**
  107909. * Allows using an object space normal map (instead of tangent space).
  107910. */
  107911. useObjectSpaceNormalMap: boolean;
  107912. private _useParallax;
  107913. /**
  107914. * Is parallax enabled or not.
  107915. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107916. */
  107917. useParallax: boolean;
  107918. private _useParallaxOcclusion;
  107919. /**
  107920. * Is parallax occlusion enabled or not.
  107921. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107922. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107923. */
  107924. useParallaxOcclusion: boolean;
  107925. /**
  107926. * 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.
  107927. */
  107928. parallaxScaleBias: number;
  107929. private _roughness;
  107930. /**
  107931. * Helps to define how blurry the reflections should appears in the material.
  107932. */
  107933. roughness: number;
  107934. /**
  107935. * In case of refraction, define the value of the index of refraction.
  107936. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107937. */
  107938. indexOfRefraction: number;
  107939. /**
  107940. * Invert the refraction texture alongside the y axis.
  107941. * It can be useful with procedural textures or probe for instance.
  107942. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107943. */
  107944. invertRefractionY: boolean;
  107945. /**
  107946. * Defines the alpha limits in alpha test mode.
  107947. */
  107948. alphaCutOff: number;
  107949. private _useLightmapAsShadowmap;
  107950. /**
  107951. * In case of light mapping, define whether the map contains light or shadow informations.
  107952. */
  107953. useLightmapAsShadowmap: boolean;
  107954. private _diffuseFresnelParameters;
  107955. /**
  107956. * Define the diffuse fresnel parameters of the material.
  107957. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107958. */
  107959. diffuseFresnelParameters: FresnelParameters;
  107960. private _opacityFresnelParameters;
  107961. /**
  107962. * Define the opacity fresnel parameters of the material.
  107963. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107964. */
  107965. opacityFresnelParameters: FresnelParameters;
  107966. private _reflectionFresnelParameters;
  107967. /**
  107968. * Define the reflection fresnel parameters of the material.
  107969. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107970. */
  107971. reflectionFresnelParameters: FresnelParameters;
  107972. private _refractionFresnelParameters;
  107973. /**
  107974. * Define the refraction fresnel parameters of the material.
  107975. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107976. */
  107977. refractionFresnelParameters: FresnelParameters;
  107978. private _emissiveFresnelParameters;
  107979. /**
  107980. * Define the emissive fresnel parameters of the material.
  107981. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107982. */
  107983. emissiveFresnelParameters: FresnelParameters;
  107984. private _useReflectionFresnelFromSpecular;
  107985. /**
  107986. * If true automatically deducts the fresnels values from the material specularity.
  107987. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107988. */
  107989. useReflectionFresnelFromSpecular: boolean;
  107990. private _useGlossinessFromSpecularMapAlpha;
  107991. /**
  107992. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107993. */
  107994. useGlossinessFromSpecularMapAlpha: boolean;
  107995. private _maxSimultaneousLights;
  107996. /**
  107997. * Defines the maximum number of lights that can be used in the material
  107998. */
  107999. maxSimultaneousLights: number;
  108000. private _invertNormalMapX;
  108001. /**
  108002. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108003. */
  108004. invertNormalMapX: boolean;
  108005. private _invertNormalMapY;
  108006. /**
  108007. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108008. */
  108009. invertNormalMapY: boolean;
  108010. private _twoSidedLighting;
  108011. /**
  108012. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108013. */
  108014. twoSidedLighting: boolean;
  108015. /**
  108016. * Default configuration related to image processing available in the standard Material.
  108017. */
  108018. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108019. /**
  108020. * Gets the image processing configuration used either in this material.
  108021. */
  108022. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108023. /**
  108024. * Sets the Default image processing configuration used either in the this material.
  108025. *
  108026. * If sets to null, the scene one is in use.
  108027. */
  108028. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108029. /**
  108030. * Keep track of the image processing observer to allow dispose and replace.
  108031. */
  108032. private _imageProcessingObserver;
  108033. /**
  108034. * Attaches a new image processing configuration to the Standard Material.
  108035. * @param configuration
  108036. */
  108037. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108038. /**
  108039. * Gets wether the color curves effect is enabled.
  108040. */
  108041. get cameraColorCurvesEnabled(): boolean;
  108042. /**
  108043. * Sets wether the color curves effect is enabled.
  108044. */
  108045. set cameraColorCurvesEnabled(value: boolean);
  108046. /**
  108047. * Gets wether the color grading effect is enabled.
  108048. */
  108049. get cameraColorGradingEnabled(): boolean;
  108050. /**
  108051. * Gets wether the color grading effect is enabled.
  108052. */
  108053. set cameraColorGradingEnabled(value: boolean);
  108054. /**
  108055. * Gets wether tonemapping is enabled or not.
  108056. */
  108057. get cameraToneMappingEnabled(): boolean;
  108058. /**
  108059. * Sets wether tonemapping is enabled or not
  108060. */
  108061. set cameraToneMappingEnabled(value: boolean);
  108062. /**
  108063. * The camera exposure used on this material.
  108064. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108065. * This corresponds to a photographic exposure.
  108066. */
  108067. get cameraExposure(): number;
  108068. /**
  108069. * The camera exposure used on this material.
  108070. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108071. * This corresponds to a photographic exposure.
  108072. */
  108073. set cameraExposure(value: number);
  108074. /**
  108075. * Gets The camera contrast used on this material.
  108076. */
  108077. get cameraContrast(): number;
  108078. /**
  108079. * Sets The camera contrast used on this material.
  108080. */
  108081. set cameraContrast(value: number);
  108082. /**
  108083. * Gets the Color Grading 2D Lookup Texture.
  108084. */
  108085. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108086. /**
  108087. * Sets the Color Grading 2D Lookup Texture.
  108088. */
  108089. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108090. /**
  108091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108093. * 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;
  108094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108095. */
  108096. get cameraColorCurves(): Nullable<ColorCurves>;
  108097. /**
  108098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108100. * 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;
  108101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108102. */
  108103. set cameraColorCurves(value: Nullable<ColorCurves>);
  108104. /**
  108105. * Defines the detail map parameters for the material.
  108106. */
  108107. readonly detailMap: DetailMapConfiguration;
  108108. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108109. protected _worldViewProjectionMatrix: Matrix;
  108110. protected _globalAmbientColor: Color3;
  108111. protected _useLogarithmicDepth: boolean;
  108112. protected _rebuildInParallel: boolean;
  108113. /**
  108114. * Instantiates a new standard material.
  108115. * This is the default material used in Babylon. It is the best trade off between quality
  108116. * and performances.
  108117. * @see https://doc.babylonjs.com/babylon101/materials
  108118. * @param name Define the name of the material in the scene
  108119. * @param scene Define the scene the material belong to
  108120. */
  108121. constructor(name: string, scene: Scene);
  108122. /**
  108123. * Gets a boolean indicating that current material needs to register RTT
  108124. */
  108125. get hasRenderTargetTextures(): boolean;
  108126. /**
  108127. * Gets the current class name of the material e.g. "StandardMaterial"
  108128. * Mainly use in serialization.
  108129. * @returns the class name
  108130. */
  108131. getClassName(): string;
  108132. /**
  108133. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108134. * You can try switching to logarithmic depth.
  108135. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108136. */
  108137. get useLogarithmicDepth(): boolean;
  108138. set useLogarithmicDepth(value: boolean);
  108139. /**
  108140. * Specifies if the material will require alpha blending
  108141. * @returns a boolean specifying if alpha blending is needed
  108142. */
  108143. needAlphaBlending(): boolean;
  108144. /**
  108145. * Specifies if this material should be rendered in alpha test mode
  108146. * @returns a boolean specifying if an alpha test is needed.
  108147. */
  108148. needAlphaTesting(): boolean;
  108149. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108150. /**
  108151. * Get the texture used for alpha test purpose.
  108152. * @returns the diffuse texture in case of the standard material.
  108153. */
  108154. getAlphaTestTexture(): Nullable<BaseTexture>;
  108155. /**
  108156. * Get if the submesh is ready to be used and all its information available.
  108157. * Child classes can use it to update shaders
  108158. * @param mesh defines the mesh to check
  108159. * @param subMesh defines which submesh to check
  108160. * @param useInstances specifies that instances should be used
  108161. * @returns a boolean indicating that the submesh is ready or not
  108162. */
  108163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108164. /**
  108165. * Builds the material UBO layouts.
  108166. * Used internally during the effect preparation.
  108167. */
  108168. buildUniformLayout(): void;
  108169. /**
  108170. * Unbinds the material from the mesh
  108171. */
  108172. unbind(): void;
  108173. /**
  108174. * Binds the submesh to this material by preparing the effect and shader to draw
  108175. * @param world defines the world transformation matrix
  108176. * @param mesh defines the mesh containing the submesh
  108177. * @param subMesh defines the submesh to bind the material to
  108178. */
  108179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108180. /**
  108181. * Get the list of animatables in the material.
  108182. * @returns the list of animatables object used in the material
  108183. */
  108184. getAnimatables(): IAnimatable[];
  108185. /**
  108186. * Gets the active textures from the material
  108187. * @returns an array of textures
  108188. */
  108189. getActiveTextures(): BaseTexture[];
  108190. /**
  108191. * Specifies if the material uses a texture
  108192. * @param texture defines the texture to check against the material
  108193. * @returns a boolean specifying if the material uses the texture
  108194. */
  108195. hasTexture(texture: BaseTexture): boolean;
  108196. /**
  108197. * Disposes the material
  108198. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108199. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108200. */
  108201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108202. /**
  108203. * Makes a duplicate of the material, and gives it a new name
  108204. * @param name defines the new name for the duplicated material
  108205. * @returns the cloned material
  108206. */
  108207. clone(name: string): StandardMaterial;
  108208. /**
  108209. * Serializes this material in a JSON representation
  108210. * @returns the serialized material object
  108211. */
  108212. serialize(): any;
  108213. /**
  108214. * Creates a standard material from parsed material data
  108215. * @param source defines the JSON representation of the material
  108216. * @param scene defines the hosting scene
  108217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108218. * @returns a new standard material
  108219. */
  108220. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108221. /**
  108222. * Are diffuse textures enabled in the application.
  108223. */
  108224. static get DiffuseTextureEnabled(): boolean;
  108225. static set DiffuseTextureEnabled(value: boolean);
  108226. /**
  108227. * Are detail textures enabled in the application.
  108228. */
  108229. static get DetailTextureEnabled(): boolean;
  108230. static set DetailTextureEnabled(value: boolean);
  108231. /**
  108232. * Are ambient textures enabled in the application.
  108233. */
  108234. static get AmbientTextureEnabled(): boolean;
  108235. static set AmbientTextureEnabled(value: boolean);
  108236. /**
  108237. * Are opacity textures enabled in the application.
  108238. */
  108239. static get OpacityTextureEnabled(): boolean;
  108240. static set OpacityTextureEnabled(value: boolean);
  108241. /**
  108242. * Are reflection textures enabled in the application.
  108243. */
  108244. static get ReflectionTextureEnabled(): boolean;
  108245. static set ReflectionTextureEnabled(value: boolean);
  108246. /**
  108247. * Are emissive textures enabled in the application.
  108248. */
  108249. static get EmissiveTextureEnabled(): boolean;
  108250. static set EmissiveTextureEnabled(value: boolean);
  108251. /**
  108252. * Are specular textures enabled in the application.
  108253. */
  108254. static get SpecularTextureEnabled(): boolean;
  108255. static set SpecularTextureEnabled(value: boolean);
  108256. /**
  108257. * Are bump textures enabled in the application.
  108258. */
  108259. static get BumpTextureEnabled(): boolean;
  108260. static set BumpTextureEnabled(value: boolean);
  108261. /**
  108262. * Are lightmap textures enabled in the application.
  108263. */
  108264. static get LightmapTextureEnabled(): boolean;
  108265. static set LightmapTextureEnabled(value: boolean);
  108266. /**
  108267. * Are refraction textures enabled in the application.
  108268. */
  108269. static get RefractionTextureEnabled(): boolean;
  108270. static set RefractionTextureEnabled(value: boolean);
  108271. /**
  108272. * Are color grading textures enabled in the application.
  108273. */
  108274. static get ColorGradingTextureEnabled(): boolean;
  108275. static set ColorGradingTextureEnabled(value: boolean);
  108276. /**
  108277. * Are fresnels enabled in the application.
  108278. */
  108279. static get FresnelEnabled(): boolean;
  108280. static set FresnelEnabled(value: boolean);
  108281. }
  108282. }
  108283. declare module BABYLON {
  108284. /**
  108285. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108286. *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.
  108287. * The SPS is also a particle system. It provides some methods to manage the particles.
  108288. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108289. *
  108290. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108291. */
  108292. export class SolidParticleSystem implements IDisposable {
  108293. /**
  108294. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108295. * Example : var p = SPS.particles[i];
  108296. */
  108297. particles: SolidParticle[];
  108298. /**
  108299. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108300. */
  108301. nbParticles: number;
  108302. /**
  108303. * If the particles must ever face the camera (default false). Useful for planar particles.
  108304. */
  108305. billboard: boolean;
  108306. /**
  108307. * Recompute normals when adding a shape
  108308. */
  108309. recomputeNormals: boolean;
  108310. /**
  108311. * This a counter ofr your own usage. It's not set by any SPS functions.
  108312. */
  108313. counter: number;
  108314. /**
  108315. * The SPS name. This name is also given to the underlying mesh.
  108316. */
  108317. name: string;
  108318. /**
  108319. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108320. */
  108321. mesh: Mesh;
  108322. /**
  108323. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108324. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108325. */
  108326. vars: any;
  108327. /**
  108328. * This array is populated when the SPS is set as 'pickable'.
  108329. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108330. * Each element of this array is an object `{idx: int, faceId: int}`.
  108331. * `idx` is the picked particle index in the `SPS.particles` array
  108332. * `faceId` is the picked face index counted within this particle.
  108333. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108334. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108335. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108336. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108337. */
  108338. pickedParticles: {
  108339. idx: number;
  108340. faceId: number;
  108341. }[];
  108342. /**
  108343. * This array is populated when the SPS is set as 'pickable'
  108344. * Each key of this array is a submesh index.
  108345. * Each element of this array is a second array defined like this :
  108346. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108347. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108348. * `idx` is the picked particle index in the `SPS.particles` array
  108349. * `faceId` is the picked face index counted within this particle.
  108350. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108351. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108352. */
  108353. pickedBySubMesh: {
  108354. idx: number;
  108355. faceId: number;
  108356. }[][];
  108357. /**
  108358. * This array is populated when `enableDepthSort` is set to true.
  108359. * Each element of this array is an instance of the class DepthSortedParticle.
  108360. */
  108361. depthSortedParticles: DepthSortedParticle[];
  108362. /**
  108363. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108364. * @hidden
  108365. */
  108366. _bSphereOnly: boolean;
  108367. /**
  108368. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108369. * @hidden
  108370. */
  108371. _bSphereRadiusFactor: number;
  108372. private _scene;
  108373. private _positions;
  108374. private _indices;
  108375. private _normals;
  108376. private _colors;
  108377. private _uvs;
  108378. private _indices32;
  108379. private _positions32;
  108380. private _normals32;
  108381. private _fixedNormal32;
  108382. private _colors32;
  108383. private _uvs32;
  108384. private _index;
  108385. private _updatable;
  108386. private _pickable;
  108387. private _isVisibilityBoxLocked;
  108388. private _alwaysVisible;
  108389. private _depthSort;
  108390. private _expandable;
  108391. private _shapeCounter;
  108392. private _copy;
  108393. private _color;
  108394. private _computeParticleColor;
  108395. private _computeParticleTexture;
  108396. private _computeParticleRotation;
  108397. private _computeParticleVertex;
  108398. private _computeBoundingBox;
  108399. private _depthSortParticles;
  108400. private _camera;
  108401. private _mustUnrotateFixedNormals;
  108402. private _particlesIntersect;
  108403. private _needs32Bits;
  108404. private _isNotBuilt;
  108405. private _lastParticleId;
  108406. private _idxOfId;
  108407. private _multimaterialEnabled;
  108408. private _useModelMaterial;
  108409. private _indicesByMaterial;
  108410. private _materialIndexes;
  108411. private _depthSortFunction;
  108412. private _materialSortFunction;
  108413. private _materials;
  108414. private _multimaterial;
  108415. private _materialIndexesById;
  108416. private _defaultMaterial;
  108417. private _autoUpdateSubMeshes;
  108418. private _tmpVertex;
  108419. /**
  108420. * Creates a SPS (Solid Particle System) object.
  108421. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108422. * @param scene (Scene) is the scene in which the SPS is added.
  108423. * @param options defines the options of the sps e.g.
  108424. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108425. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108426. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108427. * * 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.
  108428. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108429. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108430. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108431. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108432. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108433. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108434. */
  108435. constructor(name: string, scene: Scene, options?: {
  108436. updatable?: boolean;
  108437. isPickable?: boolean;
  108438. enableDepthSort?: boolean;
  108439. particleIntersection?: boolean;
  108440. boundingSphereOnly?: boolean;
  108441. bSphereRadiusFactor?: number;
  108442. expandable?: boolean;
  108443. useModelMaterial?: boolean;
  108444. enableMultiMaterial?: boolean;
  108445. });
  108446. /**
  108447. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108448. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108449. * @returns the created mesh
  108450. */
  108451. buildMesh(): Mesh;
  108452. /**
  108453. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108454. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108455. * Thus the particles generated from `digest()` have their property `position` set yet.
  108456. * @param mesh ( Mesh ) is the mesh to be digested
  108457. * @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
  108458. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108459. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108460. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108461. * @returns the current SPS
  108462. */
  108463. digest(mesh: Mesh, options?: {
  108464. facetNb?: number;
  108465. number?: number;
  108466. delta?: number;
  108467. storage?: [];
  108468. }): SolidParticleSystem;
  108469. /**
  108470. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108471. * @hidden
  108472. */
  108473. private _unrotateFixedNormals;
  108474. /**
  108475. * Resets the temporary working copy particle
  108476. * @hidden
  108477. */
  108478. private _resetCopy;
  108479. /**
  108480. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108481. * @param p the current index in the positions array to be updated
  108482. * @param ind the current index in the indices array
  108483. * @param shape a Vector3 array, the shape geometry
  108484. * @param positions the positions array to be updated
  108485. * @param meshInd the shape indices array
  108486. * @param indices the indices array to be updated
  108487. * @param meshUV the shape uv array
  108488. * @param uvs the uv array to be updated
  108489. * @param meshCol the shape color array
  108490. * @param colors the color array to be updated
  108491. * @param meshNor the shape normals array
  108492. * @param normals the normals array to be updated
  108493. * @param idx the particle index
  108494. * @param idxInShape the particle index in its shape
  108495. * @param options the addShape() method passed options
  108496. * @model the particle model
  108497. * @hidden
  108498. */
  108499. private _meshBuilder;
  108500. /**
  108501. * Returns a shape Vector3 array from positions float array
  108502. * @param positions float array
  108503. * @returns a vector3 array
  108504. * @hidden
  108505. */
  108506. private _posToShape;
  108507. /**
  108508. * Returns a shapeUV array from a float uvs (array deep copy)
  108509. * @param uvs as a float array
  108510. * @returns a shapeUV array
  108511. * @hidden
  108512. */
  108513. private _uvsToShapeUV;
  108514. /**
  108515. * Adds a new particle object in the particles array
  108516. * @param idx particle index in particles array
  108517. * @param id particle id
  108518. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108519. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108520. * @param model particle ModelShape object
  108521. * @param shapeId model shape identifier
  108522. * @param idxInShape index of the particle in the current model
  108523. * @param bInfo model bounding info object
  108524. * @param storage target storage array, if any
  108525. * @hidden
  108526. */
  108527. private _addParticle;
  108528. /**
  108529. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108530. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108531. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108532. * @param nb (positive integer) the number of particles to be created from this model
  108533. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108534. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108535. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108536. * @returns the number of shapes in the system
  108537. */
  108538. addShape(mesh: Mesh, nb: number, options?: {
  108539. positionFunction?: any;
  108540. vertexFunction?: any;
  108541. storage?: [];
  108542. }): number;
  108543. /**
  108544. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108545. * @hidden
  108546. */
  108547. private _rebuildParticle;
  108548. /**
  108549. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108550. * @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.
  108551. * @returns the SPS.
  108552. */
  108553. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108554. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108555. * Returns an array with the removed particles.
  108556. * 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.
  108557. * The SPS can't be empty so at least one particle needs to remain in place.
  108558. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108559. * @param start index of the first particle to remove
  108560. * @param end index of the last particle to remove (included)
  108561. * @returns an array populated with the removed particles
  108562. */
  108563. removeParticles(start: number, end: number): SolidParticle[];
  108564. /**
  108565. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108566. * @param solidParticleArray an array populated with Solid Particles objects
  108567. * @returns the SPS
  108568. */
  108569. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108570. /**
  108571. * Creates a new particle and modifies the SPS mesh geometry :
  108572. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108573. * - calls _addParticle() to populate the particle array
  108574. * factorized code from addShape() and insertParticlesFromArray()
  108575. * @param idx particle index in the particles array
  108576. * @param i particle index in its shape
  108577. * @param modelShape particle ModelShape object
  108578. * @param shape shape vertex array
  108579. * @param meshInd shape indices array
  108580. * @param meshUV shape uv array
  108581. * @param meshCol shape color array
  108582. * @param meshNor shape normals array
  108583. * @param bbInfo shape bounding info
  108584. * @param storage target particle storage
  108585. * @options addShape() passed options
  108586. * @hidden
  108587. */
  108588. private _insertNewParticle;
  108589. /**
  108590. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108591. * This method calls `updateParticle()` for each particle of the SPS.
  108592. * For an animated SPS, it is usually called within the render loop.
  108593. * 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.
  108594. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108595. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108596. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108597. * @returns the SPS.
  108598. */
  108599. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108600. /**
  108601. * Disposes the SPS.
  108602. */
  108603. dispose(): void;
  108604. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108605. * idx is the particle index in the SPS
  108606. * faceId is the picked face index counted within this particle.
  108607. * Returns null if the pickInfo can't identify a picked particle.
  108608. * @param pickingInfo (PickingInfo object)
  108609. * @returns {idx: number, faceId: number} or null
  108610. */
  108611. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108612. idx: number;
  108613. faceId: number;
  108614. }>;
  108615. /**
  108616. * Returns a SolidParticle object from its identifier : particle.id
  108617. * @param id (integer) the particle Id
  108618. * @returns the searched particle or null if not found in the SPS.
  108619. */
  108620. getParticleById(id: number): Nullable<SolidParticle>;
  108621. /**
  108622. * Returns a new array populated with the particles having the passed shapeId.
  108623. * @param shapeId (integer) the shape identifier
  108624. * @returns a new solid particle array
  108625. */
  108626. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108627. /**
  108628. * Populates the passed array "ref" with the particles having the passed shapeId.
  108629. * @param shapeId the shape identifier
  108630. * @returns the SPS
  108631. * @param ref
  108632. */
  108633. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108634. /**
  108635. * Computes the required SubMeshes according the materials assigned to the particles.
  108636. * @returns the solid particle system.
  108637. * Does nothing if called before the SPS mesh is built.
  108638. */
  108639. computeSubMeshes(): SolidParticleSystem;
  108640. /**
  108641. * Sorts the solid particles by material when MultiMaterial is enabled.
  108642. * Updates the indices32 array.
  108643. * Updates the indicesByMaterial array.
  108644. * Updates the mesh indices array.
  108645. * @returns the SPS
  108646. * @hidden
  108647. */
  108648. private _sortParticlesByMaterial;
  108649. /**
  108650. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108651. * @hidden
  108652. */
  108653. private _setMaterialIndexesById;
  108654. /**
  108655. * Returns an array with unique values of Materials from the passed array
  108656. * @param array the material array to be checked and filtered
  108657. * @hidden
  108658. */
  108659. private _filterUniqueMaterialId;
  108660. /**
  108661. * Sets a new Standard Material as _defaultMaterial if not already set.
  108662. * @hidden
  108663. */
  108664. private _setDefaultMaterial;
  108665. /**
  108666. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108667. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108668. * @returns the SPS.
  108669. */
  108670. refreshVisibleSize(): SolidParticleSystem;
  108671. /**
  108672. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108673. * @param size the size (float) of the visibility box
  108674. * note : this doesn't lock the SPS mesh bounding box.
  108675. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108676. */
  108677. setVisibilityBox(size: number): void;
  108678. /**
  108679. * Gets whether the SPS as always visible or not
  108680. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108681. */
  108682. get isAlwaysVisible(): boolean;
  108683. /**
  108684. * Sets the SPS as always visible or not
  108685. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108686. */
  108687. set isAlwaysVisible(val: boolean);
  108688. /**
  108689. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108690. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108691. */
  108692. set isVisibilityBoxLocked(val: boolean);
  108693. /**
  108694. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108695. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108696. */
  108697. get isVisibilityBoxLocked(): boolean;
  108698. /**
  108699. * Tells to `setParticles()` to compute the particle rotations or not.
  108700. * Default value : true. The SPS is faster when it's set to false.
  108701. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108702. */
  108703. set computeParticleRotation(val: boolean);
  108704. /**
  108705. * Tells to `setParticles()` to compute the particle colors or not.
  108706. * Default value : true. The SPS is faster when it's set to false.
  108707. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108708. */
  108709. set computeParticleColor(val: boolean);
  108710. set computeParticleTexture(val: boolean);
  108711. /**
  108712. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108713. * Default value : false. The SPS is faster when it's set to false.
  108714. * Note : the particle custom vertex positions aren't stored values.
  108715. */
  108716. set computeParticleVertex(val: boolean);
  108717. /**
  108718. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108719. */
  108720. set computeBoundingBox(val: boolean);
  108721. /**
  108722. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108723. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108724. * Default : `true`
  108725. */
  108726. set depthSortParticles(val: boolean);
  108727. /**
  108728. * Gets if `setParticles()` computes the particle rotations or not.
  108729. * Default value : true. The SPS is faster when it's set to false.
  108730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108731. */
  108732. get computeParticleRotation(): boolean;
  108733. /**
  108734. * Gets if `setParticles()` computes the particle colors or not.
  108735. * Default value : true. The SPS is faster when it's set to false.
  108736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108737. */
  108738. get computeParticleColor(): boolean;
  108739. /**
  108740. * Gets if `setParticles()` computes the particle textures or not.
  108741. * Default value : true. The SPS is faster when it's set to false.
  108742. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108743. */
  108744. get computeParticleTexture(): boolean;
  108745. /**
  108746. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108747. * Default value : false. The SPS is faster when it's set to false.
  108748. * Note : the particle custom vertex positions aren't stored values.
  108749. */
  108750. get computeParticleVertex(): boolean;
  108751. /**
  108752. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108753. */
  108754. get computeBoundingBox(): boolean;
  108755. /**
  108756. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108757. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108758. * Default : `true`
  108759. */
  108760. get depthSortParticles(): boolean;
  108761. /**
  108762. * Gets if the SPS is created as expandable at construction time.
  108763. * Default : `false`
  108764. */
  108765. get expandable(): boolean;
  108766. /**
  108767. * Gets if the SPS supports the Multi Materials
  108768. */
  108769. get multimaterialEnabled(): boolean;
  108770. /**
  108771. * Gets if the SPS uses the model materials for its own multimaterial.
  108772. */
  108773. get useModelMaterial(): boolean;
  108774. /**
  108775. * The SPS used material array.
  108776. */
  108777. get materials(): Material[];
  108778. /**
  108779. * Sets the SPS MultiMaterial from the passed materials.
  108780. * Note : the passed array is internally copied and not used then by reference.
  108781. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108782. */
  108783. setMultiMaterial(materials: Material[]): void;
  108784. /**
  108785. * The SPS computed multimaterial object
  108786. */
  108787. get multimaterial(): MultiMaterial;
  108788. set multimaterial(mm: MultiMaterial);
  108789. /**
  108790. * If the subMeshes must be updated on the next call to setParticles()
  108791. */
  108792. get autoUpdateSubMeshes(): boolean;
  108793. set autoUpdateSubMeshes(val: boolean);
  108794. /**
  108795. * This function does nothing. It may be overwritten to set all the particle first values.
  108796. * The SPS doesn't call this function, you may have to call it by your own.
  108797. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108798. */
  108799. initParticles(): void;
  108800. /**
  108801. * This function does nothing. It may be overwritten to recycle a particle.
  108802. * The SPS doesn't call this function, you may have to call it by your own.
  108803. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108804. * @param particle The particle to recycle
  108805. * @returns the recycled particle
  108806. */
  108807. recycleParticle(particle: SolidParticle): SolidParticle;
  108808. /**
  108809. * Updates a particle : this function should be overwritten by the user.
  108810. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108811. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108812. * @example : just set a particle position or velocity and recycle conditions
  108813. * @param particle The particle to update
  108814. * @returns the updated particle
  108815. */
  108816. updateParticle(particle: SolidParticle): SolidParticle;
  108817. /**
  108818. * Updates a vertex of a particle : it can be overwritten by the user.
  108819. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108820. * @param particle the current particle
  108821. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108822. * @param pt the index of the current vertex in the particle shape
  108823. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108824. * @example : just set a vertex particle position or color
  108825. * @returns the sps
  108826. */
  108827. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108828. /**
  108829. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108830. * This does nothing and may be overwritten by the user.
  108831. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108832. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108833. * @param update the boolean update value actually passed to setParticles()
  108834. */
  108835. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108836. /**
  108837. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108838. * This will be passed three parameters.
  108839. * This does nothing and may be overwritten by the user.
  108840. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108841. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108842. * @param update the boolean update value actually passed to setParticles()
  108843. */
  108844. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108845. }
  108846. }
  108847. declare module BABYLON {
  108848. /**
  108849. * Represents one particle of a solid particle system.
  108850. */
  108851. export class SolidParticle {
  108852. /**
  108853. * particle global index
  108854. */
  108855. idx: number;
  108856. /**
  108857. * particle identifier
  108858. */
  108859. id: number;
  108860. /**
  108861. * The color of the particle
  108862. */
  108863. color: Nullable<Color4>;
  108864. /**
  108865. * The world space position of the particle.
  108866. */
  108867. position: Vector3;
  108868. /**
  108869. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108870. */
  108871. rotation: Vector3;
  108872. /**
  108873. * The world space rotation quaternion of the particle.
  108874. */
  108875. rotationQuaternion: Nullable<Quaternion>;
  108876. /**
  108877. * The scaling of the particle.
  108878. */
  108879. scaling: Vector3;
  108880. /**
  108881. * The uvs of the particle.
  108882. */
  108883. uvs: Vector4;
  108884. /**
  108885. * The current speed of the particle.
  108886. */
  108887. velocity: Vector3;
  108888. /**
  108889. * The pivot point in the particle local space.
  108890. */
  108891. pivot: Vector3;
  108892. /**
  108893. * Must the particle be translated from its pivot point in its local space ?
  108894. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108895. * Default : false
  108896. */
  108897. translateFromPivot: boolean;
  108898. /**
  108899. * Is the particle active or not ?
  108900. */
  108901. alive: boolean;
  108902. /**
  108903. * Is the particle visible or not ?
  108904. */
  108905. isVisible: boolean;
  108906. /**
  108907. * Index of this particle in the global "positions" array (Internal use)
  108908. * @hidden
  108909. */
  108910. _pos: number;
  108911. /**
  108912. * @hidden Index of this particle in the global "indices" array (Internal use)
  108913. */
  108914. _ind: number;
  108915. /**
  108916. * @hidden ModelShape of this particle (Internal use)
  108917. */
  108918. _model: ModelShape;
  108919. /**
  108920. * ModelShape id of this particle
  108921. */
  108922. shapeId: number;
  108923. /**
  108924. * Index of the particle in its shape id
  108925. */
  108926. idxInShape: number;
  108927. /**
  108928. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108929. */
  108930. _modelBoundingInfo: BoundingInfo;
  108931. /**
  108932. * @hidden Particle BoundingInfo object (Internal use)
  108933. */
  108934. _boundingInfo: BoundingInfo;
  108935. /**
  108936. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108937. */
  108938. _sps: SolidParticleSystem;
  108939. /**
  108940. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108941. */
  108942. _stillInvisible: boolean;
  108943. /**
  108944. * @hidden Last computed particle rotation matrix
  108945. */
  108946. _rotationMatrix: number[];
  108947. /**
  108948. * Parent particle Id, if any.
  108949. * Default null.
  108950. */
  108951. parentId: Nullable<number>;
  108952. /**
  108953. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108954. */
  108955. materialIndex: Nullable<number>;
  108956. /**
  108957. * Custom object or properties.
  108958. */
  108959. props: Nullable<any>;
  108960. /**
  108961. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108962. * The possible values are :
  108963. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108964. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108967. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108968. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108969. * */
  108970. cullingStrategy: number;
  108971. /**
  108972. * @hidden Internal global position in the SPS.
  108973. */
  108974. _globalPosition: Vector3;
  108975. /**
  108976. * Creates a Solid Particle object.
  108977. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108978. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108979. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108980. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108981. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108982. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108983. * @param shapeId (integer) is the model shape identifier in the SPS.
  108984. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108985. * @param sps defines the sps it is associated to
  108986. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108987. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108988. */
  108989. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108990. /**
  108991. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108992. * @param target the particle target
  108993. * @returns the current particle
  108994. */
  108995. copyToRef(target: SolidParticle): SolidParticle;
  108996. /**
  108997. * Legacy support, changed scale to scaling
  108998. */
  108999. get scale(): Vector3;
  109000. /**
  109001. * Legacy support, changed scale to scaling
  109002. */
  109003. set scale(scale: Vector3);
  109004. /**
  109005. * Legacy support, changed quaternion to rotationQuaternion
  109006. */
  109007. get quaternion(): Nullable<Quaternion>;
  109008. /**
  109009. * Legacy support, changed quaternion to rotationQuaternion
  109010. */
  109011. set quaternion(q: Nullable<Quaternion>);
  109012. /**
  109013. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109014. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109015. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109016. * @returns true if it intersects
  109017. */
  109018. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109019. /**
  109020. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109021. * A particle is in the frustum if its bounding box intersects the frustum
  109022. * @param frustumPlanes defines the frustum to test
  109023. * @returns true if the particle is in the frustum planes
  109024. */
  109025. isInFrustum(frustumPlanes: Plane[]): boolean;
  109026. /**
  109027. * get the rotation matrix of the particle
  109028. * @hidden
  109029. */
  109030. getRotationMatrix(m: Matrix): void;
  109031. }
  109032. /**
  109033. * Represents the shape of the model used by one particle of a solid particle system.
  109034. * SPS internal tool, don't use it manually.
  109035. */
  109036. export class ModelShape {
  109037. /**
  109038. * The shape id
  109039. * @hidden
  109040. */
  109041. shapeID: number;
  109042. /**
  109043. * flat array of model positions (internal use)
  109044. * @hidden
  109045. */
  109046. _shape: Vector3[];
  109047. /**
  109048. * flat array of model UVs (internal use)
  109049. * @hidden
  109050. */
  109051. _shapeUV: number[];
  109052. /**
  109053. * color array of the model
  109054. * @hidden
  109055. */
  109056. _shapeColors: number[];
  109057. /**
  109058. * indices array of the model
  109059. * @hidden
  109060. */
  109061. _indices: number[];
  109062. /**
  109063. * normals array of the model
  109064. * @hidden
  109065. */
  109066. _normals: number[];
  109067. /**
  109068. * length of the shape in the model indices array (internal use)
  109069. * @hidden
  109070. */
  109071. _indicesLength: number;
  109072. /**
  109073. * Custom position function (internal use)
  109074. * @hidden
  109075. */
  109076. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109077. /**
  109078. * Custom vertex function (internal use)
  109079. * @hidden
  109080. */
  109081. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109082. /**
  109083. * Model material (internal use)
  109084. * @hidden
  109085. */
  109086. _material: Nullable<Material>;
  109087. /**
  109088. * 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.
  109089. * SPS internal tool, don't use it manually.
  109090. * @hidden
  109091. */
  109092. 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>);
  109093. }
  109094. /**
  109095. * Represents a Depth Sorted Particle in the solid particle system.
  109096. * @hidden
  109097. */
  109098. export class DepthSortedParticle {
  109099. /**
  109100. * Particle index
  109101. */
  109102. idx: number;
  109103. /**
  109104. * Index of the particle in the "indices" array
  109105. */
  109106. ind: number;
  109107. /**
  109108. * Length of the particle shape in the "indices" array
  109109. */
  109110. indicesLength: number;
  109111. /**
  109112. * Squared distance from the particle to the camera
  109113. */
  109114. sqDistance: number;
  109115. /**
  109116. * Material index when used with MultiMaterials
  109117. */
  109118. materialIndex: number;
  109119. /**
  109120. * Creates a new sorted particle
  109121. * @param materialIndex
  109122. */
  109123. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109124. }
  109125. /**
  109126. * Represents a solid particle vertex
  109127. */
  109128. export class SolidParticleVertex {
  109129. /**
  109130. * Vertex position
  109131. */
  109132. position: Vector3;
  109133. /**
  109134. * Vertex color
  109135. */
  109136. color: Color4;
  109137. /**
  109138. * Vertex UV
  109139. */
  109140. uv: Vector2;
  109141. /**
  109142. * Creates a new solid particle vertex
  109143. */
  109144. constructor();
  109145. /** Vertex x coordinate */
  109146. get x(): number;
  109147. set x(val: number);
  109148. /** Vertex y coordinate */
  109149. get y(): number;
  109150. set y(val: number);
  109151. /** Vertex z coordinate */
  109152. get z(): number;
  109153. set z(val: number);
  109154. }
  109155. }
  109156. declare module BABYLON {
  109157. /**
  109158. * @hidden
  109159. */
  109160. export class _MeshCollisionData {
  109161. _checkCollisions: boolean;
  109162. _collisionMask: number;
  109163. _collisionGroup: number;
  109164. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109165. _collider: Nullable<Collider>;
  109166. _oldPositionForCollisions: Vector3;
  109167. _diffPositionForCollisions: Vector3;
  109168. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109169. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109170. }
  109171. }
  109172. declare module BABYLON {
  109173. /** @hidden */
  109174. class _FacetDataStorage {
  109175. facetPositions: Vector3[];
  109176. facetNormals: Vector3[];
  109177. facetPartitioning: number[][];
  109178. facetNb: number;
  109179. partitioningSubdivisions: number;
  109180. partitioningBBoxRatio: number;
  109181. facetDataEnabled: boolean;
  109182. facetParameters: any;
  109183. bbSize: Vector3;
  109184. subDiv: {
  109185. max: number;
  109186. X: number;
  109187. Y: number;
  109188. Z: number;
  109189. };
  109190. facetDepthSort: boolean;
  109191. facetDepthSortEnabled: boolean;
  109192. depthSortedIndices: IndicesArray;
  109193. depthSortedFacets: {
  109194. ind: number;
  109195. sqDistance: number;
  109196. }[];
  109197. facetDepthSortFunction: (f1: {
  109198. ind: number;
  109199. sqDistance: number;
  109200. }, f2: {
  109201. ind: number;
  109202. sqDistance: number;
  109203. }) => number;
  109204. facetDepthSortFrom: Vector3;
  109205. facetDepthSortOrigin: Vector3;
  109206. invertedMatrix: Matrix;
  109207. }
  109208. /**
  109209. * @hidden
  109210. **/
  109211. class _InternalAbstractMeshDataInfo {
  109212. _hasVertexAlpha: boolean;
  109213. _useVertexColors: boolean;
  109214. _numBoneInfluencers: number;
  109215. _applyFog: boolean;
  109216. _receiveShadows: boolean;
  109217. _facetData: _FacetDataStorage;
  109218. _visibility: number;
  109219. _skeleton: Nullable<Skeleton>;
  109220. _layerMask: number;
  109221. _computeBonesUsingShaders: boolean;
  109222. _isActive: boolean;
  109223. _onlyForInstances: boolean;
  109224. _isActiveIntermediate: boolean;
  109225. _onlyForInstancesIntermediate: boolean;
  109226. _actAsRegularMesh: boolean;
  109227. }
  109228. /**
  109229. * Class used to store all common mesh properties
  109230. */
  109231. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109232. /** No occlusion */
  109233. static OCCLUSION_TYPE_NONE: number;
  109234. /** Occlusion set to optimisitic */
  109235. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109236. /** Occlusion set to strict */
  109237. static OCCLUSION_TYPE_STRICT: number;
  109238. /** Use an accurante occlusion algorithm */
  109239. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109240. /** Use a conservative occlusion algorithm */
  109241. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109242. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109243. * Test order :
  109244. * Is the bounding sphere outside the frustum ?
  109245. * If not, are the bounding box vertices outside the frustum ?
  109246. * It not, then the cullable object is in the frustum.
  109247. */
  109248. static readonly CULLINGSTRATEGY_STANDARD: number;
  109249. /** Culling strategy : Bounding Sphere Only.
  109250. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109251. * It's also less accurate than the standard because some not visible objects can still be selected.
  109252. * Test : is the bounding sphere outside the frustum ?
  109253. * If not, then the cullable object is in the frustum.
  109254. */
  109255. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109256. /** Culling strategy : Optimistic Inclusion.
  109257. * This in an inclusion test first, then the standard exclusion test.
  109258. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109259. * 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.
  109260. * Anyway, it's as accurate as the standard strategy.
  109261. * Test :
  109262. * Is the cullable object bounding sphere center in the frustum ?
  109263. * If not, apply the default culling strategy.
  109264. */
  109265. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109266. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109267. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109268. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109269. * 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.
  109270. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109271. * Test :
  109272. * Is the cullable object bounding sphere center in the frustum ?
  109273. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109274. */
  109275. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109276. /**
  109277. * No billboard
  109278. */
  109279. static get BILLBOARDMODE_NONE(): number;
  109280. /** Billboard on X axis */
  109281. static get BILLBOARDMODE_X(): number;
  109282. /** Billboard on Y axis */
  109283. static get BILLBOARDMODE_Y(): number;
  109284. /** Billboard on Z axis */
  109285. static get BILLBOARDMODE_Z(): number;
  109286. /** Billboard on all axes */
  109287. static get BILLBOARDMODE_ALL(): number;
  109288. /** Billboard on using position instead of orientation */
  109289. static get BILLBOARDMODE_USE_POSITION(): number;
  109290. /** @hidden */
  109291. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109292. /**
  109293. * The culling strategy to use to check whether the mesh must be rendered or not.
  109294. * This value can be changed at any time and will be used on the next render mesh selection.
  109295. * The possible values are :
  109296. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109297. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109299. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109300. * Please read each static variable documentation to get details about the culling process.
  109301. * */
  109302. cullingStrategy: number;
  109303. /**
  109304. * Gets the number of facets in the mesh
  109305. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109306. */
  109307. get facetNb(): number;
  109308. /**
  109309. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109310. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109311. */
  109312. get partitioningSubdivisions(): number;
  109313. set partitioningSubdivisions(nb: number);
  109314. /**
  109315. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109316. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109317. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109318. */
  109319. get partitioningBBoxRatio(): number;
  109320. set partitioningBBoxRatio(ratio: number);
  109321. /**
  109322. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109323. * Works only for updatable meshes.
  109324. * Doesn't work with multi-materials
  109325. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109326. */
  109327. get mustDepthSortFacets(): boolean;
  109328. set mustDepthSortFacets(sort: boolean);
  109329. /**
  109330. * The location (Vector3) where the facet depth sort must be computed from.
  109331. * By default, the active camera position.
  109332. * Used only when facet depth sort is enabled
  109333. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109334. */
  109335. get facetDepthSortFrom(): Vector3;
  109336. set facetDepthSortFrom(location: Vector3);
  109337. /**
  109338. * gets a boolean indicating if facetData is enabled
  109339. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109340. */
  109341. get isFacetDataEnabled(): boolean;
  109342. /** @hidden */
  109343. _updateNonUniformScalingState(value: boolean): boolean;
  109344. /**
  109345. * An event triggered when this mesh collides with another one
  109346. */
  109347. onCollideObservable: Observable<AbstractMesh>;
  109348. /** Set a function to call when this mesh collides with another one */
  109349. set onCollide(callback: () => void);
  109350. /**
  109351. * An event triggered when the collision's position changes
  109352. */
  109353. onCollisionPositionChangeObservable: Observable<Vector3>;
  109354. /** Set a function to call when the collision's position changes */
  109355. set onCollisionPositionChange(callback: () => void);
  109356. /**
  109357. * An event triggered when material is changed
  109358. */
  109359. onMaterialChangedObservable: Observable<AbstractMesh>;
  109360. /**
  109361. * Gets or sets the orientation for POV movement & rotation
  109362. */
  109363. definedFacingForward: boolean;
  109364. /** @hidden */
  109365. _occlusionQuery: Nullable<WebGLQuery>;
  109366. /** @hidden */
  109367. _renderingGroup: Nullable<RenderingGroup>;
  109368. /**
  109369. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109370. */
  109371. get visibility(): number;
  109372. /**
  109373. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109374. */
  109375. set visibility(value: number);
  109376. /** Gets or sets the alpha index used to sort transparent meshes
  109377. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109378. */
  109379. alphaIndex: number;
  109380. /**
  109381. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109382. */
  109383. isVisible: boolean;
  109384. /**
  109385. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109386. */
  109387. isPickable: boolean;
  109388. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109389. showSubMeshesBoundingBox: boolean;
  109390. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109391. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109392. */
  109393. isBlocker: boolean;
  109394. /**
  109395. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109396. */
  109397. enablePointerMoveEvents: boolean;
  109398. /**
  109399. * Specifies the rendering group id for this mesh (0 by default)
  109400. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109401. */
  109402. renderingGroupId: number;
  109403. private _material;
  109404. /** Gets or sets current material */
  109405. get material(): Nullable<Material>;
  109406. set material(value: Nullable<Material>);
  109407. /**
  109408. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109409. * @see https://doc.babylonjs.com/babylon101/shadows
  109410. */
  109411. get receiveShadows(): boolean;
  109412. set receiveShadows(value: boolean);
  109413. /** Defines color to use when rendering outline */
  109414. outlineColor: Color3;
  109415. /** Define width to use when rendering outline */
  109416. outlineWidth: number;
  109417. /** Defines color to use when rendering overlay */
  109418. overlayColor: Color3;
  109419. /** Defines alpha to use when rendering overlay */
  109420. overlayAlpha: number;
  109421. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109422. get hasVertexAlpha(): boolean;
  109423. set hasVertexAlpha(value: boolean);
  109424. /** 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) */
  109425. get useVertexColors(): boolean;
  109426. set useVertexColors(value: boolean);
  109427. /**
  109428. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109429. */
  109430. get computeBonesUsingShaders(): boolean;
  109431. set computeBonesUsingShaders(value: boolean);
  109432. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109433. get numBoneInfluencers(): number;
  109434. set numBoneInfluencers(value: number);
  109435. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109436. get applyFog(): boolean;
  109437. set applyFog(value: boolean);
  109438. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109439. useOctreeForRenderingSelection: boolean;
  109440. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109441. useOctreeForPicking: boolean;
  109442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109443. useOctreeForCollisions: boolean;
  109444. /**
  109445. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109446. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109447. */
  109448. get layerMask(): number;
  109449. set layerMask(value: number);
  109450. /**
  109451. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109452. */
  109453. alwaysSelectAsActiveMesh: boolean;
  109454. /**
  109455. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109456. */
  109457. doNotSyncBoundingInfo: boolean;
  109458. /**
  109459. * Gets or sets the current action manager
  109460. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109461. */
  109462. actionManager: Nullable<AbstractActionManager>;
  109463. private _meshCollisionData;
  109464. /**
  109465. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109466. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109467. */
  109468. ellipsoid: Vector3;
  109469. /**
  109470. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109471. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109472. */
  109473. ellipsoidOffset: Vector3;
  109474. /**
  109475. * Gets or sets a collision mask used to mask collisions (default is -1).
  109476. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109477. */
  109478. get collisionMask(): number;
  109479. set collisionMask(mask: number);
  109480. /**
  109481. * Gets or sets the current collision group mask (-1 by default).
  109482. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109483. */
  109484. get collisionGroup(): number;
  109485. set collisionGroup(mask: number);
  109486. /**
  109487. * Gets or sets current surrounding meshes (null by default).
  109488. *
  109489. * By default collision detection is tested against every mesh in the scene.
  109490. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109491. * meshes will be tested for the collision.
  109492. *
  109493. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109494. */
  109495. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109496. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109497. /**
  109498. * Defines edge width used when edgesRenderer is enabled
  109499. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109500. */
  109501. edgesWidth: number;
  109502. /**
  109503. * Defines edge color used when edgesRenderer is enabled
  109504. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109505. */
  109506. edgesColor: Color4;
  109507. /** @hidden */
  109508. _edgesRenderer: Nullable<IEdgesRenderer>;
  109509. /** @hidden */
  109510. _masterMesh: Nullable<AbstractMesh>;
  109511. /** @hidden */
  109512. _boundingInfo: Nullable<BoundingInfo>;
  109513. /** @hidden */
  109514. _renderId: number;
  109515. /**
  109516. * Gets or sets the list of subMeshes
  109517. * @see https://doc.babylonjs.com/how_to/multi_materials
  109518. */
  109519. subMeshes: SubMesh[];
  109520. /** @hidden */
  109521. _intersectionsInProgress: AbstractMesh[];
  109522. /** @hidden */
  109523. _unIndexed: boolean;
  109524. /** @hidden */
  109525. _lightSources: Light[];
  109526. /** Gets the list of lights affecting that mesh */
  109527. get lightSources(): Light[];
  109528. /** @hidden */
  109529. get _positions(): Nullable<Vector3[]>;
  109530. /** @hidden */
  109531. _waitingData: {
  109532. lods: Nullable<any>;
  109533. actions: Nullable<any>;
  109534. freezeWorldMatrix: Nullable<boolean>;
  109535. };
  109536. /** @hidden */
  109537. _bonesTransformMatrices: Nullable<Float32Array>;
  109538. /** @hidden */
  109539. _transformMatrixTexture: Nullable<RawTexture>;
  109540. /**
  109541. * Gets or sets a skeleton to apply skining transformations
  109542. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109543. */
  109544. set skeleton(value: Nullable<Skeleton>);
  109545. get skeleton(): Nullable<Skeleton>;
  109546. /**
  109547. * An event triggered when the mesh is rebuilt.
  109548. */
  109549. onRebuildObservable: Observable<AbstractMesh>;
  109550. /**
  109551. * Creates a new AbstractMesh
  109552. * @param name defines the name of the mesh
  109553. * @param scene defines the hosting scene
  109554. */
  109555. constructor(name: string, scene?: Nullable<Scene>);
  109556. /**
  109557. * Returns the string "AbstractMesh"
  109558. * @returns "AbstractMesh"
  109559. */
  109560. getClassName(): string;
  109561. /**
  109562. * Gets a string representation of the current mesh
  109563. * @param fullDetails defines a boolean indicating if full details must be included
  109564. * @returns a string representation of the current mesh
  109565. */
  109566. toString(fullDetails?: boolean): string;
  109567. /**
  109568. * @hidden
  109569. */
  109570. protected _getEffectiveParent(): Nullable<Node>;
  109571. /** @hidden */
  109572. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109573. /** @hidden */
  109574. _rebuild(): void;
  109575. /** @hidden */
  109576. _resyncLightSources(): void;
  109577. /** @hidden */
  109578. _resyncLightSource(light: Light): void;
  109579. /** @hidden */
  109580. _unBindEffect(): void;
  109581. /** @hidden */
  109582. _removeLightSource(light: Light, dispose: boolean): void;
  109583. private _markSubMeshesAsDirty;
  109584. /** @hidden */
  109585. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109586. /** @hidden */
  109587. _markSubMeshesAsAttributesDirty(): void;
  109588. /** @hidden */
  109589. _markSubMeshesAsMiscDirty(): void;
  109590. /**
  109591. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109592. */
  109593. get scaling(): Vector3;
  109594. set scaling(newScaling: Vector3);
  109595. /**
  109596. * Returns true if the mesh is blocked. Implemented by child classes
  109597. */
  109598. get isBlocked(): boolean;
  109599. /**
  109600. * Returns the mesh itself by default. Implemented by child classes
  109601. * @param camera defines the camera to use to pick the right LOD level
  109602. * @returns the currentAbstractMesh
  109603. */
  109604. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109605. /**
  109606. * Returns 0 by default. Implemented by child classes
  109607. * @returns an integer
  109608. */
  109609. getTotalVertices(): number;
  109610. /**
  109611. * Returns a positive integer : the total number of indices in this mesh geometry.
  109612. * @returns the numner of indices or zero if the mesh has no geometry.
  109613. */
  109614. getTotalIndices(): number;
  109615. /**
  109616. * Returns null by default. Implemented by child classes
  109617. * @returns null
  109618. */
  109619. getIndices(): Nullable<IndicesArray>;
  109620. /**
  109621. * Returns the array of the requested vertex data kind. Implemented by child classes
  109622. * @param kind defines the vertex data kind to use
  109623. * @returns null
  109624. */
  109625. getVerticesData(kind: string): Nullable<FloatArray>;
  109626. /**
  109627. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109628. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109629. * Note that a new underlying VertexBuffer object is created each call.
  109630. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109631. * @param kind defines vertex data kind:
  109632. * * VertexBuffer.PositionKind
  109633. * * VertexBuffer.UVKind
  109634. * * VertexBuffer.UV2Kind
  109635. * * VertexBuffer.UV3Kind
  109636. * * VertexBuffer.UV4Kind
  109637. * * VertexBuffer.UV5Kind
  109638. * * VertexBuffer.UV6Kind
  109639. * * VertexBuffer.ColorKind
  109640. * * VertexBuffer.MatricesIndicesKind
  109641. * * VertexBuffer.MatricesIndicesExtraKind
  109642. * * VertexBuffer.MatricesWeightsKind
  109643. * * VertexBuffer.MatricesWeightsExtraKind
  109644. * @param data defines the data source
  109645. * @param updatable defines if the data must be flagged as updatable (or static)
  109646. * @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
  109647. * @returns the current mesh
  109648. */
  109649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109650. /**
  109651. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109652. * If the mesh has no geometry, it is simply returned as it is.
  109653. * @param kind defines vertex data kind:
  109654. * * VertexBuffer.PositionKind
  109655. * * VertexBuffer.UVKind
  109656. * * VertexBuffer.UV2Kind
  109657. * * VertexBuffer.UV3Kind
  109658. * * VertexBuffer.UV4Kind
  109659. * * VertexBuffer.UV5Kind
  109660. * * VertexBuffer.UV6Kind
  109661. * * VertexBuffer.ColorKind
  109662. * * VertexBuffer.MatricesIndicesKind
  109663. * * VertexBuffer.MatricesIndicesExtraKind
  109664. * * VertexBuffer.MatricesWeightsKind
  109665. * * VertexBuffer.MatricesWeightsExtraKind
  109666. * @param data defines the data source
  109667. * @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
  109668. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109669. * @returns the current mesh
  109670. */
  109671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109672. /**
  109673. * Sets the mesh indices,
  109674. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109675. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109676. * @param totalVertices Defines the total number of vertices
  109677. * @returns the current mesh
  109678. */
  109679. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109680. /**
  109681. * Gets a boolean indicating if specific vertex data is present
  109682. * @param kind defines the vertex data kind to use
  109683. * @returns true is data kind is present
  109684. */
  109685. isVerticesDataPresent(kind: string): boolean;
  109686. /**
  109687. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109688. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109689. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109690. * @returns a BoundingInfo
  109691. */
  109692. getBoundingInfo(): BoundingInfo;
  109693. /**
  109694. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109695. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109696. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109697. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109698. * @returns the current mesh
  109699. */
  109700. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109701. /**
  109702. * Overwrite the current bounding info
  109703. * @param boundingInfo defines the new bounding info
  109704. * @returns the current mesh
  109705. */
  109706. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109707. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109708. get useBones(): boolean;
  109709. /** @hidden */
  109710. _preActivate(): void;
  109711. /** @hidden */
  109712. _preActivateForIntermediateRendering(renderId: number): void;
  109713. /** @hidden */
  109714. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109715. /** @hidden */
  109716. _postActivate(): void;
  109717. /** @hidden */
  109718. _freeze(): void;
  109719. /** @hidden */
  109720. _unFreeze(): void;
  109721. /**
  109722. * Gets the current world matrix
  109723. * @returns a Matrix
  109724. */
  109725. getWorldMatrix(): Matrix;
  109726. /** @hidden */
  109727. _getWorldMatrixDeterminant(): number;
  109728. /**
  109729. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109730. */
  109731. get isAnInstance(): boolean;
  109732. /**
  109733. * Gets a boolean indicating if this mesh has instances
  109734. */
  109735. get hasInstances(): boolean;
  109736. /**
  109737. * Gets a boolean indicating if this mesh has thin instances
  109738. */
  109739. get hasThinInstances(): boolean;
  109740. /**
  109741. * Perform relative position change from the point of view of behind the front of the mesh.
  109742. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109743. * Supports definition of mesh facing forward or backward
  109744. * @param amountRight defines the distance on the right axis
  109745. * @param amountUp defines the distance on the up axis
  109746. * @param amountForward defines the distance on the forward axis
  109747. * @returns the current mesh
  109748. */
  109749. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109750. /**
  109751. * Calculate relative position change from the point of view of behind the front of the mesh.
  109752. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109753. * Supports definition of mesh facing forward or backward
  109754. * @param amountRight defines the distance on the right axis
  109755. * @param amountUp defines the distance on the up axis
  109756. * @param amountForward defines the distance on the forward axis
  109757. * @returns the new displacement vector
  109758. */
  109759. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109760. /**
  109761. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109762. * Supports definition of mesh facing forward or backward
  109763. * @param flipBack defines the flip
  109764. * @param twirlClockwise defines the twirl
  109765. * @param tiltRight defines the tilt
  109766. * @returns the current mesh
  109767. */
  109768. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109769. /**
  109770. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109771. * Supports definition of mesh facing forward or backward.
  109772. * @param flipBack defines the flip
  109773. * @param twirlClockwise defines the twirl
  109774. * @param tiltRight defines the tilt
  109775. * @returns the new rotation vector
  109776. */
  109777. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109778. /**
  109779. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109780. * This means the mesh underlying bounding box and sphere are recomputed.
  109781. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109782. * @returns the current mesh
  109783. */
  109784. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109785. /** @hidden */
  109786. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109787. /** @hidden */
  109788. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109789. /** @hidden */
  109790. _updateBoundingInfo(): AbstractMesh;
  109791. /** @hidden */
  109792. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109793. /** @hidden */
  109794. protected _afterComputeWorldMatrix(): void;
  109795. /** @hidden */
  109796. get _effectiveMesh(): AbstractMesh;
  109797. /**
  109798. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109799. * A mesh is in the frustum if its bounding box intersects the frustum
  109800. * @param frustumPlanes defines the frustum to test
  109801. * @returns true if the mesh is in the frustum planes
  109802. */
  109803. isInFrustum(frustumPlanes: Plane[]): boolean;
  109804. /**
  109805. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109806. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109807. * @param frustumPlanes defines the frustum to test
  109808. * @returns true if the mesh is completely in the frustum planes
  109809. */
  109810. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109811. /**
  109812. * True if the mesh intersects another mesh or a SolidParticle object
  109813. * @param mesh defines a target mesh or SolidParticle to test
  109814. * @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)
  109815. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109816. * @returns true if there is an intersection
  109817. */
  109818. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109819. /**
  109820. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109821. * @param point defines the point to test
  109822. * @returns true if there is an intersection
  109823. */
  109824. intersectsPoint(point: Vector3): boolean;
  109825. /**
  109826. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109827. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109828. */
  109829. get checkCollisions(): boolean;
  109830. set checkCollisions(collisionEnabled: boolean);
  109831. /**
  109832. * Gets Collider object used to compute collisions (not physics)
  109833. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109834. */
  109835. get collider(): Nullable<Collider>;
  109836. /**
  109837. * Move the mesh using collision engine
  109838. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109839. * @param displacement defines the requested displacement vector
  109840. * @returns the current mesh
  109841. */
  109842. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109843. private _onCollisionPositionChange;
  109844. /** @hidden */
  109845. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109846. /** @hidden */
  109847. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109848. /** @hidden */
  109849. _checkCollision(collider: Collider): AbstractMesh;
  109850. /** @hidden */
  109851. _generatePointsArray(): boolean;
  109852. /**
  109853. * Checks if the passed Ray intersects with the mesh
  109854. * @param ray defines the ray to use
  109855. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109857. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109858. * @returns the picking info
  109859. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109860. */
  109861. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109862. /**
  109863. * Clones the current mesh
  109864. * @param name defines the mesh name
  109865. * @param newParent defines the new mesh parent
  109866. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109867. * @returns the new mesh
  109868. */
  109869. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109870. /**
  109871. * Disposes all the submeshes of the current meshnp
  109872. * @returns the current mesh
  109873. */
  109874. releaseSubMeshes(): AbstractMesh;
  109875. /**
  109876. * Releases resources associated with this abstract mesh.
  109877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109879. */
  109880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109881. /**
  109882. * Adds the passed mesh as a child to the current mesh
  109883. * @param mesh defines the child mesh
  109884. * @returns the current mesh
  109885. */
  109886. addChild(mesh: AbstractMesh): AbstractMesh;
  109887. /**
  109888. * Removes the passed mesh from the current mesh children list
  109889. * @param mesh defines the child mesh
  109890. * @returns the current mesh
  109891. */
  109892. removeChild(mesh: AbstractMesh): AbstractMesh;
  109893. /** @hidden */
  109894. private _initFacetData;
  109895. /**
  109896. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109897. * This method can be called within the render loop.
  109898. * 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
  109899. * @returns the current mesh
  109900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109901. */
  109902. updateFacetData(): AbstractMesh;
  109903. /**
  109904. * Returns the facetLocalNormals array.
  109905. * The normals are expressed in the mesh local spac
  109906. * @returns an array of Vector3
  109907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109908. */
  109909. getFacetLocalNormals(): Vector3[];
  109910. /**
  109911. * Returns the facetLocalPositions array.
  109912. * The facet positions are expressed in the mesh local space
  109913. * @returns an array of Vector3
  109914. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109915. */
  109916. getFacetLocalPositions(): Vector3[];
  109917. /**
  109918. * Returns the facetLocalPartioning array
  109919. * @returns an array of array of numbers
  109920. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109921. */
  109922. getFacetLocalPartitioning(): number[][];
  109923. /**
  109924. * Returns the i-th facet position in the world system.
  109925. * This method allocates a new Vector3 per call
  109926. * @param i defines the facet index
  109927. * @returns a new Vector3
  109928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109929. */
  109930. getFacetPosition(i: number): Vector3;
  109931. /**
  109932. * Sets the reference Vector3 with the i-th facet position in the world system
  109933. * @param i defines the facet index
  109934. * @param ref defines the target vector
  109935. * @returns the current mesh
  109936. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109937. */
  109938. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109939. /**
  109940. * Returns the i-th facet normal in the world system.
  109941. * This method allocates a new Vector3 per call
  109942. * @param i defines the facet index
  109943. * @returns a new Vector3
  109944. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109945. */
  109946. getFacetNormal(i: number): Vector3;
  109947. /**
  109948. * Sets the reference Vector3 with the i-th facet normal in the world system
  109949. * @param i defines the facet index
  109950. * @param ref defines the target vector
  109951. * @returns the current mesh
  109952. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109953. */
  109954. getFacetNormalToRef(i: number, ref: Vector3): this;
  109955. /**
  109956. * 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)
  109957. * @param x defines x coordinate
  109958. * @param y defines y coordinate
  109959. * @param z defines z coordinate
  109960. * @returns the array of facet indexes
  109961. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109962. */
  109963. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109964. /**
  109965. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109966. * @param projected sets as the (x,y,z) world projection on the facet
  109967. * @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
  109968. * @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
  109969. * @param x defines x coordinate
  109970. * @param y defines y coordinate
  109971. * @param z defines z coordinate
  109972. * @returns the face index if found (or null instead)
  109973. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109974. */
  109975. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109976. /**
  109977. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109978. * @param projected sets as the (x,y,z) local projection on the facet
  109979. * @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
  109980. * @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
  109981. * @param x defines x coordinate
  109982. * @param y defines y coordinate
  109983. * @param z defines z coordinate
  109984. * @returns the face index if found (or null instead)
  109985. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109986. */
  109987. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109988. /**
  109989. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109990. * @returns the parameters
  109991. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109992. */
  109993. getFacetDataParameters(): any;
  109994. /**
  109995. * Disables the feature FacetData and frees the related memory
  109996. * @returns the current mesh
  109997. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109998. */
  109999. disableFacetData(): AbstractMesh;
  110000. /**
  110001. * Updates the AbstractMesh indices array
  110002. * @param indices defines the data source
  110003. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110004. * @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)
  110005. * @returns the current mesh
  110006. */
  110007. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110008. /**
  110009. * Creates new normals data for the mesh
  110010. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110011. * @returns the current mesh
  110012. */
  110013. createNormals(updatable: boolean): AbstractMesh;
  110014. /**
  110015. * Align the mesh with a normal
  110016. * @param normal defines the normal to use
  110017. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110018. * @returns the current mesh
  110019. */
  110020. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110021. /** @hidden */
  110022. _checkOcclusionQuery(): boolean;
  110023. /**
  110024. * Disables the mesh edge rendering mode
  110025. * @returns the currentAbstractMesh
  110026. */
  110027. disableEdgesRendering(): AbstractMesh;
  110028. /**
  110029. * Enables the edge rendering mode on the mesh.
  110030. * This mode makes the mesh edges visible
  110031. * @param epsilon defines the maximal distance between two angles to detect a face
  110032. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110033. * @returns the currentAbstractMesh
  110034. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110035. */
  110036. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110037. /**
  110038. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110039. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110040. */
  110041. getConnectedParticleSystems(): IParticleSystem[];
  110042. }
  110043. }
  110044. declare module BABYLON {
  110045. /**
  110046. * Interface used to define ActionEvent
  110047. */
  110048. export interface IActionEvent {
  110049. /** The mesh or sprite that triggered the action */
  110050. source: any;
  110051. /** The X mouse cursor position at the time of the event */
  110052. pointerX: number;
  110053. /** The Y mouse cursor position at the time of the event */
  110054. pointerY: number;
  110055. /** The mesh that is currently pointed at (can be null) */
  110056. meshUnderPointer: Nullable<AbstractMesh>;
  110057. /** the original (browser) event that triggered the ActionEvent */
  110058. sourceEvent?: any;
  110059. /** additional data for the event */
  110060. additionalData?: any;
  110061. }
  110062. /**
  110063. * ActionEvent is the event being sent when an action is triggered.
  110064. */
  110065. export class ActionEvent implements IActionEvent {
  110066. /** The mesh or sprite that triggered the action */
  110067. source: any;
  110068. /** The X mouse cursor position at the time of the event */
  110069. pointerX: number;
  110070. /** The Y mouse cursor position at the time of the event */
  110071. pointerY: number;
  110072. /** The mesh that is currently pointed at (can be null) */
  110073. meshUnderPointer: Nullable<AbstractMesh>;
  110074. /** the original (browser) event that triggered the ActionEvent */
  110075. sourceEvent?: any;
  110076. /** additional data for the event */
  110077. additionalData?: any;
  110078. /**
  110079. * Creates a new ActionEvent
  110080. * @param source The mesh or sprite that triggered the action
  110081. * @param pointerX The X mouse cursor position at the time of the event
  110082. * @param pointerY The Y mouse cursor position at the time of the event
  110083. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110084. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110085. * @param additionalData additional data for the event
  110086. */
  110087. constructor(
  110088. /** The mesh or sprite that triggered the action */
  110089. source: any,
  110090. /** The X mouse cursor position at the time of the event */
  110091. pointerX: number,
  110092. /** The Y mouse cursor position at the time of the event */
  110093. pointerY: number,
  110094. /** The mesh that is currently pointed at (can be null) */
  110095. meshUnderPointer: Nullable<AbstractMesh>,
  110096. /** the original (browser) event that triggered the ActionEvent */
  110097. sourceEvent?: any,
  110098. /** additional data for the event */
  110099. additionalData?: any);
  110100. /**
  110101. * Helper function to auto-create an ActionEvent from a source mesh.
  110102. * @param source The source mesh that triggered the event
  110103. * @param evt The original (browser) event
  110104. * @param additionalData additional data for the event
  110105. * @returns the new ActionEvent
  110106. */
  110107. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110108. /**
  110109. * Helper function to auto-create an ActionEvent from a source sprite
  110110. * @param source The source sprite that triggered the event
  110111. * @param scene Scene associated with the sprite
  110112. * @param evt The original (browser) event
  110113. * @param additionalData additional data for the event
  110114. * @returns the new ActionEvent
  110115. */
  110116. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110117. /**
  110118. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110119. * @param scene the scene where the event occurred
  110120. * @param evt The original (browser) event
  110121. * @returns the new ActionEvent
  110122. */
  110123. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110124. /**
  110125. * Helper function to auto-create an ActionEvent from a primitive
  110126. * @param prim defines the target primitive
  110127. * @param pointerPos defines the pointer position
  110128. * @param evt The original (browser) event
  110129. * @param additionalData additional data for the event
  110130. * @returns the new ActionEvent
  110131. */
  110132. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110133. }
  110134. }
  110135. declare module BABYLON {
  110136. /**
  110137. * Abstract class used to decouple action Manager from scene and meshes.
  110138. * Do not instantiate.
  110139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110140. */
  110141. export abstract class AbstractActionManager implements IDisposable {
  110142. /** Gets the list of active triggers */
  110143. static Triggers: {
  110144. [key: string]: number;
  110145. };
  110146. /** Gets the cursor to use when hovering items */
  110147. hoverCursor: string;
  110148. /** Gets the list of actions */
  110149. actions: IAction[];
  110150. /**
  110151. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110152. */
  110153. isRecursive: boolean;
  110154. /**
  110155. * Releases all associated resources
  110156. */
  110157. abstract dispose(): void;
  110158. /**
  110159. * Does this action manager has pointer triggers
  110160. */
  110161. abstract get hasPointerTriggers(): boolean;
  110162. /**
  110163. * Does this action manager has pick triggers
  110164. */
  110165. abstract get hasPickTriggers(): boolean;
  110166. /**
  110167. * Process a specific trigger
  110168. * @param trigger defines the trigger to process
  110169. * @param evt defines the event details to be processed
  110170. */
  110171. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110172. /**
  110173. * Does this action manager handles actions of any of the given triggers
  110174. * @param triggers defines the triggers to be tested
  110175. * @return a boolean indicating whether one (or more) of the triggers is handled
  110176. */
  110177. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110178. /**
  110179. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110180. * speed.
  110181. * @param triggerA defines the trigger to be tested
  110182. * @param triggerB defines the trigger to be tested
  110183. * @return a boolean indicating whether one (or more) of the triggers is handled
  110184. */
  110185. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110186. /**
  110187. * Does this action manager handles actions of a given trigger
  110188. * @param trigger defines the trigger to be tested
  110189. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110190. * @return whether the trigger is handled
  110191. */
  110192. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110193. /**
  110194. * Serialize this manager to a JSON object
  110195. * @param name defines the property name to store this manager
  110196. * @returns a JSON representation of this manager
  110197. */
  110198. abstract serialize(name: string): any;
  110199. /**
  110200. * Registers an action to this action manager
  110201. * @param action defines the action to be registered
  110202. * @return the action amended (prepared) after registration
  110203. */
  110204. abstract registerAction(action: IAction): Nullable<IAction>;
  110205. /**
  110206. * Unregisters an action to this action manager
  110207. * @param action defines the action to be unregistered
  110208. * @return a boolean indicating whether the action has been unregistered
  110209. */
  110210. abstract unregisterAction(action: IAction): Boolean;
  110211. /**
  110212. * Does exist one action manager with at least one trigger
  110213. **/
  110214. static get HasTriggers(): boolean;
  110215. /**
  110216. * Does exist one action manager with at least one pick trigger
  110217. **/
  110218. static get HasPickTriggers(): boolean;
  110219. /**
  110220. * Does exist one action manager that handles actions of a given trigger
  110221. * @param trigger defines the trigger to be tested
  110222. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110223. **/
  110224. static HasSpecificTrigger(trigger: number): boolean;
  110225. }
  110226. }
  110227. declare module BABYLON {
  110228. /**
  110229. * Defines how a node can be built from a string name.
  110230. */
  110231. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110232. /**
  110233. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110234. */
  110235. export class Node implements IBehaviorAware<Node> {
  110236. /** @hidden */
  110237. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110238. private static _NodeConstructors;
  110239. /**
  110240. * Add a new node constructor
  110241. * @param type defines the type name of the node to construct
  110242. * @param constructorFunc defines the constructor function
  110243. */
  110244. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110245. /**
  110246. * Returns a node constructor based on type name
  110247. * @param type defines the type name
  110248. * @param name defines the new node name
  110249. * @param scene defines the hosting scene
  110250. * @param options defines optional options to transmit to constructors
  110251. * @returns the new constructor or null
  110252. */
  110253. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110254. /**
  110255. * Gets or sets the name of the node
  110256. */
  110257. name: string;
  110258. /**
  110259. * Gets or sets the id of the node
  110260. */
  110261. id: string;
  110262. /**
  110263. * Gets or sets the unique id of the node
  110264. */
  110265. uniqueId: number;
  110266. /**
  110267. * Gets or sets a string used to store user defined state for the node
  110268. */
  110269. state: string;
  110270. /**
  110271. * Gets or sets an object used to store user defined information for the node
  110272. */
  110273. metadata: any;
  110274. /**
  110275. * For internal use only. Please do not use.
  110276. */
  110277. reservedDataStore: any;
  110278. /**
  110279. * List of inspectable custom properties (used by the Inspector)
  110280. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110281. */
  110282. inspectableCustomProperties: IInspectable[];
  110283. private _doNotSerialize;
  110284. /**
  110285. * Gets or sets a boolean used to define if the node must be serialized
  110286. */
  110287. get doNotSerialize(): boolean;
  110288. set doNotSerialize(value: boolean);
  110289. /** @hidden */
  110290. _isDisposed: boolean;
  110291. /**
  110292. * Gets a list of Animations associated with the node
  110293. */
  110294. animations: Animation[];
  110295. protected _ranges: {
  110296. [name: string]: Nullable<AnimationRange>;
  110297. };
  110298. /**
  110299. * Callback raised when the node is ready to be used
  110300. */
  110301. onReady: Nullable<(node: Node) => void>;
  110302. private _isEnabled;
  110303. private _isParentEnabled;
  110304. private _isReady;
  110305. /** @hidden */
  110306. _currentRenderId: number;
  110307. private _parentUpdateId;
  110308. /** @hidden */
  110309. _childUpdateId: number;
  110310. /** @hidden */
  110311. _waitingParentId: Nullable<string>;
  110312. /** @hidden */
  110313. _scene: Scene;
  110314. /** @hidden */
  110315. _cache: any;
  110316. private _parentNode;
  110317. private _children;
  110318. /** @hidden */
  110319. _worldMatrix: Matrix;
  110320. /** @hidden */
  110321. _worldMatrixDeterminant: number;
  110322. /** @hidden */
  110323. _worldMatrixDeterminantIsDirty: boolean;
  110324. /** @hidden */
  110325. private _sceneRootNodesIndex;
  110326. /**
  110327. * Gets a boolean indicating if the node has been disposed
  110328. * @returns true if the node was disposed
  110329. */
  110330. isDisposed(): boolean;
  110331. /**
  110332. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110333. * @see https://doc.babylonjs.com/how_to/parenting
  110334. */
  110335. set parent(parent: Nullable<Node>);
  110336. get parent(): Nullable<Node>;
  110337. /** @hidden */
  110338. _addToSceneRootNodes(): void;
  110339. /** @hidden */
  110340. _removeFromSceneRootNodes(): void;
  110341. private _animationPropertiesOverride;
  110342. /**
  110343. * Gets or sets the animation properties override
  110344. */
  110345. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110346. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110347. /**
  110348. * Gets a string idenfifying the name of the class
  110349. * @returns "Node" string
  110350. */
  110351. getClassName(): string;
  110352. /** @hidden */
  110353. readonly _isNode: boolean;
  110354. /**
  110355. * An event triggered when the mesh is disposed
  110356. */
  110357. onDisposeObservable: Observable<Node>;
  110358. private _onDisposeObserver;
  110359. /**
  110360. * Sets a callback that will be raised when the node will be disposed
  110361. */
  110362. set onDispose(callback: () => void);
  110363. /**
  110364. * Creates a new Node
  110365. * @param name the name and id to be given to this node
  110366. * @param scene the scene this node will be added to
  110367. */
  110368. constructor(name: string, scene?: Nullable<Scene>);
  110369. /**
  110370. * Gets the scene of the node
  110371. * @returns a scene
  110372. */
  110373. getScene(): Scene;
  110374. /**
  110375. * Gets the engine of the node
  110376. * @returns a Engine
  110377. */
  110378. getEngine(): Engine;
  110379. private _behaviors;
  110380. /**
  110381. * Attach a behavior to the node
  110382. * @see https://doc.babylonjs.com/features/behaviour
  110383. * @param behavior defines the behavior to attach
  110384. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110385. * @returns the current Node
  110386. */
  110387. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110388. /**
  110389. * Remove an attached behavior
  110390. * @see https://doc.babylonjs.com/features/behaviour
  110391. * @param behavior defines the behavior to attach
  110392. * @returns the current Node
  110393. */
  110394. removeBehavior(behavior: Behavior<Node>): Node;
  110395. /**
  110396. * Gets the list of attached behaviors
  110397. * @see https://doc.babylonjs.com/features/behaviour
  110398. */
  110399. get behaviors(): Behavior<Node>[];
  110400. /**
  110401. * Gets an attached behavior by name
  110402. * @param name defines the name of the behavior to look for
  110403. * @see https://doc.babylonjs.com/features/behaviour
  110404. * @returns null if behavior was not found else the requested behavior
  110405. */
  110406. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110407. /**
  110408. * Returns the latest update of the World matrix
  110409. * @returns a Matrix
  110410. */
  110411. getWorldMatrix(): Matrix;
  110412. /** @hidden */
  110413. _getWorldMatrixDeterminant(): number;
  110414. /**
  110415. * Returns directly the latest state of the mesh World matrix.
  110416. * A Matrix is returned.
  110417. */
  110418. get worldMatrixFromCache(): Matrix;
  110419. /** @hidden */
  110420. _initCache(): void;
  110421. /** @hidden */
  110422. updateCache(force?: boolean): void;
  110423. /** @hidden */
  110424. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110425. /** @hidden */
  110426. _updateCache(ignoreParentClass?: boolean): void;
  110427. /** @hidden */
  110428. _isSynchronized(): boolean;
  110429. /** @hidden */
  110430. _markSyncedWithParent(): void;
  110431. /** @hidden */
  110432. isSynchronizedWithParent(): boolean;
  110433. /** @hidden */
  110434. isSynchronized(): boolean;
  110435. /**
  110436. * Is this node ready to be used/rendered
  110437. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110438. * @return true if the node is ready
  110439. */
  110440. isReady(completeCheck?: boolean): boolean;
  110441. /**
  110442. * Is this node enabled?
  110443. * 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
  110444. * @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
  110445. * @return whether this node (and its parent) is enabled
  110446. */
  110447. isEnabled(checkAncestors?: boolean): boolean;
  110448. /** @hidden */
  110449. protected _syncParentEnabledState(): void;
  110450. /**
  110451. * Set the enabled state of this node
  110452. * @param value defines the new enabled state
  110453. */
  110454. setEnabled(value: boolean): void;
  110455. /**
  110456. * Is this node a descendant of the given node?
  110457. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110458. * @param ancestor defines the parent node to inspect
  110459. * @returns a boolean indicating if this node is a descendant of the given node
  110460. */
  110461. isDescendantOf(ancestor: Node): boolean;
  110462. /** @hidden */
  110463. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110464. /**
  110465. * Will return all nodes that have this node as ascendant
  110466. * @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
  110467. * @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
  110468. * @return all children nodes of all types
  110469. */
  110470. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110471. /**
  110472. * Get all child-meshes of this node
  110473. * @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)
  110474. * @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
  110475. * @returns an array of AbstractMesh
  110476. */
  110477. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110478. /**
  110479. * Get all direct children of this node
  110480. * @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
  110481. * @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)
  110482. * @returns an array of Node
  110483. */
  110484. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110485. /** @hidden */
  110486. _setReady(state: boolean): void;
  110487. /**
  110488. * Get an animation by name
  110489. * @param name defines the name of the animation to look for
  110490. * @returns null if not found else the requested animation
  110491. */
  110492. getAnimationByName(name: string): Nullable<Animation>;
  110493. /**
  110494. * Creates an animation range for this node
  110495. * @param name defines the name of the range
  110496. * @param from defines the starting key
  110497. * @param to defines the end key
  110498. */
  110499. createAnimationRange(name: string, from: number, to: number): void;
  110500. /**
  110501. * Delete a specific animation range
  110502. * @param name defines the name of the range to delete
  110503. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110504. */
  110505. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110506. /**
  110507. * Get an animation range by name
  110508. * @param name defines the name of the animation range to look for
  110509. * @returns null if not found else the requested animation range
  110510. */
  110511. getAnimationRange(name: string): Nullable<AnimationRange>;
  110512. /**
  110513. * Gets the list of all animation ranges defined on this node
  110514. * @returns an array
  110515. */
  110516. getAnimationRanges(): Nullable<AnimationRange>[];
  110517. /**
  110518. * Will start the animation sequence
  110519. * @param name defines the range frames for animation sequence
  110520. * @param loop defines if the animation should loop (false by default)
  110521. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110522. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110523. * @returns the object created for this animation. If range does not exist, it will return null
  110524. */
  110525. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110526. /**
  110527. * Serialize animation ranges into a JSON compatible object
  110528. * @returns serialization object
  110529. */
  110530. serializeAnimationRanges(): any;
  110531. /**
  110532. * Computes the world matrix of the node
  110533. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110534. * @returns the world matrix
  110535. */
  110536. computeWorldMatrix(force?: boolean): Matrix;
  110537. /**
  110538. * Releases resources associated with this node.
  110539. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110540. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110541. */
  110542. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110543. /**
  110544. * Parse animation range data from a serialization object and store them into a given node
  110545. * @param node defines where to store the animation ranges
  110546. * @param parsedNode defines the serialization object to read data from
  110547. * @param scene defines the hosting scene
  110548. */
  110549. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110550. /**
  110551. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110552. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110553. * @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
  110554. * @returns the new bounding vectors
  110555. */
  110556. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110557. min: Vector3;
  110558. max: Vector3;
  110559. };
  110560. }
  110561. }
  110562. declare module BABYLON {
  110563. /**
  110564. * @hidden
  110565. */
  110566. export class _IAnimationState {
  110567. key: number;
  110568. repeatCount: number;
  110569. workValue?: any;
  110570. loopMode?: number;
  110571. offsetValue?: any;
  110572. highLimitValue?: any;
  110573. }
  110574. /**
  110575. * Class used to store any kind of animation
  110576. */
  110577. export class Animation {
  110578. /**Name of the animation */
  110579. name: string;
  110580. /**Property to animate */
  110581. targetProperty: string;
  110582. /**The frames per second of the animation */
  110583. framePerSecond: number;
  110584. /**The data type of the animation */
  110585. dataType: number;
  110586. /**The loop mode of the animation */
  110587. loopMode?: number | undefined;
  110588. /**Specifies if blending should be enabled */
  110589. enableBlending?: boolean | undefined;
  110590. /**
  110591. * Use matrix interpolation instead of using direct key value when animating matrices
  110592. */
  110593. static AllowMatricesInterpolation: boolean;
  110594. /**
  110595. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110596. */
  110597. static AllowMatrixDecomposeForInterpolation: boolean;
  110598. /** Define the Url to load snippets */
  110599. static SnippetUrl: string;
  110600. /** Snippet ID if the animation was created from the snippet server */
  110601. snippetId: string;
  110602. /**
  110603. * Stores the key frames of the animation
  110604. */
  110605. private _keys;
  110606. /**
  110607. * Stores the easing function of the animation
  110608. */
  110609. private _easingFunction;
  110610. /**
  110611. * @hidden Internal use only
  110612. */
  110613. _runtimeAnimations: RuntimeAnimation[];
  110614. /**
  110615. * The set of event that will be linked to this animation
  110616. */
  110617. private _events;
  110618. /**
  110619. * Stores an array of target property paths
  110620. */
  110621. targetPropertyPath: string[];
  110622. /**
  110623. * Stores the blending speed of the animation
  110624. */
  110625. blendingSpeed: number;
  110626. /**
  110627. * Stores the animation ranges for the animation
  110628. */
  110629. private _ranges;
  110630. /**
  110631. * @hidden Internal use
  110632. */
  110633. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110634. /**
  110635. * Sets up an animation
  110636. * @param property The property to animate
  110637. * @param animationType The animation type to apply
  110638. * @param framePerSecond The frames per second of the animation
  110639. * @param easingFunction The easing function used in the animation
  110640. * @returns The created animation
  110641. */
  110642. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110643. /**
  110644. * Create and start an animation on a node
  110645. * @param name defines the name of the global animation that will be run on all nodes
  110646. * @param node defines the root node where the animation will take place
  110647. * @param targetProperty defines property to animate
  110648. * @param framePerSecond defines the number of frame per second yo use
  110649. * @param totalFrame defines the number of frames in total
  110650. * @param from defines the initial value
  110651. * @param to defines the final value
  110652. * @param loopMode defines which loop mode you want to use (off by default)
  110653. * @param easingFunction defines the easing function to use (linear by default)
  110654. * @param onAnimationEnd defines the callback to call when animation end
  110655. * @returns the animatable created for this animation
  110656. */
  110657. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110658. /**
  110659. * Create and start an animation on a node and its descendants
  110660. * @param name defines the name of the global animation that will be run on all nodes
  110661. * @param node defines the root node where the animation will take place
  110662. * @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
  110663. * @param targetProperty defines property to animate
  110664. * @param framePerSecond defines the number of frame per second to use
  110665. * @param totalFrame defines the number of frames in total
  110666. * @param from defines the initial value
  110667. * @param to defines the final value
  110668. * @param loopMode defines which loop mode you want to use (off by default)
  110669. * @param easingFunction defines the easing function to use (linear by default)
  110670. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110671. * @returns the list of animatables created for all nodes
  110672. * @example https://www.babylonjs-playground.com/#MH0VLI
  110673. */
  110674. 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[]>;
  110675. /**
  110676. * Creates a new animation, merges it with the existing animations and starts it
  110677. * @param name Name of the animation
  110678. * @param node Node which contains the scene that begins the animations
  110679. * @param targetProperty Specifies which property to animate
  110680. * @param framePerSecond The frames per second of the animation
  110681. * @param totalFrame The total number of frames
  110682. * @param from The frame at the beginning of the animation
  110683. * @param to The frame at the end of the animation
  110684. * @param loopMode Specifies the loop mode of the animation
  110685. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110686. * @param onAnimationEnd Callback to run once the animation is complete
  110687. * @returns Nullable animation
  110688. */
  110689. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110690. /**
  110691. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110692. * @param sourceAnimation defines the Animation containing keyframes to convert
  110693. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110694. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110695. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110696. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110697. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110698. */
  110699. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110700. /**
  110701. * Transition property of an host to the target Value
  110702. * @param property The property to transition
  110703. * @param targetValue The target Value of the property
  110704. * @param host The object where the property to animate belongs
  110705. * @param scene Scene used to run the animation
  110706. * @param frameRate Framerate (in frame/s) to use
  110707. * @param transition The transition type we want to use
  110708. * @param duration The duration of the animation, in milliseconds
  110709. * @param onAnimationEnd Callback trigger at the end of the animation
  110710. * @returns Nullable animation
  110711. */
  110712. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110713. /**
  110714. * Return the array of runtime animations currently using this animation
  110715. */
  110716. get runtimeAnimations(): RuntimeAnimation[];
  110717. /**
  110718. * Specifies if any of the runtime animations are currently running
  110719. */
  110720. get hasRunningRuntimeAnimations(): boolean;
  110721. /**
  110722. * Initializes the animation
  110723. * @param name Name of the animation
  110724. * @param targetProperty Property to animate
  110725. * @param framePerSecond The frames per second of the animation
  110726. * @param dataType The data type of the animation
  110727. * @param loopMode The loop mode of the animation
  110728. * @param enableBlending Specifies if blending should be enabled
  110729. */
  110730. constructor(
  110731. /**Name of the animation */
  110732. name: string,
  110733. /**Property to animate */
  110734. targetProperty: string,
  110735. /**The frames per second of the animation */
  110736. framePerSecond: number,
  110737. /**The data type of the animation */
  110738. dataType: number,
  110739. /**The loop mode of the animation */
  110740. loopMode?: number | undefined,
  110741. /**Specifies if blending should be enabled */
  110742. enableBlending?: boolean | undefined);
  110743. /**
  110744. * Converts the animation to a string
  110745. * @param fullDetails support for multiple levels of logging within scene loading
  110746. * @returns String form of the animation
  110747. */
  110748. toString(fullDetails?: boolean): string;
  110749. /**
  110750. * Add an event to this animation
  110751. * @param event Event to add
  110752. */
  110753. addEvent(event: AnimationEvent): void;
  110754. /**
  110755. * Remove all events found at the given frame
  110756. * @param frame The frame to remove events from
  110757. */
  110758. removeEvents(frame: number): void;
  110759. /**
  110760. * Retrieves all the events from the animation
  110761. * @returns Events from the animation
  110762. */
  110763. getEvents(): AnimationEvent[];
  110764. /**
  110765. * Creates an animation range
  110766. * @param name Name of the animation range
  110767. * @param from Starting frame of the animation range
  110768. * @param to Ending frame of the animation
  110769. */
  110770. createRange(name: string, from: number, to: number): void;
  110771. /**
  110772. * Deletes an animation range by name
  110773. * @param name Name of the animation range to delete
  110774. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110775. */
  110776. deleteRange(name: string, deleteFrames?: boolean): void;
  110777. /**
  110778. * Gets the animation range by name, or null if not defined
  110779. * @param name Name of the animation range
  110780. * @returns Nullable animation range
  110781. */
  110782. getRange(name: string): Nullable<AnimationRange>;
  110783. /**
  110784. * Gets the key frames from the animation
  110785. * @returns The key frames of the animation
  110786. */
  110787. getKeys(): Array<IAnimationKey>;
  110788. /**
  110789. * Gets the highest frame rate of the animation
  110790. * @returns Highest frame rate of the animation
  110791. */
  110792. getHighestFrame(): number;
  110793. /**
  110794. * Gets the easing function of the animation
  110795. * @returns Easing function of the animation
  110796. */
  110797. getEasingFunction(): IEasingFunction;
  110798. /**
  110799. * Sets the easing function of the animation
  110800. * @param easingFunction A custom mathematical formula for animation
  110801. */
  110802. setEasingFunction(easingFunction: EasingFunction): void;
  110803. /**
  110804. * Interpolates a scalar linearly
  110805. * @param startValue Start value of the animation curve
  110806. * @param endValue End value of the animation curve
  110807. * @param gradient Scalar amount to interpolate
  110808. * @returns Interpolated scalar value
  110809. */
  110810. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110811. /**
  110812. * Interpolates a scalar cubically
  110813. * @param startValue Start value of the animation curve
  110814. * @param outTangent End tangent of the animation
  110815. * @param endValue End value of the animation curve
  110816. * @param inTangent Start tangent of the animation curve
  110817. * @param gradient Scalar amount to interpolate
  110818. * @returns Interpolated scalar value
  110819. */
  110820. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110821. /**
  110822. * Interpolates a quaternion using a spherical linear interpolation
  110823. * @param startValue Start value of the animation curve
  110824. * @param endValue End value of the animation curve
  110825. * @param gradient Scalar amount to interpolate
  110826. * @returns Interpolated quaternion value
  110827. */
  110828. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110829. /**
  110830. * Interpolates a quaternion cubically
  110831. * @param startValue Start value of the animation curve
  110832. * @param outTangent End tangent of the animation curve
  110833. * @param endValue End value of the animation curve
  110834. * @param inTangent Start tangent of the animation curve
  110835. * @param gradient Scalar amount to interpolate
  110836. * @returns Interpolated quaternion value
  110837. */
  110838. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110839. /**
  110840. * Interpolates a Vector3 linearl
  110841. * @param startValue Start value of the animation curve
  110842. * @param endValue End value of the animation curve
  110843. * @param gradient Scalar amount to interpolate
  110844. * @returns Interpolated scalar value
  110845. */
  110846. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110847. /**
  110848. * Interpolates a Vector3 cubically
  110849. * @param startValue Start value of the animation curve
  110850. * @param outTangent End tangent of the animation
  110851. * @param endValue End value of the animation curve
  110852. * @param inTangent Start tangent of the animation curve
  110853. * @param gradient Scalar amount to interpolate
  110854. * @returns InterpolatedVector3 value
  110855. */
  110856. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110857. /**
  110858. * Interpolates a Vector2 linearly
  110859. * @param startValue Start value of the animation curve
  110860. * @param endValue End value of the animation curve
  110861. * @param gradient Scalar amount to interpolate
  110862. * @returns Interpolated Vector2 value
  110863. */
  110864. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110865. /**
  110866. * Interpolates a Vector2 cubically
  110867. * @param startValue Start value of the animation curve
  110868. * @param outTangent End tangent of the animation
  110869. * @param endValue End value of the animation curve
  110870. * @param inTangent Start tangent of the animation curve
  110871. * @param gradient Scalar amount to interpolate
  110872. * @returns Interpolated Vector2 value
  110873. */
  110874. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110875. /**
  110876. * Interpolates a size linearly
  110877. * @param startValue Start value of the animation curve
  110878. * @param endValue End value of the animation curve
  110879. * @param gradient Scalar amount to interpolate
  110880. * @returns Interpolated Size value
  110881. */
  110882. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110883. /**
  110884. * Interpolates a Color3 linearly
  110885. * @param startValue Start value of the animation curve
  110886. * @param endValue End value of the animation curve
  110887. * @param gradient Scalar amount to interpolate
  110888. * @returns Interpolated Color3 value
  110889. */
  110890. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110891. /**
  110892. * Interpolates a Color4 linearly
  110893. * @param startValue Start value of the animation curve
  110894. * @param endValue End value of the animation curve
  110895. * @param gradient Scalar amount to interpolate
  110896. * @returns Interpolated Color3 value
  110897. */
  110898. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110899. /**
  110900. * @hidden Internal use only
  110901. */
  110902. _getKeyValue(value: any): any;
  110903. /**
  110904. * @hidden Internal use only
  110905. */
  110906. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110907. /**
  110908. * Defines the function to use to interpolate matrices
  110909. * @param startValue defines the start matrix
  110910. * @param endValue defines the end matrix
  110911. * @param gradient defines the gradient between both matrices
  110912. * @param result defines an optional target matrix where to store the interpolation
  110913. * @returns the interpolated matrix
  110914. */
  110915. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110916. /**
  110917. * Makes a copy of the animation
  110918. * @returns Cloned animation
  110919. */
  110920. clone(): Animation;
  110921. /**
  110922. * Sets the key frames of the animation
  110923. * @param values The animation key frames to set
  110924. */
  110925. setKeys(values: Array<IAnimationKey>): void;
  110926. /**
  110927. * Serializes the animation to an object
  110928. * @returns Serialized object
  110929. */
  110930. serialize(): any;
  110931. /**
  110932. * Float animation type
  110933. */
  110934. static readonly ANIMATIONTYPE_FLOAT: number;
  110935. /**
  110936. * Vector3 animation type
  110937. */
  110938. static readonly ANIMATIONTYPE_VECTOR3: number;
  110939. /**
  110940. * Quaternion animation type
  110941. */
  110942. static readonly ANIMATIONTYPE_QUATERNION: number;
  110943. /**
  110944. * Matrix animation type
  110945. */
  110946. static readonly ANIMATIONTYPE_MATRIX: number;
  110947. /**
  110948. * Color3 animation type
  110949. */
  110950. static readonly ANIMATIONTYPE_COLOR3: number;
  110951. /**
  110952. * Color3 animation type
  110953. */
  110954. static readonly ANIMATIONTYPE_COLOR4: number;
  110955. /**
  110956. * Vector2 animation type
  110957. */
  110958. static readonly ANIMATIONTYPE_VECTOR2: number;
  110959. /**
  110960. * Size animation type
  110961. */
  110962. static readonly ANIMATIONTYPE_SIZE: number;
  110963. /**
  110964. * Relative Loop Mode
  110965. */
  110966. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110967. /**
  110968. * Cycle Loop Mode
  110969. */
  110970. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110971. /**
  110972. * Constant Loop Mode
  110973. */
  110974. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110975. /** @hidden */
  110976. static _UniversalLerp(left: any, right: any, amount: number): any;
  110977. /**
  110978. * Parses an animation object and creates an animation
  110979. * @param parsedAnimation Parsed animation object
  110980. * @returns Animation object
  110981. */
  110982. static Parse(parsedAnimation: any): Animation;
  110983. /**
  110984. * Appends the serialized animations from the source animations
  110985. * @param source Source containing the animations
  110986. * @param destination Target to store the animations
  110987. */
  110988. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110989. /**
  110990. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110991. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110992. * @param url defines the url to load from
  110993. * @returns a promise that will resolve to the new animation or an array of animations
  110994. */
  110995. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110996. /**
  110997. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110998. * @param snippetId defines the snippet to load
  110999. * @returns a promise that will resolve to the new animation or a new array of animations
  111000. */
  111001. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111002. }
  111003. }
  111004. declare module BABYLON {
  111005. /**
  111006. * Interface containing an array of animations
  111007. */
  111008. export interface IAnimatable {
  111009. /**
  111010. * Array of animations
  111011. */
  111012. animations: Nullable<Array<Animation>>;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111017. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111018. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111019. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111020. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111021. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111022. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111023. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111024. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111025. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111026. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111027. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111028. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111029. /**
  111030. * Decorator used to define property that can be serialized as reference to a camera
  111031. * @param sourceName defines the name of the property to decorate
  111032. */
  111033. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111034. /**
  111035. * Class used to help serialization objects
  111036. */
  111037. export class SerializationHelper {
  111038. /** @hidden */
  111039. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111040. /** @hidden */
  111041. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111042. /** @hidden */
  111043. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111044. /** @hidden */
  111045. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111046. /**
  111047. * Appends the serialized animations from the source animations
  111048. * @param source Source containing the animations
  111049. * @param destination Target to store the animations
  111050. */
  111051. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111052. /**
  111053. * Static function used to serialized a specific entity
  111054. * @param entity defines the entity to serialize
  111055. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111056. * @returns a JSON compatible object representing the serialization of the entity
  111057. */
  111058. static Serialize<T>(entity: T, serializationObject?: any): any;
  111059. /**
  111060. * Creates a new entity from a serialization data object
  111061. * @param creationFunction defines a function used to instanciated the new entity
  111062. * @param source defines the source serialization data
  111063. * @param scene defines the hosting scene
  111064. * @param rootUrl defines the root url for resources
  111065. * @returns a new entity
  111066. */
  111067. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111068. /**
  111069. * Clones an object
  111070. * @param creationFunction defines the function used to instanciate the new object
  111071. * @param source defines the source object
  111072. * @returns the cloned object
  111073. */
  111074. static Clone<T>(creationFunction: () => T, source: T): T;
  111075. /**
  111076. * Instanciates a new object based on a source one (some data will be shared between both object)
  111077. * @param creationFunction defines the function used to instanciate the new object
  111078. * @param source defines the source object
  111079. * @returns the new object
  111080. */
  111081. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111082. }
  111083. }
  111084. declare module BABYLON {
  111085. /**
  111086. * Base class of all the textures in babylon.
  111087. * It groups all the common properties the materials, post process, lights... might need
  111088. * in order to make a correct use of the texture.
  111089. */
  111090. export class BaseTexture implements IAnimatable {
  111091. /**
  111092. * Default anisotropic filtering level for the application.
  111093. * It is set to 4 as a good tradeoff between perf and quality.
  111094. */
  111095. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111096. /**
  111097. * Gets or sets the unique id of the texture
  111098. */
  111099. uniqueId: number;
  111100. /**
  111101. * Define the name of the texture.
  111102. */
  111103. name: string;
  111104. /**
  111105. * Gets or sets an object used to store user defined information.
  111106. */
  111107. metadata: any;
  111108. /**
  111109. * For internal use only. Please do not use.
  111110. */
  111111. reservedDataStore: any;
  111112. private _hasAlpha;
  111113. /**
  111114. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111115. */
  111116. set hasAlpha(value: boolean);
  111117. get hasAlpha(): boolean;
  111118. /**
  111119. * Defines if the alpha value should be determined via the rgb values.
  111120. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111121. */
  111122. getAlphaFromRGB: boolean;
  111123. /**
  111124. * Intensity or strength of the texture.
  111125. * It is commonly used by materials to fine tune the intensity of the texture
  111126. */
  111127. level: number;
  111128. /**
  111129. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111130. * This is part of the texture as textures usually maps to one uv set.
  111131. */
  111132. coordinatesIndex: number;
  111133. private _coordinatesMode;
  111134. /**
  111135. * How a texture is mapped.
  111136. *
  111137. * | Value | Type | Description |
  111138. * | ----- | ----------------------------------- | ----------- |
  111139. * | 0 | EXPLICIT_MODE | |
  111140. * | 1 | SPHERICAL_MODE | |
  111141. * | 2 | PLANAR_MODE | |
  111142. * | 3 | CUBIC_MODE | |
  111143. * | 4 | PROJECTION_MODE | |
  111144. * | 5 | SKYBOX_MODE | |
  111145. * | 6 | INVCUBIC_MODE | |
  111146. * | 7 | EQUIRECTANGULAR_MODE | |
  111147. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111148. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111149. */
  111150. set coordinatesMode(value: number);
  111151. get coordinatesMode(): number;
  111152. /**
  111153. * | Value | Type | Description |
  111154. * | ----- | ------------------ | ----------- |
  111155. * | 0 | CLAMP_ADDRESSMODE | |
  111156. * | 1 | WRAP_ADDRESSMODE | |
  111157. * | 2 | MIRROR_ADDRESSMODE | |
  111158. */
  111159. wrapU: number;
  111160. /**
  111161. * | Value | Type | Description |
  111162. * | ----- | ------------------ | ----------- |
  111163. * | 0 | CLAMP_ADDRESSMODE | |
  111164. * | 1 | WRAP_ADDRESSMODE | |
  111165. * | 2 | MIRROR_ADDRESSMODE | |
  111166. */
  111167. wrapV: number;
  111168. /**
  111169. * | Value | Type | Description |
  111170. * | ----- | ------------------ | ----------- |
  111171. * | 0 | CLAMP_ADDRESSMODE | |
  111172. * | 1 | WRAP_ADDRESSMODE | |
  111173. * | 2 | MIRROR_ADDRESSMODE | |
  111174. */
  111175. wrapR: number;
  111176. /**
  111177. * With compliant hardware and browser (supporting anisotropic filtering)
  111178. * this defines the level of anisotropic filtering in the texture.
  111179. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111180. */
  111181. anisotropicFilteringLevel: number;
  111182. /**
  111183. * Define if the texture is a cube texture or if false a 2d texture.
  111184. */
  111185. get isCube(): boolean;
  111186. set isCube(value: boolean);
  111187. /**
  111188. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111189. */
  111190. get is3D(): boolean;
  111191. set is3D(value: boolean);
  111192. /**
  111193. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111194. */
  111195. get is2DArray(): boolean;
  111196. set is2DArray(value: boolean);
  111197. /**
  111198. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111199. * HDR texture are usually stored in linear space.
  111200. * This only impacts the PBR and Background materials
  111201. */
  111202. gammaSpace: boolean;
  111203. /**
  111204. * Gets or sets whether or not the texture contains RGBD data.
  111205. */
  111206. get isRGBD(): boolean;
  111207. set isRGBD(value: boolean);
  111208. /**
  111209. * Is Z inverted in the texture (useful in a cube texture).
  111210. */
  111211. invertZ: boolean;
  111212. /**
  111213. * Are mip maps generated for this texture or not.
  111214. */
  111215. get noMipmap(): boolean;
  111216. /**
  111217. * @hidden
  111218. */
  111219. lodLevelInAlpha: boolean;
  111220. /**
  111221. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111222. */
  111223. get lodGenerationOffset(): number;
  111224. set lodGenerationOffset(value: number);
  111225. /**
  111226. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111227. */
  111228. get lodGenerationScale(): number;
  111229. set lodGenerationScale(value: number);
  111230. /**
  111231. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111232. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111233. * average roughness values.
  111234. */
  111235. get linearSpecularLOD(): boolean;
  111236. set linearSpecularLOD(value: boolean);
  111237. /**
  111238. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111239. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111240. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111241. */
  111242. get irradianceTexture(): Nullable<BaseTexture>;
  111243. set irradianceTexture(value: Nullable<BaseTexture>);
  111244. /**
  111245. * Define if the texture is a render target.
  111246. */
  111247. isRenderTarget: boolean;
  111248. /**
  111249. * Define the unique id of the texture in the scene.
  111250. */
  111251. get uid(): string;
  111252. /** @hidden */
  111253. _prefiltered: boolean;
  111254. /**
  111255. * Return a string representation of the texture.
  111256. * @returns the texture as a string
  111257. */
  111258. toString(): string;
  111259. /**
  111260. * Get the class name of the texture.
  111261. * @returns "BaseTexture"
  111262. */
  111263. getClassName(): string;
  111264. /**
  111265. * Define the list of animation attached to the texture.
  111266. */
  111267. animations: Animation[];
  111268. /**
  111269. * An event triggered when the texture is disposed.
  111270. */
  111271. onDisposeObservable: Observable<BaseTexture>;
  111272. private _onDisposeObserver;
  111273. /**
  111274. * Callback triggered when the texture has been disposed.
  111275. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111276. */
  111277. set onDispose(callback: () => void);
  111278. /**
  111279. * Define the current state of the loading sequence when in delayed load mode.
  111280. */
  111281. delayLoadState: number;
  111282. private _scene;
  111283. private _engine;
  111284. /** @hidden */
  111285. _texture: Nullable<InternalTexture>;
  111286. private _uid;
  111287. /**
  111288. * Define if the texture is preventinga material to render or not.
  111289. * If not and the texture is not ready, the engine will use a default black texture instead.
  111290. */
  111291. get isBlocking(): boolean;
  111292. /**
  111293. * Instantiates a new BaseTexture.
  111294. * Base class of all the textures in babylon.
  111295. * It groups all the common properties the materials, post process, lights... might need
  111296. * in order to make a correct use of the texture.
  111297. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111298. */
  111299. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111300. /**
  111301. * Get the scene the texture belongs to.
  111302. * @returns the scene or null if undefined
  111303. */
  111304. getScene(): Nullable<Scene>;
  111305. /** @hidden */
  111306. protected _getEngine(): Nullable<ThinEngine>;
  111307. /**
  111308. * Get the texture transform matrix used to offset tile the texture for istance.
  111309. * @returns the transformation matrix
  111310. */
  111311. getTextureMatrix(): Matrix;
  111312. /**
  111313. * Get the texture reflection matrix used to rotate/transform the reflection.
  111314. * @returns the reflection matrix
  111315. */
  111316. getReflectionTextureMatrix(): Matrix;
  111317. /**
  111318. * Get the underlying lower level texture from Babylon.
  111319. * @returns the insternal texture
  111320. */
  111321. getInternalTexture(): Nullable<InternalTexture>;
  111322. /**
  111323. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111324. * @returns true if ready or not blocking
  111325. */
  111326. isReadyOrNotBlocking(): boolean;
  111327. /**
  111328. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111329. * @returns true if fully ready
  111330. */
  111331. isReady(): boolean;
  111332. private _cachedSize;
  111333. /**
  111334. * Get the size of the texture.
  111335. * @returns the texture size.
  111336. */
  111337. getSize(): ISize;
  111338. /**
  111339. * Get the base size of the texture.
  111340. * It can be different from the size if the texture has been resized for POT for instance
  111341. * @returns the base size
  111342. */
  111343. getBaseSize(): ISize;
  111344. /**
  111345. * Update the sampling mode of the texture.
  111346. * Default is Trilinear mode.
  111347. *
  111348. * | Value | Type | Description |
  111349. * | ----- | ------------------ | ----------- |
  111350. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111351. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111352. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111353. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111354. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111355. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111356. * | 7 | NEAREST_LINEAR | |
  111357. * | 8 | NEAREST_NEAREST | |
  111358. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111359. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111360. * | 11 | LINEAR_LINEAR | |
  111361. * | 12 | LINEAR_NEAREST | |
  111362. *
  111363. * > _mag_: magnification filter (close to the viewer)
  111364. * > _min_: minification filter (far from the viewer)
  111365. * > _mip_: filter used between mip map levels
  111366. *@param samplingMode Define the new sampling mode of the texture
  111367. */
  111368. updateSamplingMode(samplingMode: number): void;
  111369. /**
  111370. * Scales the texture if is `canRescale()`
  111371. * @param ratio the resize factor we want to use to rescale
  111372. */
  111373. scale(ratio: number): void;
  111374. /**
  111375. * Get if the texture can rescale.
  111376. */
  111377. get canRescale(): boolean;
  111378. /** @hidden */
  111379. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111380. /** @hidden */
  111381. _rebuild(): void;
  111382. /**
  111383. * Triggers the load sequence in delayed load mode.
  111384. */
  111385. delayLoad(): void;
  111386. /**
  111387. * Clones the texture.
  111388. * @returns the cloned texture
  111389. */
  111390. clone(): Nullable<BaseTexture>;
  111391. /**
  111392. * Get the texture underlying type (INT, FLOAT...)
  111393. */
  111394. get textureType(): number;
  111395. /**
  111396. * Get the texture underlying format (RGB, RGBA...)
  111397. */
  111398. get textureFormat(): number;
  111399. /**
  111400. * Indicates that textures need to be re-calculated for all materials
  111401. */
  111402. protected _markAllSubMeshesAsTexturesDirty(): void;
  111403. /**
  111404. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111405. * This will returns an RGBA array buffer containing either in values (0-255) or
  111406. * float values (0-1) depending of the underlying buffer type.
  111407. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111408. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111409. * @param buffer defines a user defined buffer to fill with data (can be null)
  111410. * @returns The Array buffer containing the pixels data.
  111411. */
  111412. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111413. /**
  111414. * Release and destroy the underlying lower level texture aka internalTexture.
  111415. */
  111416. releaseInternalTexture(): void;
  111417. /** @hidden */
  111418. get _lodTextureHigh(): Nullable<BaseTexture>;
  111419. /** @hidden */
  111420. get _lodTextureMid(): Nullable<BaseTexture>;
  111421. /** @hidden */
  111422. get _lodTextureLow(): Nullable<BaseTexture>;
  111423. /**
  111424. * Dispose the texture and release its associated resources.
  111425. */
  111426. dispose(): void;
  111427. /**
  111428. * Serialize the texture into a JSON representation that can be parsed later on.
  111429. * @returns the JSON representation of the texture
  111430. */
  111431. serialize(): any;
  111432. /**
  111433. * Helper function to be called back once a list of texture contains only ready textures.
  111434. * @param textures Define the list of textures to wait for
  111435. * @param callback Define the callback triggered once the entire list will be ready
  111436. */
  111437. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111438. private static _isScene;
  111439. }
  111440. }
  111441. declare module BABYLON {
  111442. /**
  111443. * Options to be used when creating an effect.
  111444. */
  111445. export interface IEffectCreationOptions {
  111446. /**
  111447. * Atrributes that will be used in the shader.
  111448. */
  111449. attributes: string[];
  111450. /**
  111451. * Uniform varible names that will be set in the shader.
  111452. */
  111453. uniformsNames: string[];
  111454. /**
  111455. * Uniform buffer variable names that will be set in the shader.
  111456. */
  111457. uniformBuffersNames: string[];
  111458. /**
  111459. * Sampler texture variable names that will be set in the shader.
  111460. */
  111461. samplers: string[];
  111462. /**
  111463. * Define statements that will be set in the shader.
  111464. */
  111465. defines: any;
  111466. /**
  111467. * Possible fallbacks for this effect to improve performance when needed.
  111468. */
  111469. fallbacks: Nullable<IEffectFallbacks>;
  111470. /**
  111471. * Callback that will be called when the shader is compiled.
  111472. */
  111473. onCompiled: Nullable<(effect: Effect) => void>;
  111474. /**
  111475. * Callback that will be called if an error occurs during shader compilation.
  111476. */
  111477. onError: Nullable<(effect: Effect, errors: string) => void>;
  111478. /**
  111479. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111480. */
  111481. indexParameters?: any;
  111482. /**
  111483. * Max number of lights that can be used in the shader.
  111484. */
  111485. maxSimultaneousLights?: number;
  111486. /**
  111487. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111488. */
  111489. transformFeedbackVaryings?: Nullable<string[]>;
  111490. /**
  111491. * 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
  111492. */
  111493. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111494. /**
  111495. * Is this effect rendering to several color attachments ?
  111496. */
  111497. multiTarget?: boolean;
  111498. }
  111499. /**
  111500. * Effect containing vertex and fragment shader that can be executed on an object.
  111501. */
  111502. export class Effect implements IDisposable {
  111503. /**
  111504. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111505. */
  111506. static ShadersRepository: string;
  111507. /**
  111508. * Enable logging of the shader code when a compilation error occurs
  111509. */
  111510. static LogShaderCodeOnCompilationError: boolean;
  111511. /**
  111512. * Name of the effect.
  111513. */
  111514. name: any;
  111515. /**
  111516. * String container all the define statements that should be set on the shader.
  111517. */
  111518. defines: string;
  111519. /**
  111520. * Callback that will be called when the shader is compiled.
  111521. */
  111522. onCompiled: Nullable<(effect: Effect) => void>;
  111523. /**
  111524. * Callback that will be called if an error occurs during shader compilation.
  111525. */
  111526. onError: Nullable<(effect: Effect, errors: string) => void>;
  111527. /**
  111528. * Callback that will be called when effect is bound.
  111529. */
  111530. onBind: Nullable<(effect: Effect) => void>;
  111531. /**
  111532. * Unique ID of the effect.
  111533. */
  111534. uniqueId: number;
  111535. /**
  111536. * Observable that will be called when the shader is compiled.
  111537. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111538. */
  111539. onCompileObservable: Observable<Effect>;
  111540. /**
  111541. * Observable that will be called if an error occurs during shader compilation.
  111542. */
  111543. onErrorObservable: Observable<Effect>;
  111544. /** @hidden */
  111545. _onBindObservable: Nullable<Observable<Effect>>;
  111546. /**
  111547. * @hidden
  111548. * Specifies if the effect was previously ready
  111549. */
  111550. _wasPreviouslyReady: boolean;
  111551. /**
  111552. * Observable that will be called when effect is bound.
  111553. */
  111554. get onBindObservable(): Observable<Effect>;
  111555. /** @hidden */
  111556. _bonesComputationForcedToCPU: boolean;
  111557. /** @hidden */
  111558. _multiTarget: boolean;
  111559. private static _uniqueIdSeed;
  111560. private _engine;
  111561. private _uniformBuffersNames;
  111562. private _uniformBuffersNamesList;
  111563. private _uniformsNames;
  111564. private _samplerList;
  111565. private _samplers;
  111566. private _isReady;
  111567. private _compilationError;
  111568. private _allFallbacksProcessed;
  111569. private _attributesNames;
  111570. private _attributes;
  111571. private _attributeLocationByName;
  111572. private _uniforms;
  111573. /**
  111574. * Key for the effect.
  111575. * @hidden
  111576. */
  111577. _key: string;
  111578. private _indexParameters;
  111579. private _fallbacks;
  111580. private _vertexSourceCode;
  111581. private _fragmentSourceCode;
  111582. private _vertexSourceCodeOverride;
  111583. private _fragmentSourceCodeOverride;
  111584. private _transformFeedbackVaryings;
  111585. /**
  111586. * Compiled shader to webGL program.
  111587. * @hidden
  111588. */
  111589. _pipelineContext: Nullable<IPipelineContext>;
  111590. private _valueCache;
  111591. private static _baseCache;
  111592. /**
  111593. * Instantiates an effect.
  111594. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111595. * @param baseName Name of the effect.
  111596. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111597. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111598. * @param samplers List of sampler variables that will be passed to the shader.
  111599. * @param engine Engine to be used to render the effect
  111600. * @param defines Define statements to be added to the shader.
  111601. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111602. * @param onCompiled Callback that will be called when the shader is compiled.
  111603. * @param onError Callback that will be called if an error occurs during shader compilation.
  111604. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111605. */
  111606. 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);
  111607. private _useFinalCode;
  111608. /**
  111609. * Unique key for this effect
  111610. */
  111611. get key(): string;
  111612. /**
  111613. * If the effect has been compiled and prepared.
  111614. * @returns if the effect is compiled and prepared.
  111615. */
  111616. isReady(): boolean;
  111617. private _isReadyInternal;
  111618. /**
  111619. * The engine the effect was initialized with.
  111620. * @returns the engine.
  111621. */
  111622. getEngine(): Engine;
  111623. /**
  111624. * The pipeline context for this effect
  111625. * @returns the associated pipeline context
  111626. */
  111627. getPipelineContext(): Nullable<IPipelineContext>;
  111628. /**
  111629. * The set of names of attribute variables for the shader.
  111630. * @returns An array of attribute names.
  111631. */
  111632. getAttributesNames(): string[];
  111633. /**
  111634. * Returns the attribute at the given index.
  111635. * @param index The index of the attribute.
  111636. * @returns The location of the attribute.
  111637. */
  111638. getAttributeLocation(index: number): number;
  111639. /**
  111640. * Returns the attribute based on the name of the variable.
  111641. * @param name of the attribute to look up.
  111642. * @returns the attribute location.
  111643. */
  111644. getAttributeLocationByName(name: string): number;
  111645. /**
  111646. * The number of attributes.
  111647. * @returns the numnber of attributes.
  111648. */
  111649. getAttributesCount(): number;
  111650. /**
  111651. * Gets the index of a uniform variable.
  111652. * @param uniformName of the uniform to look up.
  111653. * @returns the index.
  111654. */
  111655. getUniformIndex(uniformName: string): number;
  111656. /**
  111657. * Returns the attribute based on the name of the variable.
  111658. * @param uniformName of the uniform to look up.
  111659. * @returns the location of the uniform.
  111660. */
  111661. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111662. /**
  111663. * Returns an array of sampler variable names
  111664. * @returns The array of sampler variable names.
  111665. */
  111666. getSamplers(): string[];
  111667. /**
  111668. * Returns an array of uniform variable names
  111669. * @returns The array of uniform variable names.
  111670. */
  111671. getUniformNames(): string[];
  111672. /**
  111673. * Returns an array of uniform buffer variable names
  111674. * @returns The array of uniform buffer variable names.
  111675. */
  111676. getUniformBuffersNames(): string[];
  111677. /**
  111678. * Returns the index parameters used to create the effect
  111679. * @returns The index parameters object
  111680. */
  111681. getIndexParameters(): any;
  111682. /**
  111683. * The error from the last compilation.
  111684. * @returns the error string.
  111685. */
  111686. getCompilationError(): string;
  111687. /**
  111688. * Gets a boolean indicating that all fallbacks were used during compilation
  111689. * @returns true if all fallbacks were used
  111690. */
  111691. allFallbacksProcessed(): boolean;
  111692. /**
  111693. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111694. * @param func The callback to be used.
  111695. */
  111696. executeWhenCompiled(func: (effect: Effect) => void): void;
  111697. private _checkIsReady;
  111698. private _loadShader;
  111699. /**
  111700. * Gets the vertex shader source code of this effect
  111701. */
  111702. get vertexSourceCode(): string;
  111703. /**
  111704. * Gets the fragment shader source code of this effect
  111705. */
  111706. get fragmentSourceCode(): string;
  111707. /**
  111708. * Recompiles the webGL program
  111709. * @param vertexSourceCode The source code for the vertex shader.
  111710. * @param fragmentSourceCode The source code for the fragment shader.
  111711. * @param onCompiled Callback called when completed.
  111712. * @param onError Callback called on error.
  111713. * @hidden
  111714. */
  111715. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111716. /**
  111717. * Prepares the effect
  111718. * @hidden
  111719. */
  111720. _prepareEffect(): void;
  111721. private _getShaderCodeAndErrorLine;
  111722. private _processCompilationErrors;
  111723. /**
  111724. * Checks if the effect is supported. (Must be called after compilation)
  111725. */
  111726. get isSupported(): boolean;
  111727. /**
  111728. * Binds a texture to the engine to be used as output of the shader.
  111729. * @param channel Name of the output variable.
  111730. * @param texture Texture to bind.
  111731. * @hidden
  111732. */
  111733. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111734. /**
  111735. * Sets a texture on the engine to be used in the shader.
  111736. * @param channel Name of the sampler variable.
  111737. * @param texture Texture to set.
  111738. */
  111739. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111740. /**
  111741. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111742. * @param channel Name of the sampler variable.
  111743. * @param texture Texture to set.
  111744. */
  111745. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111746. /**
  111747. * Sets an array of textures on the engine to be used in the shader.
  111748. * @param channel Name of the variable.
  111749. * @param textures Textures to set.
  111750. */
  111751. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111752. /**
  111753. * 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)
  111754. * @param channel Name of the sampler variable.
  111755. * @param postProcess Post process to get the input texture from.
  111756. */
  111757. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111758. /**
  111759. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111760. * 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)
  111761. * @param channel Name of the sampler variable.
  111762. * @param postProcess Post process to get the output texture from.
  111763. */
  111764. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111765. /** @hidden */
  111766. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111767. /** @hidden */
  111768. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111769. /** @hidden */
  111770. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111771. /** @hidden */
  111772. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111773. /**
  111774. * Binds a buffer to a uniform.
  111775. * @param buffer Buffer to bind.
  111776. * @param name Name of the uniform variable to bind to.
  111777. */
  111778. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111779. /**
  111780. * Binds block to a uniform.
  111781. * @param blockName Name of the block to bind.
  111782. * @param index Index to bind.
  111783. */
  111784. bindUniformBlock(blockName: string, index: number): void;
  111785. /**
  111786. * Sets an interger value on a uniform variable.
  111787. * @param uniformName Name of the variable.
  111788. * @param value Value to be set.
  111789. * @returns this effect.
  111790. */
  111791. setInt(uniformName: string, value: number): Effect;
  111792. /**
  111793. * Sets an int array on a uniform variable.
  111794. * @param uniformName Name of the variable.
  111795. * @param array array to be set.
  111796. * @returns this effect.
  111797. */
  111798. setIntArray(uniformName: string, array: Int32Array): Effect;
  111799. /**
  111800. * 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)
  111801. * @param uniformName Name of the variable.
  111802. * @param array array to be set.
  111803. * @returns this effect.
  111804. */
  111805. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111806. /**
  111807. * 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)
  111808. * @param uniformName Name of the variable.
  111809. * @param array array to be set.
  111810. * @returns this effect.
  111811. */
  111812. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111813. /**
  111814. * 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)
  111815. * @param uniformName Name of the variable.
  111816. * @param array array to be set.
  111817. * @returns this effect.
  111818. */
  111819. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111820. /**
  111821. * Sets an float array on a uniform variable.
  111822. * @param uniformName Name of the variable.
  111823. * @param array array to be set.
  111824. * @returns this effect.
  111825. */
  111826. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111827. /**
  111828. * 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)
  111829. * @param uniformName Name of the variable.
  111830. * @param array array to be set.
  111831. * @returns this effect.
  111832. */
  111833. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111834. /**
  111835. * 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)
  111836. * @param uniformName Name of the variable.
  111837. * @param array array to be set.
  111838. * @returns this effect.
  111839. */
  111840. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111841. /**
  111842. * 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)
  111843. * @param uniformName Name of the variable.
  111844. * @param array array to be set.
  111845. * @returns this effect.
  111846. */
  111847. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111848. /**
  111849. * Sets an array on a uniform variable.
  111850. * @param uniformName Name of the variable.
  111851. * @param array array to be set.
  111852. * @returns this effect.
  111853. */
  111854. setArray(uniformName: string, array: number[]): Effect;
  111855. /**
  111856. * 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)
  111857. * @param uniformName Name of the variable.
  111858. * @param array array to be set.
  111859. * @returns this effect.
  111860. */
  111861. setArray2(uniformName: string, array: number[]): Effect;
  111862. /**
  111863. * 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)
  111864. * @param uniformName Name of the variable.
  111865. * @param array array to be set.
  111866. * @returns this effect.
  111867. */
  111868. setArray3(uniformName: string, array: number[]): Effect;
  111869. /**
  111870. * 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)
  111871. * @param uniformName Name of the variable.
  111872. * @param array array to be set.
  111873. * @returns this effect.
  111874. */
  111875. setArray4(uniformName: string, array: number[]): Effect;
  111876. /**
  111877. * Sets matrices on a uniform variable.
  111878. * @param uniformName Name of the variable.
  111879. * @param matrices matrices to be set.
  111880. * @returns this effect.
  111881. */
  111882. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111883. /**
  111884. * Sets matrix on a uniform variable.
  111885. * @param uniformName Name of the variable.
  111886. * @param matrix matrix to be set.
  111887. * @returns this effect.
  111888. */
  111889. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111890. /**
  111891. * 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)
  111892. * @param uniformName Name of the variable.
  111893. * @param matrix matrix to be set.
  111894. * @returns this effect.
  111895. */
  111896. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111897. /**
  111898. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111899. * @param uniformName Name of the variable.
  111900. * @param matrix matrix to be set.
  111901. * @returns this effect.
  111902. */
  111903. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111904. /**
  111905. * Sets a float on a uniform variable.
  111906. * @param uniformName Name of the variable.
  111907. * @param value value to be set.
  111908. * @returns this effect.
  111909. */
  111910. setFloat(uniformName: string, value: number): Effect;
  111911. /**
  111912. * Sets a boolean on a uniform variable.
  111913. * @param uniformName Name of the variable.
  111914. * @param bool value to be set.
  111915. * @returns this effect.
  111916. */
  111917. setBool(uniformName: string, bool: boolean): Effect;
  111918. /**
  111919. * Sets a Vector2 on a uniform variable.
  111920. * @param uniformName Name of the variable.
  111921. * @param vector2 vector2 to be set.
  111922. * @returns this effect.
  111923. */
  111924. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111925. /**
  111926. * Sets a float2 on a uniform variable.
  111927. * @param uniformName Name of the variable.
  111928. * @param x First float in float2.
  111929. * @param y Second float in float2.
  111930. * @returns this effect.
  111931. */
  111932. setFloat2(uniformName: string, x: number, y: number): Effect;
  111933. /**
  111934. * Sets a Vector3 on a uniform variable.
  111935. * @param uniformName Name of the variable.
  111936. * @param vector3 Value to be set.
  111937. * @returns this effect.
  111938. */
  111939. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111940. /**
  111941. * Sets a float3 on a uniform variable.
  111942. * @param uniformName Name of the variable.
  111943. * @param x First float in float3.
  111944. * @param y Second float in float3.
  111945. * @param z Third float in float3.
  111946. * @returns this effect.
  111947. */
  111948. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111949. /**
  111950. * Sets a Vector4 on a uniform variable.
  111951. * @param uniformName Name of the variable.
  111952. * @param vector4 Value to be set.
  111953. * @returns this effect.
  111954. */
  111955. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111956. /**
  111957. * Sets a float4 on a uniform variable.
  111958. * @param uniformName Name of the variable.
  111959. * @param x First float in float4.
  111960. * @param y Second float in float4.
  111961. * @param z Third float in float4.
  111962. * @param w Fourth float in float4.
  111963. * @returns this effect.
  111964. */
  111965. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111966. /**
  111967. * Sets a Color3 on a uniform variable.
  111968. * @param uniformName Name of the variable.
  111969. * @param color3 Value to be set.
  111970. * @returns this effect.
  111971. */
  111972. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111973. /**
  111974. * Sets a Color4 on a uniform variable.
  111975. * @param uniformName Name of the variable.
  111976. * @param color3 Value to be set.
  111977. * @param alpha Alpha value to be set.
  111978. * @returns this effect.
  111979. */
  111980. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111981. /**
  111982. * Sets a Color4 on a uniform variable
  111983. * @param uniformName defines the name of the variable
  111984. * @param color4 defines the value to be set
  111985. * @returns this effect.
  111986. */
  111987. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111988. /** Release all associated resources */
  111989. dispose(): void;
  111990. /**
  111991. * This function will add a new shader to the shader store
  111992. * @param name the name of the shader
  111993. * @param pixelShader optional pixel shader content
  111994. * @param vertexShader optional vertex shader content
  111995. */
  111996. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111997. /**
  111998. * Store of each shader (The can be looked up using effect.key)
  111999. */
  112000. static ShadersStore: {
  112001. [key: string]: string;
  112002. };
  112003. /**
  112004. * Store of each included file for a shader (The can be looked up using effect.key)
  112005. */
  112006. static IncludesShadersStore: {
  112007. [key: string]: string;
  112008. };
  112009. /**
  112010. * Resets the cache of effects.
  112011. */
  112012. static ResetCache(): void;
  112013. }
  112014. }
  112015. declare module BABYLON {
  112016. /**
  112017. * Interface used to describe the capabilities of the engine relatively to the current browser
  112018. */
  112019. export interface EngineCapabilities {
  112020. /** Maximum textures units per fragment shader */
  112021. maxTexturesImageUnits: number;
  112022. /** Maximum texture units per vertex shader */
  112023. maxVertexTextureImageUnits: number;
  112024. /** Maximum textures units in the entire pipeline */
  112025. maxCombinedTexturesImageUnits: number;
  112026. /** Maximum texture size */
  112027. maxTextureSize: number;
  112028. /** Maximum texture samples */
  112029. maxSamples?: number;
  112030. /** Maximum cube texture size */
  112031. maxCubemapTextureSize: number;
  112032. /** Maximum render texture size */
  112033. maxRenderTextureSize: number;
  112034. /** Maximum number of vertex attributes */
  112035. maxVertexAttribs: number;
  112036. /** Maximum number of varyings */
  112037. maxVaryingVectors: number;
  112038. /** Maximum number of uniforms per vertex shader */
  112039. maxVertexUniformVectors: number;
  112040. /** Maximum number of uniforms per fragment shader */
  112041. maxFragmentUniformVectors: number;
  112042. /** Defines if standard derivates (dx/dy) are supported */
  112043. standardDerivatives: boolean;
  112044. /** Defines if s3tc texture compression is supported */
  112045. s3tc?: WEBGL_compressed_texture_s3tc;
  112046. /** Defines if pvrtc texture compression is supported */
  112047. pvrtc: any;
  112048. /** Defines if etc1 texture compression is supported */
  112049. etc1: any;
  112050. /** Defines if etc2 texture compression is supported */
  112051. etc2: any;
  112052. /** Defines if astc texture compression is supported */
  112053. astc: any;
  112054. /** Defines if float textures are supported */
  112055. textureFloat: boolean;
  112056. /** Defines if vertex array objects are supported */
  112057. vertexArrayObject: boolean;
  112058. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112059. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112060. /** Gets the maximum level of anisotropy supported */
  112061. maxAnisotropy: number;
  112062. /** Defines if instancing is supported */
  112063. instancedArrays: boolean;
  112064. /** Defines if 32 bits indices are supported */
  112065. uintIndices: boolean;
  112066. /** Defines if high precision shaders are supported */
  112067. highPrecisionShaderSupported: boolean;
  112068. /** Defines if depth reading in the fragment shader is supported */
  112069. fragmentDepthSupported: boolean;
  112070. /** Defines if float texture linear filtering is supported*/
  112071. textureFloatLinearFiltering: boolean;
  112072. /** Defines if rendering to float textures is supported */
  112073. textureFloatRender: boolean;
  112074. /** Defines if half float textures are supported*/
  112075. textureHalfFloat: boolean;
  112076. /** Defines if half float texture linear filtering is supported*/
  112077. textureHalfFloatLinearFiltering: boolean;
  112078. /** Defines if rendering to half float textures is supported */
  112079. textureHalfFloatRender: boolean;
  112080. /** Defines if textureLOD shader command is supported */
  112081. textureLOD: boolean;
  112082. /** Defines if draw buffers extension is supported */
  112083. drawBuffersExtension: boolean;
  112084. /** Defines if depth textures are supported */
  112085. depthTextureExtension: boolean;
  112086. /** Defines if float color buffer are supported */
  112087. colorBufferFloat: boolean;
  112088. /** Gets disjoint timer query extension (null if not supported) */
  112089. timerQuery?: EXT_disjoint_timer_query;
  112090. /** Defines if timestamp can be used with timer query */
  112091. canUseTimestampForTimerQuery: boolean;
  112092. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112093. multiview?: any;
  112094. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112095. oculusMultiview?: any;
  112096. /** Function used to let the system compiles shaders in background */
  112097. parallelShaderCompile?: {
  112098. COMPLETION_STATUS_KHR: number;
  112099. };
  112100. /** Max number of texture samples for MSAA */
  112101. maxMSAASamples: number;
  112102. /** Defines if the blend min max extension is supported */
  112103. blendMinMax: boolean;
  112104. }
  112105. }
  112106. declare module BABYLON {
  112107. /**
  112108. * @hidden
  112109. **/
  112110. export class DepthCullingState {
  112111. private _isDepthTestDirty;
  112112. private _isDepthMaskDirty;
  112113. private _isDepthFuncDirty;
  112114. private _isCullFaceDirty;
  112115. private _isCullDirty;
  112116. private _isZOffsetDirty;
  112117. private _isFrontFaceDirty;
  112118. private _depthTest;
  112119. private _depthMask;
  112120. private _depthFunc;
  112121. private _cull;
  112122. private _cullFace;
  112123. private _zOffset;
  112124. private _frontFace;
  112125. /**
  112126. * Initializes the state.
  112127. */
  112128. constructor();
  112129. get isDirty(): boolean;
  112130. get zOffset(): number;
  112131. set zOffset(value: number);
  112132. get cullFace(): Nullable<number>;
  112133. set cullFace(value: Nullable<number>);
  112134. get cull(): Nullable<boolean>;
  112135. set cull(value: Nullable<boolean>);
  112136. get depthFunc(): Nullable<number>;
  112137. set depthFunc(value: Nullable<number>);
  112138. get depthMask(): boolean;
  112139. set depthMask(value: boolean);
  112140. get depthTest(): boolean;
  112141. set depthTest(value: boolean);
  112142. get frontFace(): Nullable<number>;
  112143. set frontFace(value: Nullable<number>);
  112144. reset(): void;
  112145. apply(gl: WebGLRenderingContext): void;
  112146. }
  112147. }
  112148. declare module BABYLON {
  112149. /**
  112150. * @hidden
  112151. **/
  112152. export class StencilState {
  112153. /** 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 */
  112154. static readonly ALWAYS: number;
  112155. /** Passed to stencilOperation to specify that stencil value must be kept */
  112156. static readonly KEEP: number;
  112157. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112158. static readonly REPLACE: number;
  112159. private _isStencilTestDirty;
  112160. private _isStencilMaskDirty;
  112161. private _isStencilFuncDirty;
  112162. private _isStencilOpDirty;
  112163. private _stencilTest;
  112164. private _stencilMask;
  112165. private _stencilFunc;
  112166. private _stencilFuncRef;
  112167. private _stencilFuncMask;
  112168. private _stencilOpStencilFail;
  112169. private _stencilOpDepthFail;
  112170. private _stencilOpStencilDepthPass;
  112171. get isDirty(): boolean;
  112172. get stencilFunc(): number;
  112173. set stencilFunc(value: number);
  112174. get stencilFuncRef(): number;
  112175. set stencilFuncRef(value: number);
  112176. get stencilFuncMask(): number;
  112177. set stencilFuncMask(value: number);
  112178. get stencilOpStencilFail(): number;
  112179. set stencilOpStencilFail(value: number);
  112180. get stencilOpDepthFail(): number;
  112181. set stencilOpDepthFail(value: number);
  112182. get stencilOpStencilDepthPass(): number;
  112183. set stencilOpStencilDepthPass(value: number);
  112184. get stencilMask(): number;
  112185. set stencilMask(value: number);
  112186. get stencilTest(): boolean;
  112187. set stencilTest(value: boolean);
  112188. constructor();
  112189. reset(): void;
  112190. apply(gl: WebGLRenderingContext): void;
  112191. }
  112192. }
  112193. declare module BABYLON {
  112194. /**
  112195. * @hidden
  112196. **/
  112197. export class AlphaState {
  112198. private _isAlphaBlendDirty;
  112199. private _isBlendFunctionParametersDirty;
  112200. private _isBlendEquationParametersDirty;
  112201. private _isBlendConstantsDirty;
  112202. private _alphaBlend;
  112203. private _blendFunctionParameters;
  112204. private _blendEquationParameters;
  112205. private _blendConstants;
  112206. /**
  112207. * Initializes the state.
  112208. */
  112209. constructor();
  112210. get isDirty(): boolean;
  112211. get alphaBlend(): boolean;
  112212. set alphaBlend(value: boolean);
  112213. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112214. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112215. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112216. reset(): void;
  112217. apply(gl: WebGLRenderingContext): void;
  112218. }
  112219. }
  112220. declare module BABYLON {
  112221. /** @hidden */
  112222. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112223. attributeProcessor(attribute: string): string;
  112224. varyingProcessor(varying: string, isFragment: boolean): string;
  112225. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112226. }
  112227. }
  112228. declare module BABYLON {
  112229. /**
  112230. * Interface for attribute information associated with buffer instanciation
  112231. */
  112232. export interface InstancingAttributeInfo {
  112233. /**
  112234. * Name of the GLSL attribute
  112235. * if attribute index is not specified, this is used to retrieve the index from the effect
  112236. */
  112237. attributeName: string;
  112238. /**
  112239. * Index/offset of the attribute in the vertex shader
  112240. * if not specified, this will be computes from the name.
  112241. */
  112242. index?: number;
  112243. /**
  112244. * size of the attribute, 1, 2, 3 or 4
  112245. */
  112246. attributeSize: number;
  112247. /**
  112248. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112249. */
  112250. offset: number;
  112251. /**
  112252. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112253. * default to 1
  112254. */
  112255. divisor?: number;
  112256. /**
  112257. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112258. * default is FLOAT
  112259. */
  112260. attributeType?: number;
  112261. /**
  112262. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112263. */
  112264. normalized?: boolean;
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. interface ThinEngine {
  112269. /**
  112270. * Update a video texture
  112271. * @param texture defines the texture to update
  112272. * @param video defines the video element to use
  112273. * @param invertY defines if data must be stored with Y axis inverted
  112274. */
  112275. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112276. }
  112277. }
  112278. declare module BABYLON {
  112279. interface ThinEngine {
  112280. /**
  112281. * Creates a dynamic texture
  112282. * @param width defines the width of the texture
  112283. * @param height defines the height of the texture
  112284. * @param generateMipMaps defines if the engine should generate the mip levels
  112285. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112286. * @returns the dynamic texture inside an InternalTexture
  112287. */
  112288. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112289. /**
  112290. * Update the content of a dynamic texture
  112291. * @param texture defines the texture to update
  112292. * @param canvas defines the canvas containing the source
  112293. * @param invertY defines if data must be stored with Y axis inverted
  112294. * @param premulAlpha defines if alpha is stored as premultiplied
  112295. * @param format defines the format of the data
  112296. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112297. */
  112298. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112299. }
  112300. }
  112301. declare module BABYLON {
  112302. /**
  112303. * Settings for finer control over video usage
  112304. */
  112305. export interface VideoTextureSettings {
  112306. /**
  112307. * Applies `autoplay` to video, if specified
  112308. */
  112309. autoPlay?: boolean;
  112310. /**
  112311. * Applies `loop` to video, if specified
  112312. */
  112313. loop?: boolean;
  112314. /**
  112315. * Automatically updates internal texture from video at every frame in the render loop
  112316. */
  112317. autoUpdateTexture: boolean;
  112318. /**
  112319. * Image src displayed during the video loading or until the user interacts with the video.
  112320. */
  112321. poster?: string;
  112322. }
  112323. /**
  112324. * If you want to display a video in your scene, this is the special texture for that.
  112325. * This special texture works similar to other textures, with the exception of a few parameters.
  112326. * @see https://doc.babylonjs.com/how_to/video_texture
  112327. */
  112328. export class VideoTexture extends Texture {
  112329. /**
  112330. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112331. */
  112332. readonly autoUpdateTexture: boolean;
  112333. /**
  112334. * The video instance used by the texture internally
  112335. */
  112336. readonly video: HTMLVideoElement;
  112337. private _onUserActionRequestedObservable;
  112338. /**
  112339. * Event triggerd when a dom action is required by the user to play the video.
  112340. * This happens due to recent changes in browser policies preventing video to auto start.
  112341. */
  112342. get onUserActionRequestedObservable(): Observable<Texture>;
  112343. private _generateMipMaps;
  112344. private _stillImageCaptured;
  112345. private _displayingPosterTexture;
  112346. private _settings;
  112347. private _createInternalTextureOnEvent;
  112348. private _frameId;
  112349. private _currentSrc;
  112350. /**
  112351. * Creates a video texture.
  112352. * If you want to display a video in your scene, this is the special texture for that.
  112353. * This special texture works similar to other textures, with the exception of a few parameters.
  112354. * @see https://doc.babylonjs.com/how_to/video_texture
  112355. * @param name optional name, will detect from video source, if not defined
  112356. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112357. * @param scene is obviously the current scene.
  112358. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112359. * @param invertY is false by default but can be used to invert video on Y axis
  112360. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112361. * @param settings allows finer control over video usage
  112362. */
  112363. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112364. private _getName;
  112365. private _getVideo;
  112366. private _createInternalTexture;
  112367. private reset;
  112368. /**
  112369. * @hidden Internal method to initiate `update`.
  112370. */
  112371. _rebuild(): void;
  112372. /**
  112373. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112374. */
  112375. update(): void;
  112376. /**
  112377. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112378. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112379. */
  112380. updateTexture(isVisible: boolean): void;
  112381. protected _updateInternalTexture: () => void;
  112382. /**
  112383. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112384. * @param url New url.
  112385. */
  112386. updateURL(url: string): void;
  112387. /**
  112388. * Clones the texture.
  112389. * @returns the cloned texture
  112390. */
  112391. clone(): VideoTexture;
  112392. /**
  112393. * Dispose the texture and release its associated resources.
  112394. */
  112395. dispose(): void;
  112396. /**
  112397. * Creates a video texture straight from a stream.
  112398. * @param scene Define the scene the texture should be created in
  112399. * @param stream Define the stream the texture should be created from
  112400. * @returns The created video texture as a promise
  112401. */
  112402. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112403. /**
  112404. * Creates a video texture straight from your WebCam video feed.
  112405. * @param scene Define the scene the texture should be created in
  112406. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112407. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112408. * @returns The created video texture as a promise
  112409. */
  112410. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112411. minWidth: number;
  112412. maxWidth: number;
  112413. minHeight: number;
  112414. maxHeight: number;
  112415. deviceId: string;
  112416. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112417. /**
  112418. * Creates a video texture straight from your WebCam video feed.
  112419. * @param scene Define the scene the texture should be created in
  112420. * @param onReady Define a callback to triggered once the texture will be ready
  112421. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112422. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112423. */
  112424. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112425. minWidth: number;
  112426. maxWidth: number;
  112427. minHeight: number;
  112428. maxHeight: number;
  112429. deviceId: string;
  112430. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112431. }
  112432. }
  112433. declare module BABYLON {
  112434. /**
  112435. * Defines the interface used by objects working like Scene
  112436. * @hidden
  112437. */
  112438. export interface ISceneLike {
  112439. _addPendingData(data: any): void;
  112440. _removePendingData(data: any): void;
  112441. offlineProvider: IOfflineProvider;
  112442. }
  112443. /** Interface defining initialization parameters for Engine class */
  112444. export interface EngineOptions extends WebGLContextAttributes {
  112445. /**
  112446. * Defines if the engine should no exceed a specified device ratio
  112447. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112448. */
  112449. limitDeviceRatio?: number;
  112450. /**
  112451. * Defines if webvr should be enabled automatically
  112452. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112453. */
  112454. autoEnableWebVR?: boolean;
  112455. /**
  112456. * Defines if webgl2 should be turned off even if supported
  112457. * @see https://doc.babylonjs.com/features/webgl2
  112458. */
  112459. disableWebGL2Support?: boolean;
  112460. /**
  112461. * Defines if webaudio should be initialized as well
  112462. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112463. */
  112464. audioEngine?: boolean;
  112465. /**
  112466. * Defines if animations should run using a deterministic lock step
  112467. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112468. */
  112469. deterministicLockstep?: boolean;
  112470. /** Defines the maximum steps to use with deterministic lock step mode */
  112471. lockstepMaxSteps?: number;
  112472. /** Defines the seconds between each deterministic lock step */
  112473. timeStep?: number;
  112474. /**
  112475. * Defines that engine should ignore context lost events
  112476. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112477. */
  112478. doNotHandleContextLost?: boolean;
  112479. /**
  112480. * Defines that engine should ignore modifying touch action attribute and style
  112481. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112482. */
  112483. doNotHandleTouchAction?: boolean;
  112484. /**
  112485. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112486. */
  112487. useHighPrecisionFloats?: boolean;
  112488. /**
  112489. * Make the canvas XR Compatible for XR sessions
  112490. */
  112491. xrCompatible?: boolean;
  112492. }
  112493. /**
  112494. * The base engine class (root of all engines)
  112495. */
  112496. export class ThinEngine {
  112497. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112498. static ExceptionList: ({
  112499. key: string;
  112500. capture: string;
  112501. captureConstraint: number;
  112502. targets: string[];
  112503. } | {
  112504. key: string;
  112505. capture: null;
  112506. captureConstraint: null;
  112507. targets: string[];
  112508. })[];
  112509. /** @hidden */
  112510. static _TextureLoaders: IInternalTextureLoader[];
  112511. /**
  112512. * Returns the current npm package of the sdk
  112513. */
  112514. static get NpmPackage(): string;
  112515. /**
  112516. * Returns the current version of the framework
  112517. */
  112518. static get Version(): string;
  112519. /**
  112520. * Returns a string describing the current engine
  112521. */
  112522. get description(): string;
  112523. /**
  112524. * Gets or sets the epsilon value used by collision engine
  112525. */
  112526. static CollisionsEpsilon: number;
  112527. /**
  112528. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112529. */
  112530. static get ShadersRepository(): string;
  112531. static set ShadersRepository(value: string);
  112532. /** @hidden */
  112533. _shaderProcessor: IShaderProcessor;
  112534. /**
  112535. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112536. */
  112537. forcePOTTextures: boolean;
  112538. /**
  112539. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112540. */
  112541. isFullscreen: boolean;
  112542. /**
  112543. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112544. */
  112545. cullBackFaces: boolean;
  112546. /**
  112547. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112548. */
  112549. renderEvenInBackground: boolean;
  112550. /**
  112551. * Gets or sets a boolean indicating that cache can be kept between frames
  112552. */
  112553. preventCacheWipeBetweenFrames: boolean;
  112554. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112555. validateShaderPrograms: boolean;
  112556. /**
  112557. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112558. * This can provide greater z depth for distant objects.
  112559. */
  112560. useReverseDepthBuffer: boolean;
  112561. /**
  112562. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112563. */
  112564. disableUniformBuffers: boolean;
  112565. /** @hidden */
  112566. _uniformBuffers: UniformBuffer[];
  112567. /**
  112568. * Gets a boolean indicating that the engine supports uniform buffers
  112569. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112570. */
  112571. get supportsUniformBuffers(): boolean;
  112572. /** @hidden */
  112573. _gl: WebGLRenderingContext;
  112574. /** @hidden */
  112575. _webGLVersion: number;
  112576. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112577. protected _windowIsBackground: boolean;
  112578. protected _creationOptions: EngineOptions;
  112579. protected _highPrecisionShadersAllowed: boolean;
  112580. /** @hidden */
  112581. get _shouldUseHighPrecisionShader(): boolean;
  112582. /**
  112583. * Gets a boolean indicating that only power of 2 textures are supported
  112584. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112585. */
  112586. get needPOTTextures(): boolean;
  112587. /** @hidden */
  112588. _badOS: boolean;
  112589. /** @hidden */
  112590. _badDesktopOS: boolean;
  112591. private _hardwareScalingLevel;
  112592. /** @hidden */
  112593. _caps: EngineCapabilities;
  112594. private _isStencilEnable;
  112595. private _glVersion;
  112596. private _glRenderer;
  112597. private _glVendor;
  112598. /** @hidden */
  112599. _videoTextureSupported: boolean;
  112600. protected _renderingQueueLaunched: boolean;
  112601. protected _activeRenderLoops: (() => void)[];
  112602. /**
  112603. * Observable signaled when a context lost event is raised
  112604. */
  112605. onContextLostObservable: Observable<ThinEngine>;
  112606. /**
  112607. * Observable signaled when a context restored event is raised
  112608. */
  112609. onContextRestoredObservable: Observable<ThinEngine>;
  112610. private _onContextLost;
  112611. private _onContextRestored;
  112612. protected _contextWasLost: boolean;
  112613. /** @hidden */
  112614. _doNotHandleContextLost: boolean;
  112615. /**
  112616. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112617. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112618. */
  112619. get doNotHandleContextLost(): boolean;
  112620. set doNotHandleContextLost(value: boolean);
  112621. /**
  112622. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112623. */
  112624. disableVertexArrayObjects: boolean;
  112625. /** @hidden */
  112626. protected _colorWrite: boolean;
  112627. /** @hidden */
  112628. protected _colorWriteChanged: boolean;
  112629. /** @hidden */
  112630. protected _depthCullingState: DepthCullingState;
  112631. /** @hidden */
  112632. protected _stencilState: StencilState;
  112633. /** @hidden */
  112634. _alphaState: AlphaState;
  112635. /** @hidden */
  112636. _alphaMode: number;
  112637. /** @hidden */
  112638. _alphaEquation: number;
  112639. /** @hidden */
  112640. _internalTexturesCache: InternalTexture[];
  112641. /** @hidden */
  112642. protected _activeChannel: number;
  112643. private _currentTextureChannel;
  112644. /** @hidden */
  112645. protected _boundTexturesCache: {
  112646. [key: string]: Nullable<InternalTexture>;
  112647. };
  112648. /** @hidden */
  112649. protected _currentEffect: Nullable<Effect>;
  112650. /** @hidden */
  112651. protected _currentProgram: Nullable<WebGLProgram>;
  112652. private _compiledEffects;
  112653. private _vertexAttribArraysEnabled;
  112654. /** @hidden */
  112655. protected _cachedViewport: Nullable<IViewportLike>;
  112656. private _cachedVertexArrayObject;
  112657. /** @hidden */
  112658. protected _cachedVertexBuffers: any;
  112659. /** @hidden */
  112660. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112661. /** @hidden */
  112662. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112663. /** @hidden */
  112664. _currentRenderTarget: Nullable<InternalTexture>;
  112665. private _uintIndicesCurrentlySet;
  112666. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112667. /** @hidden */
  112668. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112669. /** @hidden */
  112670. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112671. private _currentBufferPointers;
  112672. private _currentInstanceLocations;
  112673. private _currentInstanceBuffers;
  112674. private _textureUnits;
  112675. /** @hidden */
  112676. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112677. /** @hidden */
  112678. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112679. /** @hidden */
  112680. _boundRenderFunction: any;
  112681. private _vaoRecordInProgress;
  112682. private _mustWipeVertexAttributes;
  112683. private _emptyTexture;
  112684. private _emptyCubeTexture;
  112685. private _emptyTexture3D;
  112686. private _emptyTexture2DArray;
  112687. /** @hidden */
  112688. _frameHandler: number;
  112689. private _nextFreeTextureSlots;
  112690. private _maxSimultaneousTextures;
  112691. private _activeRequests;
  112692. /** @hidden */
  112693. _transformTextureUrl: Nullable<(url: string) => string>;
  112694. protected get _supportsHardwareTextureRescaling(): boolean;
  112695. private _framebufferDimensionsObject;
  112696. /**
  112697. * sets the object from which width and height will be taken from when getting render width and height
  112698. * Will fallback to the gl object
  112699. * @param dimensions the framebuffer width and height that will be used.
  112700. */
  112701. set framebufferDimensionsObject(dimensions: Nullable<{
  112702. framebufferWidth: number;
  112703. framebufferHeight: number;
  112704. }>);
  112705. /**
  112706. * Gets the current viewport
  112707. */
  112708. get currentViewport(): Nullable<IViewportLike>;
  112709. /**
  112710. * Gets the default empty texture
  112711. */
  112712. get emptyTexture(): InternalTexture;
  112713. /**
  112714. * Gets the default empty 3D texture
  112715. */
  112716. get emptyTexture3D(): InternalTexture;
  112717. /**
  112718. * Gets the default empty 2D array texture
  112719. */
  112720. get emptyTexture2DArray(): InternalTexture;
  112721. /**
  112722. * Gets the default empty cube texture
  112723. */
  112724. get emptyCubeTexture(): InternalTexture;
  112725. /**
  112726. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112727. */
  112728. readonly premultipliedAlpha: boolean;
  112729. /**
  112730. * Observable event triggered before each texture is initialized
  112731. */
  112732. onBeforeTextureInitObservable: Observable<Texture>;
  112733. /**
  112734. * Creates a new engine
  112735. * @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
  112736. * @param antialias defines enable antialiasing (default: false)
  112737. * @param options defines further options to be sent to the getContext() function
  112738. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112739. */
  112740. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112741. private _rebuildInternalTextures;
  112742. private _rebuildEffects;
  112743. /**
  112744. * Gets a boolean indicating if all created effects are ready
  112745. * @returns true if all effects are ready
  112746. */
  112747. areAllEffectsReady(): boolean;
  112748. protected _rebuildBuffers(): void;
  112749. protected _initGLContext(): void;
  112750. /**
  112751. * Gets version of the current webGL context
  112752. */
  112753. get webGLVersion(): number;
  112754. /**
  112755. * Gets a string idenfifying the name of the class
  112756. * @returns "Engine" string
  112757. */
  112758. getClassName(): string;
  112759. /**
  112760. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112761. */
  112762. get isStencilEnable(): boolean;
  112763. /** @hidden */
  112764. _prepareWorkingCanvas(): void;
  112765. /**
  112766. * Reset the texture cache to empty state
  112767. */
  112768. resetTextureCache(): void;
  112769. /**
  112770. * Gets an object containing information about the current webGL context
  112771. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112772. */
  112773. getGlInfo(): {
  112774. vendor: string;
  112775. renderer: string;
  112776. version: string;
  112777. };
  112778. /**
  112779. * Defines the hardware scaling level.
  112780. * By default the hardware scaling level is computed from the window device ratio.
  112781. * 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.
  112782. * @param level defines the level to use
  112783. */
  112784. setHardwareScalingLevel(level: number): void;
  112785. /**
  112786. * Gets the current hardware scaling level.
  112787. * By default the hardware scaling level is computed from the window device ratio.
  112788. * 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.
  112789. * @returns a number indicating the current hardware scaling level
  112790. */
  112791. getHardwareScalingLevel(): number;
  112792. /**
  112793. * Gets the list of loaded textures
  112794. * @returns an array containing all loaded textures
  112795. */
  112796. getLoadedTexturesCache(): InternalTexture[];
  112797. /**
  112798. * Gets the object containing all engine capabilities
  112799. * @returns the EngineCapabilities object
  112800. */
  112801. getCaps(): EngineCapabilities;
  112802. /**
  112803. * stop executing a render loop function and remove it from the execution array
  112804. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112805. */
  112806. stopRenderLoop(renderFunction?: () => void): void;
  112807. /** @hidden */
  112808. _renderLoop(): void;
  112809. /**
  112810. * Gets the HTML canvas attached with the current webGL context
  112811. * @returns a HTML canvas
  112812. */
  112813. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112814. /**
  112815. * Gets host window
  112816. * @returns the host window object
  112817. */
  112818. getHostWindow(): Nullable<Window>;
  112819. /**
  112820. * Gets the current render width
  112821. * @param useScreen defines if screen size must be used (or the current render target if any)
  112822. * @returns a number defining the current render width
  112823. */
  112824. getRenderWidth(useScreen?: boolean): number;
  112825. /**
  112826. * Gets the current render height
  112827. * @param useScreen defines if screen size must be used (or the current render target if any)
  112828. * @returns a number defining the current render height
  112829. */
  112830. getRenderHeight(useScreen?: boolean): number;
  112831. /**
  112832. * Can be used to override the current requestAnimationFrame requester.
  112833. * @hidden
  112834. */
  112835. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112836. /**
  112837. * Register and execute a render loop. The engine can have more than one render function
  112838. * @param renderFunction defines the function to continuously execute
  112839. */
  112840. runRenderLoop(renderFunction: () => void): void;
  112841. /**
  112842. * Clear the current render buffer or the current render target (if any is set up)
  112843. * @param color defines the color to use
  112844. * @param backBuffer defines if the back buffer must be cleared
  112845. * @param depth defines if the depth buffer must be cleared
  112846. * @param stencil defines if the stencil buffer must be cleared
  112847. */
  112848. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112849. private _viewportCached;
  112850. /** @hidden */
  112851. _viewport(x: number, y: number, width: number, height: number): void;
  112852. /**
  112853. * Set the WebGL's viewport
  112854. * @param viewport defines the viewport element to be used
  112855. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112856. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112857. */
  112858. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112859. /**
  112860. * Begin a new frame
  112861. */
  112862. beginFrame(): void;
  112863. /**
  112864. * Enf the current frame
  112865. */
  112866. endFrame(): void;
  112867. /**
  112868. * Resize the view according to the canvas' size
  112869. */
  112870. resize(): void;
  112871. /**
  112872. * Force a specific size of the canvas
  112873. * @param width defines the new canvas' width
  112874. * @param height defines the new canvas' height
  112875. * @returns true if the size was changed
  112876. */
  112877. setSize(width: number, height: number): boolean;
  112878. /**
  112879. * Binds the frame buffer to the specified texture.
  112880. * @param texture The texture to render to or null for the default canvas
  112881. * @param faceIndex The face of the texture to render to in case of cube texture
  112882. * @param requiredWidth The width of the target to render to
  112883. * @param requiredHeight The height of the target to render to
  112884. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112885. * @param lodLevel defines the lod level to bind to the frame buffer
  112886. * @param layer defines the 2d array index to bind to frame buffer to
  112887. */
  112888. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112889. /** @hidden */
  112890. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112891. /**
  112892. * Unbind the current render target texture from the webGL context
  112893. * @param texture defines the render target texture to unbind
  112894. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112895. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112896. */
  112897. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112898. /**
  112899. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112900. */
  112901. flushFramebuffer(): void;
  112902. /**
  112903. * Unbind the current render target and bind the default framebuffer
  112904. */
  112905. restoreDefaultFramebuffer(): void;
  112906. /** @hidden */
  112907. protected _resetVertexBufferBinding(): void;
  112908. /**
  112909. * Creates a vertex buffer
  112910. * @param data the data for the vertex buffer
  112911. * @returns the new WebGL static buffer
  112912. */
  112913. createVertexBuffer(data: DataArray): DataBuffer;
  112914. private _createVertexBuffer;
  112915. /**
  112916. * Creates a dynamic vertex buffer
  112917. * @param data the data for the dynamic vertex buffer
  112918. * @returns the new WebGL dynamic buffer
  112919. */
  112920. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112921. protected _resetIndexBufferBinding(): void;
  112922. /**
  112923. * Creates a new index buffer
  112924. * @param indices defines the content of the index buffer
  112925. * @param updatable defines if the index buffer must be updatable
  112926. * @returns a new webGL buffer
  112927. */
  112928. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112929. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112930. /**
  112931. * Bind a webGL buffer to the webGL context
  112932. * @param buffer defines the buffer to bind
  112933. */
  112934. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112935. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112936. private bindBuffer;
  112937. /**
  112938. * update the bound buffer with the given data
  112939. * @param data defines the data to update
  112940. */
  112941. updateArrayBuffer(data: Float32Array): void;
  112942. private _vertexAttribPointer;
  112943. /** @hidden */
  112944. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112945. private _bindVertexBuffersAttributes;
  112946. /**
  112947. * Records a vertex array object
  112948. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112949. * @param vertexBuffers defines the list of vertex buffers to store
  112950. * @param indexBuffer defines the index buffer to store
  112951. * @param effect defines the effect to store
  112952. * @returns the new vertex array object
  112953. */
  112954. recordVertexArrayObject(vertexBuffers: {
  112955. [key: string]: VertexBuffer;
  112956. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112957. /**
  112958. * Bind a specific vertex array object
  112959. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112960. * @param vertexArrayObject defines the vertex array object to bind
  112961. * @param indexBuffer defines the index buffer to bind
  112962. */
  112963. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112964. /**
  112965. * Bind webGl buffers directly to the webGL context
  112966. * @param vertexBuffer defines the vertex buffer to bind
  112967. * @param indexBuffer defines the index buffer to bind
  112968. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112969. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112970. * @param effect defines the effect associated with the vertex buffer
  112971. */
  112972. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112973. private _unbindVertexArrayObject;
  112974. /**
  112975. * Bind a list of vertex buffers to the webGL context
  112976. * @param vertexBuffers defines the list of vertex buffers to bind
  112977. * @param indexBuffer defines the index buffer to bind
  112978. * @param effect defines the effect associated with the vertex buffers
  112979. */
  112980. bindBuffers(vertexBuffers: {
  112981. [key: string]: Nullable<VertexBuffer>;
  112982. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112983. /**
  112984. * Unbind all instance attributes
  112985. */
  112986. unbindInstanceAttributes(): void;
  112987. /**
  112988. * Release and free the memory of a vertex array object
  112989. * @param vao defines the vertex array object to delete
  112990. */
  112991. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112992. /** @hidden */
  112993. _releaseBuffer(buffer: DataBuffer): boolean;
  112994. protected _deleteBuffer(buffer: DataBuffer): void;
  112995. /**
  112996. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112997. * @param instancesBuffer defines the webGL buffer to update and bind
  112998. * @param data defines the data to store in the buffer
  112999. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  113000. */
  113001. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113002. /**
  113003. * Bind the content of a webGL buffer used with instantiation
  113004. * @param instancesBuffer defines the webGL buffer to bind
  113005. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113006. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113007. */
  113008. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113009. /**
  113010. * Disable the instance attribute corresponding to the name in parameter
  113011. * @param name defines the name of the attribute to disable
  113012. */
  113013. disableInstanceAttributeByName(name: string): void;
  113014. /**
  113015. * Disable the instance attribute corresponding to the location in parameter
  113016. * @param attributeLocation defines the attribute location of the attribute to disable
  113017. */
  113018. disableInstanceAttribute(attributeLocation: number): void;
  113019. /**
  113020. * Disable the attribute corresponding to the location in parameter
  113021. * @param attributeLocation defines the attribute location of the attribute to disable
  113022. */
  113023. disableAttributeByIndex(attributeLocation: number): void;
  113024. /**
  113025. * Send a draw order
  113026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113027. * @param indexStart defines the starting index
  113028. * @param indexCount defines the number of index to draw
  113029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113030. */
  113031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113032. /**
  113033. * Draw a list of points
  113034. * @param verticesStart defines the index of first vertex to draw
  113035. * @param verticesCount defines the count of vertices to draw
  113036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113037. */
  113038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113039. /**
  113040. * Draw a list of unindexed primitives
  113041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113042. * @param verticesStart defines the index of first vertex to draw
  113043. * @param verticesCount defines the count of vertices to draw
  113044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113045. */
  113046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113047. /**
  113048. * Draw a list of indexed primitives
  113049. * @param fillMode defines the primitive to use
  113050. * @param indexStart defines the starting index
  113051. * @param indexCount defines the number of index to draw
  113052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113053. */
  113054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113055. /**
  113056. * Draw a list of unindexed primitives
  113057. * @param fillMode defines the primitive to use
  113058. * @param verticesStart defines the index of first vertex to draw
  113059. * @param verticesCount defines the count of vertices to draw
  113060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113061. */
  113062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113063. private _drawMode;
  113064. /** @hidden */
  113065. protected _reportDrawCall(): void;
  113066. /** @hidden */
  113067. _releaseEffect(effect: Effect): void;
  113068. /** @hidden */
  113069. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113070. /**
  113071. * Create a new effect (used to store vertex/fragment shaders)
  113072. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113073. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113074. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113075. * @param samplers defines an array of string used to represent textures
  113076. * @param defines defines the string containing the defines to use to compile the shaders
  113077. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113078. * @param onCompiled defines a function to call when the effect creation is successful
  113079. * @param onError defines a function to call when the effect creation has failed
  113080. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113081. * @returns the new Effect
  113082. */
  113083. 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;
  113084. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113085. private _compileShader;
  113086. private _compileRawShader;
  113087. /** @hidden */
  113088. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113089. /**
  113090. * Directly creates a webGL program
  113091. * @param pipelineContext defines the pipeline context to attach to
  113092. * @param vertexCode defines the vertex shader code to use
  113093. * @param fragmentCode defines the fragment shader code to use
  113094. * @param context defines the webGL context to use (if not set, the current one will be used)
  113095. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113096. * @returns the new webGL program
  113097. */
  113098. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113099. /**
  113100. * Creates a webGL program
  113101. * @param pipelineContext defines the pipeline context to attach to
  113102. * @param vertexCode defines the vertex shader code to use
  113103. * @param fragmentCode defines the fragment shader code to use
  113104. * @param defines defines the string containing the defines to use to compile the shaders
  113105. * @param context defines the webGL context to use (if not set, the current one will be used)
  113106. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113107. * @returns the new webGL program
  113108. */
  113109. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113110. /**
  113111. * Creates a new pipeline context
  113112. * @returns the new pipeline
  113113. */
  113114. createPipelineContext(): IPipelineContext;
  113115. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113116. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113117. /** @hidden */
  113118. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113119. /** @hidden */
  113120. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113121. /** @hidden */
  113122. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113123. /**
  113124. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113125. * @param pipelineContext defines the pipeline context to use
  113126. * @param uniformsNames defines the list of uniform names
  113127. * @returns an array of webGL uniform locations
  113128. */
  113129. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113130. /**
  113131. * Gets the lsit of active attributes for a given webGL program
  113132. * @param pipelineContext defines the pipeline context to use
  113133. * @param attributesNames defines the list of attribute names to get
  113134. * @returns an array of indices indicating the offset of each attribute
  113135. */
  113136. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113137. /**
  113138. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113139. * @param effect defines the effect to activate
  113140. */
  113141. enableEffect(effect: Nullable<Effect>): void;
  113142. /**
  113143. * Set the value of an uniform to a number (int)
  113144. * @param uniform defines the webGL uniform location where to store the value
  113145. * @param value defines the int number to store
  113146. */
  113147. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113148. /**
  113149. * Set the value of an uniform to an array of int32
  113150. * @param uniform defines the webGL uniform location where to store the value
  113151. * @param array defines the array of int32 to store
  113152. */
  113153. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113154. /**
  113155. * Set the value of an uniform to an array of int32 (stored as vec2)
  113156. * @param uniform defines the webGL uniform location where to store the value
  113157. * @param array defines the array of int32 to store
  113158. */
  113159. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113160. /**
  113161. * Set the value of an uniform to an array of int32 (stored as vec3)
  113162. * @param uniform defines the webGL uniform location where to store the value
  113163. * @param array defines the array of int32 to store
  113164. */
  113165. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113166. /**
  113167. * Set the value of an uniform to an array of int32 (stored as vec4)
  113168. * @param uniform defines the webGL uniform location where to store the value
  113169. * @param array defines the array of int32 to store
  113170. */
  113171. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113172. /**
  113173. * Set the value of an uniform to an array of number
  113174. * @param uniform defines the webGL uniform location where to store the value
  113175. * @param array defines the array of number to store
  113176. */
  113177. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113178. /**
  113179. * Set the value of an uniform to an array of number (stored as vec2)
  113180. * @param uniform defines the webGL uniform location where to store the value
  113181. * @param array defines the array of number to store
  113182. */
  113183. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113184. /**
  113185. * Set the value of an uniform to an array of number (stored as vec3)
  113186. * @param uniform defines the webGL uniform location where to store the value
  113187. * @param array defines the array of number to store
  113188. */
  113189. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113190. /**
  113191. * Set the value of an uniform to an array of number (stored as vec4)
  113192. * @param uniform defines the webGL uniform location where to store the value
  113193. * @param array defines the array of number to store
  113194. */
  113195. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113196. /**
  113197. * Set the value of an uniform to an array of float32 (stored as matrices)
  113198. * @param uniform defines the webGL uniform location where to store the value
  113199. * @param matrices defines the array of float32 to store
  113200. */
  113201. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113202. /**
  113203. * Set the value of an uniform to a matrix (3x3)
  113204. * @param uniform defines the webGL uniform location where to store the value
  113205. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113206. */
  113207. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113208. /**
  113209. * Set the value of an uniform to a matrix (2x2)
  113210. * @param uniform defines the webGL uniform location where to store the value
  113211. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113212. */
  113213. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113214. /**
  113215. * Set the value of an uniform to a number (float)
  113216. * @param uniform defines the webGL uniform location where to store the value
  113217. * @param value defines the float number to store
  113218. */
  113219. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113220. /**
  113221. * Set the value of an uniform to a vec2
  113222. * @param uniform defines the webGL uniform location where to store the value
  113223. * @param x defines the 1st component of the value
  113224. * @param y defines the 2nd component of the value
  113225. */
  113226. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113227. /**
  113228. * Set the value of an uniform to a vec3
  113229. * @param uniform defines the webGL uniform location where to store the value
  113230. * @param x defines the 1st component of the value
  113231. * @param y defines the 2nd component of the value
  113232. * @param z defines the 3rd component of the value
  113233. */
  113234. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113235. /**
  113236. * Set the value of an uniform to a vec4
  113237. * @param uniform defines the webGL uniform location where to store the value
  113238. * @param x defines the 1st component of the value
  113239. * @param y defines the 2nd component of the value
  113240. * @param z defines the 3rd component of the value
  113241. * @param w defines the 4th component of the value
  113242. */
  113243. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113244. /**
  113245. * Apply all cached states (depth, culling, stencil and alpha)
  113246. */
  113247. applyStates(): void;
  113248. /**
  113249. * Enable or disable color writing
  113250. * @param enable defines the state to set
  113251. */
  113252. setColorWrite(enable: boolean): void;
  113253. /**
  113254. * Gets a boolean indicating if color writing is enabled
  113255. * @returns the current color writing state
  113256. */
  113257. getColorWrite(): boolean;
  113258. /**
  113259. * Gets the depth culling state manager
  113260. */
  113261. get depthCullingState(): DepthCullingState;
  113262. /**
  113263. * Gets the alpha state manager
  113264. */
  113265. get alphaState(): AlphaState;
  113266. /**
  113267. * Gets the stencil state manager
  113268. */
  113269. get stencilState(): StencilState;
  113270. /**
  113271. * Clears the list of texture accessible through engine.
  113272. * This can help preventing texture load conflict due to name collision.
  113273. */
  113274. clearInternalTexturesCache(): void;
  113275. /**
  113276. * Force the entire cache to be cleared
  113277. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113278. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113279. */
  113280. wipeCaches(bruteForce?: boolean): void;
  113281. /** @hidden */
  113282. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113283. min: number;
  113284. mag: number;
  113285. };
  113286. /** @hidden */
  113287. _createTexture(): WebGLTexture;
  113288. /**
  113289. * Usually called from Texture.ts.
  113290. * Passed information to create a WebGLTexture
  113291. * @param url defines a value which contains one of the following:
  113292. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113293. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113294. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113295. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113296. * @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)
  113297. * @param scene needed for loading to the correct scene
  113298. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113299. * @param onLoad optional callback to be called upon successful completion
  113300. * @param onError optional callback to be called upon failure
  113301. * @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
  113302. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113303. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113304. * @param forcedExtension defines the extension to use to pick the right loader
  113305. * @param mimeType defines an optional mime type
  113306. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113307. */
  113308. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  113309. /**
  113310. * Loads an image as an HTMLImageElement.
  113311. * @param input url string, ArrayBuffer, or Blob to load
  113312. * @param onLoad callback called when the image successfully loads
  113313. * @param onError callback called when the image fails to load
  113314. * @param offlineProvider offline provider for caching
  113315. * @param mimeType optional mime type
  113316. * @returns the HTMLImageElement of the loaded image
  113317. * @hidden
  113318. */
  113319. 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>;
  113320. /**
  113321. * @hidden
  113322. */
  113323. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113324. private _unpackFlipYCached;
  113325. /**
  113326. * In case you are sharing the context with other applications, it might
  113327. * be interested to not cache the unpack flip y state to ensure a consistent
  113328. * value would be set.
  113329. */
  113330. enableUnpackFlipYCached: boolean;
  113331. /** @hidden */
  113332. _unpackFlipY(value: boolean): void;
  113333. /** @hidden */
  113334. _getUnpackAlignement(): number;
  113335. private _getTextureTarget;
  113336. /**
  113337. * Update the sampling mode of a given texture
  113338. * @param samplingMode defines the required sampling mode
  113339. * @param texture defines the texture to update
  113340. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113341. */
  113342. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113343. /**
  113344. * Update the sampling mode of a given texture
  113345. * @param texture defines the texture to update
  113346. * @param wrapU defines the texture wrap mode of the u coordinates
  113347. * @param wrapV defines the texture wrap mode of the v coordinates
  113348. * @param wrapR defines the texture wrap mode of the r coordinates
  113349. */
  113350. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113351. /** @hidden */
  113352. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113353. width: number;
  113354. height: number;
  113355. layers?: number;
  113356. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113357. /** @hidden */
  113358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113359. /** @hidden */
  113360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113361. /**
  113362. * Update a portion of an internal texture
  113363. * @param texture defines the texture to update
  113364. * @param imageData defines the data to store into the texture
  113365. * @param xOffset defines the x coordinates of the update rectangle
  113366. * @param yOffset defines the y coordinates of the update rectangle
  113367. * @param width defines the width of the update rectangle
  113368. * @param height defines the height of the update rectangle
  113369. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113370. * @param lod defines the lod level to update (0 by default)
  113371. */
  113372. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113373. /** @hidden */
  113374. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113375. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113376. private _prepareWebGLTexture;
  113377. /** @hidden */
  113378. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113379. private _getDepthStencilBuffer;
  113380. /** @hidden */
  113381. _releaseFramebufferObjects(texture: InternalTexture): void;
  113382. /** @hidden */
  113383. _releaseTexture(texture: InternalTexture): void;
  113384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113385. protected _setProgram(program: WebGLProgram): void;
  113386. protected _boundUniforms: {
  113387. [key: number]: WebGLUniformLocation;
  113388. };
  113389. /**
  113390. * Binds an effect to the webGL context
  113391. * @param effect defines the effect to bind
  113392. */
  113393. bindSamplers(effect: Effect): void;
  113394. private _activateCurrentTexture;
  113395. /** @hidden */
  113396. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113397. /** @hidden */
  113398. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113399. /**
  113400. * Unbind all textures from the webGL context
  113401. */
  113402. unbindAllTextures(): void;
  113403. /**
  113404. * Sets a texture to the according uniform.
  113405. * @param channel The texture channel
  113406. * @param uniform The uniform to set
  113407. * @param texture The texture to apply
  113408. */
  113409. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113410. private _bindSamplerUniformToChannel;
  113411. private _getTextureWrapMode;
  113412. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113413. /**
  113414. * Sets an array of texture to the webGL context
  113415. * @param channel defines the channel where the texture array must be set
  113416. * @param uniform defines the associated uniform location
  113417. * @param textures defines the array of textures to bind
  113418. */
  113419. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113420. /** @hidden */
  113421. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113422. private _setTextureParameterFloat;
  113423. private _setTextureParameterInteger;
  113424. /**
  113425. * Unbind all vertex attributes from the webGL context
  113426. */
  113427. unbindAllAttributes(): void;
  113428. /**
  113429. * 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
  113430. */
  113431. releaseEffects(): void;
  113432. /**
  113433. * Dispose and release all associated resources
  113434. */
  113435. dispose(): void;
  113436. /**
  113437. * Attach a new callback raised when context lost event is fired
  113438. * @param callback defines the callback to call
  113439. */
  113440. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113441. /**
  113442. * Attach a new callback raised when context restored event is fired
  113443. * @param callback defines the callback to call
  113444. */
  113445. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113446. /**
  113447. * Get the current error code of the webGL context
  113448. * @returns the error code
  113449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113450. */
  113451. getError(): number;
  113452. private _canRenderToFloatFramebuffer;
  113453. private _canRenderToHalfFloatFramebuffer;
  113454. private _canRenderToFramebuffer;
  113455. /** @hidden */
  113456. _getWebGLTextureType(type: number): number;
  113457. /** @hidden */
  113458. _getInternalFormat(format: number): number;
  113459. /** @hidden */
  113460. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113461. /** @hidden */
  113462. _getRGBAMultiSampleBufferFormat(type: number): number;
  113463. /** @hidden */
  113464. _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;
  113465. /**
  113466. * Loads a file from a url
  113467. * @param url url to load
  113468. * @param onSuccess callback called when the file successfully loads
  113469. * @param onProgress callback called while file is loading (if the server supports this mode)
  113470. * @param offlineProvider defines the offline provider for caching
  113471. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113472. * @param onError callback called when the file fails to load
  113473. * @returns a file request object
  113474. * @hidden
  113475. */
  113476. 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;
  113477. /**
  113478. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113479. * @param x defines the x coordinate of the rectangle where pixels must be read
  113480. * @param y defines the y coordinate of the rectangle where pixels must be read
  113481. * @param width defines the width of the rectangle where pixels must be read
  113482. * @param height defines the height of the rectangle where pixels must be read
  113483. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113484. * @returns a Uint8Array containing RGBA colors
  113485. */
  113486. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113487. private static _isSupported;
  113488. /**
  113489. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113490. * @returns true if the engine can be created
  113491. * @ignorenaming
  113492. */
  113493. static isSupported(): boolean;
  113494. /**
  113495. * Find the next highest power of two.
  113496. * @param x Number to start search from.
  113497. * @return Next highest power of two.
  113498. */
  113499. static CeilingPOT(x: number): number;
  113500. /**
  113501. * Find the next lowest power of two.
  113502. * @param x Number to start search from.
  113503. * @return Next lowest power of two.
  113504. */
  113505. static FloorPOT(x: number): number;
  113506. /**
  113507. * Find the nearest power of two.
  113508. * @param x Number to start search from.
  113509. * @return Next nearest power of two.
  113510. */
  113511. static NearestPOT(x: number): number;
  113512. /**
  113513. * Get the closest exponent of two
  113514. * @param value defines the value to approximate
  113515. * @param max defines the maximum value to return
  113516. * @param mode defines how to define the closest value
  113517. * @returns closest exponent of two of the given value
  113518. */
  113519. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113520. /**
  113521. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113522. * @param func - the function to be called
  113523. * @param requester - the object that will request the next frame. Falls back to window.
  113524. * @returns frame number
  113525. */
  113526. static QueueNewFrame(func: () => void, requester?: any): number;
  113527. /**
  113528. * Gets host document
  113529. * @returns the host document object
  113530. */
  113531. getHostDocument(): Nullable<Document>;
  113532. }
  113533. }
  113534. declare module BABYLON {
  113535. /**
  113536. * Class representing spherical harmonics coefficients to the 3rd degree
  113537. */
  113538. export class SphericalHarmonics {
  113539. /**
  113540. * Defines whether or not the harmonics have been prescaled for rendering.
  113541. */
  113542. preScaled: boolean;
  113543. /**
  113544. * The l0,0 coefficients of the spherical harmonics
  113545. */
  113546. l00: Vector3;
  113547. /**
  113548. * The l1,-1 coefficients of the spherical harmonics
  113549. */
  113550. l1_1: Vector3;
  113551. /**
  113552. * The l1,0 coefficients of the spherical harmonics
  113553. */
  113554. l10: Vector3;
  113555. /**
  113556. * The l1,1 coefficients of the spherical harmonics
  113557. */
  113558. l11: Vector3;
  113559. /**
  113560. * The l2,-2 coefficients of the spherical harmonics
  113561. */
  113562. l2_2: Vector3;
  113563. /**
  113564. * The l2,-1 coefficients of the spherical harmonics
  113565. */
  113566. l2_1: Vector3;
  113567. /**
  113568. * The l2,0 coefficients of the spherical harmonics
  113569. */
  113570. l20: Vector3;
  113571. /**
  113572. * The l2,1 coefficients of the spherical harmonics
  113573. */
  113574. l21: Vector3;
  113575. /**
  113576. * The l2,2 coefficients of the spherical harmonics
  113577. */
  113578. l22: Vector3;
  113579. /**
  113580. * Adds a light to the spherical harmonics
  113581. * @param direction the direction of the light
  113582. * @param color the color of the light
  113583. * @param deltaSolidAngle the delta solid angle of the light
  113584. */
  113585. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113586. /**
  113587. * Scales the spherical harmonics by the given amount
  113588. * @param scale the amount to scale
  113589. */
  113590. scaleInPlace(scale: number): void;
  113591. /**
  113592. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113593. *
  113594. * ```
  113595. * E_lm = A_l * L_lm
  113596. * ```
  113597. *
  113598. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113599. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113600. * the scaling factors are given in equation 9.
  113601. */
  113602. convertIncidentRadianceToIrradiance(): void;
  113603. /**
  113604. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113605. *
  113606. * ```
  113607. * L = (1/pi) * E * rho
  113608. * ```
  113609. *
  113610. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113611. */
  113612. convertIrradianceToLambertianRadiance(): void;
  113613. /**
  113614. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113615. * required operations at run time.
  113616. *
  113617. * This is simply done by scaling back the SH with Ylm constants parameter.
  113618. * The trigonometric part being applied by the shader at run time.
  113619. */
  113620. preScaleForRendering(): void;
  113621. /**
  113622. * Constructs a spherical harmonics from an array.
  113623. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113624. * @returns the spherical harmonics
  113625. */
  113626. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113627. /**
  113628. * Gets the spherical harmonics from polynomial
  113629. * @param polynomial the spherical polynomial
  113630. * @returns the spherical harmonics
  113631. */
  113632. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113633. }
  113634. /**
  113635. * Class representing spherical polynomial coefficients to the 3rd degree
  113636. */
  113637. export class SphericalPolynomial {
  113638. private _harmonics;
  113639. /**
  113640. * The spherical harmonics used to create the polynomials.
  113641. */
  113642. get preScaledHarmonics(): SphericalHarmonics;
  113643. /**
  113644. * The x coefficients of the spherical polynomial
  113645. */
  113646. x: Vector3;
  113647. /**
  113648. * The y coefficients of the spherical polynomial
  113649. */
  113650. y: Vector3;
  113651. /**
  113652. * The z coefficients of the spherical polynomial
  113653. */
  113654. z: Vector3;
  113655. /**
  113656. * The xx coefficients of the spherical polynomial
  113657. */
  113658. xx: Vector3;
  113659. /**
  113660. * The yy coefficients of the spherical polynomial
  113661. */
  113662. yy: Vector3;
  113663. /**
  113664. * The zz coefficients of the spherical polynomial
  113665. */
  113666. zz: Vector3;
  113667. /**
  113668. * The xy coefficients of the spherical polynomial
  113669. */
  113670. xy: Vector3;
  113671. /**
  113672. * The yz coefficients of the spherical polynomial
  113673. */
  113674. yz: Vector3;
  113675. /**
  113676. * The zx coefficients of the spherical polynomial
  113677. */
  113678. zx: Vector3;
  113679. /**
  113680. * Adds an ambient color to the spherical polynomial
  113681. * @param color the color to add
  113682. */
  113683. addAmbient(color: Color3): void;
  113684. /**
  113685. * Scales the spherical polynomial by the given amount
  113686. * @param scale the amount to scale
  113687. */
  113688. scaleInPlace(scale: number): void;
  113689. /**
  113690. * Gets the spherical polynomial from harmonics
  113691. * @param harmonics the spherical harmonics
  113692. * @returns the spherical polynomial
  113693. */
  113694. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113695. /**
  113696. * Constructs a spherical polynomial from an array.
  113697. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113698. * @returns the spherical polynomial
  113699. */
  113700. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113701. }
  113702. }
  113703. declare module BABYLON {
  113704. /**
  113705. * Defines the source of the internal texture
  113706. */
  113707. export enum InternalTextureSource {
  113708. /**
  113709. * The source of the texture data is unknown
  113710. */
  113711. Unknown = 0,
  113712. /**
  113713. * Texture data comes from an URL
  113714. */
  113715. Url = 1,
  113716. /**
  113717. * Texture data is only used for temporary storage
  113718. */
  113719. Temp = 2,
  113720. /**
  113721. * Texture data comes from raw data (ArrayBuffer)
  113722. */
  113723. Raw = 3,
  113724. /**
  113725. * Texture content is dynamic (video or dynamic texture)
  113726. */
  113727. Dynamic = 4,
  113728. /**
  113729. * Texture content is generated by rendering to it
  113730. */
  113731. RenderTarget = 5,
  113732. /**
  113733. * Texture content is part of a multi render target process
  113734. */
  113735. MultiRenderTarget = 6,
  113736. /**
  113737. * Texture data comes from a cube data file
  113738. */
  113739. Cube = 7,
  113740. /**
  113741. * Texture data comes from a raw cube data
  113742. */
  113743. CubeRaw = 8,
  113744. /**
  113745. * Texture data come from a prefiltered cube data file
  113746. */
  113747. CubePrefiltered = 9,
  113748. /**
  113749. * Texture content is raw 3D data
  113750. */
  113751. Raw3D = 10,
  113752. /**
  113753. * Texture content is raw 2D array data
  113754. */
  113755. Raw2DArray = 11,
  113756. /**
  113757. * Texture content is a depth texture
  113758. */
  113759. Depth = 12,
  113760. /**
  113761. * Texture data comes from a raw cube data encoded with RGBD
  113762. */
  113763. CubeRawRGBD = 13
  113764. }
  113765. /**
  113766. * Class used to store data associated with WebGL texture data for the engine
  113767. * This class should not be used directly
  113768. */
  113769. export class InternalTexture {
  113770. /** @hidden */
  113771. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113772. /**
  113773. * Defines if the texture is ready
  113774. */
  113775. isReady: boolean;
  113776. /**
  113777. * Defines if the texture is a cube texture
  113778. */
  113779. isCube: boolean;
  113780. /**
  113781. * Defines if the texture contains 3D data
  113782. */
  113783. is3D: boolean;
  113784. /**
  113785. * Defines if the texture contains 2D array data
  113786. */
  113787. is2DArray: boolean;
  113788. /**
  113789. * Defines if the texture contains multiview data
  113790. */
  113791. isMultiview: boolean;
  113792. /**
  113793. * Gets the URL used to load this texture
  113794. */
  113795. url: string;
  113796. /**
  113797. * Gets the sampling mode of the texture
  113798. */
  113799. samplingMode: number;
  113800. /**
  113801. * Gets a boolean indicating if the texture needs mipmaps generation
  113802. */
  113803. generateMipMaps: boolean;
  113804. /**
  113805. * Gets the number of samples used by the texture (WebGL2+ only)
  113806. */
  113807. samples: number;
  113808. /**
  113809. * Gets the type of the texture (int, float...)
  113810. */
  113811. type: number;
  113812. /**
  113813. * Gets the format of the texture (RGB, RGBA...)
  113814. */
  113815. format: number;
  113816. /**
  113817. * Observable called when the texture is loaded
  113818. */
  113819. onLoadedObservable: Observable<InternalTexture>;
  113820. /**
  113821. * Gets the width of the texture
  113822. */
  113823. width: number;
  113824. /**
  113825. * Gets the height of the texture
  113826. */
  113827. height: number;
  113828. /**
  113829. * Gets the depth of the texture
  113830. */
  113831. depth: number;
  113832. /**
  113833. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113834. */
  113835. baseWidth: number;
  113836. /**
  113837. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113838. */
  113839. baseHeight: number;
  113840. /**
  113841. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113842. */
  113843. baseDepth: number;
  113844. /**
  113845. * Gets a boolean indicating if the texture is inverted on Y axis
  113846. */
  113847. invertY: boolean;
  113848. /** @hidden */
  113849. _invertVScale: boolean;
  113850. /** @hidden */
  113851. _associatedChannel: number;
  113852. /** @hidden */
  113853. _source: InternalTextureSource;
  113854. /** @hidden */
  113855. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113856. /** @hidden */
  113857. _bufferView: Nullable<ArrayBufferView>;
  113858. /** @hidden */
  113859. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113860. /** @hidden */
  113861. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113862. /** @hidden */
  113863. _size: number;
  113864. /** @hidden */
  113865. _extension: string;
  113866. /** @hidden */
  113867. _files: Nullable<string[]>;
  113868. /** @hidden */
  113869. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113870. /** @hidden */
  113871. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113872. /** @hidden */
  113873. _framebuffer: Nullable<WebGLFramebuffer>;
  113874. /** @hidden */
  113875. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113876. /** @hidden */
  113877. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113878. /** @hidden */
  113879. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113880. /** @hidden */
  113881. _attachments: Nullable<number[]>;
  113882. /** @hidden */
  113883. _textureArray: Nullable<InternalTexture[]>;
  113884. /** @hidden */
  113885. _cachedCoordinatesMode: Nullable<number>;
  113886. /** @hidden */
  113887. _cachedWrapU: Nullable<number>;
  113888. /** @hidden */
  113889. _cachedWrapV: Nullable<number>;
  113890. /** @hidden */
  113891. _cachedWrapR: Nullable<number>;
  113892. /** @hidden */
  113893. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113894. /** @hidden */
  113895. _isDisabled: boolean;
  113896. /** @hidden */
  113897. _compression: Nullable<string>;
  113898. /** @hidden */
  113899. _generateStencilBuffer: boolean;
  113900. /** @hidden */
  113901. _generateDepthBuffer: boolean;
  113902. /** @hidden */
  113903. _comparisonFunction: number;
  113904. /** @hidden */
  113905. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113906. /** @hidden */
  113907. _lodGenerationScale: number;
  113908. /** @hidden */
  113909. _lodGenerationOffset: number;
  113910. /** @hidden */
  113911. _depthStencilTexture: Nullable<InternalTexture>;
  113912. /** @hidden */
  113913. _colorTextureArray: Nullable<WebGLTexture>;
  113914. /** @hidden */
  113915. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113916. /** @hidden */
  113917. _lodTextureHigh: Nullable<BaseTexture>;
  113918. /** @hidden */
  113919. _lodTextureMid: Nullable<BaseTexture>;
  113920. /** @hidden */
  113921. _lodTextureLow: Nullable<BaseTexture>;
  113922. /** @hidden */
  113923. _isRGBD: boolean;
  113924. /** @hidden */
  113925. _linearSpecularLOD: boolean;
  113926. /** @hidden */
  113927. _irradianceTexture: Nullable<BaseTexture>;
  113928. /** @hidden */
  113929. _webGLTexture: Nullable<WebGLTexture>;
  113930. /** @hidden */
  113931. _references: number;
  113932. private _engine;
  113933. /**
  113934. * Gets the Engine the texture belongs to.
  113935. * @returns The babylon engine
  113936. */
  113937. getEngine(): ThinEngine;
  113938. /**
  113939. * Gets the data source type of the texture
  113940. */
  113941. get source(): InternalTextureSource;
  113942. /**
  113943. * Creates a new InternalTexture
  113944. * @param engine defines the engine to use
  113945. * @param source defines the type of data that will be used
  113946. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113947. */
  113948. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113949. /**
  113950. * Increments the number of references (ie. the number of Texture that point to it)
  113951. */
  113952. incrementReferences(): void;
  113953. /**
  113954. * Change the size of the texture (not the size of the content)
  113955. * @param width defines the new width
  113956. * @param height defines the new height
  113957. * @param depth defines the new depth (1 by default)
  113958. */
  113959. updateSize(width: int, height: int, depth?: int): void;
  113960. /** @hidden */
  113961. _rebuild(): void;
  113962. /** @hidden */
  113963. _swapAndDie(target: InternalTexture): void;
  113964. /**
  113965. * Dispose the current allocated resources
  113966. */
  113967. dispose(): void;
  113968. }
  113969. }
  113970. declare module BABYLON {
  113971. /**
  113972. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113973. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113974. */
  113975. export class Analyser {
  113976. /**
  113977. * Gets or sets the smoothing
  113978. * @ignorenaming
  113979. */
  113980. SMOOTHING: number;
  113981. /**
  113982. * Gets or sets the FFT table size
  113983. * @ignorenaming
  113984. */
  113985. FFT_SIZE: number;
  113986. /**
  113987. * Gets or sets the bar graph amplitude
  113988. * @ignorenaming
  113989. */
  113990. BARGRAPHAMPLITUDE: number;
  113991. /**
  113992. * Gets or sets the position of the debug canvas
  113993. * @ignorenaming
  113994. */
  113995. DEBUGCANVASPOS: {
  113996. x: number;
  113997. y: number;
  113998. };
  113999. /**
  114000. * Gets or sets the debug canvas size
  114001. * @ignorenaming
  114002. */
  114003. DEBUGCANVASSIZE: {
  114004. width: number;
  114005. height: number;
  114006. };
  114007. private _byteFreqs;
  114008. private _byteTime;
  114009. private _floatFreqs;
  114010. private _webAudioAnalyser;
  114011. private _debugCanvas;
  114012. private _debugCanvasContext;
  114013. private _scene;
  114014. private _registerFunc;
  114015. private _audioEngine;
  114016. /**
  114017. * Creates a new analyser
  114018. * @param scene defines hosting scene
  114019. */
  114020. constructor(scene: Scene);
  114021. /**
  114022. * Get the number of data values you will have to play with for the visualization
  114023. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114024. * @returns a number
  114025. */
  114026. getFrequencyBinCount(): number;
  114027. /**
  114028. * Gets the current frequency data as a byte array
  114029. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114030. * @returns a Uint8Array
  114031. */
  114032. getByteFrequencyData(): Uint8Array;
  114033. /**
  114034. * Gets the current waveform as a byte array
  114035. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114036. * @returns a Uint8Array
  114037. */
  114038. getByteTimeDomainData(): Uint8Array;
  114039. /**
  114040. * Gets the current frequency data as a float array
  114041. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114042. * @returns a Float32Array
  114043. */
  114044. getFloatFrequencyData(): Float32Array;
  114045. /**
  114046. * Renders the debug canvas
  114047. */
  114048. drawDebugCanvas(): void;
  114049. /**
  114050. * Stops rendering the debug canvas and removes it
  114051. */
  114052. stopDebugCanvas(): void;
  114053. /**
  114054. * Connects two audio nodes
  114055. * @param inputAudioNode defines first node to connect
  114056. * @param outputAudioNode defines second node to connect
  114057. */
  114058. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114059. /**
  114060. * Releases all associated resources
  114061. */
  114062. dispose(): void;
  114063. }
  114064. }
  114065. declare module BABYLON {
  114066. /**
  114067. * This represents an audio engine and it is responsible
  114068. * to play, synchronize and analyse sounds throughout the application.
  114069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114070. */
  114071. export interface IAudioEngine extends IDisposable {
  114072. /**
  114073. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114074. */
  114075. readonly canUseWebAudio: boolean;
  114076. /**
  114077. * Gets the current AudioContext if available.
  114078. */
  114079. readonly audioContext: Nullable<AudioContext>;
  114080. /**
  114081. * The master gain node defines the global audio volume of your audio engine.
  114082. */
  114083. readonly masterGain: GainNode;
  114084. /**
  114085. * Gets whether or not mp3 are supported by your browser.
  114086. */
  114087. readonly isMP3supported: boolean;
  114088. /**
  114089. * Gets whether or not ogg are supported by your browser.
  114090. */
  114091. readonly isOGGsupported: boolean;
  114092. /**
  114093. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114094. * @ignoreNaming
  114095. */
  114096. WarnedWebAudioUnsupported: boolean;
  114097. /**
  114098. * Defines if the audio engine relies on a custom unlocked button.
  114099. * In this case, the embedded button will not be displayed.
  114100. */
  114101. useCustomUnlockedButton: boolean;
  114102. /**
  114103. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114104. */
  114105. readonly unlocked: boolean;
  114106. /**
  114107. * Event raised when audio has been unlocked on the browser.
  114108. */
  114109. onAudioUnlockedObservable: Observable<AudioEngine>;
  114110. /**
  114111. * Event raised when audio has been locked on the browser.
  114112. */
  114113. onAudioLockedObservable: Observable<AudioEngine>;
  114114. /**
  114115. * Flags the audio engine in Locked state.
  114116. * This happens due to new browser policies preventing audio to autoplay.
  114117. */
  114118. lock(): void;
  114119. /**
  114120. * Unlocks the audio engine once a user action has been done on the dom.
  114121. * This is helpful to resume play once browser policies have been satisfied.
  114122. */
  114123. unlock(): void;
  114124. /**
  114125. * Gets the global volume sets on the master gain.
  114126. * @returns the global volume if set or -1 otherwise
  114127. */
  114128. getGlobalVolume(): number;
  114129. /**
  114130. * Sets the global volume of your experience (sets on the master gain).
  114131. * @param newVolume Defines the new global volume of the application
  114132. */
  114133. setGlobalVolume(newVolume: number): void;
  114134. /**
  114135. * Connect the audio engine to an audio analyser allowing some amazing
  114136. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114138. * @param analyser The analyser to connect to the engine
  114139. */
  114140. connectToAnalyser(analyser: Analyser): void;
  114141. }
  114142. /**
  114143. * This represents the default audio engine used in babylon.
  114144. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114145. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114146. */
  114147. export class AudioEngine implements IAudioEngine {
  114148. private _audioContext;
  114149. private _audioContextInitialized;
  114150. private _muteButton;
  114151. private _hostElement;
  114152. /**
  114153. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114154. */
  114155. canUseWebAudio: boolean;
  114156. /**
  114157. * The master gain node defines the global audio volume of your audio engine.
  114158. */
  114159. masterGain: GainNode;
  114160. /**
  114161. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114162. * @ignoreNaming
  114163. */
  114164. WarnedWebAudioUnsupported: boolean;
  114165. /**
  114166. * Gets whether or not mp3 are supported by your browser.
  114167. */
  114168. isMP3supported: boolean;
  114169. /**
  114170. * Gets whether or not ogg are supported by your browser.
  114171. */
  114172. isOGGsupported: boolean;
  114173. /**
  114174. * Gets whether audio has been unlocked on the device.
  114175. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114176. * a user interaction has happened.
  114177. */
  114178. unlocked: boolean;
  114179. /**
  114180. * Defines if the audio engine relies on a custom unlocked button.
  114181. * In this case, the embedded button will not be displayed.
  114182. */
  114183. useCustomUnlockedButton: boolean;
  114184. /**
  114185. * Event raised when audio has been unlocked on the browser.
  114186. */
  114187. onAudioUnlockedObservable: Observable<AudioEngine>;
  114188. /**
  114189. * Event raised when audio has been locked on the browser.
  114190. */
  114191. onAudioLockedObservable: Observable<AudioEngine>;
  114192. /**
  114193. * Gets the current AudioContext if available.
  114194. */
  114195. get audioContext(): Nullable<AudioContext>;
  114196. private _connectedAnalyser;
  114197. /**
  114198. * Instantiates a new audio engine.
  114199. *
  114200. * There should be only one per page as some browsers restrict the number
  114201. * of audio contexts you can create.
  114202. * @param hostElement defines the host element where to display the mute icon if necessary
  114203. */
  114204. constructor(hostElement?: Nullable<HTMLElement>);
  114205. /**
  114206. * Flags the audio engine in Locked state.
  114207. * This happens due to new browser policies preventing audio to autoplay.
  114208. */
  114209. lock(): void;
  114210. /**
  114211. * Unlocks the audio engine once a user action has been done on the dom.
  114212. * This is helpful to resume play once browser policies have been satisfied.
  114213. */
  114214. unlock(): void;
  114215. private _resumeAudioContext;
  114216. private _initializeAudioContext;
  114217. private _tryToRun;
  114218. private _triggerRunningState;
  114219. private _triggerSuspendedState;
  114220. private _displayMuteButton;
  114221. private _moveButtonToTopLeft;
  114222. private _onResize;
  114223. private _hideMuteButton;
  114224. /**
  114225. * Destroy and release the resources associated with the audio ccontext.
  114226. */
  114227. dispose(): void;
  114228. /**
  114229. * Gets the global volume sets on the master gain.
  114230. * @returns the global volume if set or -1 otherwise
  114231. */
  114232. getGlobalVolume(): number;
  114233. /**
  114234. * Sets the global volume of your experience (sets on the master gain).
  114235. * @param newVolume Defines the new global volume of the application
  114236. */
  114237. setGlobalVolume(newVolume: number): void;
  114238. /**
  114239. * Connect the audio engine to an audio analyser allowing some amazing
  114240. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114242. * @param analyser The analyser to connect to the engine
  114243. */
  114244. connectToAnalyser(analyser: Analyser): void;
  114245. }
  114246. }
  114247. declare module BABYLON {
  114248. /**
  114249. * Interface used to present a loading screen while loading a scene
  114250. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114251. */
  114252. export interface ILoadingScreen {
  114253. /**
  114254. * Function called to display the loading screen
  114255. */
  114256. displayLoadingUI: () => void;
  114257. /**
  114258. * Function called to hide the loading screen
  114259. */
  114260. hideLoadingUI: () => void;
  114261. /**
  114262. * Gets or sets the color to use for the background
  114263. */
  114264. loadingUIBackgroundColor: string;
  114265. /**
  114266. * Gets or sets the text to display while loading
  114267. */
  114268. loadingUIText: string;
  114269. }
  114270. /**
  114271. * Class used for the default loading screen
  114272. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114273. */
  114274. export class DefaultLoadingScreen implements ILoadingScreen {
  114275. private _renderingCanvas;
  114276. private _loadingText;
  114277. private _loadingDivBackgroundColor;
  114278. private _loadingDiv;
  114279. private _loadingTextDiv;
  114280. /** Gets or sets the logo url to use for the default loading screen */
  114281. static DefaultLogoUrl: string;
  114282. /** Gets or sets the spinner url to use for the default loading screen */
  114283. static DefaultSpinnerUrl: string;
  114284. /**
  114285. * Creates a new default loading screen
  114286. * @param _renderingCanvas defines the canvas used to render the scene
  114287. * @param _loadingText defines the default text to display
  114288. * @param _loadingDivBackgroundColor defines the default background color
  114289. */
  114290. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114291. /**
  114292. * Function called to display the loading screen
  114293. */
  114294. displayLoadingUI(): void;
  114295. /**
  114296. * Function called to hide the loading screen
  114297. */
  114298. hideLoadingUI(): void;
  114299. /**
  114300. * Gets or sets the text to display while loading
  114301. */
  114302. set loadingUIText(text: string);
  114303. get loadingUIText(): string;
  114304. /**
  114305. * Gets or sets the color to use for the background
  114306. */
  114307. get loadingUIBackgroundColor(): string;
  114308. set loadingUIBackgroundColor(color: string);
  114309. private _resizeLoadingUI;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * Interface for any object that can request an animation frame
  114315. */
  114316. export interface ICustomAnimationFrameRequester {
  114317. /**
  114318. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114319. */
  114320. renderFunction?: Function;
  114321. /**
  114322. * Called to request the next frame to render to
  114323. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114324. */
  114325. requestAnimationFrame: Function;
  114326. /**
  114327. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114328. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114329. */
  114330. requestID?: number;
  114331. }
  114332. }
  114333. declare module BABYLON {
  114334. /**
  114335. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114336. */
  114337. export class PerformanceMonitor {
  114338. private _enabled;
  114339. private _rollingFrameTime;
  114340. private _lastFrameTimeMs;
  114341. /**
  114342. * constructor
  114343. * @param frameSampleSize The number of samples required to saturate the sliding window
  114344. */
  114345. constructor(frameSampleSize?: number);
  114346. /**
  114347. * Samples current frame
  114348. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114349. */
  114350. sampleFrame(timeMs?: number): void;
  114351. /**
  114352. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114353. */
  114354. get averageFrameTime(): number;
  114355. /**
  114356. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114357. */
  114358. get averageFrameTimeVariance(): number;
  114359. /**
  114360. * Returns the frame time of the most recent frame
  114361. */
  114362. get instantaneousFrameTime(): number;
  114363. /**
  114364. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114365. */
  114366. get averageFPS(): number;
  114367. /**
  114368. * Returns the average framerate in frames per second using the most recent frame time
  114369. */
  114370. get instantaneousFPS(): number;
  114371. /**
  114372. * Returns true if enough samples have been taken to completely fill the sliding window
  114373. */
  114374. get isSaturated(): boolean;
  114375. /**
  114376. * Enables contributions to the sliding window sample set
  114377. */
  114378. enable(): void;
  114379. /**
  114380. * Disables contributions to the sliding window sample set
  114381. * Samples will not be interpolated over the disabled period
  114382. */
  114383. disable(): void;
  114384. /**
  114385. * Returns true if sampling is enabled
  114386. */
  114387. get isEnabled(): boolean;
  114388. /**
  114389. * Resets performance monitor
  114390. */
  114391. reset(): void;
  114392. }
  114393. /**
  114394. * RollingAverage
  114395. *
  114396. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114397. */
  114398. export class RollingAverage {
  114399. /**
  114400. * Current average
  114401. */
  114402. average: number;
  114403. /**
  114404. * Current variance
  114405. */
  114406. variance: number;
  114407. protected _samples: Array<number>;
  114408. protected _sampleCount: number;
  114409. protected _pos: number;
  114410. protected _m2: number;
  114411. /**
  114412. * constructor
  114413. * @param length The number of samples required to saturate the sliding window
  114414. */
  114415. constructor(length: number);
  114416. /**
  114417. * Adds a sample to the sample set
  114418. * @param v The sample value
  114419. */
  114420. add(v: number): void;
  114421. /**
  114422. * Returns previously added values or null if outside of history or outside the sliding window domain
  114423. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114424. * @return Value previously recorded with add() or null if outside of range
  114425. */
  114426. history(i: number): number;
  114427. /**
  114428. * Returns true if enough samples have been taken to completely fill the sliding window
  114429. * @return true if sample-set saturated
  114430. */
  114431. isSaturated(): boolean;
  114432. /**
  114433. * Resets the rolling average (equivalent to 0 samples taken so far)
  114434. */
  114435. reset(): void;
  114436. /**
  114437. * Wraps a value around the sample range boundaries
  114438. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114439. * @return Wrapped position in sample range
  114440. */
  114441. protected _wrapPosition(i: number): number;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /**
  114446. * This class is used to track a performance counter which is number based.
  114447. * The user has access to many properties which give statistics of different nature.
  114448. *
  114449. * The implementer can track two kinds of Performance Counter: time and count.
  114450. * 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.
  114451. * 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.
  114452. */
  114453. export class PerfCounter {
  114454. /**
  114455. * Gets or sets a global boolean to turn on and off all the counters
  114456. */
  114457. static Enabled: boolean;
  114458. /**
  114459. * Returns the smallest value ever
  114460. */
  114461. get min(): number;
  114462. /**
  114463. * Returns the biggest value ever
  114464. */
  114465. get max(): number;
  114466. /**
  114467. * Returns the average value since the performance counter is running
  114468. */
  114469. get average(): number;
  114470. /**
  114471. * Returns the average value of the last second the counter was monitored
  114472. */
  114473. get lastSecAverage(): number;
  114474. /**
  114475. * Returns the current value
  114476. */
  114477. get current(): number;
  114478. /**
  114479. * Gets the accumulated total
  114480. */
  114481. get total(): number;
  114482. /**
  114483. * Gets the total value count
  114484. */
  114485. get count(): number;
  114486. /**
  114487. * Creates a new counter
  114488. */
  114489. constructor();
  114490. /**
  114491. * Call this method to start monitoring a new frame.
  114492. * 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.
  114493. */
  114494. fetchNewFrame(): void;
  114495. /**
  114496. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114497. * @param newCount the count value to add to the monitored count
  114498. * @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.
  114499. */
  114500. addCount(newCount: number, fetchResult: boolean): void;
  114501. /**
  114502. * Start monitoring this performance counter
  114503. */
  114504. beginMonitoring(): void;
  114505. /**
  114506. * Compute the time lapsed since the previous beginMonitoring() call.
  114507. * @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
  114508. */
  114509. endMonitoring(newFrame?: boolean): void;
  114510. private _fetchResult;
  114511. private _startMonitoringTime;
  114512. private _min;
  114513. private _max;
  114514. private _average;
  114515. private _current;
  114516. private _totalValueCount;
  114517. private _totalAccumulated;
  114518. private _lastSecAverage;
  114519. private _lastSecAccumulated;
  114520. private _lastSecTime;
  114521. private _lastSecValueCount;
  114522. }
  114523. }
  114524. declare module BABYLON {
  114525. interface ThinEngine {
  114526. /**
  114527. * Sets alpha constants used by some alpha blending modes
  114528. * @param r defines the red component
  114529. * @param g defines the green component
  114530. * @param b defines the blue component
  114531. * @param a defines the alpha component
  114532. */
  114533. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114534. /**
  114535. * Sets the current alpha mode
  114536. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114537. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114538. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114539. */
  114540. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114541. /**
  114542. * Gets the current alpha mode
  114543. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114544. * @returns the current alpha mode
  114545. */
  114546. getAlphaMode(): number;
  114547. /**
  114548. * Sets the current alpha equation
  114549. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114550. */
  114551. setAlphaEquation(equation: number): void;
  114552. /**
  114553. * Gets the current alpha equation.
  114554. * @returns the current alpha equation
  114555. */
  114556. getAlphaEquation(): number;
  114557. }
  114558. }
  114559. declare module BABYLON {
  114560. interface ThinEngine {
  114561. /** @hidden */
  114562. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114563. }
  114564. }
  114565. declare module BABYLON {
  114566. /**
  114567. * Defines the interface used by display changed events
  114568. */
  114569. export interface IDisplayChangedEventArgs {
  114570. /** Gets the vrDisplay object (if any) */
  114571. vrDisplay: Nullable<any>;
  114572. /** Gets a boolean indicating if webVR is supported */
  114573. vrSupported: boolean;
  114574. }
  114575. /**
  114576. * Defines the interface used by objects containing a viewport (like a camera)
  114577. */
  114578. interface IViewportOwnerLike {
  114579. /**
  114580. * Gets or sets the viewport
  114581. */
  114582. viewport: IViewportLike;
  114583. }
  114584. /**
  114585. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114586. */
  114587. export class Engine extends ThinEngine {
  114588. /** Defines that alpha blending is disabled */
  114589. static readonly ALPHA_DISABLE: number;
  114590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114591. static readonly ALPHA_ADD: number;
  114592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114593. static readonly ALPHA_COMBINE: number;
  114594. /** Defines that alpha blending to DEST - SRC * DEST */
  114595. static readonly ALPHA_SUBTRACT: number;
  114596. /** Defines that alpha blending to SRC * DEST */
  114597. static readonly ALPHA_MULTIPLY: number;
  114598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114599. static readonly ALPHA_MAXIMIZED: number;
  114600. /** Defines that alpha blending to SRC + DEST */
  114601. static readonly ALPHA_ONEONE: number;
  114602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114603. static readonly ALPHA_PREMULTIPLIED: number;
  114604. /**
  114605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114607. */
  114608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114610. static readonly ALPHA_INTERPOLATE: number;
  114611. /**
  114612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114614. */
  114615. static readonly ALPHA_SCREENMODE: number;
  114616. /** Defines that the ressource is not delayed*/
  114617. static readonly DELAYLOADSTATE_NONE: number;
  114618. /** Defines that the ressource was successfully delay loaded */
  114619. static readonly DELAYLOADSTATE_LOADED: number;
  114620. /** Defines that the ressource is currently delay loading */
  114621. static readonly DELAYLOADSTATE_LOADING: number;
  114622. /** Defines that the ressource is delayed and has not started loading */
  114623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114625. static readonly NEVER: number;
  114626. /** 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 */
  114627. static readonly ALWAYS: number;
  114628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114629. static readonly LESS: number;
  114630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114631. static readonly EQUAL: number;
  114632. /** 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 */
  114633. static readonly LEQUAL: number;
  114634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114635. static readonly GREATER: number;
  114636. /** 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 */
  114637. static readonly GEQUAL: number;
  114638. /** 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 */
  114639. static readonly NOTEQUAL: number;
  114640. /** Passed to stencilOperation to specify that stencil value must be kept */
  114641. static readonly KEEP: number;
  114642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114643. static readonly REPLACE: number;
  114644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114645. static readonly INCR: number;
  114646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114647. static readonly DECR: number;
  114648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114649. static readonly INVERT: number;
  114650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114651. static readonly INCR_WRAP: number;
  114652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114653. static readonly DECR_WRAP: number;
  114654. /** Texture is not repeating outside of 0..1 UVs */
  114655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114656. /** Texture is repeating outside of 0..1 UVs */
  114657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114658. /** Texture is repeating and mirrored */
  114659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114660. /** ALPHA */
  114661. static readonly TEXTUREFORMAT_ALPHA: number;
  114662. /** LUMINANCE */
  114663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114664. /** LUMINANCE_ALPHA */
  114665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114666. /** RGB */
  114667. static readonly TEXTUREFORMAT_RGB: number;
  114668. /** RGBA */
  114669. static readonly TEXTUREFORMAT_RGBA: number;
  114670. /** RED */
  114671. static readonly TEXTUREFORMAT_RED: number;
  114672. /** RED (2nd reference) */
  114673. static readonly TEXTUREFORMAT_R: number;
  114674. /** RG */
  114675. static readonly TEXTUREFORMAT_RG: number;
  114676. /** RED_INTEGER */
  114677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114678. /** RED_INTEGER (2nd reference) */
  114679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114680. /** RG_INTEGER */
  114681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114682. /** RGB_INTEGER */
  114683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114684. /** RGBA_INTEGER */
  114685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114686. /** UNSIGNED_BYTE */
  114687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114688. /** UNSIGNED_BYTE (2nd reference) */
  114689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114690. /** FLOAT */
  114691. static readonly TEXTURETYPE_FLOAT: number;
  114692. /** HALF_FLOAT */
  114693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114694. /** BYTE */
  114695. static readonly TEXTURETYPE_BYTE: number;
  114696. /** SHORT */
  114697. static readonly TEXTURETYPE_SHORT: number;
  114698. /** UNSIGNED_SHORT */
  114699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114700. /** INT */
  114701. static readonly TEXTURETYPE_INT: number;
  114702. /** UNSIGNED_INT */
  114703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114704. /** UNSIGNED_SHORT_4_4_4_4 */
  114705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114706. /** UNSIGNED_SHORT_5_5_5_1 */
  114707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114708. /** UNSIGNED_SHORT_5_6_5 */
  114709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114710. /** UNSIGNED_INT_2_10_10_10_REV */
  114711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114712. /** UNSIGNED_INT_24_8 */
  114713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114714. /** UNSIGNED_INT_10F_11F_11F_REV */
  114715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114716. /** UNSIGNED_INT_5_9_9_9_REV */
  114717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114720. /** nearest is mag = nearest and min = nearest and mip = linear */
  114721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114724. /** Trilinear is mag = linear and min = linear and mip = linear */
  114725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114726. /** nearest is mag = nearest and min = nearest and mip = linear */
  114727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114730. /** Trilinear is mag = linear and min = linear and mip = linear */
  114731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114732. /** mag = nearest and min = nearest and mip = nearest */
  114733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114734. /** mag = nearest and min = linear and mip = nearest */
  114735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114736. /** mag = nearest and min = linear and mip = linear */
  114737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114738. /** mag = nearest and min = linear and mip = none */
  114739. static readonly TEXTURE_NEAREST_LINEAR: number;
  114740. /** mag = nearest and min = nearest and mip = none */
  114741. static readonly TEXTURE_NEAREST_NEAREST: number;
  114742. /** mag = linear and min = nearest and mip = nearest */
  114743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114744. /** mag = linear and min = nearest and mip = linear */
  114745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114746. /** mag = linear and min = linear and mip = none */
  114747. static readonly TEXTURE_LINEAR_LINEAR: number;
  114748. /** mag = linear and min = nearest and mip = none */
  114749. static readonly TEXTURE_LINEAR_NEAREST: number;
  114750. /** Explicit coordinates mode */
  114751. static readonly TEXTURE_EXPLICIT_MODE: number;
  114752. /** Spherical coordinates mode */
  114753. static readonly TEXTURE_SPHERICAL_MODE: number;
  114754. /** Planar coordinates mode */
  114755. static readonly TEXTURE_PLANAR_MODE: number;
  114756. /** Cubic coordinates mode */
  114757. static readonly TEXTURE_CUBIC_MODE: number;
  114758. /** Projection coordinates mode */
  114759. static readonly TEXTURE_PROJECTION_MODE: number;
  114760. /** Skybox coordinates mode */
  114761. static readonly TEXTURE_SKYBOX_MODE: number;
  114762. /** Inverse Cubic coordinates mode */
  114763. static readonly TEXTURE_INVCUBIC_MODE: number;
  114764. /** Equirectangular coordinates mode */
  114765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114766. /** Equirectangular Fixed coordinates mode */
  114767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114768. /** Equirectangular Fixed Mirrored coordinates mode */
  114769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114771. static readonly SCALEMODE_FLOOR: number;
  114772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114773. static readonly SCALEMODE_NEAREST: number;
  114774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114775. static readonly SCALEMODE_CEILING: number;
  114776. /**
  114777. * Returns the current npm package of the sdk
  114778. */
  114779. static get NpmPackage(): string;
  114780. /**
  114781. * Returns the current version of the framework
  114782. */
  114783. static get Version(): string;
  114784. /** Gets the list of created engines */
  114785. static get Instances(): Engine[];
  114786. /**
  114787. * Gets the latest created engine
  114788. */
  114789. static get LastCreatedEngine(): Nullable<Engine>;
  114790. /**
  114791. * Gets the latest created scene
  114792. */
  114793. static get LastCreatedScene(): Nullable<Scene>;
  114794. /**
  114795. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114796. * @param flag defines which part of the materials must be marked as dirty
  114797. * @param predicate defines a predicate used to filter which materials should be affected
  114798. */
  114799. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114800. /**
  114801. * Method called to create the default loading screen.
  114802. * This can be overriden in your own app.
  114803. * @param canvas The rendering canvas element
  114804. * @returns The loading screen
  114805. */
  114806. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114807. /**
  114808. * Method called to create the default rescale post process on each engine.
  114809. */
  114810. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114811. /**
  114812. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114813. **/
  114814. enableOfflineSupport: boolean;
  114815. /**
  114816. * 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)
  114817. **/
  114818. disableManifestCheck: boolean;
  114819. /**
  114820. * Gets the list of created scenes
  114821. */
  114822. scenes: Scene[];
  114823. /**
  114824. * Event raised when a new scene is created
  114825. */
  114826. onNewSceneAddedObservable: Observable<Scene>;
  114827. /**
  114828. * Gets the list of created postprocesses
  114829. */
  114830. postProcesses: PostProcess[];
  114831. /**
  114832. * Gets a boolean indicating if the pointer is currently locked
  114833. */
  114834. isPointerLock: boolean;
  114835. /**
  114836. * Observable event triggered each time the rendering canvas is resized
  114837. */
  114838. onResizeObservable: Observable<Engine>;
  114839. /**
  114840. * Observable event triggered each time the canvas loses focus
  114841. */
  114842. onCanvasBlurObservable: Observable<Engine>;
  114843. /**
  114844. * Observable event triggered each time the canvas gains focus
  114845. */
  114846. onCanvasFocusObservable: Observable<Engine>;
  114847. /**
  114848. * Observable event triggered each time the canvas receives pointerout event
  114849. */
  114850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114851. /**
  114852. * Observable raised when the engine begins a new frame
  114853. */
  114854. onBeginFrameObservable: Observable<Engine>;
  114855. /**
  114856. * If set, will be used to request the next animation frame for the render loop
  114857. */
  114858. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114859. /**
  114860. * Observable raised when the engine ends the current frame
  114861. */
  114862. onEndFrameObservable: Observable<Engine>;
  114863. /**
  114864. * Observable raised when the engine is about to compile a shader
  114865. */
  114866. onBeforeShaderCompilationObservable: Observable<Engine>;
  114867. /**
  114868. * Observable raised when the engine has jsut compiled a shader
  114869. */
  114870. onAfterShaderCompilationObservable: Observable<Engine>;
  114871. /**
  114872. * Gets the audio engine
  114873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114874. * @ignorenaming
  114875. */
  114876. static audioEngine: IAudioEngine;
  114877. /**
  114878. * Default AudioEngine factory responsible of creating the Audio Engine.
  114879. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114880. */
  114881. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114882. /**
  114883. * Default offline support factory responsible of creating a tool used to store data locally.
  114884. * By default, this will create a Database object if the workload has been embedded.
  114885. */
  114886. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114887. private _loadingScreen;
  114888. private _pointerLockRequested;
  114889. private _rescalePostProcess;
  114890. private _deterministicLockstep;
  114891. private _lockstepMaxSteps;
  114892. private _timeStep;
  114893. protected get _supportsHardwareTextureRescaling(): boolean;
  114894. private _fps;
  114895. private _deltaTime;
  114896. /** @hidden */
  114897. _drawCalls: PerfCounter;
  114898. /** 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 */
  114899. canvasTabIndex: number;
  114900. /**
  114901. * Turn this value on if you want to pause FPS computation when in background
  114902. */
  114903. disablePerformanceMonitorInBackground: boolean;
  114904. private _performanceMonitor;
  114905. /**
  114906. * Gets the performance monitor attached to this engine
  114907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114908. */
  114909. get performanceMonitor(): PerformanceMonitor;
  114910. private _onFocus;
  114911. private _onBlur;
  114912. private _onCanvasPointerOut;
  114913. private _onCanvasBlur;
  114914. private _onCanvasFocus;
  114915. private _onFullscreenChange;
  114916. private _onPointerLockChange;
  114917. /**
  114918. * Gets the HTML element used to attach event listeners
  114919. * @returns a HTML element
  114920. */
  114921. getInputElement(): Nullable<HTMLElement>;
  114922. /**
  114923. * Creates a new engine
  114924. * @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
  114925. * @param antialias defines enable antialiasing (default: false)
  114926. * @param options defines further options to be sent to the getContext() function
  114927. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114928. */
  114929. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114930. /**
  114931. * Gets current aspect ratio
  114932. * @param viewportOwner defines the camera to use to get the aspect ratio
  114933. * @param useScreen defines if screen size must be used (or the current render target if any)
  114934. * @returns a number defining the aspect ratio
  114935. */
  114936. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114937. /**
  114938. * Gets current screen aspect ratio
  114939. * @returns a number defining the aspect ratio
  114940. */
  114941. getScreenAspectRatio(): number;
  114942. /**
  114943. * Gets the client rect of the HTML canvas attached with the current webGL context
  114944. * @returns a client rectanglee
  114945. */
  114946. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114947. /**
  114948. * Gets the client rect of the HTML element used for events
  114949. * @returns a client rectanglee
  114950. */
  114951. getInputElementClientRect(): Nullable<ClientRect>;
  114952. /**
  114953. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114955. * @returns true if engine is in deterministic lock step mode
  114956. */
  114957. isDeterministicLockStep(): boolean;
  114958. /**
  114959. * Gets the max steps when engine is running in deterministic lock step
  114960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114961. * @returns the max steps
  114962. */
  114963. getLockstepMaxSteps(): number;
  114964. /**
  114965. * Returns the time in ms between steps when using deterministic lock step.
  114966. * @returns time step in (ms)
  114967. */
  114968. getTimeStep(): number;
  114969. /**
  114970. * Force the mipmap generation for the given render target texture
  114971. * @param texture defines the render target texture to use
  114972. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114973. */
  114974. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114975. /** States */
  114976. /**
  114977. * Set various states to the webGL context
  114978. * @param culling defines backface culling state
  114979. * @param zOffset defines the value to apply to zOffset (0 by default)
  114980. * @param force defines if states must be applied even if cache is up to date
  114981. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114982. */
  114983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114984. /**
  114985. * Set the z offset to apply to current rendering
  114986. * @param value defines the offset to apply
  114987. */
  114988. setZOffset(value: number): void;
  114989. /**
  114990. * Gets the current value of the zOffset
  114991. * @returns the current zOffset state
  114992. */
  114993. getZOffset(): number;
  114994. /**
  114995. * Enable or disable depth buffering
  114996. * @param enable defines the state to set
  114997. */
  114998. setDepthBuffer(enable: boolean): void;
  114999. /**
  115000. * Gets a boolean indicating if depth writing is enabled
  115001. * @returns the current depth writing state
  115002. */
  115003. getDepthWrite(): boolean;
  115004. /**
  115005. * Enable or disable depth writing
  115006. * @param enable defines the state to set
  115007. */
  115008. setDepthWrite(enable: boolean): void;
  115009. /**
  115010. * Gets a boolean indicating if stencil buffer is enabled
  115011. * @returns the current stencil buffer state
  115012. */
  115013. getStencilBuffer(): boolean;
  115014. /**
  115015. * Enable or disable the stencil buffer
  115016. * @param enable defines if the stencil buffer must be enabled or disabled
  115017. */
  115018. setStencilBuffer(enable: boolean): void;
  115019. /**
  115020. * Gets the current stencil mask
  115021. * @returns a number defining the new stencil mask to use
  115022. */
  115023. getStencilMask(): number;
  115024. /**
  115025. * Sets the current stencil mask
  115026. * @param mask defines the new stencil mask to use
  115027. */
  115028. setStencilMask(mask: number): void;
  115029. /**
  115030. * Gets the current stencil function
  115031. * @returns a number defining the stencil function to use
  115032. */
  115033. getStencilFunction(): number;
  115034. /**
  115035. * Gets the current stencil reference value
  115036. * @returns a number defining the stencil reference value to use
  115037. */
  115038. getStencilFunctionReference(): number;
  115039. /**
  115040. * Gets the current stencil mask
  115041. * @returns a number defining the stencil mask to use
  115042. */
  115043. getStencilFunctionMask(): number;
  115044. /**
  115045. * Sets the current stencil function
  115046. * @param stencilFunc defines the new stencil function to use
  115047. */
  115048. setStencilFunction(stencilFunc: number): void;
  115049. /**
  115050. * Sets the current stencil reference
  115051. * @param reference defines the new stencil reference to use
  115052. */
  115053. setStencilFunctionReference(reference: number): void;
  115054. /**
  115055. * Sets the current stencil mask
  115056. * @param mask defines the new stencil mask to use
  115057. */
  115058. setStencilFunctionMask(mask: number): void;
  115059. /**
  115060. * Gets the current stencil operation when stencil fails
  115061. * @returns a number defining stencil operation to use when stencil fails
  115062. */
  115063. getStencilOperationFail(): number;
  115064. /**
  115065. * Gets the current stencil operation when depth fails
  115066. * @returns a number defining stencil operation to use when depth fails
  115067. */
  115068. getStencilOperationDepthFail(): number;
  115069. /**
  115070. * Gets the current stencil operation when stencil passes
  115071. * @returns a number defining stencil operation to use when stencil passes
  115072. */
  115073. getStencilOperationPass(): number;
  115074. /**
  115075. * Sets the stencil operation to use when stencil fails
  115076. * @param operation defines the stencil operation to use when stencil fails
  115077. */
  115078. setStencilOperationFail(operation: number): void;
  115079. /**
  115080. * Sets the stencil operation to use when depth fails
  115081. * @param operation defines the stencil operation to use when depth fails
  115082. */
  115083. setStencilOperationDepthFail(operation: number): void;
  115084. /**
  115085. * Sets the stencil operation to use when stencil passes
  115086. * @param operation defines the stencil operation to use when stencil passes
  115087. */
  115088. setStencilOperationPass(operation: number): void;
  115089. /**
  115090. * Sets a boolean indicating if the dithering state is enabled or disabled
  115091. * @param value defines the dithering state
  115092. */
  115093. setDitheringState(value: boolean): void;
  115094. /**
  115095. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115096. * @param value defines the rasterizer state
  115097. */
  115098. setRasterizerState(value: boolean): void;
  115099. /**
  115100. * Gets the current depth function
  115101. * @returns a number defining the depth function
  115102. */
  115103. getDepthFunction(): Nullable<number>;
  115104. /**
  115105. * Sets the current depth function
  115106. * @param depthFunc defines the function to use
  115107. */
  115108. setDepthFunction(depthFunc: number): void;
  115109. /**
  115110. * Sets the current depth function to GREATER
  115111. */
  115112. setDepthFunctionToGreater(): void;
  115113. /**
  115114. * Sets the current depth function to GEQUAL
  115115. */
  115116. setDepthFunctionToGreaterOrEqual(): void;
  115117. /**
  115118. * Sets the current depth function to LESS
  115119. */
  115120. setDepthFunctionToLess(): void;
  115121. /**
  115122. * Sets the current depth function to LEQUAL
  115123. */
  115124. setDepthFunctionToLessOrEqual(): void;
  115125. private _cachedStencilBuffer;
  115126. private _cachedStencilFunction;
  115127. private _cachedStencilMask;
  115128. private _cachedStencilOperationPass;
  115129. private _cachedStencilOperationFail;
  115130. private _cachedStencilOperationDepthFail;
  115131. private _cachedStencilReference;
  115132. /**
  115133. * Caches the the state of the stencil buffer
  115134. */
  115135. cacheStencilState(): void;
  115136. /**
  115137. * Restores the state of the stencil buffer
  115138. */
  115139. restoreStencilState(): void;
  115140. /**
  115141. * Directly set the WebGL Viewport
  115142. * @param x defines the x coordinate of the viewport (in screen space)
  115143. * @param y defines the y coordinate of the viewport (in screen space)
  115144. * @param width defines the width of the viewport (in screen space)
  115145. * @param height defines the height of the viewport (in screen space)
  115146. * @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
  115147. */
  115148. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115149. /**
  115150. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115151. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115152. * @param y defines the y-coordinate of the corner of the clear rectangle
  115153. * @param width defines the width of the clear rectangle
  115154. * @param height defines the height of the clear rectangle
  115155. * @param clearColor defines the clear color
  115156. */
  115157. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115158. /**
  115159. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115160. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115161. * @param y defines the y-coordinate of the corner of the clear rectangle
  115162. * @param width defines the width of the clear rectangle
  115163. * @param height defines the height of the clear rectangle
  115164. */
  115165. enableScissor(x: number, y: number, width: number, height: number): void;
  115166. /**
  115167. * Disable previously set scissor test rectangle
  115168. */
  115169. disableScissor(): void;
  115170. protected _reportDrawCall(): void;
  115171. /**
  115172. * Initializes a webVR display and starts listening to display change events
  115173. * The onVRDisplayChangedObservable will be notified upon these changes
  115174. * @returns The onVRDisplayChangedObservable
  115175. */
  115176. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115177. /** @hidden */
  115178. _prepareVRComponent(): void;
  115179. /** @hidden */
  115180. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115181. /** @hidden */
  115182. _submitVRFrame(): void;
  115183. /**
  115184. * Call this function to leave webVR mode
  115185. * Will do nothing if webVR is not supported or if there is no webVR device
  115186. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115187. */
  115188. disableVR(): void;
  115189. /**
  115190. * Gets a boolean indicating that the system is in VR mode and is presenting
  115191. * @returns true if VR mode is engaged
  115192. */
  115193. isVRPresenting(): boolean;
  115194. /** @hidden */
  115195. _requestVRFrame(): void;
  115196. /** @hidden */
  115197. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115198. /**
  115199. * Gets the source code of the vertex shader associated with a specific webGL program
  115200. * @param program defines the program to use
  115201. * @returns a string containing the source code of the vertex shader associated with the program
  115202. */
  115203. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115204. /**
  115205. * Gets the source code of the fragment shader associated with a specific webGL program
  115206. * @param program defines the program to use
  115207. * @returns a string containing the source code of the fragment shader associated with the program
  115208. */
  115209. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115210. /**
  115211. * Sets a depth stencil texture from a render target to the according uniform.
  115212. * @param channel The texture channel
  115213. * @param uniform The uniform to set
  115214. * @param texture The render target texture containing the depth stencil texture to apply
  115215. */
  115216. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115217. /**
  115218. * Sets a texture to the webGL context from a postprocess
  115219. * @param channel defines the channel to use
  115220. * @param postProcess defines the source postprocess
  115221. */
  115222. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115223. /**
  115224. * Binds the output of the passed in post process to the texture channel specified
  115225. * @param channel The channel the texture should be bound to
  115226. * @param postProcess The post process which's output should be bound
  115227. */
  115228. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115229. protected _rebuildBuffers(): void;
  115230. /** @hidden */
  115231. _renderFrame(): void;
  115232. _renderLoop(): void;
  115233. /** @hidden */
  115234. _renderViews(): boolean;
  115235. /**
  115236. * Toggle full screen mode
  115237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115238. */
  115239. switchFullscreen(requestPointerLock: boolean): void;
  115240. /**
  115241. * Enters full screen mode
  115242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115243. */
  115244. enterFullscreen(requestPointerLock: boolean): void;
  115245. /**
  115246. * Exits full screen mode
  115247. */
  115248. exitFullscreen(): void;
  115249. /**
  115250. * Enters Pointerlock mode
  115251. */
  115252. enterPointerlock(): void;
  115253. /**
  115254. * Exits Pointerlock mode
  115255. */
  115256. exitPointerlock(): void;
  115257. /**
  115258. * Begin a new frame
  115259. */
  115260. beginFrame(): void;
  115261. /**
  115262. * Enf the current frame
  115263. */
  115264. endFrame(): void;
  115265. resize(): void;
  115266. /**
  115267. * Force a specific size of the canvas
  115268. * @param width defines the new canvas' width
  115269. * @param height defines the new canvas' height
  115270. * @returns true if the size was changed
  115271. */
  115272. setSize(width: number, height: number): boolean;
  115273. /**
  115274. * Updates a dynamic vertex buffer.
  115275. * @param vertexBuffer the vertex buffer to update
  115276. * @param data the data used to update the vertex buffer
  115277. * @param byteOffset the byte offset of the data
  115278. * @param byteLength the byte length of the data
  115279. */
  115280. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115281. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115283. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115284. _releaseTexture(texture: InternalTexture): void;
  115285. /**
  115286. * @hidden
  115287. * Rescales a texture
  115288. * @param source input texutre
  115289. * @param destination destination texture
  115290. * @param scene scene to use to render the resize
  115291. * @param internalFormat format to use when resizing
  115292. * @param onComplete callback to be called when resize has completed
  115293. */
  115294. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115295. /**
  115296. * Gets the current framerate
  115297. * @returns a number representing the framerate
  115298. */
  115299. getFps(): number;
  115300. /**
  115301. * Gets the time spent between current and previous frame
  115302. * @returns a number representing the delta time in ms
  115303. */
  115304. getDeltaTime(): number;
  115305. private _measureFps;
  115306. /** @hidden */
  115307. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115308. /**
  115309. * Update a dynamic index buffer
  115310. * @param indexBuffer defines the target index buffer
  115311. * @param indices defines the data to update
  115312. * @param offset defines the offset in the target index buffer where update should start
  115313. */
  115314. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115315. /**
  115316. * Updates the sample count of a render target texture
  115317. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115318. * @param texture defines the texture to update
  115319. * @param samples defines the sample count to set
  115320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115321. */
  115322. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115323. /**
  115324. * Updates a depth texture Comparison Mode and Function.
  115325. * If the comparison Function is equal to 0, the mode will be set to none.
  115326. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115327. * @param texture The texture to set the comparison function for
  115328. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115329. */
  115330. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115331. /**
  115332. * Creates a webGL buffer to use with instanciation
  115333. * @param capacity defines the size of the buffer
  115334. * @returns the webGL buffer
  115335. */
  115336. createInstancesBuffer(capacity: number): DataBuffer;
  115337. /**
  115338. * Delete a webGL buffer used with instanciation
  115339. * @param buffer defines the webGL buffer to delete
  115340. */
  115341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115342. private _clientWaitAsync;
  115343. /** @hidden */
  115344. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115345. dispose(): void;
  115346. private _disableTouchAction;
  115347. /**
  115348. * Display the loading screen
  115349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115350. */
  115351. displayLoadingUI(): void;
  115352. /**
  115353. * Hide the loading screen
  115354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115355. */
  115356. hideLoadingUI(): void;
  115357. /**
  115358. * Gets the current loading screen object
  115359. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115360. */
  115361. get loadingScreen(): ILoadingScreen;
  115362. /**
  115363. * Sets the current loading screen object
  115364. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115365. */
  115366. set loadingScreen(loadingScreen: ILoadingScreen);
  115367. /**
  115368. * Sets the current loading screen text
  115369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115370. */
  115371. set loadingUIText(text: string);
  115372. /**
  115373. * Sets the current loading screen background color
  115374. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115375. */
  115376. set loadingUIBackgroundColor(color: string);
  115377. /** Pointerlock and fullscreen */
  115378. /**
  115379. * Ask the browser to promote the current element to pointerlock mode
  115380. * @param element defines the DOM element to promote
  115381. */
  115382. static _RequestPointerlock(element: HTMLElement): void;
  115383. /**
  115384. * Asks the browser to exit pointerlock mode
  115385. */
  115386. static _ExitPointerlock(): void;
  115387. /**
  115388. * Ask the browser to promote the current element to fullscreen rendering mode
  115389. * @param element defines the DOM element to promote
  115390. */
  115391. static _RequestFullscreen(element: HTMLElement): void;
  115392. /**
  115393. * Asks the browser to exit fullscreen mode
  115394. */
  115395. static _ExitFullscreen(): void;
  115396. }
  115397. }
  115398. declare module BABYLON {
  115399. /**
  115400. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115401. * during the life time of the application.
  115402. */
  115403. export class EngineStore {
  115404. /** Gets the list of created engines */
  115405. static Instances: Engine[];
  115406. /** @hidden */
  115407. static _LastCreatedScene: Nullable<Scene>;
  115408. /**
  115409. * Gets the latest created engine
  115410. */
  115411. static get LastCreatedEngine(): Nullable<Engine>;
  115412. /**
  115413. * Gets the latest created scene
  115414. */
  115415. static get LastCreatedScene(): Nullable<Scene>;
  115416. /**
  115417. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115418. * @ignorenaming
  115419. */
  115420. static UseFallbackTexture: boolean;
  115421. /**
  115422. * Texture content used if a texture cannot loaded
  115423. * @ignorenaming
  115424. */
  115425. static FallbackTexture: string;
  115426. }
  115427. }
  115428. declare module BABYLON {
  115429. /**
  115430. * Helper class that provides a small promise polyfill
  115431. */
  115432. export class PromisePolyfill {
  115433. /**
  115434. * Static function used to check if the polyfill is required
  115435. * If this is the case then the function will inject the polyfill to window.Promise
  115436. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115437. */
  115438. static Apply(force?: boolean): void;
  115439. }
  115440. }
  115441. declare module BABYLON {
  115442. /**
  115443. * Interface for screenshot methods with describe argument called `size` as object with options
  115444. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115445. */
  115446. export interface IScreenshotSize {
  115447. /**
  115448. * number in pixels for canvas height
  115449. */
  115450. height?: number;
  115451. /**
  115452. * multiplier allowing render at a higher or lower resolution
  115453. * If value is defined then height and width will be ignored and taken from camera
  115454. */
  115455. precision?: number;
  115456. /**
  115457. * number in pixels for canvas width
  115458. */
  115459. width?: number;
  115460. }
  115461. }
  115462. declare module BABYLON {
  115463. interface IColor4Like {
  115464. r: float;
  115465. g: float;
  115466. b: float;
  115467. a: float;
  115468. }
  115469. /**
  115470. * Class containing a set of static utilities functions
  115471. */
  115472. export class Tools {
  115473. /**
  115474. * Gets or sets the base URL to use to load assets
  115475. */
  115476. static get BaseUrl(): string;
  115477. static set BaseUrl(value: string);
  115478. /**
  115479. * Enable/Disable Custom HTTP Request Headers globally.
  115480. * default = false
  115481. * @see CustomRequestHeaders
  115482. */
  115483. static UseCustomRequestHeaders: boolean;
  115484. /**
  115485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115486. * i.e. when loading files, where the server/service expects an Authorization header
  115487. */
  115488. static CustomRequestHeaders: {
  115489. [key: string]: string;
  115490. };
  115491. /**
  115492. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115493. */
  115494. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115495. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115496. /**
  115497. * Default behaviour for cors in the application.
  115498. * It can be a string if the expected behavior is identical in the entire app.
  115499. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115500. */
  115501. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115502. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115503. /**
  115504. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115505. * @ignorenaming
  115506. */
  115507. static get UseFallbackTexture(): boolean;
  115508. static set UseFallbackTexture(value: boolean);
  115509. /**
  115510. * Use this object to register external classes like custom textures or material
  115511. * to allow the laoders to instantiate them
  115512. */
  115513. static get RegisteredExternalClasses(): {
  115514. [key: string]: Object;
  115515. };
  115516. static set RegisteredExternalClasses(classes: {
  115517. [key: string]: Object;
  115518. });
  115519. /**
  115520. * Texture content used if a texture cannot loaded
  115521. * @ignorenaming
  115522. */
  115523. static get fallbackTexture(): string;
  115524. static set fallbackTexture(value: string);
  115525. /**
  115526. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115527. * @param u defines the coordinate on X axis
  115528. * @param v defines the coordinate on Y axis
  115529. * @param width defines the width of the source data
  115530. * @param height defines the height of the source data
  115531. * @param pixels defines the source byte array
  115532. * @param color defines the output color
  115533. */
  115534. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115535. /**
  115536. * Interpolates between a and b via alpha
  115537. * @param a The lower value (returned when alpha = 0)
  115538. * @param b The upper value (returned when alpha = 1)
  115539. * @param alpha The interpolation-factor
  115540. * @return The mixed value
  115541. */
  115542. static Mix(a: number, b: number, alpha: number): number;
  115543. /**
  115544. * Tries to instantiate a new object from a given class name
  115545. * @param className defines the class name to instantiate
  115546. * @returns the new object or null if the system was not able to do the instantiation
  115547. */
  115548. static Instantiate(className: string): any;
  115549. /**
  115550. * Provides a slice function that will work even on IE
  115551. * @param data defines the array to slice
  115552. * @param start defines the start of the data (optional)
  115553. * @param end defines the end of the data (optional)
  115554. * @returns the new sliced array
  115555. */
  115556. static Slice<T>(data: T, start?: number, end?: number): T;
  115557. /**
  115558. * Polyfill for setImmediate
  115559. * @param action defines the action to execute after the current execution block
  115560. */
  115561. static SetImmediate(action: () => void): void;
  115562. /**
  115563. * Function indicating if a number is an exponent of 2
  115564. * @param value defines the value to test
  115565. * @returns true if the value is an exponent of 2
  115566. */
  115567. static IsExponentOfTwo(value: number): boolean;
  115568. private static _tmpFloatArray;
  115569. /**
  115570. * Returns the nearest 32-bit single precision float representation of a Number
  115571. * @param value A Number. If the parameter is of a different type, it will get converted
  115572. * to a number or to NaN if it cannot be converted
  115573. * @returns number
  115574. */
  115575. static FloatRound(value: number): number;
  115576. /**
  115577. * Extracts the filename from a path
  115578. * @param path defines the path to use
  115579. * @returns the filename
  115580. */
  115581. static GetFilename(path: string): string;
  115582. /**
  115583. * Extracts the "folder" part of a path (everything before the filename).
  115584. * @param uri The URI to extract the info from
  115585. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115586. * @returns The "folder" part of the path
  115587. */
  115588. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115589. /**
  115590. * Extracts text content from a DOM element hierarchy
  115591. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115592. */
  115593. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115594. /**
  115595. * Convert an angle in radians to degrees
  115596. * @param angle defines the angle to convert
  115597. * @returns the angle in degrees
  115598. */
  115599. static ToDegrees(angle: number): number;
  115600. /**
  115601. * Convert an angle in degrees to radians
  115602. * @param angle defines the angle to convert
  115603. * @returns the angle in radians
  115604. */
  115605. static ToRadians(angle: number): number;
  115606. /**
  115607. * Returns an array if obj is not an array
  115608. * @param obj defines the object to evaluate as an array
  115609. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115610. * @returns either obj directly if obj is an array or a new array containing obj
  115611. */
  115612. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115613. /**
  115614. * Gets the pointer prefix to use
  115615. * @param engine defines the engine we are finding the prefix for
  115616. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115617. */
  115618. static GetPointerPrefix(engine: Engine): string;
  115619. /**
  115620. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115621. * @param url define the url we are trying
  115622. * @param element define the dom element where to configure the cors policy
  115623. */
  115624. static SetCorsBehavior(url: string | string[], element: {
  115625. crossOrigin: string | null;
  115626. }): void;
  115627. /**
  115628. * Removes unwanted characters from an url
  115629. * @param url defines the url to clean
  115630. * @returns the cleaned url
  115631. */
  115632. static CleanUrl(url: string): string;
  115633. /**
  115634. * Gets or sets a function used to pre-process url before using them to load assets
  115635. */
  115636. static get PreprocessUrl(): (url: string) => string;
  115637. static set PreprocessUrl(processor: (url: string) => string);
  115638. /**
  115639. * Loads an image as an HTMLImageElement.
  115640. * @param input url string, ArrayBuffer, or Blob to load
  115641. * @param onLoad callback called when the image successfully loads
  115642. * @param onError callback called when the image fails to load
  115643. * @param offlineProvider offline provider for caching
  115644. * @param mimeType optional mime type
  115645. * @returns the HTMLImageElement of the loaded image
  115646. */
  115647. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115648. /**
  115649. * Loads a file from a url
  115650. * @param url url string, ArrayBuffer, or Blob to load
  115651. * @param onSuccess callback called when the file successfully loads
  115652. * @param onProgress callback called while file is loading (if the server supports this mode)
  115653. * @param offlineProvider defines the offline provider for caching
  115654. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115655. * @param onError callback called when the file fails to load
  115656. * @returns a file request object
  115657. */
  115658. 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;
  115659. /**
  115660. * Loads a file from a url
  115661. * @param url the file url to load
  115662. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115663. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115664. */
  115665. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115666. /**
  115667. * Load a script (identified by an url). When the url returns, the
  115668. * content of this file is added into a new script element, attached to the DOM (body element)
  115669. * @param scriptUrl defines the url of the script to laod
  115670. * @param onSuccess defines the callback called when the script is loaded
  115671. * @param onError defines the callback to call if an error occurs
  115672. * @param scriptId defines the id of the script element
  115673. */
  115674. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115675. /**
  115676. * Load an asynchronous script (identified by an url). When the url returns, the
  115677. * content of this file is added into a new script element, attached to the DOM (body element)
  115678. * @param scriptUrl defines the url of the script to laod
  115679. * @param scriptId defines the id of the script element
  115680. * @returns a promise request object
  115681. */
  115682. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115683. /**
  115684. * Loads a file from a blob
  115685. * @param fileToLoad defines the blob to use
  115686. * @param callback defines the callback to call when data is loaded
  115687. * @param progressCallback defines the callback to call during loading process
  115688. * @returns a file request object
  115689. */
  115690. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115691. /**
  115692. * Reads a file from a File object
  115693. * @param file defines the file to load
  115694. * @param onSuccess defines the callback to call when data is loaded
  115695. * @param onProgress defines the callback to call during loading process
  115696. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115697. * @param onError defines the callback to call when an error occurs
  115698. * @returns a file request object
  115699. */
  115700. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115701. /**
  115702. * Creates a data url from a given string content
  115703. * @param content defines the content to convert
  115704. * @returns the new data url link
  115705. */
  115706. static FileAsURL(content: string): string;
  115707. /**
  115708. * Format the given number to a specific decimal format
  115709. * @param value defines the number to format
  115710. * @param decimals defines the number of decimals to use
  115711. * @returns the formatted string
  115712. */
  115713. static Format(value: number, decimals?: number): string;
  115714. /**
  115715. * Tries to copy an object by duplicating every property
  115716. * @param source defines the source object
  115717. * @param destination defines the target object
  115718. * @param doNotCopyList defines a list of properties to avoid
  115719. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115720. */
  115721. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115722. /**
  115723. * Gets a boolean indicating if the given object has no own property
  115724. * @param obj defines the object to test
  115725. * @returns true if object has no own property
  115726. */
  115727. static IsEmpty(obj: any): boolean;
  115728. /**
  115729. * Function used to register events at window level
  115730. * @param windowElement defines the Window object to use
  115731. * @param events defines the events to register
  115732. */
  115733. static RegisterTopRootEvents(windowElement: Window, events: {
  115734. name: string;
  115735. handler: Nullable<(e: FocusEvent) => any>;
  115736. }[]): void;
  115737. /**
  115738. * Function used to unregister events from window level
  115739. * @param windowElement defines the Window object to use
  115740. * @param events defines the events to unregister
  115741. */
  115742. static UnregisterTopRootEvents(windowElement: Window, events: {
  115743. name: string;
  115744. handler: Nullable<(e: FocusEvent) => any>;
  115745. }[]): void;
  115746. /**
  115747. * @ignore
  115748. */
  115749. static _ScreenshotCanvas: HTMLCanvasElement;
  115750. /**
  115751. * Dumps the current bound framebuffer
  115752. * @param width defines the rendering width
  115753. * @param height defines the rendering height
  115754. * @param engine defines the hosting engine
  115755. * @param successCallback defines the callback triggered once the data are available
  115756. * @param mimeType defines the mime type of the result
  115757. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115758. */
  115759. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115760. /**
  115761. * Converts the canvas data to blob.
  115762. * This acts as a polyfill for browsers not supporting the to blob function.
  115763. * @param canvas Defines the canvas to extract the data from
  115764. * @param successCallback Defines the callback triggered once the data are available
  115765. * @param mimeType Defines the mime type of the result
  115766. */
  115767. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115768. /**
  115769. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115770. * @param successCallback defines the callback triggered once the data are available
  115771. * @param mimeType defines the mime type of the result
  115772. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115773. */
  115774. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115775. /**
  115776. * Downloads a blob in the browser
  115777. * @param blob defines the blob to download
  115778. * @param fileName defines the name of the downloaded file
  115779. */
  115780. static Download(blob: Blob, fileName: string): void;
  115781. /**
  115782. * Captures a screenshot of the current rendering
  115783. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115784. * @param engine defines the rendering engine
  115785. * @param camera defines the source camera
  115786. * @param size This parameter can be set to a single number or to an object with the
  115787. * following (optional) properties: precision, width, height. If a single number is passed,
  115788. * it will be used for both width and height. If an object is passed, the screenshot size
  115789. * will be derived from the parameters. The precision property is a multiplier allowing
  115790. * rendering at a higher or lower resolution
  115791. * @param successCallback defines the callback receives a single parameter which contains the
  115792. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115793. * src parameter of an <img> to display it
  115794. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115795. * Check your browser for supported MIME types
  115796. */
  115797. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115798. /**
  115799. * Captures a screenshot of the current rendering
  115800. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115801. * @param engine defines the rendering engine
  115802. * @param camera defines the source camera
  115803. * @param size This parameter can be set to a single number or to an object with the
  115804. * following (optional) properties: precision, width, height. If a single number is passed,
  115805. * it will be used for both width and height. If an object is passed, the screenshot size
  115806. * will be derived from the parameters. The precision property is a multiplier allowing
  115807. * rendering at a higher or lower resolution
  115808. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115809. * Check your browser for supported MIME types
  115810. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115811. * to the src parameter of an <img> to display it
  115812. */
  115813. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115814. /**
  115815. * Generates an image screenshot from the specified camera.
  115816. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115817. * @param engine The engine to use for rendering
  115818. * @param camera The camera to use for rendering
  115819. * @param size This parameter can be set to a single number or to an object with the
  115820. * following (optional) properties: precision, width, height. If a single number is passed,
  115821. * it will be used for both width and height. If an object is passed, the screenshot size
  115822. * will be derived from the parameters. The precision property is a multiplier allowing
  115823. * rendering at a higher or lower resolution
  115824. * @param successCallback The callback receives a single parameter which contains the
  115825. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115826. * src parameter of an <img> to display it
  115827. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115828. * Check your browser for supported MIME types
  115829. * @param samples Texture samples (default: 1)
  115830. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115831. * @param fileName A name for for the downloaded file.
  115832. */
  115833. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115834. /**
  115835. * Generates an image screenshot from the specified camera.
  115836. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115837. * @param engine The engine to use for rendering
  115838. * @param camera The camera to use for rendering
  115839. * @param size This parameter can be set to a single number or to an object with the
  115840. * following (optional) properties: precision, width, height. If a single number is passed,
  115841. * it will be used for both width and height. If an object is passed, the screenshot size
  115842. * will be derived from the parameters. The precision property is a multiplier allowing
  115843. * rendering at a higher or lower resolution
  115844. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115845. * Check your browser for supported MIME types
  115846. * @param samples Texture samples (default: 1)
  115847. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115848. * @param fileName A name for for the downloaded file.
  115849. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115850. * to the src parameter of an <img> to display it
  115851. */
  115852. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115853. /**
  115854. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115855. * Be aware Math.random() could cause collisions, but:
  115856. * "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"
  115857. * @returns a pseudo random id
  115858. */
  115859. static RandomId(): string;
  115860. /**
  115861. * Test if the given uri is a base64 string
  115862. * @param uri The uri to test
  115863. * @return True if the uri is a base64 string or false otherwise
  115864. */
  115865. static IsBase64(uri: string): boolean;
  115866. /**
  115867. * Decode the given base64 uri.
  115868. * @param uri The uri to decode
  115869. * @return The decoded base64 data.
  115870. */
  115871. static DecodeBase64(uri: string): ArrayBuffer;
  115872. /**
  115873. * Gets the absolute url.
  115874. * @param url the input url
  115875. * @return the absolute url
  115876. */
  115877. static GetAbsoluteUrl(url: string): string;
  115878. /**
  115879. * No log
  115880. */
  115881. static readonly NoneLogLevel: number;
  115882. /**
  115883. * Only message logs
  115884. */
  115885. static readonly MessageLogLevel: number;
  115886. /**
  115887. * Only warning logs
  115888. */
  115889. static readonly WarningLogLevel: number;
  115890. /**
  115891. * Only error logs
  115892. */
  115893. static readonly ErrorLogLevel: number;
  115894. /**
  115895. * All logs
  115896. */
  115897. static readonly AllLogLevel: number;
  115898. /**
  115899. * Gets a value indicating the number of loading errors
  115900. * @ignorenaming
  115901. */
  115902. static get errorsCount(): number;
  115903. /**
  115904. * Callback called when a new log is added
  115905. */
  115906. static OnNewCacheEntry: (entry: string) => void;
  115907. /**
  115908. * Log a message to the console
  115909. * @param message defines the message to log
  115910. */
  115911. static Log(message: string): void;
  115912. /**
  115913. * Write a warning message to the console
  115914. * @param message defines the message to log
  115915. */
  115916. static Warn(message: string): void;
  115917. /**
  115918. * Write an error message to the console
  115919. * @param message defines the message to log
  115920. */
  115921. static Error(message: string): void;
  115922. /**
  115923. * Gets current log cache (list of logs)
  115924. */
  115925. static get LogCache(): string;
  115926. /**
  115927. * Clears the log cache
  115928. */
  115929. static ClearLogCache(): void;
  115930. /**
  115931. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115932. */
  115933. static set LogLevels(level: number);
  115934. /**
  115935. * Checks if the window object exists
  115936. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115937. */
  115938. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115939. /**
  115940. * No performance log
  115941. */
  115942. static readonly PerformanceNoneLogLevel: number;
  115943. /**
  115944. * Use user marks to log performance
  115945. */
  115946. static readonly PerformanceUserMarkLogLevel: number;
  115947. /**
  115948. * Log performance to the console
  115949. */
  115950. static readonly PerformanceConsoleLogLevel: number;
  115951. private static _performance;
  115952. /**
  115953. * Sets the current performance log level
  115954. */
  115955. static set PerformanceLogLevel(level: number);
  115956. private static _StartPerformanceCounterDisabled;
  115957. private static _EndPerformanceCounterDisabled;
  115958. private static _StartUserMark;
  115959. private static _EndUserMark;
  115960. private static _StartPerformanceConsole;
  115961. private static _EndPerformanceConsole;
  115962. /**
  115963. * Starts a performance counter
  115964. */
  115965. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115966. /**
  115967. * Ends a specific performance coutner
  115968. */
  115969. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115970. /**
  115971. * Gets either window.performance.now() if supported or Date.now() else
  115972. */
  115973. static get Now(): number;
  115974. /**
  115975. * This method will return the name of the class used to create the instance of the given object.
  115976. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115977. * @param object the object to get the class name from
  115978. * @param isType defines if the object is actually a type
  115979. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115980. */
  115981. static GetClassName(object: any, isType?: boolean): string;
  115982. /**
  115983. * Gets the first element of an array satisfying a given predicate
  115984. * @param array defines the array to browse
  115985. * @param predicate defines the predicate to use
  115986. * @returns null if not found or the element
  115987. */
  115988. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115989. /**
  115990. * This method will return the name of the full name of the class, including its owning module (if any).
  115991. * 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).
  115992. * @param object the object to get the class name from
  115993. * @param isType defines if the object is actually a type
  115994. * @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.
  115995. * @ignorenaming
  115996. */
  115997. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115998. /**
  115999. * Returns a promise that resolves after the given amount of time.
  116000. * @param delay Number of milliseconds to delay
  116001. * @returns Promise that resolves after the given amount of time
  116002. */
  116003. static DelayAsync(delay: number): Promise<void>;
  116004. /**
  116005. * Utility function to detect if the current user agent is Safari
  116006. * @returns whether or not the current user agent is safari
  116007. */
  116008. static IsSafari(): boolean;
  116009. }
  116010. /**
  116011. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116012. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116013. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116014. * @param name The name of the class, case should be preserved
  116015. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116016. */
  116017. export function className(name: string, module?: string): (target: Object) => void;
  116018. /**
  116019. * An implementation of a loop for asynchronous functions.
  116020. */
  116021. export class AsyncLoop {
  116022. /**
  116023. * Defines the number of iterations for the loop
  116024. */
  116025. iterations: number;
  116026. /**
  116027. * Defines the current index of the loop.
  116028. */
  116029. index: number;
  116030. private _done;
  116031. private _fn;
  116032. private _successCallback;
  116033. /**
  116034. * Constructor.
  116035. * @param iterations the number of iterations.
  116036. * @param func the function to run each iteration
  116037. * @param successCallback the callback that will be called upon succesful execution
  116038. * @param offset starting offset.
  116039. */
  116040. constructor(
  116041. /**
  116042. * Defines the number of iterations for the loop
  116043. */
  116044. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116045. /**
  116046. * Execute the next iteration. Must be called after the last iteration was finished.
  116047. */
  116048. executeNext(): void;
  116049. /**
  116050. * Break the loop and run the success callback.
  116051. */
  116052. breakLoop(): void;
  116053. /**
  116054. * Create and run an async loop.
  116055. * @param iterations the number of iterations.
  116056. * @param fn the function to run each iteration
  116057. * @param successCallback the callback that will be called upon succesful execution
  116058. * @param offset starting offset.
  116059. * @returns the created async loop object
  116060. */
  116061. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116062. /**
  116063. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116064. * @param iterations total number of iterations
  116065. * @param syncedIterations number of synchronous iterations in each async iteration.
  116066. * @param fn the function to call each iteration.
  116067. * @param callback a success call back that will be called when iterating stops.
  116068. * @param breakFunction a break condition (optional)
  116069. * @param timeout timeout settings for the setTimeout function. default - 0.
  116070. * @returns the created async loop object
  116071. */
  116072. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116073. }
  116074. }
  116075. declare module BABYLON {
  116076. /**
  116077. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116078. * The underlying implementation relies on an associative array to ensure the best performances.
  116079. * The value can be anything including 'null' but except 'undefined'
  116080. */
  116081. export class StringDictionary<T> {
  116082. /**
  116083. * This will clear this dictionary and copy the content from the 'source' one.
  116084. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116085. * @param source the dictionary to take the content from and copy to this dictionary
  116086. */
  116087. copyFrom(source: StringDictionary<T>): void;
  116088. /**
  116089. * Get a value based from its key
  116090. * @param key the given key to get the matching value from
  116091. * @return the value if found, otherwise undefined is returned
  116092. */
  116093. get(key: string): T | undefined;
  116094. /**
  116095. * Get a value from its key or add it if it doesn't exist.
  116096. * This method will ensure you that a given key/data will be present in the dictionary.
  116097. * @param key the given key to get the matching value from
  116098. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116099. * The factory will only be invoked if there's no data for the given key.
  116100. * @return the value corresponding to the key.
  116101. */
  116102. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116103. /**
  116104. * Get a value from its key if present in the dictionary otherwise add it
  116105. * @param key the key to get the value from
  116106. * @param val if there's no such key/value pair in the dictionary add it with this value
  116107. * @return the value corresponding to the key
  116108. */
  116109. getOrAdd(key: string, val: T): T;
  116110. /**
  116111. * Check if there's a given key in the dictionary
  116112. * @param key the key to check for
  116113. * @return true if the key is present, false otherwise
  116114. */
  116115. contains(key: string): boolean;
  116116. /**
  116117. * Add a new key and its corresponding value
  116118. * @param key the key to add
  116119. * @param value the value corresponding to the key
  116120. * @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
  116121. */
  116122. add(key: string, value: T): boolean;
  116123. /**
  116124. * Update a specific value associated to a key
  116125. * @param key defines the key to use
  116126. * @param value defines the value to store
  116127. * @returns true if the value was updated (or false if the key was not found)
  116128. */
  116129. set(key: string, value: T): boolean;
  116130. /**
  116131. * Get the element of the given key and remove it from the dictionary
  116132. * @param key defines the key to search
  116133. * @returns the value associated with the key or null if not found
  116134. */
  116135. getAndRemove(key: string): Nullable<T>;
  116136. /**
  116137. * Remove a key/value from the dictionary.
  116138. * @param key the key to remove
  116139. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116140. */
  116141. remove(key: string): boolean;
  116142. /**
  116143. * Clear the whole content of the dictionary
  116144. */
  116145. clear(): void;
  116146. /**
  116147. * Gets the current count
  116148. */
  116149. get count(): number;
  116150. /**
  116151. * Execute a callback on each key/val of the dictionary.
  116152. * Note that you can remove any element in this dictionary in the callback implementation
  116153. * @param callback the callback to execute on a given key/value pair
  116154. */
  116155. forEach(callback: (key: string, val: T) => void): void;
  116156. /**
  116157. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116158. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116159. * Note that you can remove any element in this dictionary in the callback implementation
  116160. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116161. * @returns the first item
  116162. */
  116163. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116164. private _count;
  116165. private _data;
  116166. }
  116167. }
  116168. declare module BABYLON {
  116169. /** @hidden */
  116170. export interface ICollisionCoordinator {
  116171. createCollider(): Collider;
  116172. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116173. init(scene: Scene): void;
  116174. }
  116175. /** @hidden */
  116176. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116177. private _scene;
  116178. private _scaledPosition;
  116179. private _scaledVelocity;
  116180. private _finalPosition;
  116181. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116182. createCollider(): Collider;
  116183. init(scene: Scene): void;
  116184. private _collideWithWorld;
  116185. }
  116186. }
  116187. declare module BABYLON {
  116188. /**
  116189. * Class used to manage all inputs for the scene.
  116190. */
  116191. export class InputManager {
  116192. /** The distance in pixel that you have to move to prevent some events */
  116193. static DragMovementThreshold: number;
  116194. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116195. static LongPressDelay: number;
  116196. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116197. static DoubleClickDelay: number;
  116198. /** If you need to check double click without raising a single click at first click, enable this flag */
  116199. static ExclusiveDoubleClickMode: boolean;
  116200. private _wheelEventName;
  116201. private _onPointerMove;
  116202. private _onPointerDown;
  116203. private _onPointerUp;
  116204. private _initClickEvent;
  116205. private _initActionManager;
  116206. private _delayedSimpleClick;
  116207. private _delayedSimpleClickTimeout;
  116208. private _previousDelayedSimpleClickTimeout;
  116209. private _meshPickProceed;
  116210. private _previousButtonPressed;
  116211. private _currentPickResult;
  116212. private _previousPickResult;
  116213. private _totalPointersPressed;
  116214. private _doubleClickOccured;
  116215. private _pointerOverMesh;
  116216. private _pickedDownMesh;
  116217. private _pickedUpMesh;
  116218. private _pointerX;
  116219. private _pointerY;
  116220. private _unTranslatedPointerX;
  116221. private _unTranslatedPointerY;
  116222. private _startingPointerPosition;
  116223. private _previousStartingPointerPosition;
  116224. private _startingPointerTime;
  116225. private _previousStartingPointerTime;
  116226. private _pointerCaptures;
  116227. private _onKeyDown;
  116228. private _onKeyUp;
  116229. private _onCanvasFocusObserver;
  116230. private _onCanvasBlurObserver;
  116231. private _scene;
  116232. /**
  116233. * Creates a new InputManager
  116234. * @param scene defines the hosting scene
  116235. */
  116236. constructor(scene: Scene);
  116237. /**
  116238. * Gets the mesh that is currently under the pointer
  116239. */
  116240. get meshUnderPointer(): Nullable<AbstractMesh>;
  116241. /**
  116242. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116243. */
  116244. get unTranslatedPointer(): Vector2;
  116245. /**
  116246. * Gets or sets the current on-screen X position of the pointer
  116247. */
  116248. get pointerX(): number;
  116249. set pointerX(value: number);
  116250. /**
  116251. * Gets or sets the current on-screen Y position of the pointer
  116252. */
  116253. get pointerY(): number;
  116254. set pointerY(value: number);
  116255. private _updatePointerPosition;
  116256. private _processPointerMove;
  116257. private _setRayOnPointerInfo;
  116258. private _checkPrePointerObservable;
  116259. /**
  116260. * Use this method to simulate a pointer move on a mesh
  116261. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116262. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116263. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116264. */
  116265. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116266. /**
  116267. * Use this method to simulate a pointer down on a mesh
  116268. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116269. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116270. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116271. */
  116272. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116273. private _processPointerDown;
  116274. /** @hidden */
  116275. _isPointerSwiping(): boolean;
  116276. /**
  116277. * Use this method to simulate a pointer up on a mesh
  116278. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116279. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116280. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116281. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116282. */
  116283. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116284. private _processPointerUp;
  116285. /**
  116286. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116287. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116288. * @returns true if the pointer was captured
  116289. */
  116290. isPointerCaptured(pointerId?: number): boolean;
  116291. /**
  116292. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116293. * @param attachUp defines if you want to attach events to pointerup
  116294. * @param attachDown defines if you want to attach events to pointerdown
  116295. * @param attachMove defines if you want to attach events to pointermove
  116296. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116297. */
  116298. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116299. /**
  116300. * Detaches all event handlers
  116301. */
  116302. detachControl(): void;
  116303. /**
  116304. * Force the value of meshUnderPointer
  116305. * @param mesh defines the mesh to use
  116306. */
  116307. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116308. /**
  116309. * Gets the mesh under the pointer
  116310. * @returns a Mesh or null if no mesh is under the pointer
  116311. */
  116312. getPointerOverMesh(): Nullable<AbstractMesh>;
  116313. }
  116314. }
  116315. declare module BABYLON {
  116316. /**
  116317. * This class defines the direct association between an animation and a target
  116318. */
  116319. export class TargetedAnimation {
  116320. /**
  116321. * Animation to perform
  116322. */
  116323. animation: Animation;
  116324. /**
  116325. * Target to animate
  116326. */
  116327. target: any;
  116328. /**
  116329. * Returns the string "TargetedAnimation"
  116330. * @returns "TargetedAnimation"
  116331. */
  116332. getClassName(): string;
  116333. /**
  116334. * Serialize the object
  116335. * @returns the JSON object representing the current entity
  116336. */
  116337. serialize(): any;
  116338. }
  116339. /**
  116340. * Use this class to create coordinated animations on multiple targets
  116341. */
  116342. export class AnimationGroup implements IDisposable {
  116343. /** The name of the animation group */
  116344. name: string;
  116345. private _scene;
  116346. private _targetedAnimations;
  116347. private _animatables;
  116348. private _from;
  116349. private _to;
  116350. private _isStarted;
  116351. private _isPaused;
  116352. private _speedRatio;
  116353. private _loopAnimation;
  116354. private _isAdditive;
  116355. /**
  116356. * Gets or sets the unique id of the node
  116357. */
  116358. uniqueId: number;
  116359. /**
  116360. * This observable will notify when one animation have ended
  116361. */
  116362. onAnimationEndObservable: Observable<TargetedAnimation>;
  116363. /**
  116364. * Observer raised when one animation loops
  116365. */
  116366. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116367. /**
  116368. * Observer raised when all animations have looped
  116369. */
  116370. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116371. /**
  116372. * This observable will notify when all animations have ended.
  116373. */
  116374. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116375. /**
  116376. * This observable will notify when all animations have paused.
  116377. */
  116378. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116379. /**
  116380. * This observable will notify when all animations are playing.
  116381. */
  116382. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116383. /**
  116384. * Gets the first frame
  116385. */
  116386. get from(): number;
  116387. /**
  116388. * Gets the last frame
  116389. */
  116390. get to(): number;
  116391. /**
  116392. * Define if the animations are started
  116393. */
  116394. get isStarted(): boolean;
  116395. /**
  116396. * Gets a value indicating that the current group is playing
  116397. */
  116398. get isPlaying(): boolean;
  116399. /**
  116400. * Gets or sets the speed ratio to use for all animations
  116401. */
  116402. get speedRatio(): number;
  116403. /**
  116404. * Gets or sets the speed ratio to use for all animations
  116405. */
  116406. set speedRatio(value: number);
  116407. /**
  116408. * Gets or sets if all animations should loop or not
  116409. */
  116410. get loopAnimation(): boolean;
  116411. set loopAnimation(value: boolean);
  116412. /**
  116413. * Gets or sets if all animations should be evaluated additively
  116414. */
  116415. get isAdditive(): boolean;
  116416. set isAdditive(value: boolean);
  116417. /**
  116418. * Gets the targeted animations for this animation group
  116419. */
  116420. get targetedAnimations(): Array<TargetedAnimation>;
  116421. /**
  116422. * returning the list of animatables controlled by this animation group.
  116423. */
  116424. get animatables(): Array<Animatable>;
  116425. /**
  116426. * Gets the list of target animations
  116427. */
  116428. get children(): TargetedAnimation[];
  116429. /**
  116430. * Instantiates a new Animation Group.
  116431. * This helps managing several animations at once.
  116432. * @see https://doc.babylonjs.com/how_to/group
  116433. * @param name Defines the name of the group
  116434. * @param scene Defines the scene the group belongs to
  116435. */
  116436. constructor(
  116437. /** The name of the animation group */
  116438. name: string, scene?: Nullable<Scene>);
  116439. /**
  116440. * Add an animation (with its target) in the group
  116441. * @param animation defines the animation we want to add
  116442. * @param target defines the target of the animation
  116443. * @returns the TargetedAnimation object
  116444. */
  116445. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116446. /**
  116447. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116448. * It can add constant keys at begin or end
  116449. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116450. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116451. * @returns the animation group
  116452. */
  116453. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116454. private _animationLoopCount;
  116455. private _animationLoopFlags;
  116456. private _processLoop;
  116457. /**
  116458. * Start all animations on given targets
  116459. * @param loop defines if animations must loop
  116460. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116461. * @param from defines the from key (optional)
  116462. * @param to defines the to key (optional)
  116463. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116464. * @returns the current animation group
  116465. */
  116466. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116467. /**
  116468. * Pause all animations
  116469. * @returns the animation group
  116470. */
  116471. pause(): AnimationGroup;
  116472. /**
  116473. * Play all animations to initial state
  116474. * This function will start() the animations if they were not started or will restart() them if they were paused
  116475. * @param loop defines if animations must loop
  116476. * @returns the animation group
  116477. */
  116478. play(loop?: boolean): AnimationGroup;
  116479. /**
  116480. * Reset all animations to initial state
  116481. * @returns the animation group
  116482. */
  116483. reset(): AnimationGroup;
  116484. /**
  116485. * Restart animations from key 0
  116486. * @returns the animation group
  116487. */
  116488. restart(): AnimationGroup;
  116489. /**
  116490. * Stop all animations
  116491. * @returns the animation group
  116492. */
  116493. stop(): AnimationGroup;
  116494. /**
  116495. * Set animation weight for all animatables
  116496. * @param weight defines the weight to use
  116497. * @return the animationGroup
  116498. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116499. */
  116500. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116501. /**
  116502. * Synchronize and normalize all animatables with a source animatable
  116503. * @param root defines the root animatable to synchronize with
  116504. * @return the animationGroup
  116505. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116506. */
  116507. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116508. /**
  116509. * Goes to a specific frame in this animation group
  116510. * @param frame the frame number to go to
  116511. * @return the animationGroup
  116512. */
  116513. goToFrame(frame: number): AnimationGroup;
  116514. /**
  116515. * Dispose all associated resources
  116516. */
  116517. dispose(): void;
  116518. private _checkAnimationGroupEnded;
  116519. /**
  116520. * Clone the current animation group and returns a copy
  116521. * @param newName defines the name of the new group
  116522. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116523. * @returns the new aniamtion group
  116524. */
  116525. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116526. /**
  116527. * Serializes the animationGroup to an object
  116528. * @returns Serialized object
  116529. */
  116530. serialize(): any;
  116531. /**
  116532. * Returns a new AnimationGroup object parsed from the source provided.
  116533. * @param parsedAnimationGroup defines the source
  116534. * @param scene defines the scene that will receive the animationGroup
  116535. * @returns a new AnimationGroup
  116536. */
  116537. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116538. /**
  116539. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116540. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116541. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116542. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116543. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116544. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116545. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116546. */
  116547. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116548. /**
  116549. * Returns the string "AnimationGroup"
  116550. * @returns "AnimationGroup"
  116551. */
  116552. getClassName(): string;
  116553. /**
  116554. * Creates a detailled string about the object
  116555. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116556. * @returns a string representing the object
  116557. */
  116558. toString(fullDetails?: boolean): string;
  116559. }
  116560. }
  116561. declare module BABYLON {
  116562. /**
  116563. * Define an interface for all classes that will hold resources
  116564. */
  116565. export interface IDisposable {
  116566. /**
  116567. * Releases all held resources
  116568. */
  116569. dispose(): void;
  116570. }
  116571. /** Interface defining initialization parameters for Scene class */
  116572. export interface SceneOptions {
  116573. /**
  116574. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116575. * It will improve performance when the number of geometries becomes important.
  116576. */
  116577. useGeometryUniqueIdsMap?: boolean;
  116578. /**
  116579. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116580. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116581. */
  116582. useMaterialMeshMap?: boolean;
  116583. /**
  116584. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116585. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116586. */
  116587. useClonedMeshMap?: boolean;
  116588. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116589. virtual?: boolean;
  116590. }
  116591. /**
  116592. * Represents a scene to be rendered by the engine.
  116593. * @see https://doc.babylonjs.com/features/scene
  116594. */
  116595. export class Scene extends AbstractScene implements IAnimatable {
  116596. /** The fog is deactivated */
  116597. static readonly FOGMODE_NONE: number;
  116598. /** The fog density is following an exponential function */
  116599. static readonly FOGMODE_EXP: number;
  116600. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116601. static readonly FOGMODE_EXP2: number;
  116602. /** The fog density is following a linear function. */
  116603. static readonly FOGMODE_LINEAR: number;
  116604. /**
  116605. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116607. */
  116608. static MinDeltaTime: number;
  116609. /**
  116610. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116611. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116612. */
  116613. static MaxDeltaTime: number;
  116614. /**
  116615. * Factory used to create the default material.
  116616. * @param name The name of the material to create
  116617. * @param scene The scene to create the material for
  116618. * @returns The default material
  116619. */
  116620. static DefaultMaterialFactory(scene: Scene): Material;
  116621. /**
  116622. * Factory used to create the a collision coordinator.
  116623. * @returns The collision coordinator
  116624. */
  116625. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116626. /** @hidden */
  116627. _inputManager: InputManager;
  116628. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116629. cameraToUseForPointers: Nullable<Camera>;
  116630. /** @hidden */
  116631. readonly _isScene: boolean;
  116632. /** @hidden */
  116633. _blockEntityCollection: boolean;
  116634. /**
  116635. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116636. */
  116637. autoClear: boolean;
  116638. /**
  116639. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116640. */
  116641. autoClearDepthAndStencil: boolean;
  116642. /**
  116643. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116644. */
  116645. clearColor: Color4;
  116646. /**
  116647. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116648. */
  116649. ambientColor: Color3;
  116650. /**
  116651. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116652. * It should only be one of the following (if not the default embedded one):
  116653. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116654. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116655. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116656. * The material properties need to be setup according to the type of texture in use.
  116657. */
  116658. environmentBRDFTexture: BaseTexture;
  116659. /** @hidden */
  116660. protected _environmentTexture: Nullable<BaseTexture>;
  116661. /**
  116662. * Texture used in all pbr material as the reflection texture.
  116663. * As in the majority of the scene they are the same (exception for multi room and so on),
  116664. * this is easier to reference from here than from all the materials.
  116665. */
  116666. get environmentTexture(): Nullable<BaseTexture>;
  116667. /**
  116668. * Texture used in all pbr material as the reflection texture.
  116669. * As in the majority of the scene they are the same (exception for multi room and so on),
  116670. * this is easier to set here than in all the materials.
  116671. */
  116672. set environmentTexture(value: Nullable<BaseTexture>);
  116673. /** @hidden */
  116674. protected _environmentIntensity: number;
  116675. /**
  116676. * Intensity of the environment in all pbr material.
  116677. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116678. * As in the majority of the scene they are the same (exception for multi room and so on),
  116679. * this is easier to reference from here than from all the materials.
  116680. */
  116681. get environmentIntensity(): number;
  116682. /**
  116683. * Intensity of the environment in all pbr material.
  116684. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116685. * As in the majority of the scene they are the same (exception for multi room and so on),
  116686. * this is easier to set here than in all the materials.
  116687. */
  116688. set environmentIntensity(value: number);
  116689. /** @hidden */
  116690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116691. /**
  116692. * Default image processing configuration used either in the rendering
  116693. * Forward main pass or through the imageProcessingPostProcess if present.
  116694. * As in the majority of the scene they are the same (exception for multi camera),
  116695. * this is easier to reference from here than from all the materials and post process.
  116696. *
  116697. * No setter as we it is a shared configuration, you can set the values instead.
  116698. */
  116699. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116700. private _forceWireframe;
  116701. /**
  116702. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116703. */
  116704. set forceWireframe(value: boolean);
  116705. get forceWireframe(): boolean;
  116706. private _skipFrustumClipping;
  116707. /**
  116708. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116709. */
  116710. set skipFrustumClipping(value: boolean);
  116711. get skipFrustumClipping(): boolean;
  116712. private _forcePointsCloud;
  116713. /**
  116714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116715. */
  116716. set forcePointsCloud(value: boolean);
  116717. get forcePointsCloud(): boolean;
  116718. /**
  116719. * Gets or sets the active clipplane 1
  116720. */
  116721. clipPlane: Nullable<Plane>;
  116722. /**
  116723. * Gets or sets the active clipplane 2
  116724. */
  116725. clipPlane2: Nullable<Plane>;
  116726. /**
  116727. * Gets or sets the active clipplane 3
  116728. */
  116729. clipPlane3: Nullable<Plane>;
  116730. /**
  116731. * Gets or sets the active clipplane 4
  116732. */
  116733. clipPlane4: Nullable<Plane>;
  116734. /**
  116735. * Gets or sets the active clipplane 5
  116736. */
  116737. clipPlane5: Nullable<Plane>;
  116738. /**
  116739. * Gets or sets the active clipplane 6
  116740. */
  116741. clipPlane6: Nullable<Plane>;
  116742. /**
  116743. * Gets or sets a boolean indicating if animations are enabled
  116744. */
  116745. animationsEnabled: boolean;
  116746. private _animationPropertiesOverride;
  116747. /**
  116748. * Gets or sets the animation properties override
  116749. */
  116750. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116751. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116752. /**
  116753. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116754. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116755. */
  116756. useConstantAnimationDeltaTime: boolean;
  116757. /**
  116758. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116759. * Please note that it requires to run a ray cast through the scene on every frame
  116760. */
  116761. constantlyUpdateMeshUnderPointer: boolean;
  116762. /**
  116763. * Defines the HTML cursor to use when hovering over interactive elements
  116764. */
  116765. hoverCursor: string;
  116766. /**
  116767. * Defines the HTML default cursor to use (empty by default)
  116768. */
  116769. defaultCursor: string;
  116770. /**
  116771. * Defines whether cursors are handled by the scene.
  116772. */
  116773. doNotHandleCursors: boolean;
  116774. /**
  116775. * This is used to call preventDefault() on pointer down
  116776. * in order to block unwanted artifacts like system double clicks
  116777. */
  116778. preventDefaultOnPointerDown: boolean;
  116779. /**
  116780. * This is used to call preventDefault() on pointer up
  116781. * in order to block unwanted artifacts like system double clicks
  116782. */
  116783. preventDefaultOnPointerUp: boolean;
  116784. /**
  116785. * Gets or sets user defined metadata
  116786. */
  116787. metadata: any;
  116788. /**
  116789. * For internal use only. Please do not use.
  116790. */
  116791. reservedDataStore: any;
  116792. /**
  116793. * Gets the name of the plugin used to load this scene (null by default)
  116794. */
  116795. loadingPluginName: string;
  116796. /**
  116797. * Use this array to add regular expressions used to disable offline support for specific urls
  116798. */
  116799. disableOfflineSupportExceptionRules: RegExp[];
  116800. /**
  116801. * An event triggered when the scene is disposed.
  116802. */
  116803. onDisposeObservable: Observable<Scene>;
  116804. private _onDisposeObserver;
  116805. /** Sets a function to be executed when this scene is disposed. */
  116806. set onDispose(callback: () => void);
  116807. /**
  116808. * An event triggered before rendering the scene (right after animations and physics)
  116809. */
  116810. onBeforeRenderObservable: Observable<Scene>;
  116811. private _onBeforeRenderObserver;
  116812. /** Sets a function to be executed before rendering this scene */
  116813. set beforeRender(callback: Nullable<() => void>);
  116814. /**
  116815. * An event triggered after rendering the scene
  116816. */
  116817. onAfterRenderObservable: Observable<Scene>;
  116818. /**
  116819. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116820. */
  116821. onAfterRenderCameraObservable: Observable<Camera>;
  116822. private _onAfterRenderObserver;
  116823. /** Sets a function to be executed after rendering this scene */
  116824. set afterRender(callback: Nullable<() => void>);
  116825. /**
  116826. * An event triggered before animating the scene
  116827. */
  116828. onBeforeAnimationsObservable: Observable<Scene>;
  116829. /**
  116830. * An event triggered after animations processing
  116831. */
  116832. onAfterAnimationsObservable: Observable<Scene>;
  116833. /**
  116834. * An event triggered before draw calls are ready to be sent
  116835. */
  116836. onBeforeDrawPhaseObservable: Observable<Scene>;
  116837. /**
  116838. * An event triggered after draw calls have been sent
  116839. */
  116840. onAfterDrawPhaseObservable: Observable<Scene>;
  116841. /**
  116842. * An event triggered when the scene is ready
  116843. */
  116844. onReadyObservable: Observable<Scene>;
  116845. /**
  116846. * An event triggered before rendering a camera
  116847. */
  116848. onBeforeCameraRenderObservable: Observable<Camera>;
  116849. private _onBeforeCameraRenderObserver;
  116850. /** Sets a function to be executed before rendering a camera*/
  116851. set beforeCameraRender(callback: () => void);
  116852. /**
  116853. * An event triggered after rendering a camera
  116854. */
  116855. onAfterCameraRenderObservable: Observable<Camera>;
  116856. private _onAfterCameraRenderObserver;
  116857. /** Sets a function to be executed after rendering a camera*/
  116858. set afterCameraRender(callback: () => void);
  116859. /**
  116860. * An event triggered when active meshes evaluation is about to start
  116861. */
  116862. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116863. /**
  116864. * An event triggered when active meshes evaluation is done
  116865. */
  116866. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116867. /**
  116868. * An event triggered when particles rendering is about to start
  116869. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116870. */
  116871. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116872. /**
  116873. * An event triggered when particles rendering is done
  116874. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116875. */
  116876. onAfterParticlesRenderingObservable: Observable<Scene>;
  116877. /**
  116878. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116879. */
  116880. onDataLoadedObservable: Observable<Scene>;
  116881. /**
  116882. * An event triggered when a camera is created
  116883. */
  116884. onNewCameraAddedObservable: Observable<Camera>;
  116885. /**
  116886. * An event triggered when a camera is removed
  116887. */
  116888. onCameraRemovedObservable: Observable<Camera>;
  116889. /**
  116890. * An event triggered when a light is created
  116891. */
  116892. onNewLightAddedObservable: Observable<Light>;
  116893. /**
  116894. * An event triggered when a light is removed
  116895. */
  116896. onLightRemovedObservable: Observable<Light>;
  116897. /**
  116898. * An event triggered when a geometry is created
  116899. */
  116900. onNewGeometryAddedObservable: Observable<Geometry>;
  116901. /**
  116902. * An event triggered when a geometry is removed
  116903. */
  116904. onGeometryRemovedObservable: Observable<Geometry>;
  116905. /**
  116906. * An event triggered when a transform node is created
  116907. */
  116908. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116909. /**
  116910. * An event triggered when a transform node is removed
  116911. */
  116912. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116913. /**
  116914. * An event triggered when a mesh is created
  116915. */
  116916. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116917. /**
  116918. * An event triggered when a mesh is removed
  116919. */
  116920. onMeshRemovedObservable: Observable<AbstractMesh>;
  116921. /**
  116922. * An event triggered when a skeleton is created
  116923. */
  116924. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116925. /**
  116926. * An event triggered when a skeleton is removed
  116927. */
  116928. onSkeletonRemovedObservable: Observable<Skeleton>;
  116929. /**
  116930. * An event triggered when a material is created
  116931. */
  116932. onNewMaterialAddedObservable: Observable<Material>;
  116933. /**
  116934. * An event triggered when a material is removed
  116935. */
  116936. onMaterialRemovedObservable: Observable<Material>;
  116937. /**
  116938. * An event triggered when a texture is created
  116939. */
  116940. onNewTextureAddedObservable: Observable<BaseTexture>;
  116941. /**
  116942. * An event triggered when a texture is removed
  116943. */
  116944. onTextureRemovedObservable: Observable<BaseTexture>;
  116945. /**
  116946. * An event triggered when render targets are about to be rendered
  116947. * Can happen multiple times per frame.
  116948. */
  116949. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116950. /**
  116951. * An event triggered when render targets were rendered.
  116952. * Can happen multiple times per frame.
  116953. */
  116954. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116955. /**
  116956. * An event triggered before calculating deterministic simulation step
  116957. */
  116958. onBeforeStepObservable: Observable<Scene>;
  116959. /**
  116960. * An event triggered after calculating deterministic simulation step
  116961. */
  116962. onAfterStepObservable: Observable<Scene>;
  116963. /**
  116964. * An event triggered when the activeCamera property is updated
  116965. */
  116966. onActiveCameraChanged: Observable<Scene>;
  116967. /**
  116968. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116969. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116970. * 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)
  116971. */
  116972. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116973. /**
  116974. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116975. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116976. * 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)
  116977. */
  116978. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116979. /**
  116980. * This Observable will when a mesh has been imported into the scene.
  116981. */
  116982. onMeshImportedObservable: Observable<AbstractMesh>;
  116983. /**
  116984. * This Observable will when an animation file has been imported into the scene.
  116985. */
  116986. onAnimationFileImportedObservable: Observable<Scene>;
  116987. /**
  116988. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116989. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116990. */
  116991. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116992. /** @hidden */
  116993. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116994. /**
  116995. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116996. */
  116997. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116998. /**
  116999. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  117000. */
  117001. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117002. /**
  117003. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117004. */
  117005. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117006. /** Callback called when a pointer move is detected */
  117007. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117008. /** Callback called when a pointer down is detected */
  117009. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117010. /** Callback called when a pointer up is detected */
  117011. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117012. /** Callback called when a pointer pick is detected */
  117013. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117014. /**
  117015. * 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).
  117016. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117017. */
  117018. onPrePointerObservable: Observable<PointerInfoPre>;
  117019. /**
  117020. * Observable event triggered each time an input event is received from the rendering canvas
  117021. */
  117022. onPointerObservable: Observable<PointerInfo>;
  117023. /**
  117024. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117025. */
  117026. get unTranslatedPointer(): Vector2;
  117027. /**
  117028. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117029. */
  117030. static get DragMovementThreshold(): number;
  117031. static set DragMovementThreshold(value: number);
  117032. /**
  117033. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117034. */
  117035. static get LongPressDelay(): number;
  117036. static set LongPressDelay(value: number);
  117037. /**
  117038. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117039. */
  117040. static get DoubleClickDelay(): number;
  117041. static set DoubleClickDelay(value: number);
  117042. /** If you need to check double click without raising a single click at first click, enable this flag */
  117043. static get ExclusiveDoubleClickMode(): boolean;
  117044. static set ExclusiveDoubleClickMode(value: boolean);
  117045. /** @hidden */
  117046. _mirroredCameraPosition: Nullable<Vector3>;
  117047. /**
  117048. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117049. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117050. */
  117051. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117052. /**
  117053. * Observable event triggered each time an keyboard event is received from the hosting window
  117054. */
  117055. onKeyboardObservable: Observable<KeyboardInfo>;
  117056. private _useRightHandedSystem;
  117057. /**
  117058. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117059. */
  117060. set useRightHandedSystem(value: boolean);
  117061. get useRightHandedSystem(): boolean;
  117062. private _timeAccumulator;
  117063. private _currentStepId;
  117064. private _currentInternalStep;
  117065. /**
  117066. * Sets the step Id used by deterministic lock step
  117067. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117068. * @param newStepId defines the step Id
  117069. */
  117070. setStepId(newStepId: number): void;
  117071. /**
  117072. * Gets the step Id used by deterministic lock step
  117073. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117074. * @returns the step Id
  117075. */
  117076. getStepId(): number;
  117077. /**
  117078. * Gets the internal step used by deterministic lock step
  117079. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117080. * @returns the internal step
  117081. */
  117082. getInternalStep(): number;
  117083. private _fogEnabled;
  117084. /**
  117085. * Gets or sets a boolean indicating if fog is enabled on this scene
  117086. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117087. * (Default is true)
  117088. */
  117089. set fogEnabled(value: boolean);
  117090. get fogEnabled(): boolean;
  117091. private _fogMode;
  117092. /**
  117093. * Gets or sets the fog mode to use
  117094. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117095. * | mode | value |
  117096. * | --- | --- |
  117097. * | FOGMODE_NONE | 0 |
  117098. * | FOGMODE_EXP | 1 |
  117099. * | FOGMODE_EXP2 | 2 |
  117100. * | FOGMODE_LINEAR | 3 |
  117101. */
  117102. set fogMode(value: number);
  117103. get fogMode(): number;
  117104. /**
  117105. * Gets or sets the fog color to use
  117106. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117107. * (Default is Color3(0.2, 0.2, 0.3))
  117108. */
  117109. fogColor: Color3;
  117110. /**
  117111. * Gets or sets the fog density to use
  117112. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117113. * (Default is 0.1)
  117114. */
  117115. fogDensity: number;
  117116. /**
  117117. * Gets or sets the fog start distance to use
  117118. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117119. * (Default is 0)
  117120. */
  117121. fogStart: number;
  117122. /**
  117123. * Gets or sets the fog end distance to use
  117124. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117125. * (Default is 1000)
  117126. */
  117127. fogEnd: number;
  117128. /**
  117129. * Flag indicating that the frame buffer binding is handled by another component
  117130. */
  117131. prePass: boolean;
  117132. private _shadowsEnabled;
  117133. /**
  117134. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117135. */
  117136. set shadowsEnabled(value: boolean);
  117137. get shadowsEnabled(): boolean;
  117138. private _lightsEnabled;
  117139. /**
  117140. * Gets or sets a boolean indicating if lights are enabled on this scene
  117141. */
  117142. set lightsEnabled(value: boolean);
  117143. get lightsEnabled(): boolean;
  117144. /** All of the active cameras added to this scene. */
  117145. activeCameras: Camera[];
  117146. /** @hidden */
  117147. _activeCamera: Nullable<Camera>;
  117148. /** Gets or sets the current active camera */
  117149. get activeCamera(): Nullable<Camera>;
  117150. set activeCamera(value: Nullable<Camera>);
  117151. private _defaultMaterial;
  117152. /** The default material used on meshes when no material is affected */
  117153. get defaultMaterial(): Material;
  117154. /** The default material used on meshes when no material is affected */
  117155. set defaultMaterial(value: Material);
  117156. private _texturesEnabled;
  117157. /**
  117158. * Gets or sets a boolean indicating if textures are enabled on this scene
  117159. */
  117160. set texturesEnabled(value: boolean);
  117161. get texturesEnabled(): boolean;
  117162. /**
  117163. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117164. */
  117165. physicsEnabled: boolean;
  117166. /**
  117167. * Gets or sets a boolean indicating if particles are enabled on this scene
  117168. */
  117169. particlesEnabled: boolean;
  117170. /**
  117171. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117172. */
  117173. spritesEnabled: boolean;
  117174. private _skeletonsEnabled;
  117175. /**
  117176. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117177. */
  117178. set skeletonsEnabled(value: boolean);
  117179. get skeletonsEnabled(): boolean;
  117180. /**
  117181. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117182. */
  117183. lensFlaresEnabled: boolean;
  117184. /**
  117185. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117186. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117187. */
  117188. collisionsEnabled: boolean;
  117189. private _collisionCoordinator;
  117190. /** @hidden */
  117191. get collisionCoordinator(): ICollisionCoordinator;
  117192. /**
  117193. * Defines the gravity applied to this scene (used only for collisions)
  117194. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117195. */
  117196. gravity: Vector3;
  117197. /**
  117198. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117199. */
  117200. postProcessesEnabled: boolean;
  117201. /**
  117202. * The list of postprocesses added to the scene
  117203. */
  117204. postProcesses: PostProcess[];
  117205. /**
  117206. * Gets the current postprocess manager
  117207. */
  117208. postProcessManager: PostProcessManager;
  117209. /**
  117210. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117211. */
  117212. renderTargetsEnabled: boolean;
  117213. /**
  117214. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117215. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117216. */
  117217. dumpNextRenderTargets: boolean;
  117218. /**
  117219. * The list of user defined render targets added to the scene
  117220. */
  117221. customRenderTargets: RenderTargetTexture[];
  117222. /**
  117223. * Defines if texture loading must be delayed
  117224. * If true, textures will only be loaded when they need to be rendered
  117225. */
  117226. useDelayedTextureLoading: boolean;
  117227. /**
  117228. * Gets the list of meshes imported to the scene through SceneLoader
  117229. */
  117230. importedMeshesFiles: String[];
  117231. /**
  117232. * Gets or sets a boolean indicating if probes are enabled on this scene
  117233. */
  117234. probesEnabled: boolean;
  117235. /**
  117236. * Gets or sets the current offline provider to use to store scene data
  117237. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117238. */
  117239. offlineProvider: IOfflineProvider;
  117240. /**
  117241. * Gets or sets the action manager associated with the scene
  117242. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117243. */
  117244. actionManager: AbstractActionManager;
  117245. private _meshesForIntersections;
  117246. /**
  117247. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117248. */
  117249. proceduralTexturesEnabled: boolean;
  117250. private _engine;
  117251. private _totalVertices;
  117252. /** @hidden */
  117253. _activeIndices: PerfCounter;
  117254. /** @hidden */
  117255. _activeParticles: PerfCounter;
  117256. /** @hidden */
  117257. _activeBones: PerfCounter;
  117258. private _animationRatio;
  117259. /** @hidden */
  117260. _animationTimeLast: number;
  117261. /** @hidden */
  117262. _animationTime: number;
  117263. /**
  117264. * Gets or sets a general scale for animation speed
  117265. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117266. */
  117267. animationTimeScale: number;
  117268. /** @hidden */
  117269. _cachedMaterial: Nullable<Material>;
  117270. /** @hidden */
  117271. _cachedEffect: Nullable<Effect>;
  117272. /** @hidden */
  117273. _cachedVisibility: Nullable<number>;
  117274. private _renderId;
  117275. private _frameId;
  117276. private _executeWhenReadyTimeoutId;
  117277. private _intermediateRendering;
  117278. private _viewUpdateFlag;
  117279. private _projectionUpdateFlag;
  117280. /** @hidden */
  117281. _toBeDisposed: Nullable<IDisposable>[];
  117282. private _activeRequests;
  117283. /** @hidden */
  117284. _pendingData: any[];
  117285. private _isDisposed;
  117286. /**
  117287. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117288. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117289. */
  117290. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117291. private _activeMeshes;
  117292. private _processedMaterials;
  117293. private _renderTargets;
  117294. /** @hidden */
  117295. _activeParticleSystems: SmartArray<IParticleSystem>;
  117296. private _activeSkeletons;
  117297. private _softwareSkinnedMeshes;
  117298. private _renderingManager;
  117299. /** @hidden */
  117300. _activeAnimatables: Animatable[];
  117301. private _transformMatrix;
  117302. private _sceneUbo;
  117303. /** @hidden */
  117304. _viewMatrix: Matrix;
  117305. private _projectionMatrix;
  117306. /** @hidden */
  117307. _forcedViewPosition: Nullable<Vector3>;
  117308. /** @hidden */
  117309. _frustumPlanes: Plane[];
  117310. /**
  117311. * Gets the list of frustum planes (built from the active camera)
  117312. */
  117313. get frustumPlanes(): Plane[];
  117314. /**
  117315. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117316. * This is useful if there are more lights that the maximum simulteanous authorized
  117317. */
  117318. requireLightSorting: boolean;
  117319. /** @hidden */
  117320. readonly useMaterialMeshMap: boolean;
  117321. /** @hidden */
  117322. readonly useClonedMeshMap: boolean;
  117323. private _externalData;
  117324. private _uid;
  117325. /**
  117326. * @hidden
  117327. * Backing store of defined scene components.
  117328. */
  117329. _components: ISceneComponent[];
  117330. /**
  117331. * @hidden
  117332. * Backing store of defined scene components.
  117333. */
  117334. _serializableComponents: ISceneSerializableComponent[];
  117335. /**
  117336. * List of components to register on the next registration step.
  117337. */
  117338. private _transientComponents;
  117339. /**
  117340. * Registers the transient components if needed.
  117341. */
  117342. private _registerTransientComponents;
  117343. /**
  117344. * @hidden
  117345. * Add a component to the scene.
  117346. * Note that the ccomponent could be registered on th next frame if this is called after
  117347. * the register component stage.
  117348. * @param component Defines the component to add to the scene
  117349. */
  117350. _addComponent(component: ISceneComponent): void;
  117351. /**
  117352. * @hidden
  117353. * Gets a component from the scene.
  117354. * @param name defines the name of the component to retrieve
  117355. * @returns the component or null if not present
  117356. */
  117357. _getComponent(name: string): Nullable<ISceneComponent>;
  117358. /**
  117359. * @hidden
  117360. * Defines the actions happening before camera updates.
  117361. */
  117362. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117363. /**
  117364. * @hidden
  117365. * Defines the actions happening before clear the canvas.
  117366. */
  117367. _beforeClearStage: Stage<SimpleStageAction>;
  117368. /**
  117369. * @hidden
  117370. * Defines the actions when collecting render targets for the frame.
  117371. */
  117372. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117373. /**
  117374. * @hidden
  117375. * Defines the actions happening for one camera in the frame.
  117376. */
  117377. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117378. /**
  117379. * @hidden
  117380. * Defines the actions happening during the per mesh ready checks.
  117381. */
  117382. _isReadyForMeshStage: Stage<MeshStageAction>;
  117383. /**
  117384. * @hidden
  117385. * Defines the actions happening before evaluate active mesh checks.
  117386. */
  117387. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117388. /**
  117389. * @hidden
  117390. * Defines the actions happening during the evaluate sub mesh checks.
  117391. */
  117392. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117393. /**
  117394. * @hidden
  117395. * Defines the actions happening during the active mesh stage.
  117396. */
  117397. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117398. /**
  117399. * @hidden
  117400. * Defines the actions happening during the per camera render target step.
  117401. */
  117402. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117403. /**
  117404. * @hidden
  117405. * Defines the actions happening just before the active camera is drawing.
  117406. */
  117407. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117408. /**
  117409. * @hidden
  117410. * Defines the actions happening just before a render target is drawing.
  117411. */
  117412. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117413. /**
  117414. * @hidden
  117415. * Defines the actions happening just before a rendering group is drawing.
  117416. */
  117417. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117418. /**
  117419. * @hidden
  117420. * Defines the actions happening just before a mesh is drawing.
  117421. */
  117422. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117423. /**
  117424. * @hidden
  117425. * Defines the actions happening just after a mesh has been drawn.
  117426. */
  117427. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117428. /**
  117429. * @hidden
  117430. * Defines the actions happening just after a rendering group has been drawn.
  117431. */
  117432. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117433. /**
  117434. * @hidden
  117435. * Defines the actions happening just after the active camera has been drawn.
  117436. */
  117437. _afterCameraDrawStage: Stage<CameraStageAction>;
  117438. /**
  117439. * @hidden
  117440. * Defines the actions happening just after a render target has been drawn.
  117441. */
  117442. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117443. /**
  117444. * @hidden
  117445. * Defines the actions happening just after rendering all cameras and computing intersections.
  117446. */
  117447. _afterRenderStage: Stage<SimpleStageAction>;
  117448. /**
  117449. * @hidden
  117450. * Defines the actions happening when a pointer move event happens.
  117451. */
  117452. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117453. /**
  117454. * @hidden
  117455. * Defines the actions happening when a pointer down event happens.
  117456. */
  117457. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117458. /**
  117459. * @hidden
  117460. * Defines the actions happening when a pointer up event happens.
  117461. */
  117462. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117463. /**
  117464. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117465. */
  117466. private geometriesByUniqueId;
  117467. /**
  117468. * Creates a new Scene
  117469. * @param engine defines the engine to use to render this scene
  117470. * @param options defines the scene options
  117471. */
  117472. constructor(engine: Engine, options?: SceneOptions);
  117473. /**
  117474. * Gets a string idenfifying the name of the class
  117475. * @returns "Scene" string
  117476. */
  117477. getClassName(): string;
  117478. private _defaultMeshCandidates;
  117479. /**
  117480. * @hidden
  117481. */
  117482. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117483. private _defaultSubMeshCandidates;
  117484. /**
  117485. * @hidden
  117486. */
  117487. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117488. /**
  117489. * Sets the default candidate providers for the scene.
  117490. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117491. * and getCollidingSubMeshCandidates to their default function
  117492. */
  117493. setDefaultCandidateProviders(): void;
  117494. /**
  117495. * Gets the mesh that is currently under the pointer
  117496. */
  117497. get meshUnderPointer(): Nullable<AbstractMesh>;
  117498. /**
  117499. * Gets or sets the current on-screen X position of the pointer
  117500. */
  117501. get pointerX(): number;
  117502. set pointerX(value: number);
  117503. /**
  117504. * Gets or sets the current on-screen Y position of the pointer
  117505. */
  117506. get pointerY(): number;
  117507. set pointerY(value: number);
  117508. /**
  117509. * Gets the cached material (ie. the latest rendered one)
  117510. * @returns the cached material
  117511. */
  117512. getCachedMaterial(): Nullable<Material>;
  117513. /**
  117514. * Gets the cached effect (ie. the latest rendered one)
  117515. * @returns the cached effect
  117516. */
  117517. getCachedEffect(): Nullable<Effect>;
  117518. /**
  117519. * Gets the cached visibility state (ie. the latest rendered one)
  117520. * @returns the cached visibility state
  117521. */
  117522. getCachedVisibility(): Nullable<number>;
  117523. /**
  117524. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117525. * @param material defines the current material
  117526. * @param effect defines the current effect
  117527. * @param visibility defines the current visibility state
  117528. * @returns true if one parameter is not cached
  117529. */
  117530. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117531. /**
  117532. * Gets the engine associated with the scene
  117533. * @returns an Engine
  117534. */
  117535. getEngine(): Engine;
  117536. /**
  117537. * Gets the total number of vertices rendered per frame
  117538. * @returns the total number of vertices rendered per frame
  117539. */
  117540. getTotalVertices(): number;
  117541. /**
  117542. * Gets the performance counter for total vertices
  117543. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117544. */
  117545. get totalVerticesPerfCounter(): PerfCounter;
  117546. /**
  117547. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117548. * @returns the total number of active indices rendered per frame
  117549. */
  117550. getActiveIndices(): number;
  117551. /**
  117552. * Gets the performance counter for active indices
  117553. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117554. */
  117555. get totalActiveIndicesPerfCounter(): PerfCounter;
  117556. /**
  117557. * Gets the total number of active particles rendered per frame
  117558. * @returns the total number of active particles rendered per frame
  117559. */
  117560. getActiveParticles(): number;
  117561. /**
  117562. * Gets the performance counter for active particles
  117563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117564. */
  117565. get activeParticlesPerfCounter(): PerfCounter;
  117566. /**
  117567. * Gets the total number of active bones rendered per frame
  117568. * @returns the total number of active bones rendered per frame
  117569. */
  117570. getActiveBones(): number;
  117571. /**
  117572. * Gets the performance counter for active bones
  117573. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117574. */
  117575. get activeBonesPerfCounter(): PerfCounter;
  117576. /**
  117577. * Gets the array of active meshes
  117578. * @returns an array of AbstractMesh
  117579. */
  117580. getActiveMeshes(): SmartArray<AbstractMesh>;
  117581. /**
  117582. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117583. * @returns a number
  117584. */
  117585. getAnimationRatio(): number;
  117586. /**
  117587. * Gets an unique Id for the current render phase
  117588. * @returns a number
  117589. */
  117590. getRenderId(): number;
  117591. /**
  117592. * Gets an unique Id for the current frame
  117593. * @returns a number
  117594. */
  117595. getFrameId(): number;
  117596. /** Call this function if you want to manually increment the render Id*/
  117597. incrementRenderId(): void;
  117598. private _createUbo;
  117599. /**
  117600. * Use this method to simulate a pointer move on a mesh
  117601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117604. * @returns the current scene
  117605. */
  117606. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117607. /**
  117608. * Use this method to simulate a pointer down on a mesh
  117609. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117610. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117611. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117612. * @returns the current scene
  117613. */
  117614. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117615. /**
  117616. * Use this method to simulate a pointer up on a mesh
  117617. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117618. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117619. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117620. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117621. * @returns the current scene
  117622. */
  117623. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117624. /**
  117625. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117626. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117627. * @returns true if the pointer was captured
  117628. */
  117629. isPointerCaptured(pointerId?: number): boolean;
  117630. /**
  117631. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117632. * @param attachUp defines if you want to attach events to pointerup
  117633. * @param attachDown defines if you want to attach events to pointerdown
  117634. * @param attachMove defines if you want to attach events to pointermove
  117635. */
  117636. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117637. /** Detaches all event handlers*/
  117638. detachControl(): void;
  117639. /**
  117640. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117641. * Delay loaded resources are not taking in account
  117642. * @return true if all required resources are ready
  117643. */
  117644. isReady(): boolean;
  117645. /** Resets all cached information relative to material (including effect and visibility) */
  117646. resetCachedMaterial(): void;
  117647. /**
  117648. * Registers a function to be called before every frame render
  117649. * @param func defines the function to register
  117650. */
  117651. registerBeforeRender(func: () => void): void;
  117652. /**
  117653. * Unregisters a function called before every frame render
  117654. * @param func defines the function to unregister
  117655. */
  117656. unregisterBeforeRender(func: () => void): void;
  117657. /**
  117658. * Registers a function to be called after every frame render
  117659. * @param func defines the function to register
  117660. */
  117661. registerAfterRender(func: () => void): void;
  117662. /**
  117663. * Unregisters a function called after every frame render
  117664. * @param func defines the function to unregister
  117665. */
  117666. unregisterAfterRender(func: () => void): void;
  117667. private _executeOnceBeforeRender;
  117668. /**
  117669. * The provided function will run before render once and will be disposed afterwards.
  117670. * A timeout delay can be provided so that the function will be executed in N ms.
  117671. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117672. * @param func The function to be executed.
  117673. * @param timeout optional delay in ms
  117674. */
  117675. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117676. /** @hidden */
  117677. _addPendingData(data: any): void;
  117678. /** @hidden */
  117679. _removePendingData(data: any): void;
  117680. /**
  117681. * Returns the number of items waiting to be loaded
  117682. * @returns the number of items waiting to be loaded
  117683. */
  117684. getWaitingItemsCount(): number;
  117685. /**
  117686. * Returns a boolean indicating if the scene is still loading data
  117687. */
  117688. get isLoading(): boolean;
  117689. /**
  117690. * Registers a function to be executed when the scene is ready
  117691. * @param {Function} func - the function to be executed
  117692. */
  117693. executeWhenReady(func: () => void): void;
  117694. /**
  117695. * Returns a promise that resolves when the scene is ready
  117696. * @returns A promise that resolves when the scene is ready
  117697. */
  117698. whenReadyAsync(): Promise<void>;
  117699. /** @hidden */
  117700. _checkIsReady(): void;
  117701. /**
  117702. * Gets all animatable attached to the scene
  117703. */
  117704. get animatables(): Animatable[];
  117705. /**
  117706. * Resets the last animation time frame.
  117707. * Useful to override when animations start running when loading a scene for the first time.
  117708. */
  117709. resetLastAnimationTimeFrame(): void;
  117710. /**
  117711. * Gets the current view matrix
  117712. * @returns a Matrix
  117713. */
  117714. getViewMatrix(): Matrix;
  117715. /**
  117716. * Gets the current projection matrix
  117717. * @returns a Matrix
  117718. */
  117719. getProjectionMatrix(): Matrix;
  117720. /**
  117721. * Gets the current transform matrix
  117722. * @returns a Matrix made of View * Projection
  117723. */
  117724. getTransformMatrix(): Matrix;
  117725. /**
  117726. * Sets the current transform matrix
  117727. * @param viewL defines the View matrix to use
  117728. * @param projectionL defines the Projection matrix to use
  117729. * @param viewR defines the right View matrix to use (if provided)
  117730. * @param projectionR defines the right Projection matrix to use (if provided)
  117731. */
  117732. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117733. /**
  117734. * Gets the uniform buffer used to store scene data
  117735. * @returns a UniformBuffer
  117736. */
  117737. getSceneUniformBuffer(): UniformBuffer;
  117738. /**
  117739. * Gets an unique (relatively to the current scene) Id
  117740. * @returns an unique number for the scene
  117741. */
  117742. getUniqueId(): number;
  117743. /**
  117744. * Add a mesh to the list of scene's meshes
  117745. * @param newMesh defines the mesh to add
  117746. * @param recursive if all child meshes should also be added to the scene
  117747. */
  117748. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117749. /**
  117750. * Remove a mesh for the list of scene's meshes
  117751. * @param toRemove defines the mesh to remove
  117752. * @param recursive if all child meshes should also be removed from the scene
  117753. * @returns the index where the mesh was in the mesh list
  117754. */
  117755. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117756. /**
  117757. * Add a transform node to the list of scene's transform nodes
  117758. * @param newTransformNode defines the transform node to add
  117759. */
  117760. addTransformNode(newTransformNode: TransformNode): void;
  117761. /**
  117762. * Remove a transform node for the list of scene's transform nodes
  117763. * @param toRemove defines the transform node to remove
  117764. * @returns the index where the transform node was in the transform node list
  117765. */
  117766. removeTransformNode(toRemove: TransformNode): number;
  117767. /**
  117768. * Remove a skeleton for the list of scene's skeletons
  117769. * @param toRemove defines the skeleton to remove
  117770. * @returns the index where the skeleton was in the skeleton list
  117771. */
  117772. removeSkeleton(toRemove: Skeleton): number;
  117773. /**
  117774. * Remove a morph target for the list of scene's morph targets
  117775. * @param toRemove defines the morph target to remove
  117776. * @returns the index where the morph target was in the morph target list
  117777. */
  117778. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117779. /**
  117780. * Remove a light for the list of scene's lights
  117781. * @param toRemove defines the light to remove
  117782. * @returns the index where the light was in the light list
  117783. */
  117784. removeLight(toRemove: Light): number;
  117785. /**
  117786. * Remove a camera for the list of scene's cameras
  117787. * @param toRemove defines the camera to remove
  117788. * @returns the index where the camera was in the camera list
  117789. */
  117790. removeCamera(toRemove: Camera): number;
  117791. /**
  117792. * Remove a particle system for the list of scene's particle systems
  117793. * @param toRemove defines the particle system to remove
  117794. * @returns the index where the particle system was in the particle system list
  117795. */
  117796. removeParticleSystem(toRemove: IParticleSystem): number;
  117797. /**
  117798. * Remove a animation for the list of scene's animations
  117799. * @param toRemove defines the animation to remove
  117800. * @returns the index where the animation was in the animation list
  117801. */
  117802. removeAnimation(toRemove: Animation): number;
  117803. /**
  117804. * Will stop the animation of the given target
  117805. * @param target - the target
  117806. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117807. * @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)
  117808. */
  117809. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117810. /**
  117811. * Removes the given animation group from this scene.
  117812. * @param toRemove The animation group to remove
  117813. * @returns The index of the removed animation group
  117814. */
  117815. removeAnimationGroup(toRemove: AnimationGroup): number;
  117816. /**
  117817. * Removes the given multi-material from this scene.
  117818. * @param toRemove The multi-material to remove
  117819. * @returns The index of the removed multi-material
  117820. */
  117821. removeMultiMaterial(toRemove: MultiMaterial): number;
  117822. /**
  117823. * Removes the given material from this scene.
  117824. * @param toRemove The material to remove
  117825. * @returns The index of the removed material
  117826. */
  117827. removeMaterial(toRemove: Material): number;
  117828. /**
  117829. * Removes the given action manager from this scene.
  117830. * @param toRemove The action manager to remove
  117831. * @returns The index of the removed action manager
  117832. */
  117833. removeActionManager(toRemove: AbstractActionManager): number;
  117834. /**
  117835. * Removes the given texture from this scene.
  117836. * @param toRemove The texture to remove
  117837. * @returns The index of the removed texture
  117838. */
  117839. removeTexture(toRemove: BaseTexture): number;
  117840. /**
  117841. * Adds the given light to this scene
  117842. * @param newLight The light to add
  117843. */
  117844. addLight(newLight: Light): void;
  117845. /**
  117846. * Sorts the list list based on light priorities
  117847. */
  117848. sortLightsByPriority(): void;
  117849. /**
  117850. * Adds the given camera to this scene
  117851. * @param newCamera The camera to add
  117852. */
  117853. addCamera(newCamera: Camera): void;
  117854. /**
  117855. * Adds the given skeleton to this scene
  117856. * @param newSkeleton The skeleton to add
  117857. */
  117858. addSkeleton(newSkeleton: Skeleton): void;
  117859. /**
  117860. * Adds the given particle system to this scene
  117861. * @param newParticleSystem The particle system to add
  117862. */
  117863. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117864. /**
  117865. * Adds the given animation to this scene
  117866. * @param newAnimation The animation to add
  117867. */
  117868. addAnimation(newAnimation: Animation): void;
  117869. /**
  117870. * Adds the given animation group to this scene.
  117871. * @param newAnimationGroup The animation group to add
  117872. */
  117873. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117874. /**
  117875. * Adds the given multi-material to this scene
  117876. * @param newMultiMaterial The multi-material to add
  117877. */
  117878. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117879. /**
  117880. * Adds the given material to this scene
  117881. * @param newMaterial The material to add
  117882. */
  117883. addMaterial(newMaterial: Material): void;
  117884. /**
  117885. * Adds the given morph target to this scene
  117886. * @param newMorphTargetManager The morph target to add
  117887. */
  117888. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117889. /**
  117890. * Adds the given geometry to this scene
  117891. * @param newGeometry The geometry to add
  117892. */
  117893. addGeometry(newGeometry: Geometry): void;
  117894. /**
  117895. * Adds the given action manager to this scene
  117896. * @param newActionManager The action manager to add
  117897. */
  117898. addActionManager(newActionManager: AbstractActionManager): void;
  117899. /**
  117900. * Adds the given texture to this scene.
  117901. * @param newTexture The texture to add
  117902. */
  117903. addTexture(newTexture: BaseTexture): void;
  117904. /**
  117905. * Switch active camera
  117906. * @param newCamera defines the new active camera
  117907. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117908. */
  117909. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117910. /**
  117911. * sets the active camera of the scene using its ID
  117912. * @param id defines the camera's ID
  117913. * @return the new active camera or null if none found.
  117914. */
  117915. setActiveCameraByID(id: string): Nullable<Camera>;
  117916. /**
  117917. * sets the active camera of the scene using its name
  117918. * @param name defines the camera's name
  117919. * @returns the new active camera or null if none found.
  117920. */
  117921. setActiveCameraByName(name: string): Nullable<Camera>;
  117922. /**
  117923. * get an animation group using its name
  117924. * @param name defines the material's name
  117925. * @return the animation group or null if none found.
  117926. */
  117927. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117928. /**
  117929. * Get a material using its unique id
  117930. * @param uniqueId defines the material's unique id
  117931. * @return the material or null if none found.
  117932. */
  117933. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117934. /**
  117935. * get a material using its id
  117936. * @param id defines the material's ID
  117937. * @return the material or null if none found.
  117938. */
  117939. getMaterialByID(id: string): Nullable<Material>;
  117940. /**
  117941. * Gets a the last added material using a given id
  117942. * @param id defines the material's ID
  117943. * @return the last material with the given id or null if none found.
  117944. */
  117945. getLastMaterialByID(id: string): Nullable<Material>;
  117946. /**
  117947. * Gets a material using its name
  117948. * @param name defines the material's name
  117949. * @return the material or null if none found.
  117950. */
  117951. getMaterialByName(name: string): Nullable<Material>;
  117952. /**
  117953. * Get a texture using its unique id
  117954. * @param uniqueId defines the texture's unique id
  117955. * @return the texture or null if none found.
  117956. */
  117957. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117958. /**
  117959. * Gets a camera using its id
  117960. * @param id defines the id to look for
  117961. * @returns the camera or null if not found
  117962. */
  117963. getCameraByID(id: string): Nullable<Camera>;
  117964. /**
  117965. * Gets a camera using its unique id
  117966. * @param uniqueId defines the unique id to look for
  117967. * @returns the camera or null if not found
  117968. */
  117969. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117970. /**
  117971. * Gets a camera using its name
  117972. * @param name defines the camera's name
  117973. * @return the camera or null if none found.
  117974. */
  117975. getCameraByName(name: string): Nullable<Camera>;
  117976. /**
  117977. * Gets a bone using its id
  117978. * @param id defines the bone's id
  117979. * @return the bone or null if not found
  117980. */
  117981. getBoneByID(id: string): Nullable<Bone>;
  117982. /**
  117983. * Gets a bone using its id
  117984. * @param name defines the bone's name
  117985. * @return the bone or null if not found
  117986. */
  117987. getBoneByName(name: string): Nullable<Bone>;
  117988. /**
  117989. * Gets a light node using its name
  117990. * @param name defines the the light's name
  117991. * @return the light or null if none found.
  117992. */
  117993. getLightByName(name: string): Nullable<Light>;
  117994. /**
  117995. * Gets a light node using its id
  117996. * @param id defines the light's id
  117997. * @return the light or null if none found.
  117998. */
  117999. getLightByID(id: string): Nullable<Light>;
  118000. /**
  118001. * Gets a light node using its scene-generated unique ID
  118002. * @param uniqueId defines the light's unique id
  118003. * @return the light or null if none found.
  118004. */
  118005. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118006. /**
  118007. * Gets a particle system by id
  118008. * @param id defines the particle system id
  118009. * @return the corresponding system or null if none found
  118010. */
  118011. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118012. /**
  118013. * Gets a geometry using its ID
  118014. * @param id defines the geometry's id
  118015. * @return the geometry or null if none found.
  118016. */
  118017. getGeometryByID(id: string): Nullable<Geometry>;
  118018. private _getGeometryByUniqueID;
  118019. /**
  118020. * Add a new geometry to this scene
  118021. * @param geometry defines the geometry to be added to the scene.
  118022. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118023. * @return a boolean defining if the geometry was added or not
  118024. */
  118025. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118026. /**
  118027. * Removes an existing geometry
  118028. * @param geometry defines the geometry to be removed from the scene
  118029. * @return a boolean defining if the geometry was removed or not
  118030. */
  118031. removeGeometry(geometry: Geometry): boolean;
  118032. /**
  118033. * Gets the list of geometries attached to the scene
  118034. * @returns an array of Geometry
  118035. */
  118036. getGeometries(): Geometry[];
  118037. /**
  118038. * Gets the first added mesh found of a given ID
  118039. * @param id defines the id to search for
  118040. * @return the mesh found or null if not found at all
  118041. */
  118042. getMeshByID(id: string): Nullable<AbstractMesh>;
  118043. /**
  118044. * Gets a list of meshes using their id
  118045. * @param id defines the id to search for
  118046. * @returns a list of meshes
  118047. */
  118048. getMeshesByID(id: string): Array<AbstractMesh>;
  118049. /**
  118050. * Gets the first added transform node found of a given ID
  118051. * @param id defines the id to search for
  118052. * @return the found transform node or null if not found at all.
  118053. */
  118054. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118055. /**
  118056. * Gets a transform node with its auto-generated unique id
  118057. * @param uniqueId efines the unique id to search for
  118058. * @return the found transform node or null if not found at all.
  118059. */
  118060. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118061. /**
  118062. * Gets a list of transform nodes using their id
  118063. * @param id defines the id to search for
  118064. * @returns a list of transform nodes
  118065. */
  118066. getTransformNodesByID(id: string): Array<TransformNode>;
  118067. /**
  118068. * Gets a mesh with its auto-generated unique id
  118069. * @param uniqueId defines the unique id to search for
  118070. * @return the found mesh or null if not found at all.
  118071. */
  118072. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118073. /**
  118074. * Gets a the last added mesh using a given id
  118075. * @param id defines the id to search for
  118076. * @return the found mesh or null if not found at all.
  118077. */
  118078. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118079. /**
  118080. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118081. * @param id defines the id to search for
  118082. * @return the found node or null if not found at all
  118083. */
  118084. getLastEntryByID(id: string): Nullable<Node>;
  118085. /**
  118086. * Gets a node (Mesh, Camera, Light) using a given id
  118087. * @param id defines the id to search for
  118088. * @return the found node or null if not found at all
  118089. */
  118090. getNodeByID(id: string): Nullable<Node>;
  118091. /**
  118092. * Gets a node (Mesh, Camera, Light) using a given name
  118093. * @param name defines the name to search for
  118094. * @return the found node or null if not found at all.
  118095. */
  118096. getNodeByName(name: string): Nullable<Node>;
  118097. /**
  118098. * Gets a mesh using a given name
  118099. * @param name defines the name to search for
  118100. * @return the found mesh or null if not found at all.
  118101. */
  118102. getMeshByName(name: string): Nullable<AbstractMesh>;
  118103. /**
  118104. * Gets a transform node using a given name
  118105. * @param name defines the name to search for
  118106. * @return the found transform node or null if not found at all.
  118107. */
  118108. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118109. /**
  118110. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118111. * @param id defines the id to search for
  118112. * @return the found skeleton or null if not found at all.
  118113. */
  118114. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118115. /**
  118116. * Gets a skeleton using a given auto generated unique id
  118117. * @param uniqueId defines the unique id to search for
  118118. * @return the found skeleton or null if not found at all.
  118119. */
  118120. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118121. /**
  118122. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118123. * @param id defines the id to search for
  118124. * @return the found skeleton or null if not found at all.
  118125. */
  118126. getSkeletonById(id: string): Nullable<Skeleton>;
  118127. /**
  118128. * Gets a skeleton using a given name
  118129. * @param name defines the name to search for
  118130. * @return the found skeleton or null if not found at all.
  118131. */
  118132. getSkeletonByName(name: string): Nullable<Skeleton>;
  118133. /**
  118134. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118135. * @param id defines the id to search for
  118136. * @return the found morph target manager or null if not found at all.
  118137. */
  118138. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118139. /**
  118140. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118141. * @param id defines the id to search for
  118142. * @return the found morph target or null if not found at all.
  118143. */
  118144. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118145. /**
  118146. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118147. * @param name defines the name to search for
  118148. * @return the found morph target or null if not found at all.
  118149. */
  118150. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118151. /**
  118152. * Gets a boolean indicating if the given mesh is active
  118153. * @param mesh defines the mesh to look for
  118154. * @returns true if the mesh is in the active list
  118155. */
  118156. isActiveMesh(mesh: AbstractMesh): boolean;
  118157. /**
  118158. * Return a unique id as a string which can serve as an identifier for the scene
  118159. */
  118160. get uid(): string;
  118161. /**
  118162. * Add an externaly attached data from its key.
  118163. * This method call will fail and return false, if such key already exists.
  118164. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118165. * @param key the unique key that identifies the data
  118166. * @param data the data object to associate to the key for this Engine instance
  118167. * @return true if no such key were already present and the data was added successfully, false otherwise
  118168. */
  118169. addExternalData<T>(key: string, data: T): boolean;
  118170. /**
  118171. * Get an externaly attached data from its key
  118172. * @param key the unique key that identifies the data
  118173. * @return the associated data, if present (can be null), or undefined if not present
  118174. */
  118175. getExternalData<T>(key: string): Nullable<T>;
  118176. /**
  118177. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118178. * @param key the unique key that identifies the data
  118179. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118180. * @return the associated data, can be null if the factory returned null.
  118181. */
  118182. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118183. /**
  118184. * Remove an externaly attached data from the Engine instance
  118185. * @param key the unique key that identifies the data
  118186. * @return true if the data was successfully removed, false if it doesn't exist
  118187. */
  118188. removeExternalData(key: string): boolean;
  118189. private _evaluateSubMesh;
  118190. /**
  118191. * Clear the processed materials smart array preventing retention point in material dispose.
  118192. */
  118193. freeProcessedMaterials(): void;
  118194. private _preventFreeActiveMeshesAndRenderingGroups;
  118195. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118196. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118197. * when disposing several meshes in a row or a hierarchy of meshes.
  118198. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118199. */
  118200. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118201. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118202. /**
  118203. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118204. */
  118205. freeActiveMeshes(): void;
  118206. /**
  118207. * Clear the info related to rendering groups preventing retention points during dispose.
  118208. */
  118209. freeRenderingGroups(): void;
  118210. /** @hidden */
  118211. _isInIntermediateRendering(): boolean;
  118212. /**
  118213. * Lambda returning the list of potentially active meshes.
  118214. */
  118215. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118216. /**
  118217. * Lambda returning the list of potentially active sub meshes.
  118218. */
  118219. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118220. /**
  118221. * Lambda returning the list of potentially intersecting sub meshes.
  118222. */
  118223. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118224. /**
  118225. * Lambda returning the list of potentially colliding sub meshes.
  118226. */
  118227. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118228. private _activeMeshesFrozen;
  118229. private _skipEvaluateActiveMeshesCompletely;
  118230. /**
  118231. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118232. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118233. * @returns the current scene
  118234. */
  118235. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118236. /**
  118237. * Use this function to restart evaluating active meshes on every frame
  118238. * @returns the current scene
  118239. */
  118240. unfreezeActiveMeshes(): Scene;
  118241. private _evaluateActiveMeshes;
  118242. private _activeMesh;
  118243. /**
  118244. * Update the transform matrix to update from the current active camera
  118245. * @param force defines a boolean used to force the update even if cache is up to date
  118246. */
  118247. updateTransformMatrix(force?: boolean): void;
  118248. private _bindFrameBuffer;
  118249. /** @hidden */
  118250. _allowPostProcessClearColor: boolean;
  118251. /** @hidden */
  118252. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118253. private _processSubCameras;
  118254. private _checkIntersections;
  118255. /** @hidden */
  118256. _advancePhysicsEngineStep(step: number): void;
  118257. /**
  118258. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118259. */
  118260. getDeterministicFrameTime: () => number;
  118261. /** @hidden */
  118262. _animate(): void;
  118263. /** Execute all animations (for a frame) */
  118264. animate(): void;
  118265. /**
  118266. * Render the scene
  118267. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118268. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118269. */
  118270. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118271. /**
  118272. * Freeze all materials
  118273. * A frozen material will not be updatable but should be faster to render
  118274. */
  118275. freezeMaterials(): void;
  118276. /**
  118277. * Unfreeze all materials
  118278. * A frozen material will not be updatable but should be faster to render
  118279. */
  118280. unfreezeMaterials(): void;
  118281. /**
  118282. * Releases all held ressources
  118283. */
  118284. dispose(): void;
  118285. /**
  118286. * Gets if the scene is already disposed
  118287. */
  118288. get isDisposed(): boolean;
  118289. /**
  118290. * Call this function to reduce memory footprint of the scene.
  118291. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118292. */
  118293. clearCachedVertexData(): void;
  118294. /**
  118295. * This function will remove the local cached buffer data from texture.
  118296. * It will save memory but will prevent the texture from being rebuilt
  118297. */
  118298. cleanCachedTextureBuffer(): void;
  118299. /**
  118300. * Get the world extend vectors with an optional filter
  118301. *
  118302. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118303. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118304. */
  118305. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118306. min: Vector3;
  118307. max: Vector3;
  118308. };
  118309. /**
  118310. * Creates a ray that can be used to pick in the scene
  118311. * @param x defines the x coordinate of the origin (on-screen)
  118312. * @param y defines the y coordinate of the origin (on-screen)
  118313. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118314. * @param camera defines the camera to use for the picking
  118315. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118316. * @returns a Ray
  118317. */
  118318. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118319. /**
  118320. * Creates a ray that can be used to pick in the scene
  118321. * @param x defines the x coordinate of the origin (on-screen)
  118322. * @param y defines the y coordinate of the origin (on-screen)
  118323. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118324. * @param result defines the ray where to store the picking ray
  118325. * @param camera defines the camera to use for the picking
  118326. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118327. * @returns the current scene
  118328. */
  118329. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118330. /**
  118331. * Creates a ray that can be used to pick in the scene
  118332. * @param x defines the x coordinate of the origin (on-screen)
  118333. * @param y defines the y coordinate of the origin (on-screen)
  118334. * @param camera defines the camera to use for the picking
  118335. * @returns a Ray
  118336. */
  118337. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118338. /**
  118339. * Creates a ray that can be used to pick in the scene
  118340. * @param x defines the x coordinate of the origin (on-screen)
  118341. * @param y defines the y coordinate of the origin (on-screen)
  118342. * @param result defines the ray where to store the picking ray
  118343. * @param camera defines the camera to use for the picking
  118344. * @returns the current scene
  118345. */
  118346. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118347. /** Launch a ray to try to pick a mesh in the scene
  118348. * @param x position on screen
  118349. * @param y position on screen
  118350. * @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
  118351. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118352. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118353. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118354. * @returns a PickingInfo
  118355. */
  118356. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118357. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118358. * @param x position on screen
  118359. * @param y position on screen
  118360. * @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
  118361. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118362. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118363. * @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)
  118364. */
  118365. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118366. /** Use the given ray to pick a mesh in the scene
  118367. * @param ray The ray to use to pick meshes
  118368. * @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
  118369. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118370. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118371. * @returns a PickingInfo
  118372. */
  118373. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118374. /**
  118375. * Launch a ray to try to pick a mesh in the scene
  118376. * @param x X position on screen
  118377. * @param y Y position on screen
  118378. * @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
  118379. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118380. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118381. * @returns an array of PickingInfo
  118382. */
  118383. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118384. /**
  118385. * Launch a ray to try to pick a mesh in the scene
  118386. * @param ray Ray to use
  118387. * @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
  118388. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118389. * @returns an array of PickingInfo
  118390. */
  118391. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118392. /**
  118393. * Force the value of meshUnderPointer
  118394. * @param mesh defines the mesh to use
  118395. */
  118396. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118397. /**
  118398. * Gets the mesh under the pointer
  118399. * @returns a Mesh or null if no mesh is under the pointer
  118400. */
  118401. getPointerOverMesh(): Nullable<AbstractMesh>;
  118402. /** @hidden */
  118403. _rebuildGeometries(): void;
  118404. /** @hidden */
  118405. _rebuildTextures(): void;
  118406. private _getByTags;
  118407. /**
  118408. * Get a list of meshes by tags
  118409. * @param tagsQuery defines the tags query to use
  118410. * @param forEach defines a predicate used to filter results
  118411. * @returns an array of Mesh
  118412. */
  118413. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118414. /**
  118415. * Get a list of cameras by tags
  118416. * @param tagsQuery defines the tags query to use
  118417. * @param forEach defines a predicate used to filter results
  118418. * @returns an array of Camera
  118419. */
  118420. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118421. /**
  118422. * Get a list of lights by tags
  118423. * @param tagsQuery defines the tags query to use
  118424. * @param forEach defines a predicate used to filter results
  118425. * @returns an array of Light
  118426. */
  118427. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118428. /**
  118429. * Get a list of materials by tags
  118430. * @param tagsQuery defines the tags query to use
  118431. * @param forEach defines a predicate used to filter results
  118432. * @returns an array of Material
  118433. */
  118434. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118435. /**
  118436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118437. * This allowed control for front to back rendering or reversly depending of the special needs.
  118438. *
  118439. * @param renderingGroupId The rendering group id corresponding to its index
  118440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118443. */
  118444. 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;
  118445. /**
  118446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118447. *
  118448. * @param renderingGroupId The rendering group id corresponding to its index
  118449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118450. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118451. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118452. */
  118453. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118454. /**
  118455. * Gets the current auto clear configuration for one rendering group of the rendering
  118456. * manager.
  118457. * @param index the rendering group index to get the information for
  118458. * @returns The auto clear setup for the requested rendering group
  118459. */
  118460. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118461. private _blockMaterialDirtyMechanism;
  118462. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118463. get blockMaterialDirtyMechanism(): boolean;
  118464. set blockMaterialDirtyMechanism(value: boolean);
  118465. /**
  118466. * Will flag all materials as dirty to trigger new shader compilation
  118467. * @param flag defines the flag used to specify which material part must be marked as dirty
  118468. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118469. */
  118470. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118471. /** @hidden */
  118472. _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;
  118473. /** @hidden */
  118474. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118475. /** @hidden */
  118476. _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;
  118477. /** @hidden */
  118478. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118479. /** @hidden */
  118480. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118481. /** @hidden */
  118482. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118483. }
  118484. }
  118485. declare module BABYLON {
  118486. /**
  118487. * Set of assets to keep when moving a scene into an asset container.
  118488. */
  118489. export class KeepAssets extends AbstractScene {
  118490. }
  118491. /**
  118492. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118493. */
  118494. export class InstantiatedEntries {
  118495. /**
  118496. * List of new root nodes (eg. nodes with no parent)
  118497. */
  118498. rootNodes: TransformNode[];
  118499. /**
  118500. * List of new skeletons
  118501. */
  118502. skeletons: Skeleton[];
  118503. /**
  118504. * List of new animation groups
  118505. */
  118506. animationGroups: AnimationGroup[];
  118507. }
  118508. /**
  118509. * Container with a set of assets that can be added or removed from a scene.
  118510. */
  118511. export class AssetContainer extends AbstractScene {
  118512. private _wasAddedToScene;
  118513. /**
  118514. * The scene the AssetContainer belongs to.
  118515. */
  118516. scene: Scene;
  118517. /**
  118518. * Instantiates an AssetContainer.
  118519. * @param scene The scene the AssetContainer belongs to.
  118520. */
  118521. constructor(scene: Scene);
  118522. /**
  118523. * Instantiate or clone all meshes and add the new ones to the scene.
  118524. * Skeletons and animation groups will all be cloned
  118525. * @param nameFunction defines an optional function used to get new names for clones
  118526. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118527. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118528. */
  118529. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118530. /**
  118531. * Adds all the assets from the container to the scene.
  118532. */
  118533. addAllToScene(): void;
  118534. /**
  118535. * Removes all the assets in the container from the scene
  118536. */
  118537. removeAllFromScene(): void;
  118538. /**
  118539. * Disposes all the assets in the container
  118540. */
  118541. dispose(): void;
  118542. private _moveAssets;
  118543. /**
  118544. * Removes all the assets contained in the scene and adds them to the container.
  118545. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118546. */
  118547. moveAllFromScene(keepAssets?: KeepAssets): void;
  118548. /**
  118549. * 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.
  118550. * @returns the root mesh
  118551. */
  118552. createRootMesh(): Mesh;
  118553. /**
  118554. * Merge animations (direct and animation groups) from this asset container into a scene
  118555. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118556. * @param animatables set of animatables to retarget to a node from the scene
  118557. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118558. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118559. */
  118560. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118561. }
  118562. }
  118563. declare module BABYLON {
  118564. /**
  118565. * Defines how the parser contract is defined.
  118566. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118567. */
  118568. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118569. /**
  118570. * Defines how the individual parser contract is defined.
  118571. * These parser can parse an individual asset
  118572. */
  118573. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118574. /**
  118575. * Base class of the scene acting as a container for the different elements composing a scene.
  118576. * This class is dynamically extended by the different components of the scene increasing
  118577. * flexibility and reducing coupling
  118578. */
  118579. export abstract class AbstractScene {
  118580. /**
  118581. * Stores the list of available parsers in the application.
  118582. */
  118583. private static _BabylonFileParsers;
  118584. /**
  118585. * Stores the list of available individual parsers in the application.
  118586. */
  118587. private static _IndividualBabylonFileParsers;
  118588. /**
  118589. * Adds a parser in the list of available ones
  118590. * @param name Defines the name of the parser
  118591. * @param parser Defines the parser to add
  118592. */
  118593. static AddParser(name: string, parser: BabylonFileParser): void;
  118594. /**
  118595. * Gets a general parser from the list of avaialble ones
  118596. * @param name Defines the name of the parser
  118597. * @returns the requested parser or null
  118598. */
  118599. static GetParser(name: string): Nullable<BabylonFileParser>;
  118600. /**
  118601. * Adds n individual parser in the list of available ones
  118602. * @param name Defines the name of the parser
  118603. * @param parser Defines the parser to add
  118604. */
  118605. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118606. /**
  118607. * Gets an individual parser from the list of avaialble ones
  118608. * @param name Defines the name of the parser
  118609. * @returns the requested parser or null
  118610. */
  118611. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118612. /**
  118613. * Parser json data and populate both a scene and its associated container object
  118614. * @param jsonData Defines the data to parse
  118615. * @param scene Defines the scene to parse the data for
  118616. * @param container Defines the container attached to the parsing sequence
  118617. * @param rootUrl Defines the root url of the data
  118618. */
  118619. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118620. /**
  118621. * Gets the list of root nodes (ie. nodes with no parent)
  118622. */
  118623. rootNodes: Node[];
  118624. /** All of the cameras added to this scene
  118625. * @see https://doc.babylonjs.com/babylon101/cameras
  118626. */
  118627. cameras: Camera[];
  118628. /**
  118629. * All of the lights added to this scene
  118630. * @see https://doc.babylonjs.com/babylon101/lights
  118631. */
  118632. lights: Light[];
  118633. /**
  118634. * All of the (abstract) meshes added to this scene
  118635. */
  118636. meshes: AbstractMesh[];
  118637. /**
  118638. * The list of skeletons added to the scene
  118639. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118640. */
  118641. skeletons: Skeleton[];
  118642. /**
  118643. * All of the particle systems added to this scene
  118644. * @see https://doc.babylonjs.com/babylon101/particles
  118645. */
  118646. particleSystems: IParticleSystem[];
  118647. /**
  118648. * Gets a list of Animations associated with the scene
  118649. */
  118650. animations: Animation[];
  118651. /**
  118652. * All of the animation groups added to this scene
  118653. * @see https://doc.babylonjs.com/how_to/group
  118654. */
  118655. animationGroups: AnimationGroup[];
  118656. /**
  118657. * All of the multi-materials added to this scene
  118658. * @see https://doc.babylonjs.com/how_to/multi_materials
  118659. */
  118660. multiMaterials: MultiMaterial[];
  118661. /**
  118662. * All of the materials added to this scene
  118663. * In the context of a Scene, it is not supposed to be modified manually.
  118664. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118665. * Note also that the order of the Material within the array is not significant and might change.
  118666. * @see https://doc.babylonjs.com/babylon101/materials
  118667. */
  118668. materials: Material[];
  118669. /**
  118670. * The list of morph target managers added to the scene
  118671. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118672. */
  118673. morphTargetManagers: MorphTargetManager[];
  118674. /**
  118675. * The list of geometries used in the scene.
  118676. */
  118677. geometries: Geometry[];
  118678. /**
  118679. * All of the tranform nodes added to this scene
  118680. * In the context of a Scene, it is not supposed to be modified manually.
  118681. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118682. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118683. * @see https://doc.babylonjs.com/how_to/transformnode
  118684. */
  118685. transformNodes: TransformNode[];
  118686. /**
  118687. * ActionManagers available on the scene.
  118688. */
  118689. actionManagers: AbstractActionManager[];
  118690. /**
  118691. * Textures to keep.
  118692. */
  118693. textures: BaseTexture[];
  118694. /**
  118695. * Environment texture for the scene
  118696. */
  118697. environmentTexture: Nullable<BaseTexture>;
  118698. /**
  118699. * @returns all meshes, lights, cameras, transformNodes and bones
  118700. */
  118701. getNodes(): Array<Node>;
  118702. }
  118703. }
  118704. declare module BABYLON {
  118705. /**
  118706. * Interface used to define options for Sound class
  118707. */
  118708. export interface ISoundOptions {
  118709. /**
  118710. * Does the sound autoplay once loaded.
  118711. */
  118712. autoplay?: boolean;
  118713. /**
  118714. * Does the sound loop after it finishes playing once.
  118715. */
  118716. loop?: boolean;
  118717. /**
  118718. * Sound's volume
  118719. */
  118720. volume?: number;
  118721. /**
  118722. * Is it a spatial sound?
  118723. */
  118724. spatialSound?: boolean;
  118725. /**
  118726. * Maximum distance to hear that sound
  118727. */
  118728. maxDistance?: number;
  118729. /**
  118730. * Uses user defined attenuation function
  118731. */
  118732. useCustomAttenuation?: boolean;
  118733. /**
  118734. * Define the roll off factor of spatial sounds.
  118735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118736. */
  118737. rolloffFactor?: number;
  118738. /**
  118739. * Define the reference distance the sound should be heard perfectly.
  118740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118741. */
  118742. refDistance?: number;
  118743. /**
  118744. * Define the distance attenuation model the sound will follow.
  118745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118746. */
  118747. distanceModel?: string;
  118748. /**
  118749. * Defines the playback speed (1 by default)
  118750. */
  118751. playbackRate?: number;
  118752. /**
  118753. * Defines if the sound is from a streaming source
  118754. */
  118755. streaming?: boolean;
  118756. /**
  118757. * Defines an optional length (in seconds) inside the sound file
  118758. */
  118759. length?: number;
  118760. /**
  118761. * Defines an optional offset (in seconds) inside the sound file
  118762. */
  118763. offset?: number;
  118764. /**
  118765. * If true, URLs will not be required to state the audio file codec to use.
  118766. */
  118767. skipCodecCheck?: boolean;
  118768. }
  118769. /**
  118770. * Defines a sound that can be played in the application.
  118771. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118773. */
  118774. export class Sound {
  118775. /**
  118776. * The name of the sound in the scene.
  118777. */
  118778. name: string;
  118779. /**
  118780. * Does the sound autoplay once loaded.
  118781. */
  118782. autoplay: boolean;
  118783. /**
  118784. * Does the sound loop after it finishes playing once.
  118785. */
  118786. loop: boolean;
  118787. /**
  118788. * Does the sound use a custom attenuation curve to simulate the falloff
  118789. * happening when the source gets further away from the camera.
  118790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118791. */
  118792. useCustomAttenuation: boolean;
  118793. /**
  118794. * The sound track id this sound belongs to.
  118795. */
  118796. soundTrackId: number;
  118797. /**
  118798. * Is this sound currently played.
  118799. */
  118800. isPlaying: boolean;
  118801. /**
  118802. * Is this sound currently paused.
  118803. */
  118804. isPaused: boolean;
  118805. /**
  118806. * Does this sound enables spatial sound.
  118807. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118808. */
  118809. spatialSound: boolean;
  118810. /**
  118811. * Define the reference distance the sound should be heard perfectly.
  118812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118813. */
  118814. refDistance: number;
  118815. /**
  118816. * Define the roll off factor of spatial sounds.
  118817. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118818. */
  118819. rolloffFactor: number;
  118820. /**
  118821. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118823. */
  118824. maxDistance: number;
  118825. /**
  118826. * Define the distance attenuation model the sound will follow.
  118827. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118828. */
  118829. distanceModel: string;
  118830. /**
  118831. * @hidden
  118832. * Back Compat
  118833. **/
  118834. onended: () => any;
  118835. /**
  118836. * Gets or sets an object used to store user defined information for the sound.
  118837. */
  118838. metadata: any;
  118839. /**
  118840. * Observable event when the current playing sound finishes.
  118841. */
  118842. onEndedObservable: Observable<Sound>;
  118843. private _panningModel;
  118844. private _playbackRate;
  118845. private _streaming;
  118846. private _startTime;
  118847. private _startOffset;
  118848. private _position;
  118849. /** @hidden */
  118850. _positionInEmitterSpace: boolean;
  118851. private _localDirection;
  118852. private _volume;
  118853. private _isReadyToPlay;
  118854. private _isDirectional;
  118855. private _readyToPlayCallback;
  118856. private _audioBuffer;
  118857. private _soundSource;
  118858. private _streamingSource;
  118859. private _soundPanner;
  118860. private _soundGain;
  118861. private _inputAudioNode;
  118862. private _outputAudioNode;
  118863. private _coneInnerAngle;
  118864. private _coneOuterAngle;
  118865. private _coneOuterGain;
  118866. private _scene;
  118867. private _connectedTransformNode;
  118868. private _customAttenuationFunction;
  118869. private _registerFunc;
  118870. private _isOutputConnected;
  118871. private _htmlAudioElement;
  118872. private _urlType;
  118873. private _length?;
  118874. private _offset?;
  118875. /** @hidden */
  118876. static _SceneComponentInitialization: (scene: Scene) => void;
  118877. /**
  118878. * Create a sound and attach it to a scene
  118879. * @param name Name of your sound
  118880. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118881. * @param scene defines the scene the sound belongs to
  118882. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118883. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118884. */
  118885. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118886. /**
  118887. * Release the sound and its associated resources
  118888. */
  118889. dispose(): void;
  118890. /**
  118891. * Gets if the sounds is ready to be played or not.
  118892. * @returns true if ready, otherwise false
  118893. */
  118894. isReady(): boolean;
  118895. private _soundLoaded;
  118896. /**
  118897. * Sets the data of the sound from an audiobuffer
  118898. * @param audioBuffer The audioBuffer containing the data
  118899. */
  118900. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118901. /**
  118902. * Updates the current sounds options such as maxdistance, loop...
  118903. * @param options A JSON object containing values named as the object properties
  118904. */
  118905. updateOptions(options: ISoundOptions): void;
  118906. private _createSpatialParameters;
  118907. private _updateSpatialParameters;
  118908. /**
  118909. * Switch the panning model to HRTF:
  118910. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118912. */
  118913. switchPanningModelToHRTF(): void;
  118914. /**
  118915. * Switch the panning model to Equal Power:
  118916. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118917. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118918. */
  118919. switchPanningModelToEqualPower(): void;
  118920. private _switchPanningModel;
  118921. /**
  118922. * Connect this sound to a sound track audio node like gain...
  118923. * @param soundTrackAudioNode the sound track audio node to connect to
  118924. */
  118925. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118926. /**
  118927. * Transform this sound into a directional source
  118928. * @param coneInnerAngle Size of the inner cone in degree
  118929. * @param coneOuterAngle Size of the outer cone in degree
  118930. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118931. */
  118932. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118933. /**
  118934. * Gets or sets the inner angle for the directional cone.
  118935. */
  118936. get directionalConeInnerAngle(): number;
  118937. /**
  118938. * Gets or sets the inner angle for the directional cone.
  118939. */
  118940. set directionalConeInnerAngle(value: number);
  118941. /**
  118942. * Gets or sets the outer angle for the directional cone.
  118943. */
  118944. get directionalConeOuterAngle(): number;
  118945. /**
  118946. * Gets or sets the outer angle for the directional cone.
  118947. */
  118948. set directionalConeOuterAngle(value: number);
  118949. /**
  118950. * Sets the position of the emitter if spatial sound is enabled
  118951. * @param newPosition Defines the new posisiton
  118952. */
  118953. setPosition(newPosition: Vector3): void;
  118954. /**
  118955. * Sets the local direction of the emitter if spatial sound is enabled
  118956. * @param newLocalDirection Defines the new local direction
  118957. */
  118958. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118959. private _updateDirection;
  118960. /** @hidden */
  118961. updateDistanceFromListener(): void;
  118962. /**
  118963. * Sets a new custom attenuation function for the sound.
  118964. * @param callback Defines the function used for the attenuation
  118965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118966. */
  118967. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118968. /**
  118969. * Play the sound
  118970. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118971. * @param offset (optional) Start the sound at a specific time in seconds
  118972. * @param length (optional) Sound duration (in seconds)
  118973. */
  118974. play(time?: number, offset?: number, length?: number): void;
  118975. private _onended;
  118976. /**
  118977. * Stop the sound
  118978. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118979. */
  118980. stop(time?: number): void;
  118981. /**
  118982. * Put the sound in pause
  118983. */
  118984. pause(): void;
  118985. /**
  118986. * Sets a dedicated volume for this sounds
  118987. * @param newVolume Define the new volume of the sound
  118988. * @param time Define time for gradual change to new volume
  118989. */
  118990. setVolume(newVolume: number, time?: number): void;
  118991. /**
  118992. * Set the sound play back rate
  118993. * @param newPlaybackRate Define the playback rate the sound should be played at
  118994. */
  118995. setPlaybackRate(newPlaybackRate: number): void;
  118996. /**
  118997. * Gets the volume of the sound.
  118998. * @returns the volume of the sound
  118999. */
  119000. getVolume(): number;
  119001. /**
  119002. * Attach the sound to a dedicated mesh
  119003. * @param transformNode The transform node to connect the sound with
  119004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119005. */
  119006. attachToMesh(transformNode: TransformNode): void;
  119007. /**
  119008. * Detach the sound from the previously attached mesh
  119009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119010. */
  119011. detachFromMesh(): void;
  119012. private _onRegisterAfterWorldMatrixUpdate;
  119013. /**
  119014. * Clone the current sound in the scene.
  119015. * @returns the new sound clone
  119016. */
  119017. clone(): Nullable<Sound>;
  119018. /**
  119019. * Gets the current underlying audio buffer containing the data
  119020. * @returns the audio buffer
  119021. */
  119022. getAudioBuffer(): Nullable<AudioBuffer>;
  119023. /**
  119024. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119025. * @returns the source node
  119026. */
  119027. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119028. /**
  119029. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119030. * @returns the gain node
  119031. */
  119032. getSoundGain(): Nullable<GainNode>;
  119033. /**
  119034. * Serializes the Sound in a JSON representation
  119035. * @returns the JSON representation of the sound
  119036. */
  119037. serialize(): any;
  119038. /**
  119039. * Parse a JSON representation of a sound to innstantiate in a given scene
  119040. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119041. * @param scene Define the scene the new parsed sound should be created in
  119042. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119043. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119044. * @returns the newly parsed sound
  119045. */
  119046. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119047. }
  119048. }
  119049. declare module BABYLON {
  119050. /**
  119051. * This defines an action helpful to play a defined sound on a triggered action.
  119052. */
  119053. export class PlaySoundAction extends Action {
  119054. private _sound;
  119055. /**
  119056. * Instantiate the action
  119057. * @param triggerOptions defines the trigger options
  119058. * @param sound defines the sound to play
  119059. * @param condition defines the trigger related conditions
  119060. */
  119061. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119062. /** @hidden */
  119063. _prepare(): void;
  119064. /**
  119065. * Execute the action and play the sound.
  119066. */
  119067. execute(): void;
  119068. /**
  119069. * Serializes the actions and its related information.
  119070. * @param parent defines the object to serialize in
  119071. * @returns the serialized object
  119072. */
  119073. serialize(parent: any): any;
  119074. }
  119075. /**
  119076. * This defines an action helpful to stop a defined sound on a triggered action.
  119077. */
  119078. export class StopSoundAction extends Action {
  119079. private _sound;
  119080. /**
  119081. * Instantiate the action
  119082. * @param triggerOptions defines the trigger options
  119083. * @param sound defines the sound to stop
  119084. * @param condition defines the trigger related conditions
  119085. */
  119086. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119087. /** @hidden */
  119088. _prepare(): void;
  119089. /**
  119090. * Execute the action and stop the sound.
  119091. */
  119092. execute(): void;
  119093. /**
  119094. * Serializes the actions and its related information.
  119095. * @param parent defines the object to serialize in
  119096. * @returns the serialized object
  119097. */
  119098. serialize(parent: any): any;
  119099. }
  119100. }
  119101. declare module BABYLON {
  119102. /**
  119103. * This defines an action responsible to change the value of a property
  119104. * by interpolating between its current value and the newly set one once triggered.
  119105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119106. */
  119107. export class InterpolateValueAction extends Action {
  119108. /**
  119109. * Defines the path of the property where the value should be interpolated
  119110. */
  119111. propertyPath: string;
  119112. /**
  119113. * Defines the target value at the end of the interpolation.
  119114. */
  119115. value: any;
  119116. /**
  119117. * Defines the time it will take for the property to interpolate to the value.
  119118. */
  119119. duration: number;
  119120. /**
  119121. * Defines if the other scene animations should be stopped when the action has been triggered
  119122. */
  119123. stopOtherAnimations?: boolean;
  119124. /**
  119125. * Defines a callback raised once the interpolation animation has been done.
  119126. */
  119127. onInterpolationDone?: () => void;
  119128. /**
  119129. * Observable triggered once the interpolation animation has been done.
  119130. */
  119131. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119132. private _target;
  119133. private _effectiveTarget;
  119134. private _property;
  119135. /**
  119136. * Instantiate the action
  119137. * @param triggerOptions defines the trigger options
  119138. * @param target defines the object containing the value to interpolate
  119139. * @param propertyPath defines the path to the property in the target object
  119140. * @param value defines the target value at the end of the interpolation
  119141. * @param duration deines the time it will take for the property to interpolate to the value.
  119142. * @param condition defines the trigger related conditions
  119143. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119144. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119145. */
  119146. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119147. /** @hidden */
  119148. _prepare(): void;
  119149. /**
  119150. * Execute the action starts the value interpolation.
  119151. */
  119152. execute(): void;
  119153. /**
  119154. * Serializes the actions and its related information.
  119155. * @param parent defines the object to serialize in
  119156. * @returns the serialized object
  119157. */
  119158. serialize(parent: any): any;
  119159. }
  119160. }
  119161. declare module BABYLON {
  119162. /**
  119163. * Options allowed during the creation of a sound track.
  119164. */
  119165. export interface ISoundTrackOptions {
  119166. /**
  119167. * The volume the sound track should take during creation
  119168. */
  119169. volume?: number;
  119170. /**
  119171. * Define if the sound track is the main sound track of the scene
  119172. */
  119173. mainTrack?: boolean;
  119174. }
  119175. /**
  119176. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119177. * It will be also used in a future release to apply effects on a specific track.
  119178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119179. */
  119180. export class SoundTrack {
  119181. /**
  119182. * The unique identifier of the sound track in the scene.
  119183. */
  119184. id: number;
  119185. /**
  119186. * The list of sounds included in the sound track.
  119187. */
  119188. soundCollection: Array<Sound>;
  119189. private _outputAudioNode;
  119190. private _scene;
  119191. private _connectedAnalyser;
  119192. private _options;
  119193. private _isInitialized;
  119194. /**
  119195. * Creates a new sound track.
  119196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119197. * @param scene Define the scene the sound track belongs to
  119198. * @param options
  119199. */
  119200. constructor(scene: Scene, options?: ISoundTrackOptions);
  119201. private _initializeSoundTrackAudioGraph;
  119202. /**
  119203. * Release the sound track and its associated resources
  119204. */
  119205. dispose(): void;
  119206. /**
  119207. * Adds a sound to this sound track
  119208. * @param sound define the cound to add
  119209. * @ignoreNaming
  119210. */
  119211. AddSound(sound: Sound): void;
  119212. /**
  119213. * Removes a sound to this sound track
  119214. * @param sound define the cound to remove
  119215. * @ignoreNaming
  119216. */
  119217. RemoveSound(sound: Sound): void;
  119218. /**
  119219. * Set a global volume for the full sound track.
  119220. * @param newVolume Define the new volume of the sound track
  119221. */
  119222. setVolume(newVolume: number): void;
  119223. /**
  119224. * Switch the panning model to HRTF:
  119225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119227. */
  119228. switchPanningModelToHRTF(): void;
  119229. /**
  119230. * Switch the panning model to Equal Power:
  119231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119233. */
  119234. switchPanningModelToEqualPower(): void;
  119235. /**
  119236. * Connect the sound track to an audio analyser allowing some amazing
  119237. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119238. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119239. * @param analyser The analyser to connect to the engine
  119240. */
  119241. connectToAnalyser(analyser: Analyser): void;
  119242. }
  119243. }
  119244. declare module BABYLON {
  119245. interface AbstractScene {
  119246. /**
  119247. * The list of sounds used in the scene.
  119248. */
  119249. sounds: Nullable<Array<Sound>>;
  119250. }
  119251. interface Scene {
  119252. /**
  119253. * @hidden
  119254. * Backing field
  119255. */
  119256. _mainSoundTrack: SoundTrack;
  119257. /**
  119258. * The main sound track played by the scene.
  119259. * It cotains your primary collection of sounds.
  119260. */
  119261. mainSoundTrack: SoundTrack;
  119262. /**
  119263. * The list of sound tracks added to the scene
  119264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119265. */
  119266. soundTracks: Nullable<Array<SoundTrack>>;
  119267. /**
  119268. * Gets a sound using a given name
  119269. * @param name defines the name to search for
  119270. * @return the found sound or null if not found at all.
  119271. */
  119272. getSoundByName(name: string): Nullable<Sound>;
  119273. /**
  119274. * Gets or sets if audio support is enabled
  119275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119276. */
  119277. audioEnabled: boolean;
  119278. /**
  119279. * Gets or sets if audio will be output to headphones
  119280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119281. */
  119282. headphone: boolean;
  119283. /**
  119284. * Gets or sets custom audio listener position provider
  119285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119286. */
  119287. audioListenerPositionProvider: Nullable<() => Vector3>;
  119288. /**
  119289. * Gets or sets a refresh rate when using 3D audio positioning
  119290. */
  119291. audioPositioningRefreshRate: number;
  119292. }
  119293. /**
  119294. * Defines the sound scene component responsible to manage any sounds
  119295. * in a given scene.
  119296. */
  119297. export class AudioSceneComponent implements ISceneSerializableComponent {
  119298. /**
  119299. * The component name helpfull to identify the component in the list of scene components.
  119300. */
  119301. readonly name: string;
  119302. /**
  119303. * The scene the component belongs to.
  119304. */
  119305. scene: Scene;
  119306. private _audioEnabled;
  119307. /**
  119308. * Gets whether audio is enabled or not.
  119309. * Please use related enable/disable method to switch state.
  119310. */
  119311. get audioEnabled(): boolean;
  119312. private _headphone;
  119313. /**
  119314. * Gets whether audio is outputing to headphone or not.
  119315. * Please use the according Switch methods to change output.
  119316. */
  119317. get headphone(): boolean;
  119318. /**
  119319. * Gets or sets a refresh rate when using 3D audio positioning
  119320. */
  119321. audioPositioningRefreshRate: number;
  119322. private _audioListenerPositionProvider;
  119323. /**
  119324. * Gets the current audio listener position provider
  119325. */
  119326. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119327. /**
  119328. * Sets a custom listener position for all sounds in the scene
  119329. * By default, this is the position of the first active camera
  119330. */
  119331. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119332. /**
  119333. * Creates a new instance of the component for the given scene
  119334. * @param scene Defines the scene to register the component in
  119335. */
  119336. constructor(scene: Scene);
  119337. /**
  119338. * Registers the component in a given scene
  119339. */
  119340. register(): void;
  119341. /**
  119342. * Rebuilds the elements related to this component in case of
  119343. * context lost for instance.
  119344. */
  119345. rebuild(): void;
  119346. /**
  119347. * Serializes the component data to the specified json object
  119348. * @param serializationObject The object to serialize to
  119349. */
  119350. serialize(serializationObject: any): void;
  119351. /**
  119352. * Adds all the elements from the container to the scene
  119353. * @param container the container holding the elements
  119354. */
  119355. addFromContainer(container: AbstractScene): void;
  119356. /**
  119357. * Removes all the elements in the container from the scene
  119358. * @param container contains the elements to remove
  119359. * @param dispose if the removed element should be disposed (default: false)
  119360. */
  119361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119362. /**
  119363. * Disposes the component and the associated ressources.
  119364. */
  119365. dispose(): void;
  119366. /**
  119367. * Disables audio in the associated scene.
  119368. */
  119369. disableAudio(): void;
  119370. /**
  119371. * Enables audio in the associated scene.
  119372. */
  119373. enableAudio(): void;
  119374. /**
  119375. * Switch audio to headphone output.
  119376. */
  119377. switchAudioModeForHeadphones(): void;
  119378. /**
  119379. * Switch audio to normal speakers.
  119380. */
  119381. switchAudioModeForNormalSpeakers(): void;
  119382. private _cachedCameraDirection;
  119383. private _cachedCameraPosition;
  119384. private _lastCheck;
  119385. private _afterRender;
  119386. }
  119387. }
  119388. declare module BABYLON {
  119389. /**
  119390. * Wraps one or more Sound objects and selects one with random weight for playback.
  119391. */
  119392. export class WeightedSound {
  119393. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119394. loop: boolean;
  119395. private _coneInnerAngle;
  119396. private _coneOuterAngle;
  119397. private _volume;
  119398. /** A Sound is currently playing. */
  119399. isPlaying: boolean;
  119400. /** A Sound is currently paused. */
  119401. isPaused: boolean;
  119402. private _sounds;
  119403. private _weights;
  119404. private _currentIndex?;
  119405. /**
  119406. * Creates a new WeightedSound from the list of sounds given.
  119407. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119408. * @param sounds Array of Sounds that will be selected from.
  119409. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119410. */
  119411. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119412. /**
  119413. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119414. */
  119415. get directionalConeInnerAngle(): number;
  119416. /**
  119417. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119418. */
  119419. set directionalConeInnerAngle(value: number);
  119420. /**
  119421. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119422. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119423. */
  119424. get directionalConeOuterAngle(): number;
  119425. /**
  119426. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119427. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119428. */
  119429. set directionalConeOuterAngle(value: number);
  119430. /**
  119431. * Playback volume.
  119432. */
  119433. get volume(): number;
  119434. /**
  119435. * Playback volume.
  119436. */
  119437. set volume(value: number);
  119438. private _onended;
  119439. /**
  119440. * Suspend playback
  119441. */
  119442. pause(): void;
  119443. /**
  119444. * Stop playback
  119445. */
  119446. stop(): void;
  119447. /**
  119448. * Start playback.
  119449. * @param startOffset Position the clip head at a specific time in seconds.
  119450. */
  119451. play(startOffset?: number): void;
  119452. }
  119453. }
  119454. declare module BABYLON {
  119455. /**
  119456. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119457. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119458. */
  119459. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119460. /**
  119461. * Gets the name of the behavior.
  119462. */
  119463. get name(): string;
  119464. /**
  119465. * The easing function used by animations
  119466. */
  119467. static EasingFunction: BackEase;
  119468. /**
  119469. * The easing mode used by animations
  119470. */
  119471. static EasingMode: number;
  119472. /**
  119473. * The duration of the animation, in milliseconds
  119474. */
  119475. transitionDuration: number;
  119476. /**
  119477. * Length of the distance animated by the transition when lower radius is reached
  119478. */
  119479. lowerRadiusTransitionRange: number;
  119480. /**
  119481. * Length of the distance animated by the transition when upper radius is reached
  119482. */
  119483. upperRadiusTransitionRange: number;
  119484. private _autoTransitionRange;
  119485. /**
  119486. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119487. */
  119488. get autoTransitionRange(): boolean;
  119489. /**
  119490. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119491. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119492. */
  119493. set autoTransitionRange(value: boolean);
  119494. private _attachedCamera;
  119495. private _onAfterCheckInputsObserver;
  119496. private _onMeshTargetChangedObserver;
  119497. /**
  119498. * Initializes the behavior.
  119499. */
  119500. init(): void;
  119501. /**
  119502. * Attaches the behavior to its arc rotate camera.
  119503. * @param camera Defines the camera to attach the behavior to
  119504. */
  119505. attach(camera: ArcRotateCamera): void;
  119506. /**
  119507. * Detaches the behavior from its current arc rotate camera.
  119508. */
  119509. detach(): void;
  119510. private _radiusIsAnimating;
  119511. private _radiusBounceTransition;
  119512. private _animatables;
  119513. private _cachedWheelPrecision;
  119514. /**
  119515. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119516. * @param radiusLimit The limit to check against.
  119517. * @return Bool to indicate if at limit.
  119518. */
  119519. private _isRadiusAtLimit;
  119520. /**
  119521. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119522. * @param radiusDelta The delta by which to animate to. Can be negative.
  119523. */
  119524. private _applyBoundRadiusAnimation;
  119525. /**
  119526. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119527. */
  119528. protected _clearAnimationLocks(): void;
  119529. /**
  119530. * Stops and removes all animations that have been applied to the camera
  119531. */
  119532. stopAllAnimations(): void;
  119533. }
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * 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.
  119538. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119539. */
  119540. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119541. /**
  119542. * Gets the name of the behavior.
  119543. */
  119544. get name(): string;
  119545. private _mode;
  119546. private _radiusScale;
  119547. private _positionScale;
  119548. private _defaultElevation;
  119549. private _elevationReturnTime;
  119550. private _elevationReturnWaitTime;
  119551. private _zoomStopsAnimation;
  119552. private _framingTime;
  119553. /**
  119554. * The easing function used by animations
  119555. */
  119556. static EasingFunction: ExponentialEase;
  119557. /**
  119558. * The easing mode used by animations
  119559. */
  119560. static EasingMode: number;
  119561. /**
  119562. * Sets the current mode used by the behavior
  119563. */
  119564. set mode(mode: number);
  119565. /**
  119566. * Gets current mode used by the behavior.
  119567. */
  119568. get mode(): number;
  119569. /**
  119570. * Sets the scale applied to the radius (1 by default)
  119571. */
  119572. set radiusScale(radius: number);
  119573. /**
  119574. * Gets the scale applied to the radius
  119575. */
  119576. get radiusScale(): number;
  119577. /**
  119578. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119579. */
  119580. set positionScale(scale: number);
  119581. /**
  119582. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119583. */
  119584. get positionScale(): number;
  119585. /**
  119586. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119587. * behaviour is triggered, in radians.
  119588. */
  119589. set defaultElevation(elevation: number);
  119590. /**
  119591. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119592. * behaviour is triggered, in radians.
  119593. */
  119594. get defaultElevation(): number;
  119595. /**
  119596. * Sets the time (in milliseconds) taken to return to the default beta position.
  119597. * Negative value indicates camera should not return to default.
  119598. */
  119599. set elevationReturnTime(speed: number);
  119600. /**
  119601. * Gets the time (in milliseconds) taken to return to the default beta position.
  119602. * Negative value indicates camera should not return to default.
  119603. */
  119604. get elevationReturnTime(): number;
  119605. /**
  119606. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119607. */
  119608. set elevationReturnWaitTime(time: number);
  119609. /**
  119610. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119611. */
  119612. get elevationReturnWaitTime(): number;
  119613. /**
  119614. * Sets the flag that indicates if user zooming should stop animation.
  119615. */
  119616. set zoomStopsAnimation(flag: boolean);
  119617. /**
  119618. * Gets the flag that indicates if user zooming should stop animation.
  119619. */
  119620. get zoomStopsAnimation(): boolean;
  119621. /**
  119622. * Sets the transition time when framing the mesh, in milliseconds
  119623. */
  119624. set framingTime(time: number);
  119625. /**
  119626. * Gets the transition time when framing the mesh, in milliseconds
  119627. */
  119628. get framingTime(): number;
  119629. /**
  119630. * Define if the behavior should automatically change the configured
  119631. * camera limits and sensibilities.
  119632. */
  119633. autoCorrectCameraLimitsAndSensibility: boolean;
  119634. private _onPrePointerObservableObserver;
  119635. private _onAfterCheckInputsObserver;
  119636. private _onMeshTargetChangedObserver;
  119637. private _attachedCamera;
  119638. private _isPointerDown;
  119639. private _lastInteractionTime;
  119640. /**
  119641. * Initializes the behavior.
  119642. */
  119643. init(): void;
  119644. /**
  119645. * Attaches the behavior to its arc rotate camera.
  119646. * @param camera Defines the camera to attach the behavior to
  119647. */
  119648. attach(camera: ArcRotateCamera): void;
  119649. /**
  119650. * Detaches the behavior from its current arc rotate camera.
  119651. */
  119652. detach(): void;
  119653. private _animatables;
  119654. private _betaIsAnimating;
  119655. private _betaTransition;
  119656. private _radiusTransition;
  119657. private _vectorTransition;
  119658. /**
  119659. * Targets the given mesh and updates zoom level accordingly.
  119660. * @param mesh The mesh to target.
  119661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119663. */
  119664. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119665. /**
  119666. * Targets the given mesh with its children and updates zoom level accordingly.
  119667. * @param mesh The mesh to target.
  119668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119670. */
  119671. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119672. /**
  119673. * Targets the given meshes with their children and updates zoom level accordingly.
  119674. * @param meshes The mesh to target.
  119675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119677. */
  119678. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119679. /**
  119680. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119681. * @param minimumWorld Determines the smaller position of the bounding box extend
  119682. * @param maximumWorld Determines the bigger position of the bounding box extend
  119683. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119684. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119685. */
  119686. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119687. /**
  119688. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119689. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119690. * frustum width.
  119691. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119692. * to fully enclose the mesh in the viewing frustum.
  119693. */
  119694. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119695. /**
  119696. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119697. * is automatically returned to its default position (expected to be above ground plane).
  119698. */
  119699. private _maintainCameraAboveGround;
  119700. /**
  119701. * Returns the frustum slope based on the canvas ratio and camera FOV
  119702. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119703. */
  119704. private _getFrustumSlope;
  119705. /**
  119706. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119707. */
  119708. private _clearAnimationLocks;
  119709. /**
  119710. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119711. */
  119712. private _applyUserInteraction;
  119713. /**
  119714. * Stops and removes all animations that have been applied to the camera
  119715. */
  119716. stopAllAnimations(): void;
  119717. /**
  119718. * Gets a value indicating if the user is moving the camera
  119719. */
  119720. get isUserIsMoving(): boolean;
  119721. /**
  119722. * The camera can move all the way towards the mesh.
  119723. */
  119724. static IgnoreBoundsSizeMode: number;
  119725. /**
  119726. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119727. */
  119728. static FitFrustumSidesMode: number;
  119729. }
  119730. }
  119731. declare module BABYLON {
  119732. /**
  119733. * Base class for Camera Pointer Inputs.
  119734. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119735. * for example usage.
  119736. */
  119737. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119738. /**
  119739. * Defines the camera the input is attached to.
  119740. */
  119741. abstract camera: Camera;
  119742. /**
  119743. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119744. */
  119745. protected _altKey: boolean;
  119746. protected _ctrlKey: boolean;
  119747. protected _metaKey: boolean;
  119748. protected _shiftKey: boolean;
  119749. /**
  119750. * Which mouse buttons were pressed at time of last mouse event.
  119751. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119752. */
  119753. protected _buttonsPressed: number;
  119754. /**
  119755. * Defines the buttons associated with the input to handle camera move.
  119756. */
  119757. buttons: number[];
  119758. /**
  119759. * Attach the input controls to a specific dom element to get the input from.
  119760. * @param element Defines the element the controls should be listened from
  119761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119762. */
  119763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119764. /**
  119765. * Detach the current controls from the specified dom element.
  119766. * @param element Defines the element to stop listening the inputs from
  119767. */
  119768. detachControl(element: Nullable<HTMLElement>): void;
  119769. /**
  119770. * Gets the class name of the current input.
  119771. * @returns the class name
  119772. */
  119773. getClassName(): string;
  119774. /**
  119775. * Get the friendly name associated with the input class.
  119776. * @returns the input friendly name
  119777. */
  119778. getSimpleName(): string;
  119779. /**
  119780. * Called on pointer POINTERDOUBLETAP event.
  119781. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119782. */
  119783. protected onDoubleTap(type: string): void;
  119784. /**
  119785. * Called on pointer POINTERMOVE event if only a single touch is active.
  119786. * Override this method to provide functionality.
  119787. */
  119788. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119789. /**
  119790. * Called on pointer POINTERMOVE event if multiple touches are active.
  119791. * Override this method to provide functionality.
  119792. */
  119793. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119794. /**
  119795. * Called on JS contextmenu event.
  119796. * Override this method to provide functionality.
  119797. */
  119798. protected onContextMenu(evt: PointerEvent): void;
  119799. /**
  119800. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119801. * press.
  119802. * Override this method to provide functionality.
  119803. */
  119804. protected onButtonDown(evt: PointerEvent): void;
  119805. /**
  119806. * Called each time a new POINTERUP event occurs. Ie, for each button
  119807. * release.
  119808. * Override this method to provide functionality.
  119809. */
  119810. protected onButtonUp(evt: PointerEvent): void;
  119811. /**
  119812. * Called when window becomes inactive.
  119813. * Override this method to provide functionality.
  119814. */
  119815. protected onLostFocus(): void;
  119816. private _pointerInput;
  119817. private _observer;
  119818. private _onLostFocus;
  119819. private pointA;
  119820. private pointB;
  119821. }
  119822. }
  119823. declare module BABYLON {
  119824. /**
  119825. * Manage the pointers inputs to control an arc rotate camera.
  119826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119827. */
  119828. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119829. /**
  119830. * Defines the camera the input is attached to.
  119831. */
  119832. camera: ArcRotateCamera;
  119833. /**
  119834. * Gets the class name of the current input.
  119835. * @returns the class name
  119836. */
  119837. getClassName(): string;
  119838. /**
  119839. * Defines the buttons associated with the input to handle camera move.
  119840. */
  119841. buttons: number[];
  119842. /**
  119843. * Defines the pointer angular sensibility along the X axis or how fast is
  119844. * the camera rotating.
  119845. */
  119846. angularSensibilityX: number;
  119847. /**
  119848. * Defines the pointer angular sensibility along the Y axis or how fast is
  119849. * the camera rotating.
  119850. */
  119851. angularSensibilityY: number;
  119852. /**
  119853. * Defines the pointer pinch precision or how fast is the camera zooming.
  119854. */
  119855. pinchPrecision: number;
  119856. /**
  119857. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119858. * from 0.
  119859. * It defines the percentage of current camera.radius to use as delta when
  119860. * pinch zoom is used.
  119861. */
  119862. pinchDeltaPercentage: number;
  119863. /**
  119864. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119865. * that any object in the plane at the camera's target point will scale
  119866. * perfectly with finger motion.
  119867. * Overrides pinchDeltaPercentage and pinchPrecision.
  119868. */
  119869. useNaturalPinchZoom: boolean;
  119870. /**
  119871. * Defines the pointer panning sensibility or how fast is the camera moving.
  119872. */
  119873. panningSensibility: number;
  119874. /**
  119875. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119876. */
  119877. multiTouchPanning: boolean;
  119878. /**
  119879. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119880. * zoom (pinch) through multitouch.
  119881. */
  119882. multiTouchPanAndZoom: boolean;
  119883. /**
  119884. * Revers pinch action direction.
  119885. */
  119886. pinchInwards: boolean;
  119887. private _isPanClick;
  119888. private _twoFingerActivityCount;
  119889. private _isPinching;
  119890. /**
  119891. * Called on pointer POINTERMOVE event if only a single touch is active.
  119892. */
  119893. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119894. /**
  119895. * Called on pointer POINTERDOUBLETAP event.
  119896. */
  119897. protected onDoubleTap(type: string): void;
  119898. /**
  119899. * Called on pointer POINTERMOVE event if multiple touches are active.
  119900. */
  119901. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119902. /**
  119903. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119904. * press.
  119905. */
  119906. protected onButtonDown(evt: PointerEvent): void;
  119907. /**
  119908. * Called each time a new POINTERUP event occurs. Ie, for each button
  119909. * release.
  119910. */
  119911. protected onButtonUp(evt: PointerEvent): void;
  119912. /**
  119913. * Called when window becomes inactive.
  119914. */
  119915. protected onLostFocus(): void;
  119916. }
  119917. }
  119918. declare module BABYLON {
  119919. /**
  119920. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119921. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119922. */
  119923. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119924. /**
  119925. * Defines the camera the input is attached to.
  119926. */
  119927. camera: ArcRotateCamera;
  119928. /**
  119929. * Defines the list of key codes associated with the up action (increase alpha)
  119930. */
  119931. keysUp: number[];
  119932. /**
  119933. * Defines the list of key codes associated with the down action (decrease alpha)
  119934. */
  119935. keysDown: number[];
  119936. /**
  119937. * Defines the list of key codes associated with the left action (increase beta)
  119938. */
  119939. keysLeft: number[];
  119940. /**
  119941. * Defines the list of key codes associated with the right action (decrease beta)
  119942. */
  119943. keysRight: number[];
  119944. /**
  119945. * Defines the list of key codes associated with the reset action.
  119946. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119947. */
  119948. keysReset: number[];
  119949. /**
  119950. * Defines the panning sensibility of the inputs.
  119951. * (How fast is the camera panning)
  119952. */
  119953. panningSensibility: number;
  119954. /**
  119955. * Defines the zooming sensibility of the inputs.
  119956. * (How fast is the camera zooming)
  119957. */
  119958. zoomingSensibility: number;
  119959. /**
  119960. * Defines whether maintaining the alt key down switch the movement mode from
  119961. * orientation to zoom.
  119962. */
  119963. useAltToZoom: boolean;
  119964. /**
  119965. * Rotation speed of the camera
  119966. */
  119967. angularSpeed: number;
  119968. private _keys;
  119969. private _ctrlPressed;
  119970. private _altPressed;
  119971. private _onCanvasBlurObserver;
  119972. private _onKeyboardObserver;
  119973. private _engine;
  119974. private _scene;
  119975. /**
  119976. * Attach the input controls to a specific dom element to get the input from.
  119977. * @param element Defines the element the controls should be listened from
  119978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119979. */
  119980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119981. /**
  119982. * Detach the current controls from the specified dom element.
  119983. * @param element Defines the element to stop listening the inputs from
  119984. */
  119985. detachControl(element: Nullable<HTMLElement>): void;
  119986. /**
  119987. * Update the current camera state depending on the inputs that have been used this frame.
  119988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119989. */
  119990. checkInputs(): void;
  119991. /**
  119992. * Gets the class name of the current intput.
  119993. * @returns the class name
  119994. */
  119995. getClassName(): string;
  119996. /**
  119997. * Get the friendly name associated with the input class.
  119998. * @returns the input friendly name
  119999. */
  120000. getSimpleName(): string;
  120001. }
  120002. }
  120003. declare module BABYLON {
  120004. /**
  120005. * Manage the mouse wheel inputs to control an arc rotate camera.
  120006. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120007. */
  120008. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120009. /**
  120010. * Defines the camera the input is attached to.
  120011. */
  120012. camera: ArcRotateCamera;
  120013. /**
  120014. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120015. */
  120016. wheelPrecision: number;
  120017. /**
  120018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120020. */
  120021. wheelDeltaPercentage: number;
  120022. private _wheel;
  120023. private _observer;
  120024. private computeDeltaFromMouseWheelLegacyEvent;
  120025. /**
  120026. * Attach the input controls to a specific dom element to get the input from.
  120027. * @param element Defines the element the controls should be listened from
  120028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120029. */
  120030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120031. /**
  120032. * Detach the current controls from the specified dom element.
  120033. * @param element Defines the element to stop listening the inputs from
  120034. */
  120035. detachControl(element: Nullable<HTMLElement>): void;
  120036. /**
  120037. * Gets the class name of the current intput.
  120038. * @returns the class name
  120039. */
  120040. getClassName(): string;
  120041. /**
  120042. * Get the friendly name associated with the input class.
  120043. * @returns the input friendly name
  120044. */
  120045. getSimpleName(): string;
  120046. }
  120047. }
  120048. declare module BABYLON {
  120049. /**
  120050. * Default Inputs manager for the ArcRotateCamera.
  120051. * It groups all the default supported inputs for ease of use.
  120052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120053. */
  120054. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120055. /**
  120056. * Instantiates a new ArcRotateCameraInputsManager.
  120057. * @param camera Defines the camera the inputs belong to
  120058. */
  120059. constructor(camera: ArcRotateCamera);
  120060. /**
  120061. * Add mouse wheel input support to the input manager.
  120062. * @returns the current input manager
  120063. */
  120064. addMouseWheel(): ArcRotateCameraInputsManager;
  120065. /**
  120066. * Add pointers input support to the input manager.
  120067. * @returns the current input manager
  120068. */
  120069. addPointers(): ArcRotateCameraInputsManager;
  120070. /**
  120071. * Add keyboard input support to the input manager.
  120072. * @returns the current input manager
  120073. */
  120074. addKeyboard(): ArcRotateCameraInputsManager;
  120075. }
  120076. }
  120077. declare module BABYLON {
  120078. /**
  120079. * This represents an orbital type of camera.
  120080. *
  120081. * 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.
  120082. * 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.
  120083. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120084. */
  120085. export class ArcRotateCamera extends TargetCamera {
  120086. /**
  120087. * Defines the rotation angle of the camera along the longitudinal axis.
  120088. */
  120089. alpha: number;
  120090. /**
  120091. * Defines the rotation angle of the camera along the latitudinal axis.
  120092. */
  120093. beta: number;
  120094. /**
  120095. * Defines the radius of the camera from it s target point.
  120096. */
  120097. radius: number;
  120098. protected _target: Vector3;
  120099. protected _targetHost: Nullable<AbstractMesh>;
  120100. /**
  120101. * Defines the target point of the camera.
  120102. * The camera looks towards it form the radius distance.
  120103. */
  120104. get target(): Vector3;
  120105. set target(value: Vector3);
  120106. /**
  120107. * Define the current local position of the camera in the scene
  120108. */
  120109. get position(): Vector3;
  120110. set position(newPosition: Vector3);
  120111. protected _upVector: Vector3;
  120112. protected _upToYMatrix: Matrix;
  120113. protected _YToUpMatrix: Matrix;
  120114. /**
  120115. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120116. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120117. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120118. */
  120119. set upVector(vec: Vector3);
  120120. get upVector(): Vector3;
  120121. /**
  120122. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120123. */
  120124. setMatUp(): void;
  120125. /**
  120126. * Current inertia value on the longitudinal axis.
  120127. * The bigger this number the longer it will take for the camera to stop.
  120128. */
  120129. inertialAlphaOffset: number;
  120130. /**
  120131. * Current inertia value on the latitudinal axis.
  120132. * The bigger this number the longer it will take for the camera to stop.
  120133. */
  120134. inertialBetaOffset: number;
  120135. /**
  120136. * Current inertia value on the radius axis.
  120137. * The bigger this number the longer it will take for the camera to stop.
  120138. */
  120139. inertialRadiusOffset: number;
  120140. /**
  120141. * Minimum allowed angle on the longitudinal axis.
  120142. * This can help limiting how the Camera is able to move in the scene.
  120143. */
  120144. lowerAlphaLimit: Nullable<number>;
  120145. /**
  120146. * Maximum allowed angle on the longitudinal axis.
  120147. * This can help limiting how the Camera is able to move in the scene.
  120148. */
  120149. upperAlphaLimit: Nullable<number>;
  120150. /**
  120151. * Minimum allowed angle on the latitudinal axis.
  120152. * This can help limiting how the Camera is able to move in the scene.
  120153. */
  120154. lowerBetaLimit: number;
  120155. /**
  120156. * Maximum allowed angle on the latitudinal axis.
  120157. * This can help limiting how the Camera is able to move in the scene.
  120158. */
  120159. upperBetaLimit: number;
  120160. /**
  120161. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120162. * This can help limiting how the Camera is able to move in the scene.
  120163. */
  120164. lowerRadiusLimit: Nullable<number>;
  120165. /**
  120166. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120167. * This can help limiting how the Camera is able to move in the scene.
  120168. */
  120169. upperRadiusLimit: Nullable<number>;
  120170. /**
  120171. * Defines the current inertia value used during panning of the camera along the X axis.
  120172. */
  120173. inertialPanningX: number;
  120174. /**
  120175. * Defines the current inertia value used during panning of the camera along the Y axis.
  120176. */
  120177. inertialPanningY: number;
  120178. /**
  120179. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120180. * Basically if your fingers moves away from more than this distance you will be considered
  120181. * in pinch mode.
  120182. */
  120183. pinchToPanMaxDistance: number;
  120184. /**
  120185. * Defines the maximum distance the camera can pan.
  120186. * This could help keeping the cammera always in your scene.
  120187. */
  120188. panningDistanceLimit: Nullable<number>;
  120189. /**
  120190. * Defines the target of the camera before paning.
  120191. */
  120192. panningOriginTarget: Vector3;
  120193. /**
  120194. * Defines the value of the inertia used during panning.
  120195. * 0 would mean stop inertia and one would mean no decelleration at all.
  120196. */
  120197. panningInertia: number;
  120198. /**
  120199. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120200. */
  120201. get angularSensibilityX(): number;
  120202. set angularSensibilityX(value: number);
  120203. /**
  120204. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120205. */
  120206. get angularSensibilityY(): number;
  120207. set angularSensibilityY(value: number);
  120208. /**
  120209. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120210. */
  120211. get pinchPrecision(): number;
  120212. set pinchPrecision(value: number);
  120213. /**
  120214. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120215. * It will be used instead of pinchDeltaPrecision if different from 0.
  120216. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120217. */
  120218. get pinchDeltaPercentage(): number;
  120219. set pinchDeltaPercentage(value: number);
  120220. /**
  120221. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120222. * and pinch delta percentage.
  120223. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120224. * that any object in the plane at the camera's target point will scale
  120225. * perfectly with finger motion.
  120226. */
  120227. get useNaturalPinchZoom(): boolean;
  120228. set useNaturalPinchZoom(value: boolean);
  120229. /**
  120230. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120231. */
  120232. get panningSensibility(): number;
  120233. set panningSensibility(value: number);
  120234. /**
  120235. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120236. */
  120237. get keysUp(): number[];
  120238. set keysUp(value: number[]);
  120239. /**
  120240. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120241. */
  120242. get keysDown(): number[];
  120243. set keysDown(value: number[]);
  120244. /**
  120245. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120246. */
  120247. get keysLeft(): number[];
  120248. set keysLeft(value: number[]);
  120249. /**
  120250. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120251. */
  120252. get keysRight(): number[];
  120253. set keysRight(value: number[]);
  120254. /**
  120255. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120256. */
  120257. get wheelPrecision(): number;
  120258. set wheelPrecision(value: number);
  120259. /**
  120260. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120261. * It will be used instead of pinchDeltaPrecision if different from 0.
  120262. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120263. */
  120264. get wheelDeltaPercentage(): number;
  120265. set wheelDeltaPercentage(value: number);
  120266. /**
  120267. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120268. */
  120269. zoomOnFactor: number;
  120270. /**
  120271. * Defines a screen offset for the camera position.
  120272. */
  120273. targetScreenOffset: Vector2;
  120274. /**
  120275. * Allows the camera to be completely reversed.
  120276. * If false the camera can not arrive upside down.
  120277. */
  120278. allowUpsideDown: boolean;
  120279. /**
  120280. * Define if double tap/click is used to restore the previously saved state of the camera.
  120281. */
  120282. useInputToRestoreState: boolean;
  120283. /** @hidden */
  120284. _viewMatrix: Matrix;
  120285. /** @hidden */
  120286. _useCtrlForPanning: boolean;
  120287. /** @hidden */
  120288. _panningMouseButton: number;
  120289. /**
  120290. * Defines the input associated to the camera.
  120291. */
  120292. inputs: ArcRotateCameraInputsManager;
  120293. /** @hidden */
  120294. _reset: () => void;
  120295. /**
  120296. * Defines the allowed panning axis.
  120297. */
  120298. panningAxis: Vector3;
  120299. protected _localDirection: Vector3;
  120300. protected _transformedDirection: Vector3;
  120301. private _bouncingBehavior;
  120302. /**
  120303. * Gets the bouncing behavior of the camera if it has been enabled.
  120304. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120305. */
  120306. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120307. /**
  120308. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120309. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120310. */
  120311. get useBouncingBehavior(): boolean;
  120312. set useBouncingBehavior(value: boolean);
  120313. private _framingBehavior;
  120314. /**
  120315. * Gets the framing behavior of the camera if it has been enabled.
  120316. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120317. */
  120318. get framingBehavior(): Nullable<FramingBehavior>;
  120319. /**
  120320. * Defines if the framing behavior of the camera is enabled on the camera.
  120321. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120322. */
  120323. get useFramingBehavior(): boolean;
  120324. set useFramingBehavior(value: boolean);
  120325. private _autoRotationBehavior;
  120326. /**
  120327. * Gets the auto rotation behavior of the camera if it has been enabled.
  120328. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120329. */
  120330. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120331. /**
  120332. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120333. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120334. */
  120335. get useAutoRotationBehavior(): boolean;
  120336. set useAutoRotationBehavior(value: boolean);
  120337. /**
  120338. * Observable triggered when the mesh target has been changed on the camera.
  120339. */
  120340. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120341. /**
  120342. * Event raised when the camera is colliding with a mesh.
  120343. */
  120344. onCollide: (collidedMesh: AbstractMesh) => void;
  120345. /**
  120346. * Defines whether the camera should check collision with the objects oh the scene.
  120347. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120348. */
  120349. checkCollisions: boolean;
  120350. /**
  120351. * Defines the collision radius of the camera.
  120352. * This simulates a sphere around the camera.
  120353. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120354. */
  120355. collisionRadius: Vector3;
  120356. protected _collider: Collider;
  120357. protected _previousPosition: Vector3;
  120358. protected _collisionVelocity: Vector3;
  120359. protected _newPosition: Vector3;
  120360. protected _previousAlpha: number;
  120361. protected _previousBeta: number;
  120362. protected _previousRadius: number;
  120363. protected _collisionTriggered: boolean;
  120364. protected _targetBoundingCenter: Nullable<Vector3>;
  120365. private _computationVector;
  120366. /**
  120367. * Instantiates a new ArcRotateCamera in a given scene
  120368. * @param name Defines the name of the camera
  120369. * @param alpha Defines the camera rotation along the logitudinal axis
  120370. * @param beta Defines the camera rotation along the latitudinal axis
  120371. * @param radius Defines the camera distance from its target
  120372. * @param target Defines the camera target
  120373. * @param scene Defines the scene the camera belongs to
  120374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120375. */
  120376. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120377. /** @hidden */
  120378. _initCache(): void;
  120379. /** @hidden */
  120380. _updateCache(ignoreParentClass?: boolean): void;
  120381. protected _getTargetPosition(): Vector3;
  120382. private _storedAlpha;
  120383. private _storedBeta;
  120384. private _storedRadius;
  120385. private _storedTarget;
  120386. private _storedTargetScreenOffset;
  120387. /**
  120388. * Stores the current state of the camera (alpha, beta, radius and target)
  120389. * @returns the camera itself
  120390. */
  120391. storeState(): Camera;
  120392. /**
  120393. * @hidden
  120394. * Restored camera state. You must call storeState() first
  120395. */
  120396. _restoreStateValues(): boolean;
  120397. /** @hidden */
  120398. _isSynchronizedViewMatrix(): boolean;
  120399. /**
  120400. * Attached controls to the current camera.
  120401. * @param element Defines the element the controls should be listened from
  120402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120403. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120404. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120405. */
  120406. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120407. /**
  120408. * Detach the current controls from the camera.
  120409. * The camera will stop reacting to inputs.
  120410. * @param element Defines the element to stop listening the inputs from
  120411. */
  120412. detachControl(element: HTMLElement): void;
  120413. /** @hidden */
  120414. _checkInputs(): void;
  120415. protected _checkLimits(): void;
  120416. /**
  120417. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120418. */
  120419. rebuildAnglesAndRadius(): void;
  120420. /**
  120421. * Use a position to define the current camera related information like alpha, beta and radius
  120422. * @param position Defines the position to set the camera at
  120423. */
  120424. setPosition(position: Vector3): void;
  120425. /**
  120426. * Defines the target the camera should look at.
  120427. * This will automatically adapt alpha beta and radius to fit within the new target.
  120428. * @param target Defines the new target as a Vector or a mesh
  120429. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120430. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120431. */
  120432. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120433. /** @hidden */
  120434. _getViewMatrix(): Matrix;
  120435. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120436. /**
  120437. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120438. * @param meshes Defines the mesh to zoom on
  120439. * @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)
  120440. */
  120441. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120442. /**
  120443. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120444. * The target will be changed but the radius
  120445. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120446. * @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)
  120447. */
  120448. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120449. min: Vector3;
  120450. max: Vector3;
  120451. distance: number;
  120452. }, doNotUpdateMaxZ?: boolean): void;
  120453. /**
  120454. * @override
  120455. * Override Camera.createRigCamera
  120456. */
  120457. createRigCamera(name: string, cameraIndex: number): Camera;
  120458. /**
  120459. * @hidden
  120460. * @override
  120461. * Override Camera._updateRigCameras
  120462. */
  120463. _updateRigCameras(): void;
  120464. /**
  120465. * Destroy the camera and release the current resources hold by it.
  120466. */
  120467. dispose(): void;
  120468. /**
  120469. * Gets the current object class name.
  120470. * @return the class name
  120471. */
  120472. getClassName(): string;
  120473. }
  120474. }
  120475. declare module BABYLON {
  120476. /**
  120477. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120478. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120479. */
  120480. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120481. /**
  120482. * Gets the name of the behavior.
  120483. */
  120484. get name(): string;
  120485. private _zoomStopsAnimation;
  120486. private _idleRotationSpeed;
  120487. private _idleRotationWaitTime;
  120488. private _idleRotationSpinupTime;
  120489. /**
  120490. * Sets the flag that indicates if user zooming should stop animation.
  120491. */
  120492. set zoomStopsAnimation(flag: boolean);
  120493. /**
  120494. * Gets the flag that indicates if user zooming should stop animation.
  120495. */
  120496. get zoomStopsAnimation(): boolean;
  120497. /**
  120498. * Sets the default speed at which the camera rotates around the model.
  120499. */
  120500. set idleRotationSpeed(speed: number);
  120501. /**
  120502. * Gets the default speed at which the camera rotates around the model.
  120503. */
  120504. get idleRotationSpeed(): number;
  120505. /**
  120506. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120507. */
  120508. set idleRotationWaitTime(time: number);
  120509. /**
  120510. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120511. */
  120512. get idleRotationWaitTime(): number;
  120513. /**
  120514. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120515. */
  120516. set idleRotationSpinupTime(time: number);
  120517. /**
  120518. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120519. */
  120520. get idleRotationSpinupTime(): number;
  120521. /**
  120522. * Gets a value indicating if the camera is currently rotating because of this behavior
  120523. */
  120524. get rotationInProgress(): boolean;
  120525. private _onPrePointerObservableObserver;
  120526. private _onAfterCheckInputsObserver;
  120527. private _attachedCamera;
  120528. private _isPointerDown;
  120529. private _lastFrameTime;
  120530. private _lastInteractionTime;
  120531. private _cameraRotationSpeed;
  120532. /**
  120533. * Initializes the behavior.
  120534. */
  120535. init(): void;
  120536. /**
  120537. * Attaches the behavior to its arc rotate camera.
  120538. * @param camera Defines the camera to attach the behavior to
  120539. */
  120540. attach(camera: ArcRotateCamera): void;
  120541. /**
  120542. * Detaches the behavior from its current arc rotate camera.
  120543. */
  120544. detach(): void;
  120545. /**
  120546. * Returns true if user is scrolling.
  120547. * @return true if user is scrolling.
  120548. */
  120549. private _userIsZooming;
  120550. private _lastFrameRadius;
  120551. private _shouldAnimationStopForInteraction;
  120552. /**
  120553. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120554. */
  120555. private _applyUserInteraction;
  120556. private _userIsMoving;
  120557. }
  120558. }
  120559. declare module BABYLON {
  120560. /**
  120561. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120562. */
  120563. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120564. private ui;
  120565. /**
  120566. * The name of the behavior
  120567. */
  120568. name: string;
  120569. /**
  120570. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120571. */
  120572. distanceAwayFromFace: number;
  120573. /**
  120574. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120575. */
  120576. distanceAwayFromBottomOfFace: number;
  120577. private _faceVectors;
  120578. private _target;
  120579. private _scene;
  120580. private _onRenderObserver;
  120581. private _tmpMatrix;
  120582. private _tmpVector;
  120583. /**
  120584. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120585. * @param ui The transform node that should be attched to the mesh
  120586. */
  120587. constructor(ui: TransformNode);
  120588. /**
  120589. * Initializes the behavior
  120590. */
  120591. init(): void;
  120592. private _closestFace;
  120593. private _zeroVector;
  120594. private _lookAtTmpMatrix;
  120595. private _lookAtToRef;
  120596. /**
  120597. * Attaches the AttachToBoxBehavior to the passed in mesh
  120598. * @param target The mesh that the specified node will be attached to
  120599. */
  120600. attach(target: Mesh): void;
  120601. /**
  120602. * Detaches the behavior from the mesh
  120603. */
  120604. detach(): void;
  120605. }
  120606. }
  120607. declare module BABYLON {
  120608. /**
  120609. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120610. */
  120611. export class FadeInOutBehavior implements Behavior<Mesh> {
  120612. /**
  120613. * Time in milliseconds to delay before fading in (Default: 0)
  120614. */
  120615. delay: number;
  120616. /**
  120617. * Time in milliseconds for the mesh to fade in (Default: 300)
  120618. */
  120619. fadeInTime: number;
  120620. private _millisecondsPerFrame;
  120621. private _hovered;
  120622. private _hoverValue;
  120623. private _ownerNode;
  120624. /**
  120625. * Instatiates the FadeInOutBehavior
  120626. */
  120627. constructor();
  120628. /**
  120629. * The name of the behavior
  120630. */
  120631. get name(): string;
  120632. /**
  120633. * Initializes the behavior
  120634. */
  120635. init(): void;
  120636. /**
  120637. * Attaches the fade behavior on the passed in mesh
  120638. * @param ownerNode The mesh that will be faded in/out once attached
  120639. */
  120640. attach(ownerNode: Mesh): void;
  120641. /**
  120642. * Detaches the behavior from the mesh
  120643. */
  120644. detach(): void;
  120645. /**
  120646. * Triggers the mesh to begin fading in or out
  120647. * @param value if the object should fade in or out (true to fade in)
  120648. */
  120649. fadeIn(value: boolean): void;
  120650. private _update;
  120651. private _setAllVisibility;
  120652. }
  120653. }
  120654. declare module BABYLON {
  120655. /**
  120656. * Class containing a set of static utilities functions for managing Pivots
  120657. * @hidden
  120658. */
  120659. export class PivotTools {
  120660. private static _PivotCached;
  120661. private static _OldPivotPoint;
  120662. private static _PivotTranslation;
  120663. private static _PivotTmpVector;
  120664. /** @hidden */
  120665. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120666. /** @hidden */
  120667. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120668. }
  120669. }
  120670. declare module BABYLON {
  120671. /**
  120672. * Class containing static functions to help procedurally build meshes
  120673. */
  120674. export class PlaneBuilder {
  120675. /**
  120676. * Creates a plane mesh
  120677. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120678. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120679. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120683. * @param name defines the name of the mesh
  120684. * @param options defines the options used to create the mesh
  120685. * @param scene defines the hosting scene
  120686. * @returns the plane mesh
  120687. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120688. */
  120689. static CreatePlane(name: string, options: {
  120690. size?: number;
  120691. width?: number;
  120692. height?: number;
  120693. sideOrientation?: number;
  120694. frontUVs?: Vector4;
  120695. backUVs?: Vector4;
  120696. updatable?: boolean;
  120697. sourcePlane?: Plane;
  120698. }, scene?: Nullable<Scene>): Mesh;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /**
  120703. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120704. */
  120705. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120706. private static _AnyMouseID;
  120707. /**
  120708. * Abstract mesh the behavior is set on
  120709. */
  120710. attachedNode: AbstractMesh;
  120711. private _dragPlane;
  120712. private _scene;
  120713. private _pointerObserver;
  120714. private _beforeRenderObserver;
  120715. private static _planeScene;
  120716. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120717. /**
  120718. * 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)
  120719. */
  120720. maxDragAngle: number;
  120721. /**
  120722. * @hidden
  120723. */
  120724. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120725. /**
  120726. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120727. */
  120728. currentDraggingPointerID: number;
  120729. /**
  120730. * The last position where the pointer hit the drag plane in world space
  120731. */
  120732. lastDragPosition: Vector3;
  120733. /**
  120734. * If the behavior is currently in a dragging state
  120735. */
  120736. dragging: boolean;
  120737. /**
  120738. * 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)
  120739. */
  120740. dragDeltaRatio: number;
  120741. /**
  120742. * If the drag plane orientation should be updated during the dragging (Default: true)
  120743. */
  120744. updateDragPlane: boolean;
  120745. private _debugMode;
  120746. private _moving;
  120747. /**
  120748. * Fires each time the attached mesh is dragged with the pointer
  120749. * * delta between last drag position and current drag position in world space
  120750. * * dragDistance along the drag axis
  120751. * * dragPlaneNormal normal of the current drag plane used during the drag
  120752. * * dragPlanePoint in world space where the drag intersects the drag plane
  120753. */
  120754. onDragObservable: Observable<{
  120755. delta: Vector3;
  120756. dragPlanePoint: Vector3;
  120757. dragPlaneNormal: Vector3;
  120758. dragDistance: number;
  120759. pointerId: number;
  120760. }>;
  120761. /**
  120762. * Fires each time a drag begins (eg. mouse down on mesh)
  120763. */
  120764. onDragStartObservable: Observable<{
  120765. dragPlanePoint: Vector3;
  120766. pointerId: number;
  120767. }>;
  120768. /**
  120769. * Fires each time a drag ends (eg. mouse release after drag)
  120770. */
  120771. onDragEndObservable: Observable<{
  120772. dragPlanePoint: Vector3;
  120773. pointerId: number;
  120774. }>;
  120775. /**
  120776. * If the attached mesh should be moved when dragged
  120777. */
  120778. moveAttached: boolean;
  120779. /**
  120780. * If the drag behavior will react to drag events (Default: true)
  120781. */
  120782. enabled: boolean;
  120783. /**
  120784. * If pointer events should start and release the drag (Default: true)
  120785. */
  120786. startAndReleaseDragOnPointerEvents: boolean;
  120787. /**
  120788. * If camera controls should be detached during the drag
  120789. */
  120790. detachCameraControls: boolean;
  120791. /**
  120792. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120793. */
  120794. useObjectOrientationForDragging: boolean;
  120795. private _options;
  120796. /**
  120797. * Gets the options used by the behavior
  120798. */
  120799. get options(): {
  120800. dragAxis?: Vector3;
  120801. dragPlaneNormal?: Vector3;
  120802. };
  120803. /**
  120804. * Sets the options used by the behavior
  120805. */
  120806. set options(options: {
  120807. dragAxis?: Vector3;
  120808. dragPlaneNormal?: Vector3;
  120809. });
  120810. /**
  120811. * Creates a pointer drag behavior that can be attached to a mesh
  120812. * @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)
  120813. */
  120814. constructor(options?: {
  120815. dragAxis?: Vector3;
  120816. dragPlaneNormal?: Vector3;
  120817. });
  120818. /**
  120819. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120820. */
  120821. validateDrag: (targetPosition: Vector3) => boolean;
  120822. /**
  120823. * The name of the behavior
  120824. */
  120825. get name(): string;
  120826. /**
  120827. * Initializes the behavior
  120828. */
  120829. init(): void;
  120830. private _tmpVector;
  120831. private _alternatePickedPoint;
  120832. private _worldDragAxis;
  120833. private _targetPosition;
  120834. private _attachedElement;
  120835. /**
  120836. * Attaches the drag behavior the passed in mesh
  120837. * @param ownerNode The mesh that will be dragged around once attached
  120838. * @param predicate Predicate to use for pick filtering
  120839. */
  120840. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120841. /**
  120842. * Force relase the drag action by code.
  120843. */
  120844. releaseDrag(): void;
  120845. private _startDragRay;
  120846. private _lastPointerRay;
  120847. /**
  120848. * Simulates the start of a pointer drag event on the behavior
  120849. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120850. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120851. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120852. */
  120853. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120854. private _startDrag;
  120855. private _dragDelta;
  120856. private _moveDrag;
  120857. private _pickWithRayOnDragPlane;
  120858. private _pointA;
  120859. private _pointB;
  120860. private _pointC;
  120861. private _lineA;
  120862. private _lineB;
  120863. private _localAxis;
  120864. private _lookAt;
  120865. private _updateDragPlanePosition;
  120866. /**
  120867. * Detaches the behavior from the mesh
  120868. */
  120869. detach(): void;
  120870. }
  120871. }
  120872. declare module BABYLON {
  120873. /**
  120874. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120875. */
  120876. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120877. private _dragBehaviorA;
  120878. private _dragBehaviorB;
  120879. private _startDistance;
  120880. private _initialScale;
  120881. private _targetScale;
  120882. private _ownerNode;
  120883. private _sceneRenderObserver;
  120884. /**
  120885. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120886. */
  120887. constructor();
  120888. /**
  120889. * The name of the behavior
  120890. */
  120891. get name(): string;
  120892. /**
  120893. * Initializes the behavior
  120894. */
  120895. init(): void;
  120896. private _getCurrentDistance;
  120897. /**
  120898. * Attaches the scale behavior the passed in mesh
  120899. * @param ownerNode The mesh that will be scaled around once attached
  120900. */
  120901. attach(ownerNode: Mesh): void;
  120902. /**
  120903. * Detaches the behavior from the mesh
  120904. */
  120905. detach(): void;
  120906. }
  120907. }
  120908. declare module BABYLON {
  120909. /**
  120910. * 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
  120911. */
  120912. export class SixDofDragBehavior implements Behavior<Mesh> {
  120913. private static _virtualScene;
  120914. private _ownerNode;
  120915. private _sceneRenderObserver;
  120916. private _scene;
  120917. private _targetPosition;
  120918. private _virtualOriginMesh;
  120919. private _virtualDragMesh;
  120920. private _pointerObserver;
  120921. private _moving;
  120922. private _startingOrientation;
  120923. private _attachedElement;
  120924. /**
  120925. * 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)
  120926. */
  120927. private zDragFactor;
  120928. /**
  120929. * If the object should rotate to face the drag origin
  120930. */
  120931. rotateDraggedObject: boolean;
  120932. /**
  120933. * If the behavior is currently in a dragging state
  120934. */
  120935. dragging: boolean;
  120936. /**
  120937. * 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)
  120938. */
  120939. dragDeltaRatio: number;
  120940. /**
  120941. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120942. */
  120943. currentDraggingPointerID: number;
  120944. /**
  120945. * If camera controls should be detached during the drag
  120946. */
  120947. detachCameraControls: boolean;
  120948. /**
  120949. * Fires each time a drag starts
  120950. */
  120951. onDragStartObservable: Observable<{}>;
  120952. /**
  120953. * Fires each time a drag ends (eg. mouse release after drag)
  120954. */
  120955. onDragEndObservable: Observable<{}>;
  120956. /**
  120957. * 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
  120958. */
  120959. constructor();
  120960. /**
  120961. * The name of the behavior
  120962. */
  120963. get name(): string;
  120964. /**
  120965. * Initializes the behavior
  120966. */
  120967. init(): void;
  120968. /**
  120969. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120970. */
  120971. private get _pointerCamera();
  120972. /**
  120973. * Attaches the scale behavior the passed in mesh
  120974. * @param ownerNode The mesh that will be scaled around once attached
  120975. */
  120976. attach(ownerNode: Mesh): void;
  120977. /**
  120978. * Detaches the behavior from the mesh
  120979. */
  120980. detach(): void;
  120981. }
  120982. }
  120983. declare module BABYLON {
  120984. /**
  120985. * Class used to apply inverse kinematics to bones
  120986. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120987. */
  120988. export class BoneIKController {
  120989. private static _tmpVecs;
  120990. private static _tmpQuat;
  120991. private static _tmpMats;
  120992. /**
  120993. * Gets or sets the target mesh
  120994. */
  120995. targetMesh: AbstractMesh;
  120996. /** Gets or sets the mesh used as pole */
  120997. poleTargetMesh: AbstractMesh;
  120998. /**
  120999. * Gets or sets the bone used as pole
  121000. */
  121001. poleTargetBone: Nullable<Bone>;
  121002. /**
  121003. * Gets or sets the target position
  121004. */
  121005. targetPosition: Vector3;
  121006. /**
  121007. * Gets or sets the pole target position
  121008. */
  121009. poleTargetPosition: Vector3;
  121010. /**
  121011. * Gets or sets the pole target local offset
  121012. */
  121013. poleTargetLocalOffset: Vector3;
  121014. /**
  121015. * Gets or sets the pole angle
  121016. */
  121017. poleAngle: number;
  121018. /**
  121019. * Gets or sets the mesh associated with the controller
  121020. */
  121021. mesh: AbstractMesh;
  121022. /**
  121023. * 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)
  121024. */
  121025. slerpAmount: number;
  121026. private _bone1Quat;
  121027. private _bone1Mat;
  121028. private _bone2Ang;
  121029. private _bone1;
  121030. private _bone2;
  121031. private _bone1Length;
  121032. private _bone2Length;
  121033. private _maxAngle;
  121034. private _maxReach;
  121035. private _rightHandedSystem;
  121036. private _bendAxis;
  121037. private _slerping;
  121038. private _adjustRoll;
  121039. /**
  121040. * Gets or sets maximum allowed angle
  121041. */
  121042. get maxAngle(): number;
  121043. set maxAngle(value: number);
  121044. /**
  121045. * Creates a new BoneIKController
  121046. * @param mesh defines the mesh to control
  121047. * @param bone defines the bone to control
  121048. * @param options defines options to set up the controller
  121049. */
  121050. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121051. targetMesh?: AbstractMesh;
  121052. poleTargetMesh?: AbstractMesh;
  121053. poleTargetBone?: Bone;
  121054. poleTargetLocalOffset?: Vector3;
  121055. poleAngle?: number;
  121056. bendAxis?: Vector3;
  121057. maxAngle?: number;
  121058. slerpAmount?: number;
  121059. });
  121060. private _setMaxAngle;
  121061. /**
  121062. * Force the controller to update the bones
  121063. */
  121064. update(): void;
  121065. }
  121066. }
  121067. declare module BABYLON {
  121068. /**
  121069. * Class used to make a bone look toward a point in space
  121070. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121071. */
  121072. export class BoneLookController {
  121073. private static _tmpVecs;
  121074. private static _tmpQuat;
  121075. private static _tmpMats;
  121076. /**
  121077. * The target Vector3 that the bone will look at
  121078. */
  121079. target: Vector3;
  121080. /**
  121081. * The mesh that the bone is attached to
  121082. */
  121083. mesh: AbstractMesh;
  121084. /**
  121085. * The bone that will be looking to the target
  121086. */
  121087. bone: Bone;
  121088. /**
  121089. * The up axis of the coordinate system that is used when the bone is rotated
  121090. */
  121091. upAxis: Vector3;
  121092. /**
  121093. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121094. */
  121095. upAxisSpace: Space;
  121096. /**
  121097. * Used to make an adjustment to the yaw of the bone
  121098. */
  121099. adjustYaw: number;
  121100. /**
  121101. * Used to make an adjustment to the pitch of the bone
  121102. */
  121103. adjustPitch: number;
  121104. /**
  121105. * Used to make an adjustment to the roll of the bone
  121106. */
  121107. adjustRoll: number;
  121108. /**
  121109. * 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)
  121110. */
  121111. slerpAmount: number;
  121112. private _minYaw;
  121113. private _maxYaw;
  121114. private _minPitch;
  121115. private _maxPitch;
  121116. private _minYawSin;
  121117. private _minYawCos;
  121118. private _maxYawSin;
  121119. private _maxYawCos;
  121120. private _midYawConstraint;
  121121. private _minPitchTan;
  121122. private _maxPitchTan;
  121123. private _boneQuat;
  121124. private _slerping;
  121125. private _transformYawPitch;
  121126. private _transformYawPitchInv;
  121127. private _firstFrameSkipped;
  121128. private _yawRange;
  121129. private _fowardAxis;
  121130. /**
  121131. * Gets or sets the minimum yaw angle that the bone can look to
  121132. */
  121133. get minYaw(): number;
  121134. set minYaw(value: number);
  121135. /**
  121136. * Gets or sets the maximum yaw angle that the bone can look to
  121137. */
  121138. get maxYaw(): number;
  121139. set maxYaw(value: number);
  121140. /**
  121141. * Gets or sets the minimum pitch angle that the bone can look to
  121142. */
  121143. get minPitch(): number;
  121144. set minPitch(value: number);
  121145. /**
  121146. * Gets or sets the maximum pitch angle that the bone can look to
  121147. */
  121148. get maxPitch(): number;
  121149. set maxPitch(value: number);
  121150. /**
  121151. * Create a BoneLookController
  121152. * @param mesh the mesh that the bone belongs to
  121153. * @param bone the bone that will be looking to the target
  121154. * @param target the target Vector3 to look at
  121155. * @param options optional settings:
  121156. * * maxYaw: the maximum angle the bone will yaw to
  121157. * * minYaw: the minimum angle the bone will yaw to
  121158. * * maxPitch: the maximum angle the bone will pitch to
  121159. * * minPitch: the minimum angle the bone will yaw to
  121160. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121161. * * upAxis: the up axis of the coordinate system
  121162. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121163. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121164. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121165. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121166. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121167. * * adjustRoll: used to make an adjustment to the roll of the bone
  121168. **/
  121169. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121170. maxYaw?: number;
  121171. minYaw?: number;
  121172. maxPitch?: number;
  121173. minPitch?: number;
  121174. slerpAmount?: number;
  121175. upAxis?: Vector3;
  121176. upAxisSpace?: Space;
  121177. yawAxis?: Vector3;
  121178. pitchAxis?: Vector3;
  121179. adjustYaw?: number;
  121180. adjustPitch?: number;
  121181. adjustRoll?: number;
  121182. });
  121183. /**
  121184. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121185. */
  121186. update(): void;
  121187. private _getAngleDiff;
  121188. private _getAngleBetween;
  121189. private _isAngleBetween;
  121190. }
  121191. }
  121192. declare module BABYLON {
  121193. /**
  121194. * Manage the gamepad inputs to control an arc rotate camera.
  121195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121196. */
  121197. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121198. /**
  121199. * Defines the camera the input is attached to.
  121200. */
  121201. camera: ArcRotateCamera;
  121202. /**
  121203. * Defines the gamepad the input is gathering event from.
  121204. */
  121205. gamepad: Nullable<Gamepad>;
  121206. /**
  121207. * Defines the gamepad rotation sensiblity.
  121208. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121209. */
  121210. gamepadRotationSensibility: number;
  121211. /**
  121212. * Defines the gamepad move sensiblity.
  121213. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121214. */
  121215. gamepadMoveSensibility: number;
  121216. private _yAxisScale;
  121217. /**
  121218. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121219. */
  121220. get invertYAxis(): boolean;
  121221. set invertYAxis(value: boolean);
  121222. private _onGamepadConnectedObserver;
  121223. private _onGamepadDisconnectedObserver;
  121224. /**
  121225. * Attach the input controls to a specific dom element to get the input from.
  121226. * @param element Defines the element the controls should be listened from
  121227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121228. */
  121229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121230. /**
  121231. * Detach the current controls from the specified dom element.
  121232. * @param element Defines the element to stop listening the inputs from
  121233. */
  121234. detachControl(element: Nullable<HTMLElement>): void;
  121235. /**
  121236. * Update the current camera state depending on the inputs that have been used this frame.
  121237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121238. */
  121239. checkInputs(): void;
  121240. /**
  121241. * Gets the class name of the current intput.
  121242. * @returns the class name
  121243. */
  121244. getClassName(): string;
  121245. /**
  121246. * Get the friendly name associated with the input class.
  121247. * @returns the input friendly name
  121248. */
  121249. getSimpleName(): string;
  121250. }
  121251. }
  121252. declare module BABYLON {
  121253. interface ArcRotateCameraInputsManager {
  121254. /**
  121255. * Add orientation input support to the input manager.
  121256. * @returns the current input manager
  121257. */
  121258. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121259. }
  121260. /**
  121261. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121263. */
  121264. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121265. /**
  121266. * Defines the camera the input is attached to.
  121267. */
  121268. camera: ArcRotateCamera;
  121269. /**
  121270. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121271. */
  121272. alphaCorrection: number;
  121273. /**
  121274. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121275. */
  121276. gammaCorrection: number;
  121277. private _alpha;
  121278. private _gamma;
  121279. private _dirty;
  121280. private _deviceOrientationHandler;
  121281. /**
  121282. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121283. */
  121284. constructor();
  121285. /**
  121286. * Attach the input controls to a specific dom element to get the input from.
  121287. * @param element Defines the element the controls should be listened from
  121288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121289. */
  121290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121291. /** @hidden */
  121292. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121293. /**
  121294. * Update the current camera state depending on the inputs that have been used this frame.
  121295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121296. */
  121297. checkInputs(): void;
  121298. /**
  121299. * Detach the current controls from the specified dom element.
  121300. * @param element Defines the element to stop listening the inputs from
  121301. */
  121302. detachControl(element: Nullable<HTMLElement>): void;
  121303. /**
  121304. * Gets the class name of the current intput.
  121305. * @returns the class name
  121306. */
  121307. getClassName(): string;
  121308. /**
  121309. * Get the friendly name associated with the input class.
  121310. * @returns the input friendly name
  121311. */
  121312. getSimpleName(): string;
  121313. }
  121314. }
  121315. declare module BABYLON {
  121316. /**
  121317. * Listen to mouse events to control the camera.
  121318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121319. */
  121320. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121321. /**
  121322. * Defines the camera the input is attached to.
  121323. */
  121324. camera: FlyCamera;
  121325. /**
  121326. * Defines if touch is enabled. (Default is true.)
  121327. */
  121328. touchEnabled: boolean;
  121329. /**
  121330. * Defines the buttons associated with the input to handle camera rotation.
  121331. */
  121332. buttons: number[];
  121333. /**
  121334. * Assign buttons for Yaw control.
  121335. */
  121336. buttonsYaw: number[];
  121337. /**
  121338. * Assign buttons for Pitch control.
  121339. */
  121340. buttonsPitch: number[];
  121341. /**
  121342. * Assign buttons for Roll control.
  121343. */
  121344. buttonsRoll: number[];
  121345. /**
  121346. * Detect if any button is being pressed while mouse is moved.
  121347. * -1 = Mouse locked.
  121348. * 0 = Left button.
  121349. * 1 = Middle Button.
  121350. * 2 = Right Button.
  121351. */
  121352. activeButton: number;
  121353. /**
  121354. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121355. * Higher values reduce its sensitivity.
  121356. */
  121357. angularSensibility: number;
  121358. private _mousemoveCallback;
  121359. private _observer;
  121360. private _rollObserver;
  121361. private previousPosition;
  121362. private noPreventDefault;
  121363. private element;
  121364. /**
  121365. * Listen to mouse events to control the camera.
  121366. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121368. */
  121369. constructor(touchEnabled?: boolean);
  121370. /**
  121371. * Attach the mouse control to the HTML DOM element.
  121372. * @param element Defines the element that listens to the input events.
  121373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121374. */
  121375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121376. /**
  121377. * Detach the current controls from the specified dom element.
  121378. * @param element Defines the element to stop listening the inputs from
  121379. */
  121380. detachControl(element: Nullable<HTMLElement>): void;
  121381. /**
  121382. * Gets the class name of the current input.
  121383. * @returns the class name.
  121384. */
  121385. getClassName(): string;
  121386. /**
  121387. * Get the friendly name associated with the input class.
  121388. * @returns the input's friendly name.
  121389. */
  121390. getSimpleName(): string;
  121391. private _pointerInput;
  121392. private _onMouseMove;
  121393. /**
  121394. * Rotate camera by mouse offset.
  121395. */
  121396. private rotateCamera;
  121397. }
  121398. }
  121399. declare module BABYLON {
  121400. /**
  121401. * Default Inputs manager for the FlyCamera.
  121402. * It groups all the default supported inputs for ease of use.
  121403. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121404. */
  121405. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121406. /**
  121407. * Instantiates a new FlyCameraInputsManager.
  121408. * @param camera Defines the camera the inputs belong to.
  121409. */
  121410. constructor(camera: FlyCamera);
  121411. /**
  121412. * Add keyboard input support to the input manager.
  121413. * @returns the new FlyCameraKeyboardMoveInput().
  121414. */
  121415. addKeyboard(): FlyCameraInputsManager;
  121416. /**
  121417. * Add mouse input support to the input manager.
  121418. * @param touchEnabled Enable touch screen support.
  121419. * @returns the new FlyCameraMouseInput().
  121420. */
  121421. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121422. }
  121423. }
  121424. declare module BABYLON {
  121425. /**
  121426. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121427. * such as in a 3D Space Shooter or a Flight Simulator.
  121428. */
  121429. export class FlyCamera extends TargetCamera {
  121430. /**
  121431. * Define the collision ellipsoid of the camera.
  121432. * This is helpful for simulating a camera body, like a player's body.
  121433. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121434. */
  121435. ellipsoid: Vector3;
  121436. /**
  121437. * Define an offset for the position of the ellipsoid around the camera.
  121438. * This can be helpful if the camera is attached away from the player's body center,
  121439. * such as at its head.
  121440. */
  121441. ellipsoidOffset: Vector3;
  121442. /**
  121443. * Enable or disable collisions of the camera with the rest of the scene objects.
  121444. */
  121445. checkCollisions: boolean;
  121446. /**
  121447. * Enable or disable gravity on the camera.
  121448. */
  121449. applyGravity: boolean;
  121450. /**
  121451. * Define the current direction the camera is moving to.
  121452. */
  121453. cameraDirection: Vector3;
  121454. /**
  121455. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121456. * This overrides and empties cameraRotation.
  121457. */
  121458. rotationQuaternion: Quaternion;
  121459. /**
  121460. * Track Roll to maintain the wanted Rolling when looking around.
  121461. */
  121462. _trackRoll: number;
  121463. /**
  121464. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121465. */
  121466. rollCorrect: number;
  121467. /**
  121468. * Mimic a banked turn, Rolling the camera when Yawing.
  121469. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121470. */
  121471. bankedTurn: boolean;
  121472. /**
  121473. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121474. */
  121475. bankedTurnLimit: number;
  121476. /**
  121477. * Value of 0 disables the banked Roll.
  121478. * Value of 1 is equal to the Yaw angle in radians.
  121479. */
  121480. bankedTurnMultiplier: number;
  121481. /**
  121482. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121483. */
  121484. inputs: FlyCameraInputsManager;
  121485. /**
  121486. * Gets the input sensibility for mouse input.
  121487. * Higher values reduce sensitivity.
  121488. */
  121489. get angularSensibility(): number;
  121490. /**
  121491. * Sets the input sensibility for a mouse input.
  121492. * Higher values reduce sensitivity.
  121493. */
  121494. set angularSensibility(value: number);
  121495. /**
  121496. * Get the keys for camera movement forward.
  121497. */
  121498. get keysForward(): number[];
  121499. /**
  121500. * Set the keys for camera movement forward.
  121501. */
  121502. set keysForward(value: number[]);
  121503. /**
  121504. * Get the keys for camera movement backward.
  121505. */
  121506. get keysBackward(): number[];
  121507. set keysBackward(value: number[]);
  121508. /**
  121509. * Get the keys for camera movement up.
  121510. */
  121511. get keysUp(): number[];
  121512. /**
  121513. * Set the keys for camera movement up.
  121514. */
  121515. set keysUp(value: number[]);
  121516. /**
  121517. * Get the keys for camera movement down.
  121518. */
  121519. get keysDown(): number[];
  121520. /**
  121521. * Set the keys for camera movement down.
  121522. */
  121523. set keysDown(value: number[]);
  121524. /**
  121525. * Get the keys for camera movement left.
  121526. */
  121527. get keysLeft(): number[];
  121528. /**
  121529. * Set the keys for camera movement left.
  121530. */
  121531. set keysLeft(value: number[]);
  121532. /**
  121533. * Set the keys for camera movement right.
  121534. */
  121535. get keysRight(): number[];
  121536. /**
  121537. * Set the keys for camera movement right.
  121538. */
  121539. set keysRight(value: number[]);
  121540. /**
  121541. * Event raised when the camera collides with a mesh in the scene.
  121542. */
  121543. onCollide: (collidedMesh: AbstractMesh) => void;
  121544. private _collider;
  121545. private _needMoveForGravity;
  121546. private _oldPosition;
  121547. private _diffPosition;
  121548. private _newPosition;
  121549. /** @hidden */
  121550. _localDirection: Vector3;
  121551. /** @hidden */
  121552. _transformedDirection: Vector3;
  121553. /**
  121554. * Instantiates a FlyCamera.
  121555. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121556. * such as in a 3D Space Shooter or a Flight Simulator.
  121557. * @param name Define the name of the camera in the scene.
  121558. * @param position Define the starting position of the camera in the scene.
  121559. * @param scene Define the scene the camera belongs to.
  121560. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121561. */
  121562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121563. /**
  121564. * Attach a control to the HTML DOM element.
  121565. * @param element Defines the element that listens to the input events.
  121566. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121567. */
  121568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121569. /**
  121570. * Detach a control from the HTML DOM element.
  121571. * The camera will stop reacting to that input.
  121572. * @param element Defines the element that listens to the input events.
  121573. */
  121574. detachControl(element: HTMLElement): void;
  121575. private _collisionMask;
  121576. /**
  121577. * Get the mask that the camera ignores in collision events.
  121578. */
  121579. get collisionMask(): number;
  121580. /**
  121581. * Set the mask that the camera ignores in collision events.
  121582. */
  121583. set collisionMask(mask: number);
  121584. /** @hidden */
  121585. _collideWithWorld(displacement: Vector3): void;
  121586. /** @hidden */
  121587. private _onCollisionPositionChange;
  121588. /** @hidden */
  121589. _checkInputs(): void;
  121590. /** @hidden */
  121591. _decideIfNeedsToMove(): boolean;
  121592. /** @hidden */
  121593. _updatePosition(): void;
  121594. /**
  121595. * Restore the Roll to its target value at the rate specified.
  121596. * @param rate - Higher means slower restoring.
  121597. * @hidden
  121598. */
  121599. restoreRoll(rate: number): void;
  121600. /**
  121601. * Destroy the camera and release the current resources held by it.
  121602. */
  121603. dispose(): void;
  121604. /**
  121605. * Get the current object class name.
  121606. * @returns the class name.
  121607. */
  121608. getClassName(): string;
  121609. }
  121610. }
  121611. declare module BABYLON {
  121612. /**
  121613. * Listen to keyboard events to control the camera.
  121614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121615. */
  121616. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121617. /**
  121618. * Defines the camera the input is attached to.
  121619. */
  121620. camera: FlyCamera;
  121621. /**
  121622. * The list of keyboard keys used to control the forward move of the camera.
  121623. */
  121624. keysForward: number[];
  121625. /**
  121626. * The list of keyboard keys used to control the backward move of the camera.
  121627. */
  121628. keysBackward: number[];
  121629. /**
  121630. * The list of keyboard keys used to control the forward move of the camera.
  121631. */
  121632. keysUp: number[];
  121633. /**
  121634. * The list of keyboard keys used to control the backward move of the camera.
  121635. */
  121636. keysDown: number[];
  121637. /**
  121638. * The list of keyboard keys used to control the right strafe move of the camera.
  121639. */
  121640. keysRight: number[];
  121641. /**
  121642. * The list of keyboard keys used to control the left strafe move of the camera.
  121643. */
  121644. keysLeft: number[];
  121645. private _keys;
  121646. private _onCanvasBlurObserver;
  121647. private _onKeyboardObserver;
  121648. private _engine;
  121649. private _scene;
  121650. /**
  121651. * Attach the input controls to a specific dom element to get the input from.
  121652. * @param element Defines the element the controls should be listened from
  121653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121654. */
  121655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121656. /**
  121657. * Detach the current controls from the specified dom element.
  121658. * @param element Defines the element to stop listening the inputs from
  121659. */
  121660. detachControl(element: Nullable<HTMLElement>): void;
  121661. /**
  121662. * Gets the class name of the current intput.
  121663. * @returns the class name
  121664. */
  121665. getClassName(): string;
  121666. /** @hidden */
  121667. _onLostFocus(e: FocusEvent): void;
  121668. /**
  121669. * Get the friendly name associated with the input class.
  121670. * @returns the input friendly name
  121671. */
  121672. getSimpleName(): string;
  121673. /**
  121674. * Update the current camera state depending on the inputs that have been used this frame.
  121675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121676. */
  121677. checkInputs(): void;
  121678. }
  121679. }
  121680. declare module BABYLON {
  121681. /**
  121682. * Manage the mouse wheel inputs to control a follow camera.
  121683. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121684. */
  121685. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121686. /**
  121687. * Defines the camera the input is attached to.
  121688. */
  121689. camera: FollowCamera;
  121690. /**
  121691. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121692. */
  121693. axisControlRadius: boolean;
  121694. /**
  121695. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121696. */
  121697. axisControlHeight: boolean;
  121698. /**
  121699. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121700. */
  121701. axisControlRotation: boolean;
  121702. /**
  121703. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121704. * relation to mouseWheel events.
  121705. */
  121706. wheelPrecision: number;
  121707. /**
  121708. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121709. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121710. */
  121711. wheelDeltaPercentage: number;
  121712. private _wheel;
  121713. private _observer;
  121714. /**
  121715. * Attach the input controls to a specific dom element to get the input from.
  121716. * @param element Defines the element the controls should be listened from
  121717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121718. */
  121719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121720. /**
  121721. * Detach the current controls from the specified dom element.
  121722. * @param element Defines the element to stop listening the inputs from
  121723. */
  121724. detachControl(element: Nullable<HTMLElement>): void;
  121725. /**
  121726. * Gets the class name of the current intput.
  121727. * @returns the class name
  121728. */
  121729. getClassName(): string;
  121730. /**
  121731. * Get the friendly name associated with the input class.
  121732. * @returns the input friendly name
  121733. */
  121734. getSimpleName(): string;
  121735. }
  121736. }
  121737. declare module BABYLON {
  121738. /**
  121739. * Manage the pointers inputs to control an follow camera.
  121740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121741. */
  121742. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121743. /**
  121744. * Defines the camera the input is attached to.
  121745. */
  121746. camera: FollowCamera;
  121747. /**
  121748. * Gets the class name of the current input.
  121749. * @returns the class name
  121750. */
  121751. getClassName(): string;
  121752. /**
  121753. * Defines the pointer angular sensibility along the X axis or how fast is
  121754. * the camera rotating.
  121755. * A negative number will reverse the axis direction.
  121756. */
  121757. angularSensibilityX: number;
  121758. /**
  121759. * Defines the pointer angular sensibility along the Y axis or how fast is
  121760. * the camera rotating.
  121761. * A negative number will reverse the axis direction.
  121762. */
  121763. angularSensibilityY: number;
  121764. /**
  121765. * Defines the pointer pinch precision or how fast is the camera zooming.
  121766. * A negative number will reverse the axis direction.
  121767. */
  121768. pinchPrecision: number;
  121769. /**
  121770. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121771. * from 0.
  121772. * It defines the percentage of current camera.radius to use as delta when
  121773. * pinch zoom is used.
  121774. */
  121775. pinchDeltaPercentage: number;
  121776. /**
  121777. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121778. */
  121779. axisXControlRadius: boolean;
  121780. /**
  121781. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121782. */
  121783. axisXControlHeight: boolean;
  121784. /**
  121785. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121786. */
  121787. axisXControlRotation: boolean;
  121788. /**
  121789. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121790. */
  121791. axisYControlRadius: boolean;
  121792. /**
  121793. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121794. */
  121795. axisYControlHeight: boolean;
  121796. /**
  121797. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121798. */
  121799. axisYControlRotation: boolean;
  121800. /**
  121801. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121802. */
  121803. axisPinchControlRadius: boolean;
  121804. /**
  121805. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121806. */
  121807. axisPinchControlHeight: boolean;
  121808. /**
  121809. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121810. */
  121811. axisPinchControlRotation: boolean;
  121812. /**
  121813. * Log error messages if basic misconfiguration has occurred.
  121814. */
  121815. warningEnable: boolean;
  121816. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121817. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121818. private _warningCounter;
  121819. private _warning;
  121820. }
  121821. }
  121822. declare module BABYLON {
  121823. /**
  121824. * Default Inputs manager for the FollowCamera.
  121825. * It groups all the default supported inputs for ease of use.
  121826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121827. */
  121828. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121829. /**
  121830. * Instantiates a new FollowCameraInputsManager.
  121831. * @param camera Defines the camera the inputs belong to
  121832. */
  121833. constructor(camera: FollowCamera);
  121834. /**
  121835. * Add keyboard input support to the input manager.
  121836. * @returns the current input manager
  121837. */
  121838. addKeyboard(): FollowCameraInputsManager;
  121839. /**
  121840. * Add mouse wheel input support to the input manager.
  121841. * @returns the current input manager
  121842. */
  121843. addMouseWheel(): FollowCameraInputsManager;
  121844. /**
  121845. * Add pointers input support to the input manager.
  121846. * @returns the current input manager
  121847. */
  121848. addPointers(): FollowCameraInputsManager;
  121849. /**
  121850. * Add orientation input support to the input manager.
  121851. * @returns the current input manager
  121852. */
  121853. addVRDeviceOrientation(): FollowCameraInputsManager;
  121854. }
  121855. }
  121856. declare module BABYLON {
  121857. /**
  121858. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121859. * an arc rotate version arcFollowCamera are available.
  121860. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121861. */
  121862. export class FollowCamera extends TargetCamera {
  121863. /**
  121864. * Distance the follow camera should follow an object at
  121865. */
  121866. radius: number;
  121867. /**
  121868. * Minimum allowed distance of the camera to the axis of rotation
  121869. * (The camera can not get closer).
  121870. * This can help limiting how the Camera is able to move in the scene.
  121871. */
  121872. lowerRadiusLimit: Nullable<number>;
  121873. /**
  121874. * Maximum allowed distance of the camera to the axis of rotation
  121875. * (The camera can not get further).
  121876. * This can help limiting how the Camera is able to move in the scene.
  121877. */
  121878. upperRadiusLimit: Nullable<number>;
  121879. /**
  121880. * Define a rotation offset between the camera and the object it follows
  121881. */
  121882. rotationOffset: number;
  121883. /**
  121884. * Minimum allowed angle to camera position relative to target object.
  121885. * This can help limiting how the Camera is able to move in the scene.
  121886. */
  121887. lowerRotationOffsetLimit: Nullable<number>;
  121888. /**
  121889. * Maximum allowed angle to camera position relative to target object.
  121890. * This can help limiting how the Camera is able to move in the scene.
  121891. */
  121892. upperRotationOffsetLimit: Nullable<number>;
  121893. /**
  121894. * Define a height offset between the camera and the object it follows.
  121895. * It can help following an object from the top (like a car chaing a plane)
  121896. */
  121897. heightOffset: number;
  121898. /**
  121899. * Minimum allowed height of camera position relative to target object.
  121900. * This can help limiting how the Camera is able to move in the scene.
  121901. */
  121902. lowerHeightOffsetLimit: Nullable<number>;
  121903. /**
  121904. * Maximum allowed height of camera position relative to target object.
  121905. * This can help limiting how the Camera is able to move in the scene.
  121906. */
  121907. upperHeightOffsetLimit: Nullable<number>;
  121908. /**
  121909. * Define how fast the camera can accelerate to follow it s target.
  121910. */
  121911. cameraAcceleration: number;
  121912. /**
  121913. * Define the speed limit of the camera following an object.
  121914. */
  121915. maxCameraSpeed: number;
  121916. /**
  121917. * Define the target of the camera.
  121918. */
  121919. lockedTarget: Nullable<AbstractMesh>;
  121920. /**
  121921. * Defines the input associated with the camera.
  121922. */
  121923. inputs: FollowCameraInputsManager;
  121924. /**
  121925. * Instantiates the follow camera.
  121926. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121927. * @param name Define the name of the camera in the scene
  121928. * @param position Define the position of the camera
  121929. * @param scene Define the scene the camera belong to
  121930. * @param lockedTarget Define the target of the camera
  121931. */
  121932. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121933. private _follow;
  121934. /**
  121935. * Attached controls to the current camera.
  121936. * @param element Defines the element the controls should be listened from
  121937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121938. */
  121939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121940. /**
  121941. * Detach the current controls from the camera.
  121942. * The camera will stop reacting to inputs.
  121943. * @param element Defines the element to stop listening the inputs from
  121944. */
  121945. detachControl(element: HTMLElement): void;
  121946. /** @hidden */
  121947. _checkInputs(): void;
  121948. private _checkLimits;
  121949. /**
  121950. * Gets the camera class name.
  121951. * @returns the class name
  121952. */
  121953. getClassName(): string;
  121954. }
  121955. /**
  121956. * Arc Rotate version of the follow camera.
  121957. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121958. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121959. */
  121960. export class ArcFollowCamera extends TargetCamera {
  121961. /** The longitudinal angle of the camera */
  121962. alpha: number;
  121963. /** The latitudinal angle of the camera */
  121964. beta: number;
  121965. /** The radius of the camera from its target */
  121966. radius: number;
  121967. /** Define the camera target (the mesh it should follow) */
  121968. target: Nullable<AbstractMesh>;
  121969. private _cartesianCoordinates;
  121970. /**
  121971. * Instantiates a new ArcFollowCamera
  121972. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121973. * @param name Define the name of the camera
  121974. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121975. * @param beta Define the rotation angle of the camera around the elevation axis
  121976. * @param radius Define the radius of the camera from its target point
  121977. * @param target Define the target of the camera
  121978. * @param scene Define the scene the camera belongs to
  121979. */
  121980. constructor(name: string,
  121981. /** The longitudinal angle of the camera */
  121982. alpha: number,
  121983. /** The latitudinal angle of the camera */
  121984. beta: number,
  121985. /** The radius of the camera from its target */
  121986. radius: number,
  121987. /** Define the camera target (the mesh it should follow) */
  121988. target: Nullable<AbstractMesh>, scene: Scene);
  121989. private _follow;
  121990. /** @hidden */
  121991. _checkInputs(): void;
  121992. /**
  121993. * Returns the class name of the object.
  121994. * It is mostly used internally for serialization purposes.
  121995. */
  121996. getClassName(): string;
  121997. }
  121998. }
  121999. declare module BABYLON {
  122000. /**
  122001. * Manage the keyboard inputs to control the movement of a follow camera.
  122002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122003. */
  122004. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122005. /**
  122006. * Defines the camera the input is attached to.
  122007. */
  122008. camera: FollowCamera;
  122009. /**
  122010. * Defines the list of key codes associated with the up action (increase heightOffset)
  122011. */
  122012. keysHeightOffsetIncr: number[];
  122013. /**
  122014. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122015. */
  122016. keysHeightOffsetDecr: number[];
  122017. /**
  122018. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122019. */
  122020. keysHeightOffsetModifierAlt: boolean;
  122021. /**
  122022. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122023. */
  122024. keysHeightOffsetModifierCtrl: boolean;
  122025. /**
  122026. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122027. */
  122028. keysHeightOffsetModifierShift: boolean;
  122029. /**
  122030. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122031. */
  122032. keysRotationOffsetIncr: number[];
  122033. /**
  122034. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122035. */
  122036. keysRotationOffsetDecr: number[];
  122037. /**
  122038. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122039. */
  122040. keysRotationOffsetModifierAlt: boolean;
  122041. /**
  122042. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122043. */
  122044. keysRotationOffsetModifierCtrl: boolean;
  122045. /**
  122046. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122047. */
  122048. keysRotationOffsetModifierShift: boolean;
  122049. /**
  122050. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122051. */
  122052. keysRadiusIncr: number[];
  122053. /**
  122054. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122055. */
  122056. keysRadiusDecr: number[];
  122057. /**
  122058. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122059. */
  122060. keysRadiusModifierAlt: boolean;
  122061. /**
  122062. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122063. */
  122064. keysRadiusModifierCtrl: boolean;
  122065. /**
  122066. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122067. */
  122068. keysRadiusModifierShift: boolean;
  122069. /**
  122070. * Defines the rate of change of heightOffset.
  122071. */
  122072. heightSensibility: number;
  122073. /**
  122074. * Defines the rate of change of rotationOffset.
  122075. */
  122076. rotationSensibility: number;
  122077. /**
  122078. * Defines the rate of change of radius.
  122079. */
  122080. radiusSensibility: number;
  122081. private _keys;
  122082. private _ctrlPressed;
  122083. private _altPressed;
  122084. private _shiftPressed;
  122085. private _onCanvasBlurObserver;
  122086. private _onKeyboardObserver;
  122087. private _engine;
  122088. private _scene;
  122089. /**
  122090. * Attach the input controls to a specific dom element to get the input from.
  122091. * @param element Defines the element the controls should be listened from
  122092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122093. */
  122094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122095. /**
  122096. * Detach the current controls from the specified dom element.
  122097. * @param element Defines the element to stop listening the inputs from
  122098. */
  122099. detachControl(element: Nullable<HTMLElement>): void;
  122100. /**
  122101. * Update the current camera state depending on the inputs that have been used this frame.
  122102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122103. */
  122104. checkInputs(): void;
  122105. /**
  122106. * Gets the class name of the current input.
  122107. * @returns the class name
  122108. */
  122109. getClassName(): string;
  122110. /**
  122111. * Get the friendly name associated with the input class.
  122112. * @returns the input friendly name
  122113. */
  122114. getSimpleName(): string;
  122115. /**
  122116. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122117. * allow modification of the heightOffset value.
  122118. */
  122119. private _modifierHeightOffset;
  122120. /**
  122121. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122122. * allow modification of the rotationOffset value.
  122123. */
  122124. private _modifierRotationOffset;
  122125. /**
  122126. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122127. * allow modification of the radius value.
  122128. */
  122129. private _modifierRadius;
  122130. }
  122131. }
  122132. declare module BABYLON {
  122133. interface FreeCameraInputsManager {
  122134. /**
  122135. * @hidden
  122136. */
  122137. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122138. /**
  122139. * Add orientation input support to the input manager.
  122140. * @returns the current input manager
  122141. */
  122142. addDeviceOrientation(): FreeCameraInputsManager;
  122143. }
  122144. /**
  122145. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122146. * Screen rotation is taken into account.
  122147. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122148. */
  122149. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122150. private _camera;
  122151. private _screenOrientationAngle;
  122152. private _constantTranform;
  122153. private _screenQuaternion;
  122154. private _alpha;
  122155. private _beta;
  122156. private _gamma;
  122157. /**
  122158. * Can be used to detect if a device orientation sensor is available on a device
  122159. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122160. * @returns a promise that will resolve on orientation change
  122161. */
  122162. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122163. /**
  122164. * @hidden
  122165. */
  122166. _onDeviceOrientationChangedObservable: Observable<void>;
  122167. /**
  122168. * Instantiates a new input
  122169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122170. */
  122171. constructor();
  122172. /**
  122173. * Define the camera controlled by the input.
  122174. */
  122175. get camera(): FreeCamera;
  122176. set camera(camera: FreeCamera);
  122177. /**
  122178. * Attach the input controls to a specific dom element to get the input from.
  122179. * @param element Defines the element the controls should be listened from
  122180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122181. */
  122182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122183. private _orientationChanged;
  122184. private _deviceOrientation;
  122185. /**
  122186. * Detach the current controls from the specified dom element.
  122187. * @param element Defines the element to stop listening the inputs from
  122188. */
  122189. detachControl(element: Nullable<HTMLElement>): void;
  122190. /**
  122191. * Update the current camera state depending on the inputs that have been used this frame.
  122192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122193. */
  122194. checkInputs(): void;
  122195. /**
  122196. * Gets the class name of the current intput.
  122197. * @returns the class name
  122198. */
  122199. getClassName(): string;
  122200. /**
  122201. * Get the friendly name associated with the input class.
  122202. * @returns the input friendly name
  122203. */
  122204. getSimpleName(): string;
  122205. }
  122206. }
  122207. declare module BABYLON {
  122208. /**
  122209. * Manage the gamepad inputs to control a free camera.
  122210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122211. */
  122212. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122213. /**
  122214. * Define the camera the input is attached to.
  122215. */
  122216. camera: FreeCamera;
  122217. /**
  122218. * Define the Gamepad controlling the input
  122219. */
  122220. gamepad: Nullable<Gamepad>;
  122221. /**
  122222. * Defines the gamepad rotation sensiblity.
  122223. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122224. */
  122225. gamepadAngularSensibility: number;
  122226. /**
  122227. * Defines the gamepad move sensiblity.
  122228. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122229. */
  122230. gamepadMoveSensibility: number;
  122231. private _yAxisScale;
  122232. /**
  122233. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122234. */
  122235. get invertYAxis(): boolean;
  122236. set invertYAxis(value: boolean);
  122237. private _onGamepadConnectedObserver;
  122238. private _onGamepadDisconnectedObserver;
  122239. private _cameraTransform;
  122240. private _deltaTransform;
  122241. private _vector3;
  122242. private _vector2;
  122243. /**
  122244. * Attach the input controls to a specific dom element to get the input from.
  122245. * @param element Defines the element the controls should be listened from
  122246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122247. */
  122248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122249. /**
  122250. * Detach the current controls from the specified dom element.
  122251. * @param element Defines the element to stop listening the inputs from
  122252. */
  122253. detachControl(element: Nullable<HTMLElement>): void;
  122254. /**
  122255. * Update the current camera state depending on the inputs that have been used this frame.
  122256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122257. */
  122258. checkInputs(): void;
  122259. /**
  122260. * Gets the class name of the current intput.
  122261. * @returns the class name
  122262. */
  122263. getClassName(): string;
  122264. /**
  122265. * Get the friendly name associated with the input class.
  122266. * @returns the input friendly name
  122267. */
  122268. getSimpleName(): string;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /**
  122273. * Defines the potential axis of a Joystick
  122274. */
  122275. export enum JoystickAxis {
  122276. /** X axis */
  122277. X = 0,
  122278. /** Y axis */
  122279. Y = 1,
  122280. /** Z axis */
  122281. Z = 2
  122282. }
  122283. /**
  122284. * Represents the different customization options available
  122285. * for VirtualJoystick
  122286. */
  122287. interface VirtualJoystickCustomizations {
  122288. /**
  122289. * Size of the joystick's puck
  122290. */
  122291. puckSize: number;
  122292. /**
  122293. * Size of the joystick's container
  122294. */
  122295. containerSize: number;
  122296. /**
  122297. * Color of the joystick && puck
  122298. */
  122299. color: string;
  122300. /**
  122301. * Image URL for the joystick's puck
  122302. */
  122303. puckImage?: string;
  122304. /**
  122305. * Image URL for the joystick's container
  122306. */
  122307. containerImage?: string;
  122308. /**
  122309. * Defines the unmoving position of the joystick container
  122310. */
  122311. position?: {
  122312. x: number;
  122313. y: number;
  122314. };
  122315. /**
  122316. * Defines whether or not the joystick container is always visible
  122317. */
  122318. alwaysVisible: boolean;
  122319. /**
  122320. * Defines whether or not to limit the movement of the puck to the joystick's container
  122321. */
  122322. limitToContainer: boolean;
  122323. }
  122324. /**
  122325. * Class used to define virtual joystick (used in touch mode)
  122326. */
  122327. export class VirtualJoystick {
  122328. /**
  122329. * Gets or sets a boolean indicating that left and right values must be inverted
  122330. */
  122331. reverseLeftRight: boolean;
  122332. /**
  122333. * Gets or sets a boolean indicating that up and down values must be inverted
  122334. */
  122335. reverseUpDown: boolean;
  122336. /**
  122337. * Gets the offset value for the position (ie. the change of the position value)
  122338. */
  122339. deltaPosition: Vector3;
  122340. /**
  122341. * Gets a boolean indicating if the virtual joystick was pressed
  122342. */
  122343. pressed: boolean;
  122344. /**
  122345. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122346. */
  122347. static Canvas: Nullable<HTMLCanvasElement>;
  122348. /**
  122349. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122350. */
  122351. limitToContainer: boolean;
  122352. private static _globalJoystickIndex;
  122353. private static _alwaysVisibleSticks;
  122354. private static vjCanvasContext;
  122355. private static vjCanvasWidth;
  122356. private static vjCanvasHeight;
  122357. private static halfWidth;
  122358. private static _GetDefaultOptions;
  122359. private _action;
  122360. private _axisTargetedByLeftAndRight;
  122361. private _axisTargetedByUpAndDown;
  122362. private _joystickSensibility;
  122363. private _inversedSensibility;
  122364. private _joystickPointerID;
  122365. private _joystickColor;
  122366. private _joystickPointerPos;
  122367. private _joystickPreviousPointerPos;
  122368. private _joystickPointerStartPos;
  122369. private _deltaJoystickVector;
  122370. private _leftJoystick;
  122371. private _touches;
  122372. private _joystickPosition;
  122373. private _alwaysVisible;
  122374. private _puckImage;
  122375. private _containerImage;
  122376. private _joystickPuckSize;
  122377. private _joystickContainerSize;
  122378. private _clearPuckSize;
  122379. private _clearContainerSize;
  122380. private _clearPuckSizeOffset;
  122381. private _clearContainerSizeOffset;
  122382. private _onPointerDownHandlerRef;
  122383. private _onPointerMoveHandlerRef;
  122384. private _onPointerUpHandlerRef;
  122385. private _onResize;
  122386. /**
  122387. * Creates a new virtual joystick
  122388. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122389. * @param customizations Defines the options we want to customize the VirtualJoystick
  122390. */
  122391. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122392. /**
  122393. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122394. * @param newJoystickSensibility defines the new sensibility
  122395. */
  122396. setJoystickSensibility(newJoystickSensibility: number): void;
  122397. private _onPointerDown;
  122398. private _onPointerMove;
  122399. private _onPointerUp;
  122400. /**
  122401. * Change the color of the virtual joystick
  122402. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122403. */
  122404. setJoystickColor(newColor: string): void;
  122405. /**
  122406. * Size of the joystick's container
  122407. */
  122408. set containerSize(newSize: number);
  122409. get containerSize(): number;
  122410. /**
  122411. * Size of the joystick's puck
  122412. */
  122413. set puckSize(newSize: number);
  122414. get puckSize(): number;
  122415. /**
  122416. * Clears the set position of the joystick
  122417. */
  122418. clearPosition(): void;
  122419. /**
  122420. * Defines whether or not the joystick container is always visible
  122421. */
  122422. set alwaysVisible(value: boolean);
  122423. get alwaysVisible(): boolean;
  122424. /**
  122425. * Sets the constant position of the Joystick container
  122426. * @param x X axis coordinate
  122427. * @param y Y axis coordinate
  122428. */
  122429. setPosition(x: number, y: number): void;
  122430. /**
  122431. * Defines a callback to call when the joystick is touched
  122432. * @param action defines the callback
  122433. */
  122434. setActionOnTouch(action: () => any): void;
  122435. /**
  122436. * Defines which axis you'd like to control for left & right
  122437. * @param axis defines the axis to use
  122438. */
  122439. setAxisForLeftRight(axis: JoystickAxis): void;
  122440. /**
  122441. * Defines which axis you'd like to control for up & down
  122442. * @param axis defines the axis to use
  122443. */
  122444. setAxisForUpDown(axis: JoystickAxis): void;
  122445. /**
  122446. * Clears the canvas from the previous puck / container draw
  122447. */
  122448. private _clearPreviousDraw;
  122449. /**
  122450. * Loads `urlPath` to be used for the container's image
  122451. * @param urlPath defines the urlPath of an image to use
  122452. */
  122453. setContainerImage(urlPath: string): void;
  122454. /**
  122455. * Loads `urlPath` to be used for the puck's image
  122456. * @param urlPath defines the urlPath of an image to use
  122457. */
  122458. setPuckImage(urlPath: string): void;
  122459. /**
  122460. * Draws the Virtual Joystick's container
  122461. */
  122462. private _drawContainer;
  122463. /**
  122464. * Draws the Virtual Joystick's puck
  122465. */
  122466. private _drawPuck;
  122467. private _drawVirtualJoystick;
  122468. /**
  122469. * Release internal HTML canvas
  122470. */
  122471. releaseCanvas(): void;
  122472. }
  122473. }
  122474. declare module BABYLON {
  122475. interface FreeCameraInputsManager {
  122476. /**
  122477. * Add virtual joystick input support to the input manager.
  122478. * @returns the current input manager
  122479. */
  122480. addVirtualJoystick(): FreeCameraInputsManager;
  122481. }
  122482. /**
  122483. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122485. */
  122486. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122487. /**
  122488. * Defines the camera the input is attached to.
  122489. */
  122490. camera: FreeCamera;
  122491. private _leftjoystick;
  122492. private _rightjoystick;
  122493. /**
  122494. * Gets the left stick of the virtual joystick.
  122495. * @returns The virtual Joystick
  122496. */
  122497. getLeftJoystick(): VirtualJoystick;
  122498. /**
  122499. * Gets the right stick of the virtual joystick.
  122500. * @returns The virtual Joystick
  122501. */
  122502. getRightJoystick(): VirtualJoystick;
  122503. /**
  122504. * Update the current camera state depending on the inputs that have been used this frame.
  122505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122506. */
  122507. checkInputs(): void;
  122508. /**
  122509. * Attach the input controls to a specific dom element to get the input from.
  122510. * @param element Defines the element the controls should be listened from
  122511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122512. */
  122513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122514. /**
  122515. * Detach the current controls from the specified dom element.
  122516. * @param element Defines the element to stop listening the inputs from
  122517. */
  122518. detachControl(element: Nullable<HTMLElement>): void;
  122519. /**
  122520. * Gets the class name of the current intput.
  122521. * @returns the class name
  122522. */
  122523. getClassName(): string;
  122524. /**
  122525. * Get the friendly name associated with the input class.
  122526. * @returns the input friendly name
  122527. */
  122528. getSimpleName(): string;
  122529. }
  122530. }
  122531. declare module BABYLON {
  122532. /**
  122533. * This represents a FPS type of camera controlled by touch.
  122534. * This is like a universal camera minus the Gamepad controls.
  122535. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122536. */
  122537. export class TouchCamera extends FreeCamera {
  122538. /**
  122539. * Defines the touch sensibility for rotation.
  122540. * The higher the faster.
  122541. */
  122542. get touchAngularSensibility(): number;
  122543. set touchAngularSensibility(value: number);
  122544. /**
  122545. * Defines the touch sensibility for move.
  122546. * The higher the faster.
  122547. */
  122548. get touchMoveSensibility(): number;
  122549. set touchMoveSensibility(value: number);
  122550. /**
  122551. * Instantiates a new touch camera.
  122552. * This represents a FPS type of camera controlled by touch.
  122553. * This is like a universal camera minus the Gamepad controls.
  122554. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122555. * @param name Define the name of the camera in the scene
  122556. * @param position Define the start position of the camera in the scene
  122557. * @param scene Define the scene the camera belongs to
  122558. */
  122559. constructor(name: string, position: Vector3, scene: Scene);
  122560. /**
  122561. * Gets the current object class name.
  122562. * @return the class name
  122563. */
  122564. getClassName(): string;
  122565. /** @hidden */
  122566. _setupInputs(): void;
  122567. }
  122568. }
  122569. declare module BABYLON {
  122570. /**
  122571. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122572. * being tilted forward or back and left or right.
  122573. */
  122574. export class DeviceOrientationCamera extends FreeCamera {
  122575. private _initialQuaternion;
  122576. private _quaternionCache;
  122577. private _tmpDragQuaternion;
  122578. private _disablePointerInputWhenUsingDeviceOrientation;
  122579. /**
  122580. * Creates a new device orientation camera
  122581. * @param name The name of the camera
  122582. * @param position The start position camera
  122583. * @param scene The scene the camera belongs to
  122584. */
  122585. constructor(name: string, position: Vector3, scene: Scene);
  122586. /**
  122587. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122588. */
  122589. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122590. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122591. private _dragFactor;
  122592. /**
  122593. * Enabled turning on the y axis when the orientation sensor is active
  122594. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122595. */
  122596. enableHorizontalDragging(dragFactor?: number): void;
  122597. /**
  122598. * Gets the current instance class name ("DeviceOrientationCamera").
  122599. * This helps avoiding instanceof at run time.
  122600. * @returns the class name
  122601. */
  122602. getClassName(): string;
  122603. /**
  122604. * @hidden
  122605. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122606. */
  122607. _checkInputs(): void;
  122608. /**
  122609. * Reset the camera to its default orientation on the specified axis only.
  122610. * @param axis The axis to reset
  122611. */
  122612. resetToCurrentRotation(axis?: Axis): void;
  122613. }
  122614. }
  122615. declare module BABYLON {
  122616. /**
  122617. * Defines supported buttons for XBox360 compatible gamepads
  122618. */
  122619. export enum Xbox360Button {
  122620. /** A */
  122621. A = 0,
  122622. /** B */
  122623. B = 1,
  122624. /** X */
  122625. X = 2,
  122626. /** Y */
  122627. Y = 3,
  122628. /** Left button */
  122629. LB = 4,
  122630. /** Right button */
  122631. RB = 5,
  122632. /** Back */
  122633. Back = 8,
  122634. /** Start */
  122635. Start = 9,
  122636. /** Left stick */
  122637. LeftStick = 10,
  122638. /** Right stick */
  122639. RightStick = 11
  122640. }
  122641. /** Defines values for XBox360 DPad */
  122642. export enum Xbox360Dpad {
  122643. /** Up */
  122644. Up = 12,
  122645. /** Down */
  122646. Down = 13,
  122647. /** Left */
  122648. Left = 14,
  122649. /** Right */
  122650. Right = 15
  122651. }
  122652. /**
  122653. * Defines a XBox360 gamepad
  122654. */
  122655. export class Xbox360Pad extends Gamepad {
  122656. private _leftTrigger;
  122657. private _rightTrigger;
  122658. private _onlefttriggerchanged;
  122659. private _onrighttriggerchanged;
  122660. private _onbuttondown;
  122661. private _onbuttonup;
  122662. private _ondpaddown;
  122663. private _ondpadup;
  122664. /** Observable raised when a button is pressed */
  122665. onButtonDownObservable: Observable<Xbox360Button>;
  122666. /** Observable raised when a button is released */
  122667. onButtonUpObservable: Observable<Xbox360Button>;
  122668. /** Observable raised when a pad is pressed */
  122669. onPadDownObservable: Observable<Xbox360Dpad>;
  122670. /** Observable raised when a pad is released */
  122671. onPadUpObservable: Observable<Xbox360Dpad>;
  122672. private _buttonA;
  122673. private _buttonB;
  122674. private _buttonX;
  122675. private _buttonY;
  122676. private _buttonBack;
  122677. private _buttonStart;
  122678. private _buttonLB;
  122679. private _buttonRB;
  122680. private _buttonLeftStick;
  122681. private _buttonRightStick;
  122682. private _dPadUp;
  122683. private _dPadDown;
  122684. private _dPadLeft;
  122685. private _dPadRight;
  122686. private _isXboxOnePad;
  122687. /**
  122688. * Creates a new XBox360 gamepad object
  122689. * @param id defines the id of this gamepad
  122690. * @param index defines its index
  122691. * @param gamepad defines the internal HTML gamepad object
  122692. * @param xboxOne defines if it is a XBox One gamepad
  122693. */
  122694. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122695. /**
  122696. * Defines the callback to call when left trigger is pressed
  122697. * @param callback defines the callback to use
  122698. */
  122699. onlefttriggerchanged(callback: (value: number) => void): void;
  122700. /**
  122701. * Defines the callback to call when right trigger is pressed
  122702. * @param callback defines the callback to use
  122703. */
  122704. onrighttriggerchanged(callback: (value: number) => void): void;
  122705. /**
  122706. * Gets the left trigger value
  122707. */
  122708. get leftTrigger(): number;
  122709. /**
  122710. * Sets the left trigger value
  122711. */
  122712. set leftTrigger(newValue: number);
  122713. /**
  122714. * Gets the right trigger value
  122715. */
  122716. get rightTrigger(): number;
  122717. /**
  122718. * Sets the right trigger value
  122719. */
  122720. set rightTrigger(newValue: number);
  122721. /**
  122722. * Defines the callback to call when a button is pressed
  122723. * @param callback defines the callback to use
  122724. */
  122725. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122726. /**
  122727. * Defines the callback to call when a button is released
  122728. * @param callback defines the callback to use
  122729. */
  122730. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122731. /**
  122732. * Defines the callback to call when a pad is pressed
  122733. * @param callback defines the callback to use
  122734. */
  122735. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122736. /**
  122737. * Defines the callback to call when a pad is released
  122738. * @param callback defines the callback to use
  122739. */
  122740. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122741. private _setButtonValue;
  122742. private _setDPadValue;
  122743. /**
  122744. * Gets the value of the `A` button
  122745. */
  122746. get buttonA(): number;
  122747. /**
  122748. * Sets the value of the `A` button
  122749. */
  122750. set buttonA(value: number);
  122751. /**
  122752. * Gets the value of the `B` button
  122753. */
  122754. get buttonB(): number;
  122755. /**
  122756. * Sets the value of the `B` button
  122757. */
  122758. set buttonB(value: number);
  122759. /**
  122760. * Gets the value of the `X` button
  122761. */
  122762. get buttonX(): number;
  122763. /**
  122764. * Sets the value of the `X` button
  122765. */
  122766. set buttonX(value: number);
  122767. /**
  122768. * Gets the value of the `Y` button
  122769. */
  122770. get buttonY(): number;
  122771. /**
  122772. * Sets the value of the `Y` button
  122773. */
  122774. set buttonY(value: number);
  122775. /**
  122776. * Gets the value of the `Start` button
  122777. */
  122778. get buttonStart(): number;
  122779. /**
  122780. * Sets the value of the `Start` button
  122781. */
  122782. set buttonStart(value: number);
  122783. /**
  122784. * Gets the value of the `Back` button
  122785. */
  122786. get buttonBack(): number;
  122787. /**
  122788. * Sets the value of the `Back` button
  122789. */
  122790. set buttonBack(value: number);
  122791. /**
  122792. * Gets the value of the `Left` button
  122793. */
  122794. get buttonLB(): number;
  122795. /**
  122796. * Sets the value of the `Left` button
  122797. */
  122798. set buttonLB(value: number);
  122799. /**
  122800. * Gets the value of the `Right` button
  122801. */
  122802. get buttonRB(): number;
  122803. /**
  122804. * Sets the value of the `Right` button
  122805. */
  122806. set buttonRB(value: number);
  122807. /**
  122808. * Gets the value of the Left joystick
  122809. */
  122810. get buttonLeftStick(): number;
  122811. /**
  122812. * Sets the value of the Left joystick
  122813. */
  122814. set buttonLeftStick(value: number);
  122815. /**
  122816. * Gets the value of the Right joystick
  122817. */
  122818. get buttonRightStick(): number;
  122819. /**
  122820. * Sets the value of the Right joystick
  122821. */
  122822. set buttonRightStick(value: number);
  122823. /**
  122824. * Gets the value of D-pad up
  122825. */
  122826. get dPadUp(): number;
  122827. /**
  122828. * Sets the value of D-pad up
  122829. */
  122830. set dPadUp(value: number);
  122831. /**
  122832. * Gets the value of D-pad down
  122833. */
  122834. get dPadDown(): number;
  122835. /**
  122836. * Sets the value of D-pad down
  122837. */
  122838. set dPadDown(value: number);
  122839. /**
  122840. * Gets the value of D-pad left
  122841. */
  122842. get dPadLeft(): number;
  122843. /**
  122844. * Sets the value of D-pad left
  122845. */
  122846. set dPadLeft(value: number);
  122847. /**
  122848. * Gets the value of D-pad right
  122849. */
  122850. get dPadRight(): number;
  122851. /**
  122852. * Sets the value of D-pad right
  122853. */
  122854. set dPadRight(value: number);
  122855. /**
  122856. * Force the gamepad to synchronize with device values
  122857. */
  122858. update(): void;
  122859. /**
  122860. * Disposes the gamepad
  122861. */
  122862. dispose(): void;
  122863. }
  122864. }
  122865. declare module BABYLON {
  122866. /**
  122867. * Defines supported buttons for DualShock compatible gamepads
  122868. */
  122869. export enum DualShockButton {
  122870. /** Cross */
  122871. Cross = 0,
  122872. /** Circle */
  122873. Circle = 1,
  122874. /** Square */
  122875. Square = 2,
  122876. /** Triangle */
  122877. Triangle = 3,
  122878. /** L1 */
  122879. L1 = 4,
  122880. /** R1 */
  122881. R1 = 5,
  122882. /** Share */
  122883. Share = 8,
  122884. /** Options */
  122885. Options = 9,
  122886. /** Left stick */
  122887. LeftStick = 10,
  122888. /** Right stick */
  122889. RightStick = 11
  122890. }
  122891. /** Defines values for DualShock DPad */
  122892. export enum DualShockDpad {
  122893. /** Up */
  122894. Up = 12,
  122895. /** Down */
  122896. Down = 13,
  122897. /** Left */
  122898. Left = 14,
  122899. /** Right */
  122900. Right = 15
  122901. }
  122902. /**
  122903. * Defines a DualShock gamepad
  122904. */
  122905. export class DualShockPad extends Gamepad {
  122906. private _leftTrigger;
  122907. private _rightTrigger;
  122908. private _onlefttriggerchanged;
  122909. private _onrighttriggerchanged;
  122910. private _onbuttondown;
  122911. private _onbuttonup;
  122912. private _ondpaddown;
  122913. private _ondpadup;
  122914. /** Observable raised when a button is pressed */
  122915. onButtonDownObservable: Observable<DualShockButton>;
  122916. /** Observable raised when a button is released */
  122917. onButtonUpObservable: Observable<DualShockButton>;
  122918. /** Observable raised when a pad is pressed */
  122919. onPadDownObservable: Observable<DualShockDpad>;
  122920. /** Observable raised when a pad is released */
  122921. onPadUpObservable: Observable<DualShockDpad>;
  122922. private _buttonCross;
  122923. private _buttonCircle;
  122924. private _buttonSquare;
  122925. private _buttonTriangle;
  122926. private _buttonShare;
  122927. private _buttonOptions;
  122928. private _buttonL1;
  122929. private _buttonR1;
  122930. private _buttonLeftStick;
  122931. private _buttonRightStick;
  122932. private _dPadUp;
  122933. private _dPadDown;
  122934. private _dPadLeft;
  122935. private _dPadRight;
  122936. /**
  122937. * Creates a new DualShock gamepad object
  122938. * @param id defines the id of this gamepad
  122939. * @param index defines its index
  122940. * @param gamepad defines the internal HTML gamepad object
  122941. */
  122942. constructor(id: string, index: number, gamepad: any);
  122943. /**
  122944. * Defines the callback to call when left trigger is pressed
  122945. * @param callback defines the callback to use
  122946. */
  122947. onlefttriggerchanged(callback: (value: number) => void): void;
  122948. /**
  122949. * Defines the callback to call when right trigger is pressed
  122950. * @param callback defines the callback to use
  122951. */
  122952. onrighttriggerchanged(callback: (value: number) => void): void;
  122953. /**
  122954. * Gets the left trigger value
  122955. */
  122956. get leftTrigger(): number;
  122957. /**
  122958. * Sets the left trigger value
  122959. */
  122960. set leftTrigger(newValue: number);
  122961. /**
  122962. * Gets the right trigger value
  122963. */
  122964. get rightTrigger(): number;
  122965. /**
  122966. * Sets the right trigger value
  122967. */
  122968. set rightTrigger(newValue: number);
  122969. /**
  122970. * Defines the callback to call when a button is pressed
  122971. * @param callback defines the callback to use
  122972. */
  122973. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122974. /**
  122975. * Defines the callback to call when a button is released
  122976. * @param callback defines the callback to use
  122977. */
  122978. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122979. /**
  122980. * Defines the callback to call when a pad is pressed
  122981. * @param callback defines the callback to use
  122982. */
  122983. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122984. /**
  122985. * Defines the callback to call when a pad is released
  122986. * @param callback defines the callback to use
  122987. */
  122988. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122989. private _setButtonValue;
  122990. private _setDPadValue;
  122991. /**
  122992. * Gets the value of the `Cross` button
  122993. */
  122994. get buttonCross(): number;
  122995. /**
  122996. * Sets the value of the `Cross` button
  122997. */
  122998. set buttonCross(value: number);
  122999. /**
  123000. * Gets the value of the `Circle` button
  123001. */
  123002. get buttonCircle(): number;
  123003. /**
  123004. * Sets the value of the `Circle` button
  123005. */
  123006. set buttonCircle(value: number);
  123007. /**
  123008. * Gets the value of the `Square` button
  123009. */
  123010. get buttonSquare(): number;
  123011. /**
  123012. * Sets the value of the `Square` button
  123013. */
  123014. set buttonSquare(value: number);
  123015. /**
  123016. * Gets the value of the `Triangle` button
  123017. */
  123018. get buttonTriangle(): number;
  123019. /**
  123020. * Sets the value of the `Triangle` button
  123021. */
  123022. set buttonTriangle(value: number);
  123023. /**
  123024. * Gets the value of the `Options` button
  123025. */
  123026. get buttonOptions(): number;
  123027. /**
  123028. * Sets the value of the `Options` button
  123029. */
  123030. set buttonOptions(value: number);
  123031. /**
  123032. * Gets the value of the `Share` button
  123033. */
  123034. get buttonShare(): number;
  123035. /**
  123036. * Sets the value of the `Share` button
  123037. */
  123038. set buttonShare(value: number);
  123039. /**
  123040. * Gets the value of the `L1` button
  123041. */
  123042. get buttonL1(): number;
  123043. /**
  123044. * Sets the value of the `L1` button
  123045. */
  123046. set buttonL1(value: number);
  123047. /**
  123048. * Gets the value of the `R1` button
  123049. */
  123050. get buttonR1(): number;
  123051. /**
  123052. * Sets the value of the `R1` button
  123053. */
  123054. set buttonR1(value: number);
  123055. /**
  123056. * Gets the value of the Left joystick
  123057. */
  123058. get buttonLeftStick(): number;
  123059. /**
  123060. * Sets the value of the Left joystick
  123061. */
  123062. set buttonLeftStick(value: number);
  123063. /**
  123064. * Gets the value of the Right joystick
  123065. */
  123066. get buttonRightStick(): number;
  123067. /**
  123068. * Sets the value of the Right joystick
  123069. */
  123070. set buttonRightStick(value: number);
  123071. /**
  123072. * Gets the value of D-pad up
  123073. */
  123074. get dPadUp(): number;
  123075. /**
  123076. * Sets the value of D-pad up
  123077. */
  123078. set dPadUp(value: number);
  123079. /**
  123080. * Gets the value of D-pad down
  123081. */
  123082. get dPadDown(): number;
  123083. /**
  123084. * Sets the value of D-pad down
  123085. */
  123086. set dPadDown(value: number);
  123087. /**
  123088. * Gets the value of D-pad left
  123089. */
  123090. get dPadLeft(): number;
  123091. /**
  123092. * Sets the value of D-pad left
  123093. */
  123094. set dPadLeft(value: number);
  123095. /**
  123096. * Gets the value of D-pad right
  123097. */
  123098. get dPadRight(): number;
  123099. /**
  123100. * Sets the value of D-pad right
  123101. */
  123102. set dPadRight(value: number);
  123103. /**
  123104. * Force the gamepad to synchronize with device values
  123105. */
  123106. update(): void;
  123107. /**
  123108. * Disposes the gamepad
  123109. */
  123110. dispose(): void;
  123111. }
  123112. }
  123113. declare module BABYLON {
  123114. /**
  123115. * Manager for handling gamepads
  123116. */
  123117. export class GamepadManager {
  123118. private _scene?;
  123119. private _babylonGamepads;
  123120. private _oneGamepadConnected;
  123121. /** @hidden */
  123122. _isMonitoring: boolean;
  123123. private _gamepadEventSupported;
  123124. private _gamepadSupport?;
  123125. /**
  123126. * observable to be triggered when the gamepad controller has been connected
  123127. */
  123128. onGamepadConnectedObservable: Observable<Gamepad>;
  123129. /**
  123130. * observable to be triggered when the gamepad controller has been disconnected
  123131. */
  123132. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123133. private _onGamepadConnectedEvent;
  123134. private _onGamepadDisconnectedEvent;
  123135. /**
  123136. * Initializes the gamepad manager
  123137. * @param _scene BabylonJS scene
  123138. */
  123139. constructor(_scene?: Scene | undefined);
  123140. /**
  123141. * The gamepads in the game pad manager
  123142. */
  123143. get gamepads(): Gamepad[];
  123144. /**
  123145. * Get the gamepad controllers based on type
  123146. * @param type The type of gamepad controller
  123147. * @returns Nullable gamepad
  123148. */
  123149. getGamepadByType(type?: number): Nullable<Gamepad>;
  123150. /**
  123151. * Disposes the gamepad manager
  123152. */
  123153. dispose(): void;
  123154. private _addNewGamepad;
  123155. private _startMonitoringGamepads;
  123156. private _stopMonitoringGamepads;
  123157. /** @hidden */
  123158. _checkGamepadsStatus(): void;
  123159. private _updateGamepadObjects;
  123160. }
  123161. }
  123162. declare module BABYLON {
  123163. interface Scene {
  123164. /** @hidden */
  123165. _gamepadManager: Nullable<GamepadManager>;
  123166. /**
  123167. * Gets the gamepad manager associated with the scene
  123168. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123169. */
  123170. gamepadManager: GamepadManager;
  123171. }
  123172. /**
  123173. * Interface representing a free camera inputs manager
  123174. */
  123175. interface FreeCameraInputsManager {
  123176. /**
  123177. * Adds gamepad input support to the FreeCameraInputsManager.
  123178. * @returns the FreeCameraInputsManager
  123179. */
  123180. addGamepad(): FreeCameraInputsManager;
  123181. }
  123182. /**
  123183. * Interface representing an arc rotate camera inputs manager
  123184. */
  123185. interface ArcRotateCameraInputsManager {
  123186. /**
  123187. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123188. * @returns the camera inputs manager
  123189. */
  123190. addGamepad(): ArcRotateCameraInputsManager;
  123191. }
  123192. /**
  123193. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123194. */
  123195. export class GamepadSystemSceneComponent implements ISceneComponent {
  123196. /**
  123197. * The component name helpfull to identify the component in the list of scene components.
  123198. */
  123199. readonly name: string;
  123200. /**
  123201. * The scene the component belongs to.
  123202. */
  123203. scene: Scene;
  123204. /**
  123205. * Creates a new instance of the component for the given scene
  123206. * @param scene Defines the scene to register the component in
  123207. */
  123208. constructor(scene: Scene);
  123209. /**
  123210. * Registers the component in a given scene
  123211. */
  123212. register(): void;
  123213. /**
  123214. * Rebuilds the elements related to this component in case of
  123215. * context lost for instance.
  123216. */
  123217. rebuild(): void;
  123218. /**
  123219. * Disposes the component and the associated ressources
  123220. */
  123221. dispose(): void;
  123222. private _beforeCameraUpdate;
  123223. }
  123224. }
  123225. declare module BABYLON {
  123226. /**
  123227. * 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,
  123228. * which still works and will still be found in many Playgrounds.
  123229. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123230. */
  123231. export class UniversalCamera extends TouchCamera {
  123232. /**
  123233. * Defines the gamepad rotation sensiblity.
  123234. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123235. */
  123236. get gamepadAngularSensibility(): number;
  123237. set gamepadAngularSensibility(value: number);
  123238. /**
  123239. * Defines the gamepad move sensiblity.
  123240. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123241. */
  123242. get gamepadMoveSensibility(): number;
  123243. set gamepadMoveSensibility(value: number);
  123244. /**
  123245. * 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,
  123246. * which still works and will still be found in many Playgrounds.
  123247. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123248. * @param name Define the name of the camera in the scene
  123249. * @param position Define the start position of the camera in the scene
  123250. * @param scene Define the scene the camera belongs to
  123251. */
  123252. constructor(name: string, position: Vector3, scene: Scene);
  123253. /**
  123254. * Gets the current object class name.
  123255. * @return the class name
  123256. */
  123257. getClassName(): string;
  123258. }
  123259. }
  123260. declare module BABYLON {
  123261. /**
  123262. * This represents a FPS type of camera. This is only here for back compat purpose.
  123263. * Please use the UniversalCamera instead as both are identical.
  123264. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123265. */
  123266. export class GamepadCamera extends UniversalCamera {
  123267. /**
  123268. * Instantiates a new Gamepad Camera
  123269. * This represents a FPS type of camera. This is only here for back compat purpose.
  123270. * Please use the UniversalCamera instead as both are identical.
  123271. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123272. * @param name Define the name of the camera in the scene
  123273. * @param position Define the start position of the camera in the scene
  123274. * @param scene Define the scene the camera belongs to
  123275. */
  123276. constructor(name: string, position: Vector3, scene: Scene);
  123277. /**
  123278. * Gets the current object class name.
  123279. * @return the class name
  123280. */
  123281. getClassName(): string;
  123282. }
  123283. }
  123284. declare module BABYLON {
  123285. /** @hidden */
  123286. export var passPixelShader: {
  123287. name: string;
  123288. shader: string;
  123289. };
  123290. }
  123291. declare module BABYLON {
  123292. /** @hidden */
  123293. export var passCubePixelShader: {
  123294. name: string;
  123295. shader: string;
  123296. };
  123297. }
  123298. declare module BABYLON {
  123299. /**
  123300. * PassPostProcess which produces an output the same as it's input
  123301. */
  123302. export class PassPostProcess extends PostProcess {
  123303. /**
  123304. * Creates the PassPostProcess
  123305. * @param name The name of the effect.
  123306. * @param options The required width/height ratio to downsize to before computing the render pass.
  123307. * @param camera The camera to apply the render pass to.
  123308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123309. * @param engine The engine which the post process will be applied. (default: current engine)
  123310. * @param reusable If the post process can be reused on the same frame. (default: false)
  123311. * @param textureType The type of texture to be used when performing the post processing.
  123312. * @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)
  123313. */
  123314. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123315. }
  123316. /**
  123317. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123318. */
  123319. export class PassCubePostProcess extends PostProcess {
  123320. private _face;
  123321. /**
  123322. * Gets or sets the cube face to display.
  123323. * * 0 is +X
  123324. * * 1 is -X
  123325. * * 2 is +Y
  123326. * * 3 is -Y
  123327. * * 4 is +Z
  123328. * * 5 is -Z
  123329. */
  123330. get face(): number;
  123331. set face(value: number);
  123332. /**
  123333. * Creates the PassCubePostProcess
  123334. * @param name The name of the effect.
  123335. * @param options The required width/height ratio to downsize to before computing the render pass.
  123336. * @param camera The camera to apply the render pass to.
  123337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123338. * @param engine The engine which the post process will be applied. (default: current engine)
  123339. * @param reusable If the post process can be reused on the same frame. (default: false)
  123340. * @param textureType The type of texture to be used when performing the post processing.
  123341. * @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)
  123342. */
  123343. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123344. }
  123345. }
  123346. declare module BABYLON {
  123347. /** @hidden */
  123348. export var anaglyphPixelShader: {
  123349. name: string;
  123350. shader: string;
  123351. };
  123352. }
  123353. declare module BABYLON {
  123354. /**
  123355. * Postprocess used to generate anaglyphic rendering
  123356. */
  123357. export class AnaglyphPostProcess extends PostProcess {
  123358. private _passedProcess;
  123359. /**
  123360. * Creates a new AnaglyphPostProcess
  123361. * @param name defines postprocess name
  123362. * @param options defines creation options or target ratio scale
  123363. * @param rigCameras defines cameras using this postprocess
  123364. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123365. * @param engine defines hosting engine
  123366. * @param reusable defines if the postprocess will be reused multiple times per frame
  123367. */
  123368. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123374. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123375. */
  123376. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123377. /**
  123378. * Creates a new AnaglyphArcRotateCamera
  123379. * @param name defines camera name
  123380. * @param alpha defines alpha angle (in radians)
  123381. * @param beta defines beta angle (in radians)
  123382. * @param radius defines radius
  123383. * @param target defines camera target
  123384. * @param interaxialDistance defines distance between each color axis
  123385. * @param scene defines the hosting scene
  123386. */
  123387. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123388. /**
  123389. * Gets camera class name
  123390. * @returns AnaglyphArcRotateCamera
  123391. */
  123392. getClassName(): string;
  123393. }
  123394. }
  123395. declare module BABYLON {
  123396. /**
  123397. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123398. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123399. */
  123400. export class AnaglyphFreeCamera extends FreeCamera {
  123401. /**
  123402. * Creates a new AnaglyphFreeCamera
  123403. * @param name defines camera name
  123404. * @param position defines initial position
  123405. * @param interaxialDistance defines distance between each color axis
  123406. * @param scene defines the hosting scene
  123407. */
  123408. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123409. /**
  123410. * Gets camera class name
  123411. * @returns AnaglyphFreeCamera
  123412. */
  123413. getClassName(): string;
  123414. }
  123415. }
  123416. declare module BABYLON {
  123417. /**
  123418. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123419. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123420. */
  123421. export class AnaglyphGamepadCamera extends GamepadCamera {
  123422. /**
  123423. * Creates a new AnaglyphGamepadCamera
  123424. * @param name defines camera name
  123425. * @param position defines initial position
  123426. * @param interaxialDistance defines distance between each color axis
  123427. * @param scene defines the hosting scene
  123428. */
  123429. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123430. /**
  123431. * Gets camera class name
  123432. * @returns AnaglyphGamepadCamera
  123433. */
  123434. getClassName(): string;
  123435. }
  123436. }
  123437. declare module BABYLON {
  123438. /**
  123439. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123440. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123441. */
  123442. export class AnaglyphUniversalCamera extends UniversalCamera {
  123443. /**
  123444. * Creates a new AnaglyphUniversalCamera
  123445. * @param name defines camera name
  123446. * @param position defines initial position
  123447. * @param interaxialDistance defines distance between each color axis
  123448. * @param scene defines the hosting scene
  123449. */
  123450. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123451. /**
  123452. * Gets camera class name
  123453. * @returns AnaglyphUniversalCamera
  123454. */
  123455. getClassName(): string;
  123456. }
  123457. }
  123458. declare module BABYLON {
  123459. /**
  123460. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123461. * @see https://doc.babylonjs.com/features/cameras
  123462. */
  123463. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123464. /**
  123465. * Creates a new StereoscopicArcRotateCamera
  123466. * @param name defines camera name
  123467. * @param alpha defines alpha angle (in radians)
  123468. * @param beta defines beta angle (in radians)
  123469. * @param radius defines radius
  123470. * @param target defines camera target
  123471. * @param interaxialDistance defines distance between each color axis
  123472. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123473. * @param scene defines the hosting scene
  123474. */
  123475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123476. /**
  123477. * Gets camera class name
  123478. * @returns StereoscopicArcRotateCamera
  123479. */
  123480. getClassName(): string;
  123481. }
  123482. }
  123483. declare module BABYLON {
  123484. /**
  123485. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123486. * @see https://doc.babylonjs.com/features/cameras
  123487. */
  123488. export class StereoscopicFreeCamera extends FreeCamera {
  123489. /**
  123490. * Creates a new StereoscopicFreeCamera
  123491. * @param name defines camera name
  123492. * @param position defines initial position
  123493. * @param interaxialDistance defines distance between each color axis
  123494. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123495. * @param scene defines the hosting scene
  123496. */
  123497. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123498. /**
  123499. * Gets camera class name
  123500. * @returns StereoscopicFreeCamera
  123501. */
  123502. getClassName(): string;
  123503. }
  123504. }
  123505. declare module BABYLON {
  123506. /**
  123507. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123508. * @see https://doc.babylonjs.com/features/cameras
  123509. */
  123510. export class StereoscopicGamepadCamera extends GamepadCamera {
  123511. /**
  123512. * Creates a new StereoscopicGamepadCamera
  123513. * @param name defines camera name
  123514. * @param position defines initial position
  123515. * @param interaxialDistance defines distance between each color axis
  123516. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123517. * @param scene defines the hosting scene
  123518. */
  123519. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123520. /**
  123521. * Gets camera class name
  123522. * @returns StereoscopicGamepadCamera
  123523. */
  123524. getClassName(): string;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123530. * @see https://doc.babylonjs.com/features/cameras
  123531. */
  123532. export class StereoscopicUniversalCamera extends UniversalCamera {
  123533. /**
  123534. * Creates a new StereoscopicUniversalCamera
  123535. * @param name defines camera name
  123536. * @param position defines initial position
  123537. * @param interaxialDistance defines distance between each color axis
  123538. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123539. * @param scene defines the hosting scene
  123540. */
  123541. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123542. /**
  123543. * Gets camera class name
  123544. * @returns StereoscopicUniversalCamera
  123545. */
  123546. getClassName(): string;
  123547. }
  123548. }
  123549. declare module BABYLON {
  123550. /**
  123551. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123552. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123553. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123554. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123555. */
  123556. export class VirtualJoysticksCamera extends FreeCamera {
  123557. /**
  123558. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123559. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123560. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123561. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123562. * @param name Define the name of the camera in the scene
  123563. * @param position Define the start position of the camera in the scene
  123564. * @param scene Define the scene the camera belongs to
  123565. */
  123566. constructor(name: string, position: Vector3, scene: Scene);
  123567. /**
  123568. * Gets the current object class name.
  123569. * @return the class name
  123570. */
  123571. getClassName(): string;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * This represents all the required metrics to create a VR camera.
  123577. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123578. */
  123579. export class VRCameraMetrics {
  123580. /**
  123581. * Define the horizontal resolution off the screen.
  123582. */
  123583. hResolution: number;
  123584. /**
  123585. * Define the vertical resolution off the screen.
  123586. */
  123587. vResolution: number;
  123588. /**
  123589. * Define the horizontal screen size.
  123590. */
  123591. hScreenSize: number;
  123592. /**
  123593. * Define the vertical screen size.
  123594. */
  123595. vScreenSize: number;
  123596. /**
  123597. * Define the vertical screen center position.
  123598. */
  123599. vScreenCenter: number;
  123600. /**
  123601. * Define the distance of the eyes to the screen.
  123602. */
  123603. eyeToScreenDistance: number;
  123604. /**
  123605. * Define the distance between both lenses
  123606. */
  123607. lensSeparationDistance: number;
  123608. /**
  123609. * Define the distance between both viewer's eyes.
  123610. */
  123611. interpupillaryDistance: number;
  123612. /**
  123613. * Define the distortion factor of the VR postprocess.
  123614. * Please, touch with care.
  123615. */
  123616. distortionK: number[];
  123617. /**
  123618. * Define the chromatic aberration correction factors for the VR post process.
  123619. */
  123620. chromaAbCorrection: number[];
  123621. /**
  123622. * Define the scale factor of the post process.
  123623. * The smaller the better but the slower.
  123624. */
  123625. postProcessScaleFactor: number;
  123626. /**
  123627. * Define an offset for the lens center.
  123628. */
  123629. lensCenterOffset: number;
  123630. /**
  123631. * Define if the current vr camera should compensate the distortion of the lense or not.
  123632. */
  123633. compensateDistortion: boolean;
  123634. /**
  123635. * Defines if multiview should be enabled when rendering (Default: false)
  123636. */
  123637. multiviewEnabled: boolean;
  123638. /**
  123639. * Gets the rendering aspect ratio based on the provided resolutions.
  123640. */
  123641. get aspectRatio(): number;
  123642. /**
  123643. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123644. */
  123645. get aspectRatioFov(): number;
  123646. /**
  123647. * @hidden
  123648. */
  123649. get leftHMatrix(): Matrix;
  123650. /**
  123651. * @hidden
  123652. */
  123653. get rightHMatrix(): Matrix;
  123654. /**
  123655. * @hidden
  123656. */
  123657. get leftPreViewMatrix(): Matrix;
  123658. /**
  123659. * @hidden
  123660. */
  123661. get rightPreViewMatrix(): Matrix;
  123662. /**
  123663. * Get the default VRMetrics based on the most generic setup.
  123664. * @returns the default vr metrics
  123665. */
  123666. static GetDefault(): VRCameraMetrics;
  123667. }
  123668. }
  123669. declare module BABYLON {
  123670. /** @hidden */
  123671. export var vrDistortionCorrectionPixelShader: {
  123672. name: string;
  123673. shader: string;
  123674. };
  123675. }
  123676. declare module BABYLON {
  123677. /**
  123678. * VRDistortionCorrectionPostProcess used for mobile VR
  123679. */
  123680. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123681. private _isRightEye;
  123682. private _distortionFactors;
  123683. private _postProcessScaleFactor;
  123684. private _lensCenterOffset;
  123685. private _scaleIn;
  123686. private _scaleFactor;
  123687. private _lensCenter;
  123688. /**
  123689. * Initializes the VRDistortionCorrectionPostProcess
  123690. * @param name The name of the effect.
  123691. * @param camera The camera to apply the render pass to.
  123692. * @param isRightEye If this is for the right eye distortion
  123693. * @param vrMetrics All the required metrics for the VR camera
  123694. */
  123695. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123696. }
  123697. }
  123698. declare module BABYLON {
  123699. /**
  123700. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123701. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123702. */
  123703. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123704. /**
  123705. * Creates a new VRDeviceOrientationArcRotateCamera
  123706. * @param name defines camera name
  123707. * @param alpha defines the camera rotation along the logitudinal axis
  123708. * @param beta defines the camera rotation along the latitudinal axis
  123709. * @param radius defines the camera distance from its target
  123710. * @param target defines the camera target
  123711. * @param scene defines the scene the camera belongs to
  123712. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123713. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123714. */
  123715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123716. /**
  123717. * Gets camera class name
  123718. * @returns VRDeviceOrientationArcRotateCamera
  123719. */
  123720. getClassName(): string;
  123721. }
  123722. }
  123723. declare module BABYLON {
  123724. /**
  123725. * Camera used to simulate VR rendering (based on FreeCamera)
  123726. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123727. */
  123728. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123729. /**
  123730. * Creates a new VRDeviceOrientationFreeCamera
  123731. * @param name defines camera name
  123732. * @param position defines the start position of the camera
  123733. * @param scene defines the scene the camera belongs to
  123734. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123735. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123736. */
  123737. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123738. /**
  123739. * Gets camera class name
  123740. * @returns VRDeviceOrientationFreeCamera
  123741. */
  123742. getClassName(): string;
  123743. }
  123744. }
  123745. declare module BABYLON {
  123746. /**
  123747. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123748. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123749. */
  123750. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123751. /**
  123752. * Creates a new VRDeviceOrientationGamepadCamera
  123753. * @param name defines camera name
  123754. * @param position defines the start position of the camera
  123755. * @param scene defines the scene the camera belongs to
  123756. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123757. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123758. */
  123759. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123760. /**
  123761. * Gets camera class name
  123762. * @returns VRDeviceOrientationGamepadCamera
  123763. */
  123764. getClassName(): string;
  123765. }
  123766. }
  123767. declare module BABYLON {
  123768. /**
  123769. * A class extending Texture allowing drawing on a texture
  123770. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123771. */
  123772. export class DynamicTexture extends Texture {
  123773. private _generateMipMaps;
  123774. private _canvas;
  123775. private _context;
  123776. /**
  123777. * Creates a DynamicTexture
  123778. * @param name defines the name of the texture
  123779. * @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
  123780. * @param scene defines the scene where you want the texture
  123781. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123782. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123783. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123784. */
  123785. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123786. /**
  123787. * Get the current class name of the texture useful for serialization or dynamic coding.
  123788. * @returns "DynamicTexture"
  123789. */
  123790. getClassName(): string;
  123791. /**
  123792. * Gets the current state of canRescale
  123793. */
  123794. get canRescale(): boolean;
  123795. private _recreate;
  123796. /**
  123797. * Scales the texture
  123798. * @param ratio the scale factor to apply to both width and height
  123799. */
  123800. scale(ratio: number): void;
  123801. /**
  123802. * Resizes the texture
  123803. * @param width the new width
  123804. * @param height the new height
  123805. */
  123806. scaleTo(width: number, height: number): void;
  123807. /**
  123808. * Gets the context of the canvas used by the texture
  123809. * @returns the canvas context of the dynamic texture
  123810. */
  123811. getContext(): CanvasRenderingContext2D;
  123812. /**
  123813. * Clears the texture
  123814. */
  123815. clear(): void;
  123816. /**
  123817. * Updates the texture
  123818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123819. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123820. */
  123821. update(invertY?: boolean, premulAlpha?: boolean): void;
  123822. /**
  123823. * Draws text onto the texture
  123824. * @param text defines the text to be drawn
  123825. * @param x defines the placement of the text from the left
  123826. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123827. * @param font defines the font to be used with font-style, font-size, font-name
  123828. * @param color defines the color used for the text
  123829. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123830. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123831. * @param update defines whether texture is immediately update (default is true)
  123832. */
  123833. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123834. /**
  123835. * Clones the texture
  123836. * @returns the clone of the texture.
  123837. */
  123838. clone(): DynamicTexture;
  123839. /**
  123840. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123841. * @returns a serialized dynamic texture object
  123842. */
  123843. serialize(): any;
  123844. private _IsCanvasElement;
  123845. /** @hidden */
  123846. _rebuild(): void;
  123847. }
  123848. }
  123849. declare module BABYLON {
  123850. /** @hidden */
  123851. export var imageProcessingPixelShader: {
  123852. name: string;
  123853. shader: string;
  123854. };
  123855. }
  123856. declare module BABYLON {
  123857. /**
  123858. * ImageProcessingPostProcess
  123859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123860. */
  123861. export class ImageProcessingPostProcess extends PostProcess {
  123862. /**
  123863. * Default configuration related to image processing available in the PBR Material.
  123864. */
  123865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123866. /**
  123867. * Gets the image processing configuration used either in this material.
  123868. */
  123869. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123870. /**
  123871. * Sets the Default image processing configuration used either in the this material.
  123872. *
  123873. * If sets to null, the scene one is in use.
  123874. */
  123875. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123876. /**
  123877. * Keep track of the image processing observer to allow dispose and replace.
  123878. */
  123879. private _imageProcessingObserver;
  123880. /**
  123881. * Attaches a new image processing configuration to the PBR Material.
  123882. * @param configuration
  123883. */
  123884. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123885. /**
  123886. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123887. */
  123888. get colorCurves(): Nullable<ColorCurves>;
  123889. /**
  123890. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123891. */
  123892. set colorCurves(value: Nullable<ColorCurves>);
  123893. /**
  123894. * Gets wether the color curves effect is enabled.
  123895. */
  123896. get colorCurvesEnabled(): boolean;
  123897. /**
  123898. * Sets wether the color curves effect is enabled.
  123899. */
  123900. set colorCurvesEnabled(value: boolean);
  123901. /**
  123902. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123903. */
  123904. get colorGradingTexture(): Nullable<BaseTexture>;
  123905. /**
  123906. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123907. */
  123908. set colorGradingTexture(value: Nullable<BaseTexture>);
  123909. /**
  123910. * Gets wether the color grading effect is enabled.
  123911. */
  123912. get colorGradingEnabled(): boolean;
  123913. /**
  123914. * Gets wether the color grading effect is enabled.
  123915. */
  123916. set colorGradingEnabled(value: boolean);
  123917. /**
  123918. * Gets exposure used in the effect.
  123919. */
  123920. get exposure(): number;
  123921. /**
  123922. * Sets exposure used in the effect.
  123923. */
  123924. set exposure(value: number);
  123925. /**
  123926. * Gets wether tonemapping is enabled or not.
  123927. */
  123928. get toneMappingEnabled(): boolean;
  123929. /**
  123930. * Sets wether tonemapping is enabled or not
  123931. */
  123932. set toneMappingEnabled(value: boolean);
  123933. /**
  123934. * Gets the type of tone mapping effect.
  123935. */
  123936. get toneMappingType(): number;
  123937. /**
  123938. * Sets the type of tone mapping effect.
  123939. */
  123940. set toneMappingType(value: number);
  123941. /**
  123942. * Gets contrast used in the effect.
  123943. */
  123944. get contrast(): number;
  123945. /**
  123946. * Sets contrast used in the effect.
  123947. */
  123948. set contrast(value: number);
  123949. /**
  123950. * Gets Vignette stretch size.
  123951. */
  123952. get vignetteStretch(): number;
  123953. /**
  123954. * Sets Vignette stretch size.
  123955. */
  123956. set vignetteStretch(value: number);
  123957. /**
  123958. * Gets Vignette centre X Offset.
  123959. */
  123960. get vignetteCentreX(): number;
  123961. /**
  123962. * Sets Vignette centre X Offset.
  123963. */
  123964. set vignetteCentreX(value: number);
  123965. /**
  123966. * Gets Vignette centre Y Offset.
  123967. */
  123968. get vignetteCentreY(): number;
  123969. /**
  123970. * Sets Vignette centre Y Offset.
  123971. */
  123972. set vignetteCentreY(value: number);
  123973. /**
  123974. * Gets Vignette weight or intensity of the vignette effect.
  123975. */
  123976. get vignetteWeight(): number;
  123977. /**
  123978. * Sets Vignette weight or intensity of the vignette effect.
  123979. */
  123980. set vignetteWeight(value: number);
  123981. /**
  123982. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123983. * if vignetteEnabled is set to true.
  123984. */
  123985. get vignetteColor(): Color4;
  123986. /**
  123987. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123988. * if vignetteEnabled is set to true.
  123989. */
  123990. set vignetteColor(value: Color4);
  123991. /**
  123992. * Gets Camera field of view used by the Vignette effect.
  123993. */
  123994. get vignetteCameraFov(): number;
  123995. /**
  123996. * Sets Camera field of view used by the Vignette effect.
  123997. */
  123998. set vignetteCameraFov(value: number);
  123999. /**
  124000. * Gets the vignette blend mode allowing different kind of effect.
  124001. */
  124002. get vignetteBlendMode(): number;
  124003. /**
  124004. * Sets the vignette blend mode allowing different kind of effect.
  124005. */
  124006. set vignetteBlendMode(value: number);
  124007. /**
  124008. * Gets wether the vignette effect is enabled.
  124009. */
  124010. get vignetteEnabled(): boolean;
  124011. /**
  124012. * Sets wether the vignette effect is enabled.
  124013. */
  124014. set vignetteEnabled(value: boolean);
  124015. private _fromLinearSpace;
  124016. /**
  124017. * Gets wether the input of the processing is in Gamma or Linear Space.
  124018. */
  124019. get fromLinearSpace(): boolean;
  124020. /**
  124021. * Sets wether the input of the processing is in Gamma or Linear Space.
  124022. */
  124023. set fromLinearSpace(value: boolean);
  124024. /**
  124025. * Defines cache preventing GC.
  124026. */
  124027. private _defines;
  124028. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124029. /**
  124030. * "ImageProcessingPostProcess"
  124031. * @returns "ImageProcessingPostProcess"
  124032. */
  124033. getClassName(): string;
  124034. protected _updateParameters(): void;
  124035. dispose(camera?: Camera): void;
  124036. }
  124037. }
  124038. declare module BABYLON {
  124039. /**
  124040. * Class containing static functions to help procedurally build meshes
  124041. */
  124042. export class GroundBuilder {
  124043. /**
  124044. * Creates a ground mesh
  124045. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124046. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124048. * @param name defines the name of the mesh
  124049. * @param options defines the options used to create the mesh
  124050. * @param scene defines the hosting scene
  124051. * @returns the ground mesh
  124052. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124053. */
  124054. static CreateGround(name: string, options: {
  124055. width?: number;
  124056. height?: number;
  124057. subdivisions?: number;
  124058. subdivisionsX?: number;
  124059. subdivisionsY?: number;
  124060. updatable?: boolean;
  124061. }, scene: any): Mesh;
  124062. /**
  124063. * Creates a tiled ground mesh
  124064. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124065. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124066. * * 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
  124067. * * 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
  124068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124069. * @param name defines the name of the mesh
  124070. * @param options defines the options used to create the mesh
  124071. * @param scene defines the hosting scene
  124072. * @returns the tiled ground mesh
  124073. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124074. */
  124075. static CreateTiledGround(name: string, options: {
  124076. xmin: number;
  124077. zmin: number;
  124078. xmax: number;
  124079. zmax: number;
  124080. subdivisions?: {
  124081. w: number;
  124082. h: number;
  124083. };
  124084. precision?: {
  124085. w: number;
  124086. h: number;
  124087. };
  124088. updatable?: boolean;
  124089. }, scene?: Nullable<Scene>): Mesh;
  124090. /**
  124091. * Creates a ground mesh from a height map
  124092. * * The parameter `url` sets the URL of the height map image resource.
  124093. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124094. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124095. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124096. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124097. * * 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.
  124098. * * 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).
  124099. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124101. * @param name defines the name of the mesh
  124102. * @param url defines the url to the height map
  124103. * @param options defines the options used to create the mesh
  124104. * @param scene defines the hosting scene
  124105. * @returns the ground mesh
  124106. * @see https://doc.babylonjs.com/babylon101/height_map
  124107. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124108. */
  124109. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124110. width?: number;
  124111. height?: number;
  124112. subdivisions?: number;
  124113. minHeight?: number;
  124114. maxHeight?: number;
  124115. colorFilter?: Color3;
  124116. alphaFilter?: number;
  124117. updatable?: boolean;
  124118. onReady?: (mesh: GroundMesh) => void;
  124119. }, scene?: Nullable<Scene>): GroundMesh;
  124120. }
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * Class containing static functions to help procedurally build meshes
  124125. */
  124126. export class TorusBuilder {
  124127. /**
  124128. * Creates a torus mesh
  124129. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124130. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124131. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124135. * @param name defines the name of the mesh
  124136. * @param options defines the options used to create the mesh
  124137. * @param scene defines the hosting scene
  124138. * @returns the torus mesh
  124139. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124140. */
  124141. static CreateTorus(name: string, options: {
  124142. diameter?: number;
  124143. thickness?: number;
  124144. tessellation?: number;
  124145. updatable?: boolean;
  124146. sideOrientation?: number;
  124147. frontUVs?: Vector4;
  124148. backUVs?: Vector4;
  124149. }, scene: any): Mesh;
  124150. }
  124151. }
  124152. declare module BABYLON {
  124153. /**
  124154. * Class containing static functions to help procedurally build meshes
  124155. */
  124156. export class CylinderBuilder {
  124157. /**
  124158. * Creates a cylinder or a cone mesh
  124159. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124160. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124161. * * 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.
  124162. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124163. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124164. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124165. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124166. * * 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).
  124167. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124168. * * 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).
  124169. * * 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
  124170. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124171. * * 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
  124172. * * 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.
  124173. * * If `enclose` is false, a ring surface is one element.
  124174. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124175. * * 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
  124176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124179. * @param name defines the name of the mesh
  124180. * @param options defines the options used to create the mesh
  124181. * @param scene defines the hosting scene
  124182. * @returns the cylinder mesh
  124183. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124184. */
  124185. static CreateCylinder(name: string, options: {
  124186. height?: number;
  124187. diameterTop?: number;
  124188. diameterBottom?: number;
  124189. diameter?: number;
  124190. tessellation?: number;
  124191. subdivisions?: number;
  124192. arc?: number;
  124193. faceColors?: Color4[];
  124194. faceUV?: Vector4[];
  124195. updatable?: boolean;
  124196. hasRings?: boolean;
  124197. enclose?: boolean;
  124198. cap?: number;
  124199. sideOrientation?: number;
  124200. frontUVs?: Vector4;
  124201. backUVs?: Vector4;
  124202. }, scene: any): Mesh;
  124203. }
  124204. }
  124205. declare module BABYLON {
  124206. /**
  124207. * States of the webXR experience
  124208. */
  124209. export enum WebXRState {
  124210. /**
  124211. * Transitioning to being in XR mode
  124212. */
  124213. ENTERING_XR = 0,
  124214. /**
  124215. * Transitioning to non XR mode
  124216. */
  124217. EXITING_XR = 1,
  124218. /**
  124219. * In XR mode and presenting
  124220. */
  124221. IN_XR = 2,
  124222. /**
  124223. * Not entered XR mode
  124224. */
  124225. NOT_IN_XR = 3
  124226. }
  124227. /**
  124228. * Abstraction of the XR render target
  124229. */
  124230. export interface WebXRRenderTarget extends IDisposable {
  124231. /**
  124232. * xrpresent context of the canvas which can be used to display/mirror xr content
  124233. */
  124234. canvasContext: WebGLRenderingContext;
  124235. /**
  124236. * xr layer for the canvas
  124237. */
  124238. xrLayer: Nullable<XRWebGLLayer>;
  124239. /**
  124240. * Initializes the xr layer for the session
  124241. * @param xrSession xr session
  124242. * @returns a promise that will resolve once the XR Layer has been created
  124243. */
  124244. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124245. }
  124246. }
  124247. declare module BABYLON {
  124248. /**
  124249. * COnfiguration object for WebXR output canvas
  124250. */
  124251. export class WebXRManagedOutputCanvasOptions {
  124252. /**
  124253. * An optional canvas in case you wish to create it yourself and provide it here.
  124254. * If not provided, a new canvas will be created
  124255. */
  124256. canvasElement?: HTMLCanvasElement;
  124257. /**
  124258. * Options for this XR Layer output
  124259. */
  124260. canvasOptions?: XRWebGLLayerOptions;
  124261. /**
  124262. * CSS styling for a newly created canvas (if not provided)
  124263. */
  124264. newCanvasCssStyle?: string;
  124265. /**
  124266. * Get the default values of the configuration object
  124267. * @returns default values of this configuration object
  124268. */
  124269. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124270. }
  124271. /**
  124272. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124273. */
  124274. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124275. private _options;
  124276. private _canvas;
  124277. private _engine;
  124278. private _originalCanvasSize;
  124279. /**
  124280. * Rendering context of the canvas which can be used to display/mirror xr content
  124281. */
  124282. canvasContext: WebGLRenderingContext;
  124283. /**
  124284. * xr layer for the canvas
  124285. */
  124286. xrLayer: Nullable<XRWebGLLayer>;
  124287. /**
  124288. * Obseervers registered here will be triggered when the xr layer was initialized
  124289. */
  124290. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124291. /**
  124292. * Initializes the canvas to be added/removed upon entering/exiting xr
  124293. * @param _xrSessionManager The XR Session manager
  124294. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124295. */
  124296. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124297. /**
  124298. * Disposes of the object
  124299. */
  124300. dispose(): void;
  124301. /**
  124302. * Initializes the xr layer for the session
  124303. * @param xrSession xr session
  124304. * @returns a promise that will resolve once the XR Layer has been created
  124305. */
  124306. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124307. private _addCanvas;
  124308. private _removeCanvas;
  124309. private _setCanvasSize;
  124310. private _setManagedOutputCanvas;
  124311. }
  124312. }
  124313. declare module BABYLON {
  124314. /**
  124315. * Manages an XRSession to work with Babylon's engine
  124316. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124317. */
  124318. export class WebXRSessionManager implements IDisposable {
  124319. /** The scene which the session should be created for */
  124320. scene: Scene;
  124321. private _referenceSpace;
  124322. private _rttProvider;
  124323. private _sessionEnded;
  124324. private _xrNavigator;
  124325. private baseLayer;
  124326. /**
  124327. * The base reference space from which the session started. good if you want to reset your
  124328. * reference space
  124329. */
  124330. baseReferenceSpace: XRReferenceSpace;
  124331. /**
  124332. * Current XR frame
  124333. */
  124334. currentFrame: Nullable<XRFrame>;
  124335. /** WebXR timestamp updated every frame */
  124336. currentTimestamp: number;
  124337. /**
  124338. * Used just in case of a failure to initialize an immersive session.
  124339. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124340. */
  124341. defaultHeightCompensation: number;
  124342. /**
  124343. * Fires every time a new xrFrame arrives which can be used to update the camera
  124344. */
  124345. onXRFrameObservable: Observable<XRFrame>;
  124346. /**
  124347. * Fires when the reference space changed
  124348. */
  124349. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124350. /**
  124351. * Fires when the xr session is ended either by the device or manually done
  124352. */
  124353. onXRSessionEnded: Observable<any>;
  124354. /**
  124355. * Fires when the xr session is ended either by the device or manually done
  124356. */
  124357. onXRSessionInit: Observable<XRSession>;
  124358. /**
  124359. * Underlying xr session
  124360. */
  124361. session: XRSession;
  124362. /**
  124363. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124364. * or get the offset the player is currently at.
  124365. */
  124366. viewerReferenceSpace: XRReferenceSpace;
  124367. /**
  124368. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124369. * @param scene The scene which the session should be created for
  124370. */
  124371. constructor(
  124372. /** The scene which the session should be created for */
  124373. scene: Scene);
  124374. /**
  124375. * The current reference space used in this session. This reference space can constantly change!
  124376. * It is mainly used to offset the camera's position.
  124377. */
  124378. get referenceSpace(): XRReferenceSpace;
  124379. /**
  124380. * Set a new reference space and triggers the observable
  124381. */
  124382. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124383. /**
  124384. * Disposes of the session manager
  124385. */
  124386. dispose(): void;
  124387. /**
  124388. * Stops the xrSession and restores the render loop
  124389. * @returns Promise which resolves after it exits XR
  124390. */
  124391. exitXRAsync(): Promise<void>;
  124392. /**
  124393. * Gets the correct render target texture to be rendered this frame for this eye
  124394. * @param eye the eye for which to get the render target
  124395. * @returns the render target for the specified eye
  124396. */
  124397. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124398. /**
  124399. * Creates a WebXRRenderTarget object for the XR session
  124400. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124401. * @param options optional options to provide when creating a new render target
  124402. * @returns a WebXR render target to which the session can render
  124403. */
  124404. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124405. /**
  124406. * Initializes the manager
  124407. * After initialization enterXR can be called to start an XR session
  124408. * @returns Promise which resolves after it is initialized
  124409. */
  124410. initializeAsync(): Promise<void>;
  124411. /**
  124412. * Initializes an xr session
  124413. * @param xrSessionMode mode to initialize
  124414. * @param xrSessionInit defines optional and required values to pass to the session builder
  124415. * @returns a promise which will resolve once the session has been initialized
  124416. */
  124417. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124418. /**
  124419. * Checks if a session would be supported for the creation options specified
  124420. * @param sessionMode session mode to check if supported eg. immersive-vr
  124421. * @returns A Promise that resolves to true if supported and false if not
  124422. */
  124423. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124424. /**
  124425. * Resets the reference space to the one started the session
  124426. */
  124427. resetReferenceSpace(): void;
  124428. /**
  124429. * Starts rendering to the xr layer
  124430. */
  124431. runXRRenderLoop(): void;
  124432. /**
  124433. * Sets the reference space on the xr session
  124434. * @param referenceSpaceType space to set
  124435. * @returns a promise that will resolve once the reference space has been set
  124436. */
  124437. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124438. /**
  124439. * Updates the render state of the session
  124440. * @param state state to set
  124441. * @returns a promise that resolves once the render state has been updated
  124442. */
  124443. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124444. /**
  124445. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124446. * @param sessionMode defines the session to test
  124447. * @returns a promise with boolean as final value
  124448. */
  124449. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124450. private _createRenderTargetTexture;
  124451. }
  124452. }
  124453. declare module BABYLON {
  124454. /**
  124455. * WebXR Camera which holds the views for the xrSession
  124456. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124457. */
  124458. export class WebXRCamera extends FreeCamera {
  124459. private _xrSessionManager;
  124460. private _firstFrame;
  124461. private _referenceQuaternion;
  124462. private _referencedPosition;
  124463. private _xrInvPositionCache;
  124464. private _xrInvQuaternionCache;
  124465. /**
  124466. * Should position compensation execute on first frame.
  124467. * This is used when copying the position from a native (non XR) camera
  124468. */
  124469. compensateOnFirstFrame: boolean;
  124470. /**
  124471. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124472. * @param name the name of the camera
  124473. * @param scene the scene to add the camera to
  124474. * @param _xrSessionManager a constructed xr session manager
  124475. */
  124476. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124477. /**
  124478. * Return the user's height, unrelated to the current ground.
  124479. * This will be the y position of this camera, when ground level is 0.
  124480. */
  124481. get realWorldHeight(): number;
  124482. /** @hidden */
  124483. _updateForDualEyeDebugging(): void;
  124484. /**
  124485. * Sets this camera's transformation based on a non-vr camera
  124486. * @param otherCamera the non-vr camera to copy the transformation from
  124487. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124488. */
  124489. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124490. /**
  124491. * Gets the current instance class name ("WebXRCamera").
  124492. * @returns the class name
  124493. */
  124494. getClassName(): string;
  124495. /**
  124496. * Overriding the _getViewMatrix function, as it is computed by WebXR
  124497. */
  124498. _getViewMatrix(): Matrix;
  124499. private _rotate180;
  124500. private _updateFromXRSession;
  124501. private _updateNumberOfRigCameras;
  124502. private _updateReferenceSpace;
  124503. private _updateReferenceSpaceOffset;
  124504. }
  124505. }
  124506. declare module BABYLON {
  124507. /**
  124508. * Defining the interface required for a (webxr) feature
  124509. */
  124510. export interface IWebXRFeature extends IDisposable {
  124511. /**
  124512. * Is this feature attached
  124513. */
  124514. attached: boolean;
  124515. /**
  124516. * Should auto-attach be disabled?
  124517. */
  124518. disableAutoAttach: boolean;
  124519. /**
  124520. * Attach the feature to the session
  124521. * Will usually be called by the features manager
  124522. *
  124523. * @param force should attachment be forced (even when already attached)
  124524. * @returns true if successful.
  124525. */
  124526. attach(force?: boolean): boolean;
  124527. /**
  124528. * Detach the feature from the session
  124529. * Will usually be called by the features manager
  124530. *
  124531. * @returns true if successful.
  124532. */
  124533. detach(): boolean;
  124534. }
  124535. /**
  124536. * A list of the currently available features without referencing them
  124537. */
  124538. export class WebXRFeatureName {
  124539. /**
  124540. * The name of the anchor system feature
  124541. */
  124542. static ANCHOR_SYSTEM: string;
  124543. /**
  124544. * The name of the background remover feature
  124545. */
  124546. static BACKGROUND_REMOVER: string;
  124547. /**
  124548. * The name of the hit test feature
  124549. */
  124550. static HIT_TEST: string;
  124551. /**
  124552. * physics impostors for xr controllers feature
  124553. */
  124554. static PHYSICS_CONTROLLERS: string;
  124555. /**
  124556. * The name of the plane detection feature
  124557. */
  124558. static PLANE_DETECTION: string;
  124559. /**
  124560. * The name of the pointer selection feature
  124561. */
  124562. static POINTER_SELECTION: string;
  124563. /**
  124564. * The name of the teleportation feature
  124565. */
  124566. static TELEPORTATION: string;
  124567. }
  124568. /**
  124569. * Defining the constructor of a feature. Used to register the modules.
  124570. */
  124571. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124572. /**
  124573. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124574. * It is mainly used in AR sessions.
  124575. *
  124576. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124577. */
  124578. export class WebXRFeaturesManager implements IDisposable {
  124579. private _xrSessionManager;
  124580. private static readonly _AvailableFeatures;
  124581. private _features;
  124582. /**
  124583. * constructs a new features manages.
  124584. *
  124585. * @param _xrSessionManager an instance of WebXRSessionManager
  124586. */
  124587. constructor(_xrSessionManager: WebXRSessionManager);
  124588. /**
  124589. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124590. * Mainly used internally.
  124591. *
  124592. * @param featureName the name of the feature to register
  124593. * @param constructorFunction the function used to construct the module
  124594. * @param version the (babylon) version of the module
  124595. * @param stable is that a stable version of this module
  124596. */
  124597. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124598. /**
  124599. * Returns a constructor of a specific feature.
  124600. *
  124601. * @param featureName the name of the feature to construct
  124602. * @param version the version of the feature to load
  124603. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124604. * @param options optional options provided to the module.
  124605. * @returns a function that, when called, will return a new instance of this feature
  124606. */
  124607. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124608. /**
  124609. * Can be used to return the list of features currently registered
  124610. *
  124611. * @returns an Array of available features
  124612. */
  124613. static GetAvailableFeatures(): string[];
  124614. /**
  124615. * Gets the versions available for a specific feature
  124616. * @param featureName the name of the feature
  124617. * @returns an array with the available versions
  124618. */
  124619. static GetAvailableVersions(featureName: string): string[];
  124620. /**
  124621. * Return the latest unstable version of this feature
  124622. * @param featureName the name of the feature to search
  124623. * @returns the version number. if not found will return -1
  124624. */
  124625. static GetLatestVersionOfFeature(featureName: string): number;
  124626. /**
  124627. * Return the latest stable version of this feature
  124628. * @param featureName the name of the feature to search
  124629. * @returns the version number. if not found will return -1
  124630. */
  124631. static GetStableVersionOfFeature(featureName: string): number;
  124632. /**
  124633. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124634. * Can be used during a session to start a feature
  124635. * @param featureName the name of feature to attach
  124636. */
  124637. attachFeature(featureName: string): void;
  124638. /**
  124639. * Can be used inside a session or when the session ends to detach a specific feature
  124640. * @param featureName the name of the feature to detach
  124641. */
  124642. detachFeature(featureName: string): void;
  124643. /**
  124644. * Used to disable an already-enabled feature
  124645. * The feature will be disposed and will be recreated once enabled.
  124646. * @param featureName the feature to disable
  124647. * @returns true if disable was successful
  124648. */
  124649. disableFeature(featureName: string | {
  124650. Name: string;
  124651. }): boolean;
  124652. /**
  124653. * dispose this features manager
  124654. */
  124655. dispose(): void;
  124656. /**
  124657. * 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.
  124658. * 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.
  124659. *
  124660. * @param featureName the name of the feature to load or the class of the feature
  124661. * @param version optional version to load. if not provided the latest version will be enabled
  124662. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124663. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124664. * @returns a new constructed feature or throws an error if feature not found.
  124665. */
  124666. enableFeature(featureName: string | {
  124667. Name: string;
  124668. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124669. /**
  124670. * get the implementation of an enabled feature.
  124671. * @param featureName the name of the feature to load
  124672. * @returns the feature class, if found
  124673. */
  124674. getEnabledFeature(featureName: string): IWebXRFeature;
  124675. /**
  124676. * Get the list of enabled features
  124677. * @returns an array of enabled features
  124678. */
  124679. getEnabledFeatures(): string[];
  124680. }
  124681. }
  124682. declare module BABYLON {
  124683. /**
  124684. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124685. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124686. */
  124687. export class WebXRExperienceHelper implements IDisposable {
  124688. private scene;
  124689. private _nonVRCamera;
  124690. private _originalSceneAutoClear;
  124691. private _supported;
  124692. /**
  124693. * Camera used to render xr content
  124694. */
  124695. camera: WebXRCamera;
  124696. /** A features manager for this xr session */
  124697. featuresManager: WebXRFeaturesManager;
  124698. /**
  124699. * Observers registered here will be triggered after the camera's initial transformation is set
  124700. * This can be used to set a different ground level or an extra rotation.
  124701. *
  124702. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124703. * to the position set after this observable is done executing.
  124704. */
  124705. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124706. /**
  124707. * Fires when the state of the experience helper has changed
  124708. */
  124709. onStateChangedObservable: Observable<WebXRState>;
  124710. /** Session manager used to keep track of xr session */
  124711. sessionManager: WebXRSessionManager;
  124712. /**
  124713. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124714. */
  124715. state: WebXRState;
  124716. /**
  124717. * Creates a WebXRExperienceHelper
  124718. * @param scene The scene the helper should be created in
  124719. */
  124720. private constructor();
  124721. /**
  124722. * Creates the experience helper
  124723. * @param scene the scene to attach the experience helper to
  124724. * @returns a promise for the experience helper
  124725. */
  124726. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124727. /**
  124728. * Disposes of the experience helper
  124729. */
  124730. dispose(): void;
  124731. /**
  124732. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124733. * @param sessionMode options for the XR session
  124734. * @param referenceSpaceType frame of reference of the XR session
  124735. * @param renderTarget the output canvas that will be used to enter XR mode
  124736. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124737. * @returns promise that resolves after xr mode has entered
  124738. */
  124739. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124740. /**
  124741. * Exits XR mode and returns the scene to its original state
  124742. * @returns promise that resolves after xr mode has exited
  124743. */
  124744. exitXRAsync(): Promise<void>;
  124745. private _nonXRToXRCamera;
  124746. private _setState;
  124747. }
  124748. }
  124749. declare module BABYLON {
  124750. /**
  124751. * X-Y values for axes in WebXR
  124752. */
  124753. export interface IWebXRMotionControllerAxesValue {
  124754. /**
  124755. * The value of the x axis
  124756. */
  124757. x: number;
  124758. /**
  124759. * The value of the y-axis
  124760. */
  124761. y: number;
  124762. }
  124763. /**
  124764. * changed / previous values for the values of this component
  124765. */
  124766. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124767. /**
  124768. * current (this frame) value
  124769. */
  124770. current: T;
  124771. /**
  124772. * previous (last change) value
  124773. */
  124774. previous: T;
  124775. }
  124776. /**
  124777. * Represents changes in the component between current frame and last values recorded
  124778. */
  124779. export interface IWebXRMotionControllerComponentChanges {
  124780. /**
  124781. * will be populated with previous and current values if axes changed
  124782. */
  124783. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124784. /**
  124785. * will be populated with previous and current values if pressed changed
  124786. */
  124787. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124788. /**
  124789. * will be populated with previous and current values if touched changed
  124790. */
  124791. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124792. /**
  124793. * will be populated with previous and current values if value changed
  124794. */
  124795. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124796. }
  124797. /**
  124798. * This class represents a single component (for example button or thumbstick) of a motion controller
  124799. */
  124800. export class WebXRControllerComponent implements IDisposable {
  124801. /**
  124802. * the id of this component
  124803. */
  124804. id: string;
  124805. /**
  124806. * the type of the component
  124807. */
  124808. type: MotionControllerComponentType;
  124809. private _buttonIndex;
  124810. private _axesIndices;
  124811. private _axes;
  124812. private _changes;
  124813. private _currentValue;
  124814. private _hasChanges;
  124815. private _pressed;
  124816. private _touched;
  124817. /**
  124818. * button component type
  124819. */
  124820. static BUTTON_TYPE: MotionControllerComponentType;
  124821. /**
  124822. * squeeze component type
  124823. */
  124824. static SQUEEZE_TYPE: MotionControllerComponentType;
  124825. /**
  124826. * Thumbstick component type
  124827. */
  124828. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124829. /**
  124830. * Touchpad component type
  124831. */
  124832. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124833. /**
  124834. * trigger component type
  124835. */
  124836. static TRIGGER_TYPE: MotionControllerComponentType;
  124837. /**
  124838. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124839. * the axes data changes
  124840. */
  124841. onAxisValueChangedObservable: Observable<{
  124842. x: number;
  124843. y: number;
  124844. }>;
  124845. /**
  124846. * Observers registered here will be triggered when the state of a button changes
  124847. * State change is either pressed / touched / value
  124848. */
  124849. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124850. /**
  124851. * Creates a new component for a motion controller.
  124852. * It is created by the motion controller itself
  124853. *
  124854. * @param id the id of this component
  124855. * @param type the type of the component
  124856. * @param _buttonIndex index in the buttons array of the gamepad
  124857. * @param _axesIndices indices of the values in the axes array of the gamepad
  124858. */
  124859. constructor(
  124860. /**
  124861. * the id of this component
  124862. */
  124863. id: string,
  124864. /**
  124865. * the type of the component
  124866. */
  124867. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124868. /**
  124869. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124870. */
  124871. get axes(): IWebXRMotionControllerAxesValue;
  124872. /**
  124873. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124874. */
  124875. get changes(): IWebXRMotionControllerComponentChanges;
  124876. /**
  124877. * Return whether or not the component changed the last frame
  124878. */
  124879. get hasChanges(): boolean;
  124880. /**
  124881. * is the button currently pressed
  124882. */
  124883. get pressed(): boolean;
  124884. /**
  124885. * is the button currently touched
  124886. */
  124887. get touched(): boolean;
  124888. /**
  124889. * Get the current value of this component
  124890. */
  124891. get value(): number;
  124892. /**
  124893. * Dispose this component
  124894. */
  124895. dispose(): void;
  124896. /**
  124897. * Are there axes correlating to this component
  124898. * @return true is axes data is available
  124899. */
  124900. isAxes(): boolean;
  124901. /**
  124902. * Is this component a button (hence - pressable)
  124903. * @returns true if can be pressed
  124904. */
  124905. isButton(): boolean;
  124906. /**
  124907. * update this component using the gamepad object it is in. Called on every frame
  124908. * @param nativeController the native gamepad controller object
  124909. */
  124910. update(nativeController: IMinimalMotionControllerObject): void;
  124911. }
  124912. }
  124913. declare module BABYLON {
  124914. /**
  124915. * Interface used to represent data loading progression
  124916. */
  124917. export interface ISceneLoaderProgressEvent {
  124918. /**
  124919. * Defines if data length to load can be evaluated
  124920. */
  124921. readonly lengthComputable: boolean;
  124922. /**
  124923. * Defines the loaded data length
  124924. */
  124925. readonly loaded: number;
  124926. /**
  124927. * Defines the data length to load
  124928. */
  124929. readonly total: number;
  124930. }
  124931. /**
  124932. * Interface used by SceneLoader plugins to define supported file extensions
  124933. */
  124934. export interface ISceneLoaderPluginExtensions {
  124935. /**
  124936. * Defines the list of supported extensions
  124937. */
  124938. [extension: string]: {
  124939. isBinary: boolean;
  124940. };
  124941. }
  124942. /**
  124943. * Interface used by SceneLoader plugin factory
  124944. */
  124945. export interface ISceneLoaderPluginFactory {
  124946. /**
  124947. * Defines the name of the factory
  124948. */
  124949. name: string;
  124950. /**
  124951. * Function called to create a new plugin
  124952. * @return the new plugin
  124953. */
  124954. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124955. /**
  124956. * The callback that returns true if the data can be directly loaded.
  124957. * @param data string containing the file data
  124958. * @returns if the data can be loaded directly
  124959. */
  124960. canDirectLoad?(data: string): boolean;
  124961. }
  124962. /**
  124963. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124964. */
  124965. export interface ISceneLoaderPluginBase {
  124966. /**
  124967. * The friendly name of this plugin.
  124968. */
  124969. name: string;
  124970. /**
  124971. * The file extensions supported by this plugin.
  124972. */
  124973. extensions: string | ISceneLoaderPluginExtensions;
  124974. /**
  124975. * The callback called when loading from a url.
  124976. * @param scene scene loading this url
  124977. * @param url url to load
  124978. * @param onSuccess callback called when the file successfully loads
  124979. * @param onProgress callback called while file is loading (if the server supports this mode)
  124980. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124981. * @param onError callback called when the file fails to load
  124982. * @returns a file request object
  124983. */
  124984. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124985. /**
  124986. * The callback called when loading from a file object.
  124987. * @param scene scene loading this file
  124988. * @param file defines the file to load
  124989. * @param onSuccess defines the callback to call when data is loaded
  124990. * @param onProgress defines the callback to call during loading process
  124991. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124992. * @param onError defines the callback to call when an error occurs
  124993. * @returns a file request object
  124994. */
  124995. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124996. /**
  124997. * The callback that returns true if the data can be directly loaded.
  124998. * @param data string containing the file data
  124999. * @returns if the data can be loaded directly
  125000. */
  125001. canDirectLoad?(data: string): boolean;
  125002. /**
  125003. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125004. * @param scene scene loading this data
  125005. * @param data string containing the data
  125006. * @returns data to pass to the plugin
  125007. */
  125008. directLoad?(scene: Scene, data: string): any;
  125009. /**
  125010. * The callback that allows custom handling of the root url based on the response url.
  125011. * @param rootUrl the original root url
  125012. * @param responseURL the response url if available
  125013. * @returns the new root url
  125014. */
  125015. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125016. }
  125017. /**
  125018. * Interface used to define a SceneLoader plugin
  125019. */
  125020. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125021. /**
  125022. * Import meshes into a scene.
  125023. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125024. * @param scene The scene to import into
  125025. * @param data The data to import
  125026. * @param rootUrl The root url for scene and resources
  125027. * @param meshes The meshes array to import into
  125028. * @param particleSystems The particle systems array to import into
  125029. * @param skeletons The skeletons array to import into
  125030. * @param onError The callback when import fails
  125031. * @returns True if successful or false otherwise
  125032. */
  125033. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125034. /**
  125035. * Load into a scene.
  125036. * @param scene The scene to load into
  125037. * @param data The data to import
  125038. * @param rootUrl The root url for scene and resources
  125039. * @param onError The callback when import fails
  125040. * @returns True if successful or false otherwise
  125041. */
  125042. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125043. /**
  125044. * Load into an asset container.
  125045. * @param scene The scene to load into
  125046. * @param data The data to import
  125047. * @param rootUrl The root url for scene and resources
  125048. * @param onError The callback when import fails
  125049. * @returns The loaded asset container
  125050. */
  125051. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125052. }
  125053. /**
  125054. * Interface used to define an async SceneLoader plugin
  125055. */
  125056. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125057. /**
  125058. * Import meshes into a scene.
  125059. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125060. * @param scene The scene to import into
  125061. * @param data The data to import
  125062. * @param rootUrl The root url for scene and resources
  125063. * @param onProgress The callback when the load progresses
  125064. * @param fileName Defines the name of the file to load
  125065. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125066. */
  125067. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125068. meshes: AbstractMesh[];
  125069. particleSystems: IParticleSystem[];
  125070. skeletons: Skeleton[];
  125071. animationGroups: AnimationGroup[];
  125072. }>;
  125073. /**
  125074. * Load into a scene.
  125075. * @param scene The scene to load into
  125076. * @param data The data to import
  125077. * @param rootUrl The root url for scene and resources
  125078. * @param onProgress The callback when the load progresses
  125079. * @param fileName Defines the name of the file to load
  125080. * @returns Nothing
  125081. */
  125082. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125083. /**
  125084. * Load into an asset container.
  125085. * @param scene The scene to load into
  125086. * @param data The data to import
  125087. * @param rootUrl The root url for scene and resources
  125088. * @param onProgress The callback when the load progresses
  125089. * @param fileName Defines the name of the file to load
  125090. * @returns The loaded asset container
  125091. */
  125092. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125093. }
  125094. /**
  125095. * Mode that determines how to handle old animation groups before loading new ones.
  125096. */
  125097. export enum SceneLoaderAnimationGroupLoadingMode {
  125098. /**
  125099. * Reset all old animations to initial state then dispose them.
  125100. */
  125101. Clean = 0,
  125102. /**
  125103. * Stop all old animations.
  125104. */
  125105. Stop = 1,
  125106. /**
  125107. * Restart old animations from first frame.
  125108. */
  125109. Sync = 2,
  125110. /**
  125111. * Old animations remains untouched.
  125112. */
  125113. NoSync = 3
  125114. }
  125115. /**
  125116. * Class used to load scene from various file formats using registered plugins
  125117. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125118. */
  125119. export class SceneLoader {
  125120. /**
  125121. * No logging while loading
  125122. */
  125123. static readonly NO_LOGGING: number;
  125124. /**
  125125. * Minimal logging while loading
  125126. */
  125127. static readonly MINIMAL_LOGGING: number;
  125128. /**
  125129. * Summary logging while loading
  125130. */
  125131. static readonly SUMMARY_LOGGING: number;
  125132. /**
  125133. * Detailled logging while loading
  125134. */
  125135. static readonly DETAILED_LOGGING: number;
  125136. /**
  125137. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125138. */
  125139. static get ForceFullSceneLoadingForIncremental(): boolean;
  125140. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125141. /**
  125142. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125143. */
  125144. static get ShowLoadingScreen(): boolean;
  125145. static set ShowLoadingScreen(value: boolean);
  125146. /**
  125147. * Defines the current logging level (while loading the scene)
  125148. * @ignorenaming
  125149. */
  125150. static get loggingLevel(): number;
  125151. static set loggingLevel(value: number);
  125152. /**
  125153. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125154. */
  125155. static get CleanBoneMatrixWeights(): boolean;
  125156. static set CleanBoneMatrixWeights(value: boolean);
  125157. /**
  125158. * Event raised when a plugin is used to load a scene
  125159. */
  125160. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125161. private static _registeredPlugins;
  125162. private static _getDefaultPlugin;
  125163. private static _getPluginForExtension;
  125164. private static _getPluginForDirectLoad;
  125165. private static _getPluginForFilename;
  125166. private static _getDirectLoad;
  125167. private static _loadData;
  125168. private static _getFileInfo;
  125169. /**
  125170. * Gets a plugin that can load the given extension
  125171. * @param extension defines the extension to load
  125172. * @returns a plugin or null if none works
  125173. */
  125174. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125175. /**
  125176. * Gets a boolean indicating that the given extension can be loaded
  125177. * @param extension defines the extension to load
  125178. * @returns true if the extension is supported
  125179. */
  125180. static IsPluginForExtensionAvailable(extension: string): boolean;
  125181. /**
  125182. * Adds a new plugin to the list of registered plugins
  125183. * @param plugin defines the plugin to add
  125184. */
  125185. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125186. /**
  125187. * Import meshes into a scene
  125188. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125189. * @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)
  125190. * @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)
  125191. * @param scene the instance of BABYLON.Scene to append to
  125192. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125193. * @param onProgress a callback with a progress event for each file being loaded
  125194. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125195. * @param pluginExtension the extension used to determine the plugin
  125196. * @returns The loaded plugin
  125197. */
  125198. 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>;
  125199. /**
  125200. * Import meshes into a scene
  125201. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125202. * @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)
  125203. * @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)
  125204. * @param scene the instance of BABYLON.Scene to append to
  125205. * @param onProgress a callback with a progress event for each file being loaded
  125206. * @param pluginExtension the extension used to determine the plugin
  125207. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125208. */
  125209. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125210. meshes: AbstractMesh[];
  125211. particleSystems: IParticleSystem[];
  125212. skeletons: Skeleton[];
  125213. animationGroups: AnimationGroup[];
  125214. }>;
  125215. /**
  125216. * Load a scene
  125217. * @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)
  125218. * @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)
  125219. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125220. * @param onSuccess a callback with the scene when import succeeds
  125221. * @param onProgress a callback with a progress event for each file being loaded
  125222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125223. * @param pluginExtension the extension used to determine the plugin
  125224. * @returns The loaded plugin
  125225. */
  125226. 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>;
  125227. /**
  125228. * Load a scene
  125229. * @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)
  125230. * @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)
  125231. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125232. * @param onProgress a callback with a progress event for each file being loaded
  125233. * @param pluginExtension the extension used to determine the plugin
  125234. * @returns The loaded scene
  125235. */
  125236. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125237. /**
  125238. * Append a scene
  125239. * @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)
  125240. * @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)
  125241. * @param scene is the instance of BABYLON.Scene to append to
  125242. * @param onSuccess a callback with the scene when import succeeds
  125243. * @param onProgress a callback with a progress event for each file being loaded
  125244. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125245. * @param pluginExtension the extension used to determine the plugin
  125246. * @returns The loaded plugin
  125247. */
  125248. 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>;
  125249. /**
  125250. * Append a scene
  125251. * @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)
  125252. * @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)
  125253. * @param scene is the instance of BABYLON.Scene to append to
  125254. * @param onProgress a callback with a progress event for each file being loaded
  125255. * @param pluginExtension the extension used to determine the plugin
  125256. * @returns The given scene
  125257. */
  125258. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125259. /**
  125260. * Load a scene into an asset container
  125261. * @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)
  125262. * @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)
  125263. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125264. * @param onSuccess a callback with the scene when import succeeds
  125265. * @param onProgress a callback with a progress event for each file being loaded
  125266. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125267. * @param pluginExtension the extension used to determine the plugin
  125268. * @returns The loaded plugin
  125269. */
  125270. 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>;
  125271. /**
  125272. * Load a scene into an asset container
  125273. * @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)
  125274. * @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)
  125275. * @param scene is the instance of Scene to append to
  125276. * @param onProgress a callback with a progress event for each file being loaded
  125277. * @param pluginExtension the extension used to determine the plugin
  125278. * @returns The loaded asset container
  125279. */
  125280. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125281. /**
  125282. * Import animations from a file into a scene
  125283. * @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)
  125284. * @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)
  125285. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125286. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125287. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125288. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125289. * @param onSuccess a callback with the scene when import succeeds
  125290. * @param onProgress a callback with a progress event for each file being loaded
  125291. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125292. * @param pluginExtension the extension used to determine the plugin
  125293. */
  125294. 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;
  125295. /**
  125296. * Import animations from a file into a scene
  125297. * @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)
  125298. * @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)
  125299. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125300. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125301. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125302. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125303. * @param onSuccess a callback with the scene when import succeeds
  125304. * @param onProgress a callback with a progress event for each file being loaded
  125305. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125306. * @param pluginExtension the extension used to determine the plugin
  125307. * @returns the updated scene with imported animations
  125308. */
  125309. 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>;
  125310. }
  125311. }
  125312. declare module BABYLON {
  125313. /**
  125314. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125315. */
  125316. export type MotionControllerHandedness = "none" | "left" | "right";
  125317. /**
  125318. * The type of components available in motion controllers.
  125319. * This is not the name of the component.
  125320. */
  125321. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125322. /**
  125323. * The state of a controller component
  125324. */
  125325. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125326. /**
  125327. * The schema of motion controller layout.
  125328. * No object will be initialized using this interface
  125329. * This is used just to define the profile.
  125330. */
  125331. export interface IMotionControllerLayout {
  125332. /**
  125333. * Path to load the assets. Usually relative to the base path
  125334. */
  125335. assetPath: string;
  125336. /**
  125337. * Available components (unsorted)
  125338. */
  125339. components: {
  125340. /**
  125341. * A map of component Ids
  125342. */
  125343. [componentId: string]: {
  125344. /**
  125345. * The type of input the component outputs
  125346. */
  125347. type: MotionControllerComponentType;
  125348. /**
  125349. * The indices of this component in the gamepad object
  125350. */
  125351. gamepadIndices: {
  125352. /**
  125353. * Index of button
  125354. */
  125355. button?: number;
  125356. /**
  125357. * If available, index of x-axis
  125358. */
  125359. xAxis?: number;
  125360. /**
  125361. * If available, index of y-axis
  125362. */
  125363. yAxis?: number;
  125364. };
  125365. /**
  125366. * The mesh's root node name
  125367. */
  125368. rootNodeName: string;
  125369. /**
  125370. * Animation definitions for this model
  125371. */
  125372. visualResponses: {
  125373. [stateKey: string]: {
  125374. /**
  125375. * What property will be animated
  125376. */
  125377. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125378. /**
  125379. * What states influence this visual response
  125380. */
  125381. states: MotionControllerComponentStateType[];
  125382. /**
  125383. * Type of animation - movement or visibility
  125384. */
  125385. valueNodeProperty: "transform" | "visibility";
  125386. /**
  125387. * Base node name to move. Its position will be calculated according to the min and max nodes
  125388. */
  125389. valueNodeName?: string;
  125390. /**
  125391. * Minimum movement node
  125392. */
  125393. minNodeName?: string;
  125394. /**
  125395. * Max movement node
  125396. */
  125397. maxNodeName?: string;
  125398. };
  125399. };
  125400. /**
  125401. * If touch enabled, what is the name of node to display user feedback
  125402. */
  125403. touchPointNodeName?: string;
  125404. };
  125405. };
  125406. /**
  125407. * Is it xr standard mapping or not
  125408. */
  125409. gamepadMapping: "" | "xr-standard";
  125410. /**
  125411. * Base root node of this entire model
  125412. */
  125413. rootNodeName: string;
  125414. /**
  125415. * Defines the main button component id
  125416. */
  125417. selectComponentId: string;
  125418. }
  125419. /**
  125420. * A definition for the layout map in the input profile
  125421. */
  125422. export interface IMotionControllerLayoutMap {
  125423. /**
  125424. * Layouts with handedness type as a key
  125425. */
  125426. [handedness: string]: IMotionControllerLayout;
  125427. }
  125428. /**
  125429. * The XR Input profile schema
  125430. * Profiles can be found here:
  125431. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125432. */
  125433. export interface IMotionControllerProfile {
  125434. /**
  125435. * fallback profiles for this profileId
  125436. */
  125437. fallbackProfileIds: string[];
  125438. /**
  125439. * The layout map, with handedness as key
  125440. */
  125441. layouts: IMotionControllerLayoutMap;
  125442. /**
  125443. * The id of this profile
  125444. * correlates to the profile(s) in the xrInput.profiles array
  125445. */
  125446. profileId: string;
  125447. }
  125448. /**
  125449. * A helper-interface for the 3 meshes needed for controller button animation
  125450. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125451. */
  125452. export interface IMotionControllerButtonMeshMap {
  125453. /**
  125454. * the mesh that defines the pressed value mesh position.
  125455. * This is used to find the max-position of this button
  125456. */
  125457. pressedMesh: AbstractMesh;
  125458. /**
  125459. * the mesh that defines the unpressed value mesh position.
  125460. * This is used to find the min (or initial) position of this button
  125461. */
  125462. unpressedMesh: AbstractMesh;
  125463. /**
  125464. * The mesh that will be changed when value changes
  125465. */
  125466. valueMesh: AbstractMesh;
  125467. }
  125468. /**
  125469. * A helper-interface for the 3 meshes needed for controller axis animation.
  125470. * This will be expanded when touchpad animations are fully supported
  125471. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125472. */
  125473. export interface IMotionControllerMeshMap {
  125474. /**
  125475. * the mesh that defines the maximum value mesh position.
  125476. */
  125477. maxMesh?: AbstractMesh;
  125478. /**
  125479. * the mesh that defines the minimum value mesh position.
  125480. */
  125481. minMesh?: AbstractMesh;
  125482. /**
  125483. * The mesh that will be changed when axis value changes
  125484. */
  125485. valueMesh: AbstractMesh;
  125486. }
  125487. /**
  125488. * The elements needed for change-detection of the gamepad objects in motion controllers
  125489. */
  125490. export interface IMinimalMotionControllerObject {
  125491. /**
  125492. * Available axes of this controller
  125493. */
  125494. axes: number[];
  125495. /**
  125496. * An array of available buttons
  125497. */
  125498. buttons: Array<{
  125499. /**
  125500. * Value of the button/trigger
  125501. */
  125502. value: number;
  125503. /**
  125504. * If the button/trigger is currently touched
  125505. */
  125506. touched: boolean;
  125507. /**
  125508. * If the button/trigger is currently pressed
  125509. */
  125510. pressed: boolean;
  125511. }>;
  125512. /**
  125513. * EXPERIMENTAL haptic support.
  125514. */
  125515. hapticActuators?: Array<{
  125516. pulse: (value: number, duration: number) => Promise<boolean>;
  125517. }>;
  125518. }
  125519. /**
  125520. * An Abstract Motion controller
  125521. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125522. * Each component has an observable to check for changes in value and state
  125523. */
  125524. export abstract class WebXRAbstractMotionController implements IDisposable {
  125525. protected scene: Scene;
  125526. protected layout: IMotionControllerLayout;
  125527. /**
  125528. * The gamepad object correlating to this controller
  125529. */
  125530. gamepadObject: IMinimalMotionControllerObject;
  125531. /**
  125532. * handedness (left/right/none) of this controller
  125533. */
  125534. handedness: MotionControllerHandedness;
  125535. private _initComponent;
  125536. private _modelReady;
  125537. /**
  125538. * A map of components (WebXRControllerComponent) in this motion controller
  125539. * Components have a ComponentType and can also have both button and axis definitions
  125540. */
  125541. readonly components: {
  125542. [id: string]: WebXRControllerComponent;
  125543. };
  125544. /**
  125545. * Disable the model's animation. Can be set at any time.
  125546. */
  125547. disableAnimation: boolean;
  125548. /**
  125549. * Observers registered here will be triggered when the model of this controller is done loading
  125550. */
  125551. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125552. /**
  125553. * The profile id of this motion controller
  125554. */
  125555. abstract profileId: string;
  125556. /**
  125557. * The root mesh of the model. It is null if the model was not yet initialized
  125558. */
  125559. rootMesh: Nullable<AbstractMesh>;
  125560. /**
  125561. * constructs a new abstract motion controller
  125562. * @param scene the scene to which the model of the controller will be added
  125563. * @param layout The profile layout to load
  125564. * @param gamepadObject The gamepad object correlating to this controller
  125565. * @param handedness handedness (left/right/none) of this controller
  125566. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125567. */
  125568. constructor(scene: Scene, layout: IMotionControllerLayout,
  125569. /**
  125570. * The gamepad object correlating to this controller
  125571. */
  125572. gamepadObject: IMinimalMotionControllerObject,
  125573. /**
  125574. * handedness (left/right/none) of this controller
  125575. */
  125576. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125577. /**
  125578. * Dispose this controller, the model mesh and all its components
  125579. */
  125580. dispose(): void;
  125581. /**
  125582. * Returns all components of specific type
  125583. * @param type the type to search for
  125584. * @return an array of components with this type
  125585. */
  125586. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125587. /**
  125588. * get a component based an its component id as defined in layout.components
  125589. * @param id the id of the component
  125590. * @returns the component correlates to the id or undefined if not found
  125591. */
  125592. getComponent(id: string): WebXRControllerComponent;
  125593. /**
  125594. * Get the list of components available in this motion controller
  125595. * @returns an array of strings correlating to available components
  125596. */
  125597. getComponentIds(): string[];
  125598. /**
  125599. * Get the first component of specific type
  125600. * @param type type of component to find
  125601. * @return a controller component or null if not found
  125602. */
  125603. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125604. /**
  125605. * Get the main (Select) component of this controller as defined in the layout
  125606. * @returns the main component of this controller
  125607. */
  125608. getMainComponent(): WebXRControllerComponent;
  125609. /**
  125610. * Loads the model correlating to this controller
  125611. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125612. * @returns A promise fulfilled with the result of the model loading
  125613. */
  125614. loadModel(): Promise<boolean>;
  125615. /**
  125616. * Update this model using the current XRFrame
  125617. * @param xrFrame the current xr frame to use and update the model
  125618. */
  125619. updateFromXRFrame(xrFrame: XRFrame): void;
  125620. /**
  125621. * Backwards compatibility due to a deeply-integrated typo
  125622. */
  125623. get handness(): XREye;
  125624. /**
  125625. * Pulse (vibrate) this controller
  125626. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125627. * Consecutive calls to this function will cancel the last pulse call
  125628. *
  125629. * @param value the strength of the pulse in 0.0...1.0 range
  125630. * @param duration Duration of the pulse in milliseconds
  125631. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125632. * @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
  125633. */
  125634. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125635. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125636. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125637. /**
  125638. * Moves the axis on the controller mesh based on its current state
  125639. * @param axis the index of the axis
  125640. * @param axisValue the value of the axis which determines the meshes new position
  125641. * @hidden
  125642. */
  125643. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125644. /**
  125645. * Update the model itself with the current frame data
  125646. * @param xrFrame the frame to use for updating the model mesh
  125647. */
  125648. protected updateModel(xrFrame: XRFrame): void;
  125649. /**
  125650. * Get the filename and path for this controller's model
  125651. * @returns a map of filename and path
  125652. */
  125653. protected abstract _getFilenameAndPath(): {
  125654. filename: string;
  125655. path: string;
  125656. };
  125657. /**
  125658. * This function is called before the mesh is loaded. It checks for loading constraints.
  125659. * For example, this function can check if the GLB loader is available
  125660. * If this function returns false, the generic controller will be loaded instead
  125661. * @returns Is the client ready to load the mesh
  125662. */
  125663. protected abstract _getModelLoadingConstraints(): boolean;
  125664. /**
  125665. * This function will be called after the model was successfully loaded and can be used
  125666. * for mesh transformations before it is available for the user
  125667. * @param meshes the loaded meshes
  125668. */
  125669. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125670. /**
  125671. * Set the root mesh for this controller. Important for the WebXR controller class
  125672. * @param meshes the loaded meshes
  125673. */
  125674. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125675. /**
  125676. * A function executed each frame that updates the mesh (if needed)
  125677. * @param xrFrame the current xrFrame
  125678. */
  125679. protected abstract _updateModel(xrFrame: XRFrame): void;
  125680. private _getGenericFilenameAndPath;
  125681. private _getGenericParentMesh;
  125682. }
  125683. }
  125684. declare module BABYLON {
  125685. /**
  125686. * A generic trigger-only motion controller for WebXR
  125687. */
  125688. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125689. /**
  125690. * Static version of the profile id of this controller
  125691. */
  125692. static ProfileId: string;
  125693. profileId: string;
  125694. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125695. protected _getFilenameAndPath(): {
  125696. filename: string;
  125697. path: string;
  125698. };
  125699. protected _getModelLoadingConstraints(): boolean;
  125700. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125701. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125702. protected _updateModel(): void;
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /**
  125707. * Class containing static functions to help procedurally build meshes
  125708. */
  125709. export class SphereBuilder {
  125710. /**
  125711. * Creates a sphere mesh
  125712. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125713. * * 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`)
  125714. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125715. * * 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
  125716. * * 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)
  125717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125720. * @param name defines the name of the mesh
  125721. * @param options defines the options used to create the mesh
  125722. * @param scene defines the hosting scene
  125723. * @returns the sphere mesh
  125724. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125725. */
  125726. static CreateSphere(name: string, options: {
  125727. segments?: number;
  125728. diameter?: number;
  125729. diameterX?: number;
  125730. diameterY?: number;
  125731. diameterZ?: number;
  125732. arc?: number;
  125733. slice?: number;
  125734. sideOrientation?: number;
  125735. frontUVs?: Vector4;
  125736. backUVs?: Vector4;
  125737. updatable?: boolean;
  125738. }, scene?: Nullable<Scene>): Mesh;
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /**
  125743. * A profiled motion controller has its profile loaded from an online repository.
  125744. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125745. */
  125746. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125747. private _repositoryUrl;
  125748. private _buttonMeshMapping;
  125749. private _touchDots;
  125750. /**
  125751. * The profile ID of this controller. Will be populated when the controller initializes.
  125752. */
  125753. profileId: string;
  125754. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125755. dispose(): void;
  125756. protected _getFilenameAndPath(): {
  125757. filename: string;
  125758. path: string;
  125759. };
  125760. protected _getModelLoadingConstraints(): boolean;
  125761. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125762. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125763. protected _updateModel(_xrFrame: XRFrame): void;
  125764. }
  125765. }
  125766. declare module BABYLON {
  125767. /**
  125768. * A construction function type to create a new controller based on an xrInput object
  125769. */
  125770. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125771. /**
  125772. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125773. *
  125774. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125775. * it should be replaced with auto-loaded controllers.
  125776. *
  125777. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125778. */
  125779. export class WebXRMotionControllerManager {
  125780. private static _AvailableControllers;
  125781. private static _Fallbacks;
  125782. private static _ProfileLoadingPromises;
  125783. private static _ProfilesList;
  125784. /**
  125785. * The base URL of the online controller repository. Can be changed at any time.
  125786. */
  125787. static BaseRepositoryUrl: string;
  125788. /**
  125789. * Which repository gets priority - local or online
  125790. */
  125791. static PrioritizeOnlineRepository: boolean;
  125792. /**
  125793. * Use the online repository, or use only locally-defined controllers
  125794. */
  125795. static UseOnlineRepository: boolean;
  125796. /**
  125797. * Clear the cache used for profile loading and reload when requested again
  125798. */
  125799. static ClearProfilesCache(): void;
  125800. /**
  125801. * Register the default fallbacks.
  125802. * This function is called automatically when this file is imported.
  125803. */
  125804. static DefaultFallbacks(): void;
  125805. /**
  125806. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125807. * @param profileId the profile to which a fallback needs to be found
  125808. * @return an array with corresponding fallback profiles
  125809. */
  125810. static FindFallbackWithProfileId(profileId: string): string[];
  125811. /**
  125812. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125813. * The order of search:
  125814. *
  125815. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125816. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125817. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125818. * 4) return the generic trigger controller if none were found
  125819. *
  125820. * @param xrInput the xrInput to which a new controller is initialized
  125821. * @param scene the scene to which the model will be added
  125822. * @param forceProfile force a certain profile for this controller
  125823. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125824. */
  125825. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125826. /**
  125827. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125828. *
  125829. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125830. *
  125831. * @param type the profile type to register
  125832. * @param constructFunction the function to be called when loading this profile
  125833. */
  125834. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125835. /**
  125836. * Register a fallback to a specific profile.
  125837. * @param profileId the profileId that will receive the fallbacks
  125838. * @param fallbacks A list of fallback profiles
  125839. */
  125840. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125841. /**
  125842. * Will update the list of profiles available in the repository
  125843. * @return a promise that resolves to a map of profiles available online
  125844. */
  125845. static UpdateProfilesList(): Promise<{
  125846. [profile: string]: string;
  125847. }>;
  125848. private static _LoadProfileFromRepository;
  125849. private static _LoadProfilesFromAvailableControllers;
  125850. }
  125851. }
  125852. declare module BABYLON {
  125853. /**
  125854. * Configuration options for the WebXR controller creation
  125855. */
  125856. export interface IWebXRControllerOptions {
  125857. /**
  125858. * Should the controller mesh be animated when a user interacts with it
  125859. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125860. */
  125861. disableMotionControllerAnimation?: boolean;
  125862. /**
  125863. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125864. */
  125865. doNotLoadControllerMesh?: boolean;
  125866. /**
  125867. * Force a specific controller type for this controller.
  125868. * This can be used when creating your own profile or when testing different controllers
  125869. */
  125870. forceControllerProfile?: string;
  125871. /**
  125872. * Defines a rendering group ID for meshes that will be loaded.
  125873. * This is for the default controllers only.
  125874. */
  125875. renderingGroupId?: number;
  125876. }
  125877. /**
  125878. * Represents an XR controller
  125879. */
  125880. export class WebXRInputSource {
  125881. private _scene;
  125882. /** The underlying input source for the controller */
  125883. inputSource: XRInputSource;
  125884. private _options;
  125885. private _tmpVector;
  125886. private _uniqueId;
  125887. /**
  125888. * 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
  125889. */
  125890. grip?: AbstractMesh;
  125891. /**
  125892. * If available, this is the gamepad object related to this controller.
  125893. * Using this object it is possible to get click events and trackpad changes of the
  125894. * webxr controller that is currently being used.
  125895. */
  125896. motionController?: WebXRAbstractMotionController;
  125897. /**
  125898. * Event that fires when the controller is removed/disposed.
  125899. * The object provided as event data is this controller, after associated assets were disposed.
  125900. * uniqueId is still available.
  125901. */
  125902. onDisposeObservable: Observable<WebXRInputSource>;
  125903. /**
  125904. * Will be triggered when the mesh associated with the motion controller is done loading.
  125905. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125906. * A shortened version of controller -> motion controller -> on mesh loaded.
  125907. */
  125908. onMeshLoadedObservable: Observable<AbstractMesh>;
  125909. /**
  125910. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125911. */
  125912. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125913. /**
  125914. * Pointer which can be used to select objects or attach a visible laser to
  125915. */
  125916. pointer: AbstractMesh;
  125917. /**
  125918. * Creates the input source object
  125919. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  125920. * @param _scene the scene which the controller should be associated to
  125921. * @param inputSource the underlying input source for the controller
  125922. * @param _options options for this controller creation
  125923. */
  125924. constructor(_scene: Scene,
  125925. /** The underlying input source for the controller */
  125926. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125927. /**
  125928. * Get this controllers unique id
  125929. */
  125930. get uniqueId(): string;
  125931. /**
  125932. * Disposes of the object
  125933. */
  125934. dispose(): void;
  125935. /**
  125936. * Gets a world space ray coming from the pointer or grip
  125937. * @param result the resulting ray
  125938. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125939. */
  125940. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125941. /**
  125942. * Updates the controller pose based on the given XRFrame
  125943. * @param xrFrame xr frame to update the pose with
  125944. * @param referenceSpace reference space to use
  125945. */
  125946. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125947. }
  125948. }
  125949. declare module BABYLON {
  125950. /**
  125951. * The schema for initialization options of the XR Input class
  125952. */
  125953. export interface IWebXRInputOptions {
  125954. /**
  125955. * If set to true no model will be automatically loaded
  125956. */
  125957. doNotLoadControllerMeshes?: boolean;
  125958. /**
  125959. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125960. * If not found, the xr input profile data will be used.
  125961. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125962. */
  125963. forceInputProfile?: string;
  125964. /**
  125965. * Do not send a request to the controller repository to load the profile.
  125966. *
  125967. * Instead, use the controllers available in babylon itself.
  125968. */
  125969. disableOnlineControllerRepository?: boolean;
  125970. /**
  125971. * A custom URL for the controllers repository
  125972. */
  125973. customControllersRepositoryURL?: string;
  125974. /**
  125975. * Should the controller model's components not move according to the user input
  125976. */
  125977. disableControllerAnimation?: boolean;
  125978. /**
  125979. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125980. */
  125981. controllerOptions?: IWebXRControllerOptions;
  125982. }
  125983. /**
  125984. * XR input used to track XR inputs such as controllers/rays
  125985. */
  125986. export class WebXRInput implements IDisposable {
  125987. /**
  125988. * the xr session manager for this session
  125989. */
  125990. xrSessionManager: WebXRSessionManager;
  125991. /**
  125992. * the WebXR camera for this session. Mainly used for teleportation
  125993. */
  125994. xrCamera: WebXRCamera;
  125995. private readonly options;
  125996. /**
  125997. * XR controllers being tracked
  125998. */
  125999. controllers: Array<WebXRInputSource>;
  126000. private _frameObserver;
  126001. private _sessionEndedObserver;
  126002. private _sessionInitObserver;
  126003. /**
  126004. * Event when a controller has been connected/added
  126005. */
  126006. onControllerAddedObservable: Observable<WebXRInputSource>;
  126007. /**
  126008. * Event when a controller has been removed/disconnected
  126009. */
  126010. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126011. /**
  126012. * Initializes the WebXRInput
  126013. * @param xrSessionManager the xr session manager for this session
  126014. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126015. * @param options = initialization options for this xr input
  126016. */
  126017. constructor(
  126018. /**
  126019. * the xr session manager for this session
  126020. */
  126021. xrSessionManager: WebXRSessionManager,
  126022. /**
  126023. * the WebXR camera for this session. Mainly used for teleportation
  126024. */
  126025. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126026. private _onInputSourcesChange;
  126027. private _addAndRemoveControllers;
  126028. /**
  126029. * Disposes of the object
  126030. */
  126031. dispose(): void;
  126032. }
  126033. }
  126034. declare module BABYLON {
  126035. /**
  126036. * This is the base class for all WebXR features.
  126037. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126038. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126039. */
  126040. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126041. protected _xrSessionManager: WebXRSessionManager;
  126042. private _attached;
  126043. private _removeOnDetach;
  126044. /**
  126045. * Should auto-attach be disabled?
  126046. */
  126047. disableAutoAttach: boolean;
  126048. /**
  126049. * Construct a new (abstract) WebXR feature
  126050. * @param _xrSessionManager the xr session manager for this feature
  126051. */
  126052. constructor(_xrSessionManager: WebXRSessionManager);
  126053. /**
  126054. * Is this feature attached
  126055. */
  126056. get attached(): boolean;
  126057. /**
  126058. * attach this feature
  126059. *
  126060. * @param force should attachment be forced (even when already attached)
  126061. * @returns true if successful, false is failed or already attached
  126062. */
  126063. attach(force?: boolean): boolean;
  126064. /**
  126065. * detach this feature.
  126066. *
  126067. * @returns true if successful, false if failed or already detached
  126068. */
  126069. detach(): boolean;
  126070. /**
  126071. * Dispose this feature and all of the resources attached
  126072. */
  126073. dispose(): void;
  126074. /**
  126075. * This is used to register callbacks that will automatically be removed when detach is called.
  126076. * @param observable the observable to which the observer will be attached
  126077. * @param callback the callback to register
  126078. */
  126079. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126080. /**
  126081. * Code in this function will be executed on each xrFrame received from the browser.
  126082. * This function will not execute after the feature is detached.
  126083. * @param _xrFrame the current frame
  126084. */
  126085. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126086. }
  126087. }
  126088. declare module BABYLON {
  126089. /**
  126090. * Renders a layer on top of an existing scene
  126091. */
  126092. export class UtilityLayerRenderer implements IDisposable {
  126093. /** the original scene that will be rendered on top of */
  126094. originalScene: Scene;
  126095. private _pointerCaptures;
  126096. private _lastPointerEvents;
  126097. private static _DefaultUtilityLayer;
  126098. private static _DefaultKeepDepthUtilityLayer;
  126099. private _sharedGizmoLight;
  126100. private _renderCamera;
  126101. /**
  126102. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126103. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126104. * @returns the camera that is used when rendering the utility layer
  126105. */
  126106. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126107. /**
  126108. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126109. * @param cam the camera that should be used when rendering the utility layer
  126110. */
  126111. setRenderCamera(cam: Nullable<Camera>): void;
  126112. /**
  126113. * @hidden
  126114. * Light which used by gizmos to get light shading
  126115. */
  126116. _getSharedGizmoLight(): HemisphericLight;
  126117. /**
  126118. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126119. */
  126120. pickUtilitySceneFirst: boolean;
  126121. /**
  126122. * 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)
  126123. */
  126124. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126125. /**
  126126. * 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)
  126127. */
  126128. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126129. /**
  126130. * The scene that is rendered on top of the original scene
  126131. */
  126132. utilityLayerScene: Scene;
  126133. /**
  126134. * If the utility layer should automatically be rendered on top of existing scene
  126135. */
  126136. shouldRender: boolean;
  126137. /**
  126138. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126139. */
  126140. onlyCheckPointerDownEvents: boolean;
  126141. /**
  126142. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126143. */
  126144. processAllEvents: boolean;
  126145. /**
  126146. * Observable raised when the pointer move from the utility layer scene to the main scene
  126147. */
  126148. onPointerOutObservable: Observable<number>;
  126149. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126150. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126151. private _afterRenderObserver;
  126152. private _sceneDisposeObserver;
  126153. private _originalPointerObserver;
  126154. /**
  126155. * Instantiates a UtilityLayerRenderer
  126156. * @param originalScene the original scene that will be rendered on top of
  126157. * @param handleEvents boolean indicating if the utility layer should handle events
  126158. */
  126159. constructor(
  126160. /** the original scene that will be rendered on top of */
  126161. originalScene: Scene, handleEvents?: boolean);
  126162. private _notifyObservers;
  126163. /**
  126164. * Renders the utility layers scene on top of the original scene
  126165. */
  126166. render(): void;
  126167. /**
  126168. * Disposes of the renderer
  126169. */
  126170. dispose(): void;
  126171. private _updateCamera;
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. /**
  126176. * Options interface for the pointer selection module
  126177. */
  126178. export interface IWebXRControllerPointerSelectionOptions {
  126179. /**
  126180. * if provided, this scene will be used to render meshes.
  126181. */
  126182. customUtilityLayerScene?: Scene;
  126183. /**
  126184. * 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)
  126185. * If not disabled, the last picked point will be used to execute a pointer up event
  126186. * If disabled, pointer up event will be triggered right after the pointer down event.
  126187. * Used in screen and gaze target ray mode only
  126188. */
  126189. disablePointerUpOnTouchOut: boolean;
  126190. /**
  126191. * For gaze mode (time to select instead of press)
  126192. */
  126193. forceGazeMode: boolean;
  126194. /**
  126195. * 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
  126196. * to start a new countdown to the pointer down event.
  126197. * Defaults to 1.
  126198. */
  126199. gazeModePointerMovedFactor?: number;
  126200. /**
  126201. * Different button type to use instead of the main component
  126202. */
  126203. overrideButtonId?: string;
  126204. /**
  126205. * use this rendering group id for the meshes (optional)
  126206. */
  126207. renderingGroupId?: number;
  126208. /**
  126209. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126210. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126211. * 3000 means 3 seconds between pointing at something and selecting it
  126212. */
  126213. timeToSelect?: number;
  126214. /**
  126215. * Should meshes created here be added to a utility layer or the main scene
  126216. */
  126217. useUtilityLayer?: boolean;
  126218. /**
  126219. * the xr input to use with this pointer selection
  126220. */
  126221. xrInput: WebXRInput;
  126222. }
  126223. /**
  126224. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126225. */
  126226. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126227. private readonly _options;
  126228. private static _idCounter;
  126229. private _attachController;
  126230. private _controllers;
  126231. private _scene;
  126232. private _tmpVectorForPickCompare;
  126233. /**
  126234. * The module's name
  126235. */
  126236. static readonly Name: string;
  126237. /**
  126238. * The (Babylon) version of this module.
  126239. * This is an integer representing the implementation version.
  126240. * This number does not correspond to the WebXR specs version
  126241. */
  126242. static readonly Version: number;
  126243. /**
  126244. * Disable lighting on the laser pointer (so it will always be visible)
  126245. */
  126246. disablePointerLighting: boolean;
  126247. /**
  126248. * Disable lighting on the selection mesh (so it will always be visible)
  126249. */
  126250. disableSelectionMeshLighting: boolean;
  126251. /**
  126252. * Should the laser pointer be displayed
  126253. */
  126254. displayLaserPointer: boolean;
  126255. /**
  126256. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126257. */
  126258. displaySelectionMesh: boolean;
  126259. /**
  126260. * This color will be set to the laser pointer when selection is triggered
  126261. */
  126262. laserPointerPickedColor: Color3;
  126263. /**
  126264. * Default color of the laser pointer
  126265. */
  126266. laserPointerDefaultColor: Color3;
  126267. /**
  126268. * default color of the selection ring
  126269. */
  126270. selectionMeshDefaultColor: Color3;
  126271. /**
  126272. * This color will be applied to the selection ring when selection is triggered
  126273. */
  126274. selectionMeshPickedColor: Color3;
  126275. /**
  126276. * Optional filter to be used for ray selection. This predicate shares behavior with
  126277. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126278. */
  126279. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126280. /**
  126281. * constructs a new background remover module
  126282. * @param _xrSessionManager the session manager for this module
  126283. * @param _options read-only options to be used in this module
  126284. */
  126285. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126286. /**
  126287. * attach this feature
  126288. * Will usually be called by the features manager
  126289. *
  126290. * @returns true if successful.
  126291. */
  126292. attach(): boolean;
  126293. /**
  126294. * detach this feature.
  126295. * Will usually be called by the features manager
  126296. *
  126297. * @returns true if successful.
  126298. */
  126299. detach(): boolean;
  126300. /**
  126301. * Will get the mesh under a specific pointer.
  126302. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126303. * @param controllerId the controllerId to check
  126304. * @returns The mesh under pointer or null if no mesh is under the pointer
  126305. */
  126306. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126307. /**
  126308. * Get the xr controller that correlates to the pointer id in the pointer event
  126309. *
  126310. * @param id the pointer id to search for
  126311. * @returns the controller that correlates to this id or null if not found
  126312. */
  126313. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126314. protected _onXRFrame(_xrFrame: XRFrame): void;
  126315. private _attachGazeMode;
  126316. private _attachScreenRayMode;
  126317. private _attachTrackedPointerRayMode;
  126318. private _convertNormalToDirectionOfRay;
  126319. private _detachController;
  126320. private _generateNewMeshPair;
  126321. private _pickingMoved;
  126322. private _updatePointerDistance;
  126323. /** @hidden */
  126324. get lasterPointerDefaultColor(): Color3;
  126325. }
  126326. }
  126327. declare module BABYLON {
  126328. /**
  126329. * Button which can be used to enter a different mode of XR
  126330. */
  126331. export class WebXREnterExitUIButton {
  126332. /** button element */
  126333. element: HTMLElement;
  126334. /** XR initialization options for the button */
  126335. sessionMode: XRSessionMode;
  126336. /** Reference space type */
  126337. referenceSpaceType: XRReferenceSpaceType;
  126338. /**
  126339. * Creates a WebXREnterExitUIButton
  126340. * @param element button element
  126341. * @param sessionMode XR initialization session mode
  126342. * @param referenceSpaceType the type of reference space to be used
  126343. */
  126344. constructor(
  126345. /** button element */
  126346. element: HTMLElement,
  126347. /** XR initialization options for the button */
  126348. sessionMode: XRSessionMode,
  126349. /** Reference space type */
  126350. referenceSpaceType: XRReferenceSpaceType);
  126351. /**
  126352. * Extendable function which can be used to update the button's visuals when the state changes
  126353. * @param activeButton the current active button in the UI
  126354. */
  126355. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126356. }
  126357. /**
  126358. * Options to create the webXR UI
  126359. */
  126360. export class WebXREnterExitUIOptions {
  126361. /**
  126362. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126363. */
  126364. customButtons?: Array<WebXREnterExitUIButton>;
  126365. /**
  126366. * A reference space type to use when creating the default button.
  126367. * Default is local-floor
  126368. */
  126369. referenceSpaceType?: XRReferenceSpaceType;
  126370. /**
  126371. * Context to enter xr with
  126372. */
  126373. renderTarget?: Nullable<WebXRRenderTarget>;
  126374. /**
  126375. * A session mode to use when creating the default button.
  126376. * Default is immersive-vr
  126377. */
  126378. sessionMode?: XRSessionMode;
  126379. /**
  126380. * A list of optional features to init the session with
  126381. */
  126382. optionalFeatures?: string[];
  126383. }
  126384. /**
  126385. * UI to allow the user to enter/exit XR mode
  126386. */
  126387. export class WebXREnterExitUI implements IDisposable {
  126388. private scene;
  126389. /** version of the options passed to this UI */
  126390. options: WebXREnterExitUIOptions;
  126391. private _activeButton;
  126392. private _buttons;
  126393. private _overlay;
  126394. /**
  126395. * Fired every time the active button is changed.
  126396. *
  126397. * When xr is entered via a button that launches xr that button will be the callback parameter
  126398. *
  126399. * When exiting xr the callback parameter will be null)
  126400. */
  126401. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126402. /**
  126403. *
  126404. * @param scene babylon scene object to use
  126405. * @param options (read-only) version of the options passed to this UI
  126406. */
  126407. private constructor();
  126408. /**
  126409. * Creates UI to allow the user to enter/exit XR mode
  126410. * @param scene the scene to add the ui to
  126411. * @param helper the xr experience helper to enter/exit xr with
  126412. * @param options options to configure the UI
  126413. * @returns the created ui
  126414. */
  126415. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126416. /**
  126417. * Disposes of the XR UI component
  126418. */
  126419. dispose(): void;
  126420. private _updateButtons;
  126421. }
  126422. }
  126423. declare module BABYLON {
  126424. /**
  126425. * Class containing static functions to help procedurally build meshes
  126426. */
  126427. export class LinesBuilder {
  126428. /**
  126429. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126430. * * 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
  126431. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126432. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126433. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126434. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126435. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126436. * * 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
  126437. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126440. * @param name defines the name of the new line system
  126441. * @param options defines the options used to create the line system
  126442. * @param scene defines the hosting scene
  126443. * @returns a new line system mesh
  126444. */
  126445. static CreateLineSystem(name: string, options: {
  126446. lines: Vector3[][];
  126447. updatable?: boolean;
  126448. instance?: Nullable<LinesMesh>;
  126449. colors?: Nullable<Color4[][]>;
  126450. useVertexAlpha?: boolean;
  126451. }, scene: Nullable<Scene>): LinesMesh;
  126452. /**
  126453. * Creates a line mesh
  126454. * 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
  126455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126456. * * The parameter `points` is an array successive Vector3
  126457. * * 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
  126458. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126460. * * When updating an instance, remember that only point positions can change, not the number of points
  126461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126463. * @param name defines the name of the new line system
  126464. * @param options defines the options used to create the line system
  126465. * @param scene defines the hosting scene
  126466. * @returns a new line mesh
  126467. */
  126468. static CreateLines(name: string, options: {
  126469. points: Vector3[];
  126470. updatable?: boolean;
  126471. instance?: Nullable<LinesMesh>;
  126472. colors?: Color4[];
  126473. useVertexAlpha?: boolean;
  126474. }, scene?: Nullable<Scene>): LinesMesh;
  126475. /**
  126476. * Creates a dashed line mesh
  126477. * * 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
  126478. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126479. * * The parameter `points` is an array successive Vector3
  126480. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126481. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126482. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126483. * * 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
  126484. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126485. * * When updating an instance, remember that only point positions can change, not the number of points
  126486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126487. * @param name defines the name of the mesh
  126488. * @param options defines the options used to create the mesh
  126489. * @param scene defines the hosting scene
  126490. * @returns the dashed line mesh
  126491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126492. */
  126493. static CreateDashedLines(name: string, options: {
  126494. points: Vector3[];
  126495. dashSize?: number;
  126496. gapSize?: number;
  126497. dashNb?: number;
  126498. updatable?: boolean;
  126499. instance?: LinesMesh;
  126500. useVertexAlpha?: boolean;
  126501. }, scene?: Nullable<Scene>): LinesMesh;
  126502. }
  126503. }
  126504. declare module BABYLON {
  126505. /**
  126506. * Construction options for a timer
  126507. */
  126508. export interface ITimerOptions<T> {
  126509. /**
  126510. * Time-to-end
  126511. */
  126512. timeout: number;
  126513. /**
  126514. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126515. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126516. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126517. */
  126518. contextObservable: Observable<T>;
  126519. /**
  126520. * Optional parameters when adding an observer to the observable
  126521. */
  126522. observableParameters?: {
  126523. mask?: number;
  126524. insertFirst?: boolean;
  126525. scope?: any;
  126526. };
  126527. /**
  126528. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126529. */
  126530. breakCondition?: (data?: ITimerData<T>) => boolean;
  126531. /**
  126532. * Will be triggered when the time condition has met
  126533. */
  126534. onEnded?: (data: ITimerData<any>) => void;
  126535. /**
  126536. * Will be triggered when the break condition has met (prematurely ended)
  126537. */
  126538. onAborted?: (data: ITimerData<any>) => void;
  126539. /**
  126540. * Optional function to execute on each tick (or count)
  126541. */
  126542. onTick?: (data: ITimerData<any>) => void;
  126543. }
  126544. /**
  126545. * An interface defining the data sent by the timer
  126546. */
  126547. export interface ITimerData<T> {
  126548. /**
  126549. * When did it start
  126550. */
  126551. startTime: number;
  126552. /**
  126553. * Time now
  126554. */
  126555. currentTime: number;
  126556. /**
  126557. * Time passed since started
  126558. */
  126559. deltaTime: number;
  126560. /**
  126561. * How much is completed, in [0.0...1.0].
  126562. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126563. */
  126564. completeRate: number;
  126565. /**
  126566. * What the registered observable sent in the last count
  126567. */
  126568. payload: T;
  126569. }
  126570. /**
  126571. * The current state of the timer
  126572. */
  126573. export enum TimerState {
  126574. /**
  126575. * Timer initialized, not yet started
  126576. */
  126577. INIT = 0,
  126578. /**
  126579. * Timer started and counting
  126580. */
  126581. STARTED = 1,
  126582. /**
  126583. * Timer ended (whether aborted or time reached)
  126584. */
  126585. ENDED = 2
  126586. }
  126587. /**
  126588. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126589. *
  126590. * @param options options with which to initialize this timer
  126591. */
  126592. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126593. /**
  126594. * An advanced implementation of a timer class
  126595. */
  126596. export class AdvancedTimer<T = any> implements IDisposable {
  126597. /**
  126598. * Will notify each time the timer calculates the remaining time
  126599. */
  126600. onEachCountObservable: Observable<ITimerData<T>>;
  126601. /**
  126602. * Will trigger when the timer was aborted due to the break condition
  126603. */
  126604. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126605. /**
  126606. * Will trigger when the timer ended successfully
  126607. */
  126608. onTimerEndedObservable: Observable<ITimerData<T>>;
  126609. /**
  126610. * Will trigger when the timer state has changed
  126611. */
  126612. onStateChangedObservable: Observable<TimerState>;
  126613. private _observer;
  126614. private _contextObservable;
  126615. private _observableParameters;
  126616. private _startTime;
  126617. private _timer;
  126618. private _state;
  126619. private _breakCondition;
  126620. private _timeToEnd;
  126621. private _breakOnNextTick;
  126622. /**
  126623. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126624. * @param options construction options for this advanced timer
  126625. */
  126626. constructor(options: ITimerOptions<T>);
  126627. /**
  126628. * set a breaking condition for this timer. Default is to never break during count
  126629. * @param predicate the new break condition. Returns true to break, false otherwise
  126630. */
  126631. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126632. /**
  126633. * Reset ALL associated observables in this advanced timer
  126634. */
  126635. clearObservables(): void;
  126636. /**
  126637. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126638. *
  126639. * @param timeToEnd how much time to measure until timer ended
  126640. */
  126641. start(timeToEnd?: number): void;
  126642. /**
  126643. * Will force a stop on the next tick.
  126644. */
  126645. stop(): void;
  126646. /**
  126647. * Dispose this timer, clearing all resources
  126648. */
  126649. dispose(): void;
  126650. private _setState;
  126651. private _tick;
  126652. private _stop;
  126653. }
  126654. }
  126655. declare module BABYLON {
  126656. /**
  126657. * The options container for the teleportation module
  126658. */
  126659. export interface IWebXRTeleportationOptions {
  126660. /**
  126661. * if provided, this scene will be used to render meshes.
  126662. */
  126663. customUtilityLayerScene?: Scene;
  126664. /**
  126665. * Values to configure the default target mesh
  126666. */
  126667. defaultTargetMeshOptions?: {
  126668. /**
  126669. * Fill color of the teleportation area
  126670. */
  126671. teleportationFillColor?: string;
  126672. /**
  126673. * Border color for the teleportation area
  126674. */
  126675. teleportationBorderColor?: string;
  126676. /**
  126677. * Disable the mesh's animation sequence
  126678. */
  126679. disableAnimation?: boolean;
  126680. /**
  126681. * Disable lighting on the material or the ring and arrow
  126682. */
  126683. disableLighting?: boolean;
  126684. /**
  126685. * Override the default material of the torus and arrow
  126686. */
  126687. torusArrowMaterial?: Material;
  126688. };
  126689. /**
  126690. * A list of meshes to use as floor meshes.
  126691. * Meshes can be added and removed after initializing the feature using the
  126692. * addFloorMesh and removeFloorMesh functions
  126693. * If empty, rotation will still work
  126694. */
  126695. floorMeshes?: AbstractMesh[];
  126696. /**
  126697. * use this rendering group id for the meshes (optional)
  126698. */
  126699. renderingGroupId?: number;
  126700. /**
  126701. * Should teleportation move only to snap points
  126702. */
  126703. snapPointsOnly?: boolean;
  126704. /**
  126705. * An array of points to which the teleportation will snap to.
  126706. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126707. */
  126708. snapPositions?: Vector3[];
  126709. /**
  126710. * How close should the teleportation ray be in order to snap to position.
  126711. * Default to 0.8 units (meters)
  126712. */
  126713. snapToPositionRadius?: number;
  126714. /**
  126715. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126716. * If you want to support rotation, make sure your mesh has a direction indicator.
  126717. *
  126718. * When left untouched, the default mesh will be initialized.
  126719. */
  126720. teleportationTargetMesh?: AbstractMesh;
  126721. /**
  126722. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126723. */
  126724. timeToTeleport?: number;
  126725. /**
  126726. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126727. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126728. */
  126729. useMainComponentOnly?: boolean;
  126730. /**
  126731. * Should meshes created here be added to a utility layer or the main scene
  126732. */
  126733. useUtilityLayer?: boolean;
  126734. /**
  126735. * Babylon XR Input class for controller
  126736. */
  126737. xrInput: WebXRInput;
  126738. }
  126739. /**
  126740. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126741. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126742. * the input of the attached controllers.
  126743. */
  126744. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126745. private _options;
  126746. private _controllers;
  126747. private _currentTeleportationControllerId;
  126748. private _floorMeshes;
  126749. private _quadraticBezierCurve;
  126750. private _selectionFeature;
  126751. private _snapToPositions;
  126752. private _snappedToPoint;
  126753. private _teleportationRingMaterial?;
  126754. private _tmpRay;
  126755. private _tmpVector;
  126756. /**
  126757. * The module's name
  126758. */
  126759. static readonly Name: string;
  126760. /**
  126761. * The (Babylon) version of this module.
  126762. * This is an integer representing the implementation version.
  126763. * This number does not correspond to the webxr specs version
  126764. */
  126765. static readonly Version: number;
  126766. /**
  126767. * Is movement backwards enabled
  126768. */
  126769. backwardsMovementEnabled: boolean;
  126770. /**
  126771. * Distance to travel when moving backwards
  126772. */
  126773. backwardsTeleportationDistance: number;
  126774. /**
  126775. * The distance from the user to the inspection point in the direction of the controller
  126776. * A higher number will allow the user to move further
  126777. * defaults to 5 (meters, in xr units)
  126778. */
  126779. parabolicCheckRadius: number;
  126780. /**
  126781. * Should the module support parabolic ray on top of direct ray
  126782. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126783. * Very helpful when moving between floors / different heights
  126784. */
  126785. parabolicRayEnabled: boolean;
  126786. /**
  126787. * How much rotation should be applied when rotating right and left
  126788. */
  126789. rotationAngle: number;
  126790. /**
  126791. * Is rotation enabled when moving forward?
  126792. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126793. */
  126794. rotationEnabled: boolean;
  126795. /**
  126796. * constructs a new anchor system
  126797. * @param _xrSessionManager an instance of WebXRSessionManager
  126798. * @param _options configuration object for this feature
  126799. */
  126800. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126801. /**
  126802. * Get the snapPointsOnly flag
  126803. */
  126804. get snapPointsOnly(): boolean;
  126805. /**
  126806. * Sets the snapPointsOnly flag
  126807. * @param snapToPoints should teleportation be exclusively to snap points
  126808. */
  126809. set snapPointsOnly(snapToPoints: boolean);
  126810. /**
  126811. * Add a new mesh to the floor meshes array
  126812. * @param mesh the mesh to use as floor mesh
  126813. */
  126814. addFloorMesh(mesh: AbstractMesh): void;
  126815. /**
  126816. * Add a new snap-to point to fix teleportation to this position
  126817. * @param newSnapPoint The new Snap-To point
  126818. */
  126819. addSnapPoint(newSnapPoint: Vector3): void;
  126820. attach(): boolean;
  126821. detach(): boolean;
  126822. dispose(): void;
  126823. /**
  126824. * Remove a mesh from the floor meshes array
  126825. * @param mesh the mesh to remove
  126826. */
  126827. removeFloorMesh(mesh: AbstractMesh): void;
  126828. /**
  126829. * Remove a mesh from the floor meshes array using its name
  126830. * @param name the mesh name to remove
  126831. */
  126832. removeFloorMeshByName(name: string): void;
  126833. /**
  126834. * 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
  126835. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126836. * @returns was the point found and removed or not
  126837. */
  126838. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126839. /**
  126840. * This function sets a selection feature that will be disabled when
  126841. * the forward ray is shown and will be reattached when hidden.
  126842. * This is used to remove the selection rays when moving.
  126843. * @param selectionFeature the feature to disable when forward movement is enabled
  126844. */
  126845. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126846. protected _onXRFrame(_xrFrame: XRFrame): void;
  126847. private _attachController;
  126848. private _createDefaultTargetMesh;
  126849. private _detachController;
  126850. private _findClosestSnapPointWithRadius;
  126851. private _setTargetMeshPosition;
  126852. private _setTargetMeshVisibility;
  126853. private _showParabolicPath;
  126854. private _teleportForward;
  126855. }
  126856. }
  126857. declare module BABYLON {
  126858. /**
  126859. * Options for the default xr helper
  126860. */
  126861. export class WebXRDefaultExperienceOptions {
  126862. /**
  126863. * Enable or disable default UI to enter XR
  126864. */
  126865. disableDefaultUI?: boolean;
  126866. /**
  126867. * Should teleportation not initialize. defaults to false.
  126868. */
  126869. disableTeleportation?: boolean;
  126870. /**
  126871. * Floor meshes that will be used for teleport
  126872. */
  126873. floorMeshes?: Array<AbstractMesh>;
  126874. /**
  126875. * If set to true, the first frame will not be used to reset position
  126876. * The first frame is mainly used when copying transformation from the old camera
  126877. * Mainly used in AR
  126878. */
  126879. ignoreNativeCameraTransformation?: boolean;
  126880. /**
  126881. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126882. */
  126883. inputOptions?: IWebXRInputOptions;
  126884. /**
  126885. * optional configuration for the output canvas
  126886. */
  126887. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126888. /**
  126889. * optional UI options. This can be used among other to change session mode and reference space type
  126890. */
  126891. uiOptions?: WebXREnterExitUIOptions;
  126892. /**
  126893. * When loading teleportation and pointer select, use stable versions instead of latest.
  126894. */
  126895. useStablePlugins?: boolean;
  126896. /**
  126897. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126898. */
  126899. renderingGroupId?: number;
  126900. /**
  126901. * A list of optional features to init the session with
  126902. * If set to true, all features we support will be added
  126903. */
  126904. optionalFeatures?: boolean | string[];
  126905. }
  126906. /**
  126907. * Default experience which provides a similar setup to the previous webVRExperience
  126908. */
  126909. export class WebXRDefaultExperience {
  126910. /**
  126911. * Base experience
  126912. */
  126913. baseExperience: WebXRExperienceHelper;
  126914. /**
  126915. * Enables ui for entering/exiting xr
  126916. */
  126917. enterExitUI: WebXREnterExitUI;
  126918. /**
  126919. * Input experience extension
  126920. */
  126921. input: WebXRInput;
  126922. /**
  126923. * Enables laser pointer and selection
  126924. */
  126925. pointerSelection: WebXRControllerPointerSelection;
  126926. /**
  126927. * Default target xr should render to
  126928. */
  126929. renderTarget: WebXRRenderTarget;
  126930. /**
  126931. * Enables teleportation
  126932. */
  126933. teleportation: WebXRMotionControllerTeleportation;
  126934. private constructor();
  126935. /**
  126936. * Creates the default xr experience
  126937. * @param scene scene
  126938. * @param options options for basic configuration
  126939. * @returns resulting WebXRDefaultExperience
  126940. */
  126941. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126942. /**
  126943. * DIsposes of the experience helper
  126944. */
  126945. dispose(): void;
  126946. }
  126947. }
  126948. declare module BABYLON {
  126949. /**
  126950. * Options to modify the vr teleportation behavior.
  126951. */
  126952. export interface VRTeleportationOptions {
  126953. /**
  126954. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126955. */
  126956. floorMeshName?: string;
  126957. /**
  126958. * A list of meshes to be used as the teleportation floor. (default: empty)
  126959. */
  126960. floorMeshes?: Mesh[];
  126961. /**
  126962. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126963. */
  126964. teleportationMode?: number;
  126965. /**
  126966. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126967. */
  126968. teleportationTime?: number;
  126969. /**
  126970. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126971. */
  126972. teleportationSpeed?: number;
  126973. /**
  126974. * The easing function used in the animation or null for Linear. (default CircleEase)
  126975. */
  126976. easingFunction?: EasingFunction;
  126977. }
  126978. /**
  126979. * Options to modify the vr experience helper's behavior.
  126980. */
  126981. export interface VRExperienceHelperOptions extends WebVROptions {
  126982. /**
  126983. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126984. */
  126985. createDeviceOrientationCamera?: boolean;
  126986. /**
  126987. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126988. */
  126989. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126990. /**
  126991. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126992. */
  126993. laserToggle?: boolean;
  126994. /**
  126995. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126996. */
  126997. floorMeshes?: Mesh[];
  126998. /**
  126999. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127000. */
  127001. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127002. /**
  127003. * Defines if WebXR should be used instead of WebVR (if available)
  127004. */
  127005. useXR?: boolean;
  127006. }
  127007. /**
  127008. * Event containing information after VR has been entered
  127009. */
  127010. export class OnAfterEnteringVRObservableEvent {
  127011. /**
  127012. * If entering vr was successful
  127013. */
  127014. success: boolean;
  127015. }
  127016. /**
  127017. * Helps to quickly add VR support to an existing scene.
  127018. * See https://doc.babylonjs.com/how_to/webvr_helper
  127019. */
  127020. export class VRExperienceHelper {
  127021. /** Options to modify the vr experience helper's behavior. */
  127022. webVROptions: VRExperienceHelperOptions;
  127023. private _scene;
  127024. private _position;
  127025. private _btnVR;
  127026. private _btnVRDisplayed;
  127027. private _webVRsupported;
  127028. private _webVRready;
  127029. private _webVRrequesting;
  127030. private _webVRpresenting;
  127031. private _hasEnteredVR;
  127032. private _fullscreenVRpresenting;
  127033. private _inputElement;
  127034. private _webVRCamera;
  127035. private _vrDeviceOrientationCamera;
  127036. private _deviceOrientationCamera;
  127037. private _existingCamera;
  127038. private _onKeyDown;
  127039. private _onVrDisplayPresentChange;
  127040. private _onVRDisplayChanged;
  127041. private _onVRRequestPresentStart;
  127042. private _onVRRequestPresentComplete;
  127043. /**
  127044. * 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)
  127045. */
  127046. enableGazeEvenWhenNoPointerLock: boolean;
  127047. /**
  127048. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127049. */
  127050. exitVROnDoubleTap: boolean;
  127051. /**
  127052. * Observable raised right before entering VR.
  127053. */
  127054. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127055. /**
  127056. * Observable raised when entering VR has completed.
  127057. */
  127058. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127059. /**
  127060. * Observable raised when exiting VR.
  127061. */
  127062. onExitingVRObservable: Observable<VRExperienceHelper>;
  127063. /**
  127064. * Observable raised when controller mesh is loaded.
  127065. */
  127066. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127067. /** Return this.onEnteringVRObservable
  127068. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127069. */
  127070. get onEnteringVR(): Observable<VRExperienceHelper>;
  127071. /** Return this.onExitingVRObservable
  127072. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127073. */
  127074. get onExitingVR(): Observable<VRExperienceHelper>;
  127075. /** Return this.onControllerMeshLoadedObservable
  127076. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127077. */
  127078. get onControllerMeshLoaded(): Observable<WebVRController>;
  127079. private _rayLength;
  127080. private _useCustomVRButton;
  127081. private _teleportationRequested;
  127082. private _teleportActive;
  127083. private _floorMeshName;
  127084. private _floorMeshesCollection;
  127085. private _teleportationMode;
  127086. private _teleportationTime;
  127087. private _teleportationSpeed;
  127088. private _teleportationEasing;
  127089. private _rotationAllowed;
  127090. private _teleportBackwardsVector;
  127091. private _teleportationTarget;
  127092. private _isDefaultTeleportationTarget;
  127093. private _postProcessMove;
  127094. private _teleportationFillColor;
  127095. private _teleportationBorderColor;
  127096. private _rotationAngle;
  127097. private _haloCenter;
  127098. private _cameraGazer;
  127099. private _padSensibilityUp;
  127100. private _padSensibilityDown;
  127101. private _leftController;
  127102. private _rightController;
  127103. private _gazeColor;
  127104. private _laserColor;
  127105. private _pickedLaserColor;
  127106. private _pickedGazeColor;
  127107. /**
  127108. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127109. */
  127110. onNewMeshSelected: Observable<AbstractMesh>;
  127111. /**
  127112. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127113. * This observable will provide the mesh and the controller used to select the mesh
  127114. */
  127115. onMeshSelectedWithController: Observable<{
  127116. mesh: AbstractMesh;
  127117. controller: WebVRController;
  127118. }>;
  127119. /**
  127120. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127121. */
  127122. onNewMeshPicked: Observable<PickingInfo>;
  127123. private _circleEase;
  127124. /**
  127125. * Observable raised before camera teleportation
  127126. */
  127127. onBeforeCameraTeleport: Observable<Vector3>;
  127128. /**
  127129. * Observable raised after camera teleportation
  127130. */
  127131. onAfterCameraTeleport: Observable<Vector3>;
  127132. /**
  127133. * Observable raised when current selected mesh gets unselected
  127134. */
  127135. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127136. private _raySelectionPredicate;
  127137. /**
  127138. * To be optionaly changed by user to define custom ray selection
  127139. */
  127140. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127141. /**
  127142. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127143. */
  127144. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127145. /**
  127146. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127147. */
  127148. teleportationEnabled: boolean;
  127149. private _defaultHeight;
  127150. private _teleportationInitialized;
  127151. private _interactionsEnabled;
  127152. private _interactionsRequested;
  127153. private _displayGaze;
  127154. private _displayLaserPointer;
  127155. /**
  127156. * The mesh used to display where the user is going to teleport.
  127157. */
  127158. get teleportationTarget(): Mesh;
  127159. /**
  127160. * Sets the mesh to be used to display where the user is going to teleport.
  127161. */
  127162. set teleportationTarget(value: Mesh);
  127163. /**
  127164. * 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
  127165. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127166. * See https://doc.babylonjs.com/resources/baking_transformations
  127167. */
  127168. get gazeTrackerMesh(): Mesh;
  127169. set gazeTrackerMesh(value: Mesh);
  127170. /**
  127171. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127172. */
  127173. updateGazeTrackerScale: boolean;
  127174. /**
  127175. * If the gaze trackers color should be updated when selecting meshes
  127176. */
  127177. updateGazeTrackerColor: boolean;
  127178. /**
  127179. * If the controller laser color should be updated when selecting meshes
  127180. */
  127181. updateControllerLaserColor: boolean;
  127182. /**
  127183. * The gaze tracking mesh corresponding to the left controller
  127184. */
  127185. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127186. /**
  127187. * The gaze tracking mesh corresponding to the right controller
  127188. */
  127189. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127190. /**
  127191. * If the ray of the gaze should be displayed.
  127192. */
  127193. get displayGaze(): boolean;
  127194. /**
  127195. * Sets if the ray of the gaze should be displayed.
  127196. */
  127197. set displayGaze(value: boolean);
  127198. /**
  127199. * If the ray of the LaserPointer should be displayed.
  127200. */
  127201. get displayLaserPointer(): boolean;
  127202. /**
  127203. * Sets if the ray of the LaserPointer should be displayed.
  127204. */
  127205. set displayLaserPointer(value: boolean);
  127206. /**
  127207. * The deviceOrientationCamera used as the camera when not in VR.
  127208. */
  127209. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127210. /**
  127211. * Based on the current WebVR support, returns the current VR camera used.
  127212. */
  127213. get currentVRCamera(): Nullable<Camera>;
  127214. /**
  127215. * The webVRCamera which is used when in VR.
  127216. */
  127217. get webVRCamera(): WebVRFreeCamera;
  127218. /**
  127219. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127220. */
  127221. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127222. /**
  127223. * The html button that is used to trigger entering into VR.
  127224. */
  127225. get vrButton(): Nullable<HTMLButtonElement>;
  127226. private get _teleportationRequestInitiated();
  127227. /**
  127228. * Defines whether or not Pointer lock should be requested when switching to
  127229. * full screen.
  127230. */
  127231. requestPointerLockOnFullScreen: boolean;
  127232. /**
  127233. * If asking to force XR, this will be populated with the default xr experience
  127234. */
  127235. xr: WebXRDefaultExperience;
  127236. /**
  127237. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127238. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127239. */
  127240. xrTestDone: boolean;
  127241. /**
  127242. * Instantiates a VRExperienceHelper.
  127243. * Helps to quickly add VR support to an existing scene.
  127244. * @param scene The scene the VRExperienceHelper belongs to.
  127245. * @param webVROptions Options to modify the vr experience helper's behavior.
  127246. */
  127247. constructor(scene: Scene,
  127248. /** Options to modify the vr experience helper's behavior. */
  127249. webVROptions?: VRExperienceHelperOptions);
  127250. private completeVRInit;
  127251. private _onDefaultMeshLoaded;
  127252. private _onResize;
  127253. private _onFullscreenChange;
  127254. /**
  127255. * Gets a value indicating if we are currently in VR mode.
  127256. */
  127257. get isInVRMode(): boolean;
  127258. private onVrDisplayPresentChange;
  127259. private onVRDisplayChanged;
  127260. private moveButtonToBottomRight;
  127261. private displayVRButton;
  127262. private updateButtonVisibility;
  127263. private _cachedAngularSensibility;
  127264. /**
  127265. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127266. * Otherwise, will use the fullscreen API.
  127267. */
  127268. enterVR(): void;
  127269. /**
  127270. * Attempt to exit VR, or fullscreen.
  127271. */
  127272. exitVR(): void;
  127273. /**
  127274. * The position of the vr experience helper.
  127275. */
  127276. get position(): Vector3;
  127277. /**
  127278. * Sets the position of the vr experience helper.
  127279. */
  127280. set position(value: Vector3);
  127281. /**
  127282. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127283. */
  127284. enableInteractions(): void;
  127285. private get _noControllerIsActive();
  127286. private beforeRender;
  127287. private _isTeleportationFloor;
  127288. /**
  127289. * Adds a floor mesh to be used for teleportation.
  127290. * @param floorMesh the mesh to be used for teleportation.
  127291. */
  127292. addFloorMesh(floorMesh: Mesh): void;
  127293. /**
  127294. * Removes a floor mesh from being used for teleportation.
  127295. * @param floorMesh the mesh to be removed.
  127296. */
  127297. removeFloorMesh(floorMesh: Mesh): void;
  127298. /**
  127299. * Enables interactions and teleportation using the VR controllers and gaze.
  127300. * @param vrTeleportationOptions options to modify teleportation behavior.
  127301. */
  127302. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127303. private _onNewGamepadConnected;
  127304. private _tryEnableInteractionOnController;
  127305. private _onNewGamepadDisconnected;
  127306. private _enableInteractionOnController;
  127307. private _checkTeleportWithRay;
  127308. private _checkRotate;
  127309. private _checkTeleportBackwards;
  127310. private _enableTeleportationOnController;
  127311. private _createTeleportationCircles;
  127312. private _displayTeleportationTarget;
  127313. private _hideTeleportationTarget;
  127314. private _rotateCamera;
  127315. private _moveTeleportationSelectorTo;
  127316. private _workingVector;
  127317. private _workingQuaternion;
  127318. private _workingMatrix;
  127319. /**
  127320. * Time Constant Teleportation Mode
  127321. */
  127322. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127323. /**
  127324. * Speed Constant Teleportation Mode
  127325. */
  127326. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127327. /**
  127328. * Teleports the users feet to the desired location
  127329. * @param location The location where the user's feet should be placed
  127330. */
  127331. teleportCamera(location: Vector3): void;
  127332. private _convertNormalToDirectionOfRay;
  127333. private _castRayAndSelectObject;
  127334. private _notifySelectedMeshUnselected;
  127335. /**
  127336. * Permanently set new colors for the laser pointer
  127337. * @param color the new laser color
  127338. * @param pickedColor the new laser color when picked mesh detected
  127339. */
  127340. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127341. /**
  127342. * Set lighting enabled / disabled on the laser pointer of both controllers
  127343. * @param enabled should the lighting be enabled on the laser pointer
  127344. */
  127345. setLaserLightingState(enabled?: boolean): void;
  127346. /**
  127347. * Permanently set new colors for the gaze pointer
  127348. * @param color the new gaze color
  127349. * @param pickedColor the new gaze color when picked mesh detected
  127350. */
  127351. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127352. /**
  127353. * Sets the color of the laser ray from the vr controllers.
  127354. * @param color new color for the ray.
  127355. */
  127356. changeLaserColor(color: Color3): void;
  127357. /**
  127358. * Sets the color of the ray from the vr headsets gaze.
  127359. * @param color new color for the ray.
  127360. */
  127361. changeGazeColor(color: Color3): void;
  127362. /**
  127363. * Exits VR and disposes of the vr experience helper
  127364. */
  127365. dispose(): void;
  127366. /**
  127367. * Gets the name of the VRExperienceHelper class
  127368. * @returns "VRExperienceHelper"
  127369. */
  127370. getClassName(): string;
  127371. }
  127372. }
  127373. declare module BABYLON {
  127374. /**
  127375. * Contains an array of blocks representing the octree
  127376. */
  127377. export interface IOctreeContainer<T> {
  127378. /**
  127379. * Blocks within the octree
  127380. */
  127381. blocks: Array<OctreeBlock<T>>;
  127382. }
  127383. /**
  127384. * Class used to store a cell in an octree
  127385. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127386. */
  127387. export class OctreeBlock<T> {
  127388. /**
  127389. * Gets the content of the current block
  127390. */
  127391. entries: T[];
  127392. /**
  127393. * Gets the list of block children
  127394. */
  127395. blocks: Array<OctreeBlock<T>>;
  127396. private _depth;
  127397. private _maxDepth;
  127398. private _capacity;
  127399. private _minPoint;
  127400. private _maxPoint;
  127401. private _boundingVectors;
  127402. private _creationFunc;
  127403. /**
  127404. * Creates a new block
  127405. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127406. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127407. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127408. * @param depth defines the current depth of this block in the octree
  127409. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127410. * @param creationFunc defines a callback to call when an element is added to the block
  127411. */
  127412. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127413. /**
  127414. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127415. */
  127416. get capacity(): number;
  127417. /**
  127418. * Gets the minimum vector (in world space) of the block's bounding box
  127419. */
  127420. get minPoint(): Vector3;
  127421. /**
  127422. * Gets the maximum vector (in world space) of the block's bounding box
  127423. */
  127424. get maxPoint(): Vector3;
  127425. /**
  127426. * Add a new element to this block
  127427. * @param entry defines the element to add
  127428. */
  127429. addEntry(entry: T): void;
  127430. /**
  127431. * Remove an element from this block
  127432. * @param entry defines the element to remove
  127433. */
  127434. removeEntry(entry: T): void;
  127435. /**
  127436. * Add an array of elements to this block
  127437. * @param entries defines the array of elements to add
  127438. */
  127439. addEntries(entries: T[]): void;
  127440. /**
  127441. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127442. * @param frustumPlanes defines the frustum planes to test
  127443. * @param selection defines the array to store current content if selection is positive
  127444. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127445. */
  127446. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127447. /**
  127448. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127449. * @param sphereCenter defines the bounding sphere center
  127450. * @param sphereRadius defines the bounding sphere radius
  127451. * @param selection defines the array to store current content if selection is positive
  127452. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127453. */
  127454. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127455. /**
  127456. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127457. * @param ray defines the ray to test with
  127458. * @param selection defines the array to store current content if selection is positive
  127459. */
  127460. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127461. /**
  127462. * Subdivide the content into child blocks (this block will then be empty)
  127463. */
  127464. createInnerBlocks(): void;
  127465. /**
  127466. * @hidden
  127467. */
  127468. 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;
  127469. }
  127470. }
  127471. declare module BABYLON {
  127472. /**
  127473. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127474. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127475. */
  127476. export class Octree<T> {
  127477. /** 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.) */
  127478. maxDepth: number;
  127479. /**
  127480. * Blocks within the octree containing objects
  127481. */
  127482. blocks: Array<OctreeBlock<T>>;
  127483. /**
  127484. * Content stored in the octree
  127485. */
  127486. dynamicContent: T[];
  127487. private _maxBlockCapacity;
  127488. private _selectionContent;
  127489. private _creationFunc;
  127490. /**
  127491. * Creates a octree
  127492. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127493. * @param creationFunc function to be used to instatiate the octree
  127494. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127495. * @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.)
  127496. */
  127497. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127498. /** 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.) */
  127499. maxDepth?: number);
  127500. /**
  127501. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127502. * @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);
  127503. * @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);
  127504. * @param entries meshes to be added to the octree blocks
  127505. */
  127506. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127507. /**
  127508. * Adds a mesh to the octree
  127509. * @param entry Mesh to add to the octree
  127510. */
  127511. addMesh(entry: T): void;
  127512. /**
  127513. * Remove an element from the octree
  127514. * @param entry defines the element to remove
  127515. */
  127516. removeMesh(entry: T): void;
  127517. /**
  127518. * Selects an array of meshes within the frustum
  127519. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127520. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127521. * @returns array of meshes within the frustum
  127522. */
  127523. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127524. /**
  127525. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127526. * @param sphereCenter defines the bounding sphere center
  127527. * @param sphereRadius defines the bounding sphere radius
  127528. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127529. * @returns an array of objects that intersect the sphere
  127530. */
  127531. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127532. /**
  127533. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127534. * @param ray defines the ray to test with
  127535. * @returns array of intersected objects
  127536. */
  127537. intersectsRay(ray: Ray): SmartArray<T>;
  127538. /**
  127539. * Adds a mesh into the octree block if it intersects the block
  127540. */
  127541. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127542. /**
  127543. * Adds a submesh into the octree block if it intersects the block
  127544. */
  127545. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127546. }
  127547. }
  127548. declare module BABYLON {
  127549. interface Scene {
  127550. /**
  127551. * @hidden
  127552. * Backing Filed
  127553. */
  127554. _selectionOctree: Octree<AbstractMesh>;
  127555. /**
  127556. * Gets the octree used to boost mesh selection (picking)
  127557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127558. */
  127559. selectionOctree: Octree<AbstractMesh>;
  127560. /**
  127561. * Creates or updates the octree used to boost selection (picking)
  127562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127563. * @param maxCapacity defines the maximum capacity per leaf
  127564. * @param maxDepth defines the maximum depth of the octree
  127565. * @returns an octree of AbstractMesh
  127566. */
  127567. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127568. }
  127569. interface AbstractMesh {
  127570. /**
  127571. * @hidden
  127572. * Backing Field
  127573. */
  127574. _submeshesOctree: Octree<SubMesh>;
  127575. /**
  127576. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127577. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127578. * @param maxCapacity defines the maximum size of each block (64 by default)
  127579. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127580. * @returns the new octree
  127581. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127583. */
  127584. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127585. }
  127586. /**
  127587. * Defines the octree scene component responsible to manage any octrees
  127588. * in a given scene.
  127589. */
  127590. export class OctreeSceneComponent {
  127591. /**
  127592. * The component name help to identify the component in the list of scene components.
  127593. */
  127594. readonly name: string;
  127595. /**
  127596. * The scene the component belongs to.
  127597. */
  127598. scene: Scene;
  127599. /**
  127600. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127601. */
  127602. readonly checksIsEnabled: boolean;
  127603. /**
  127604. * Creates a new instance of the component for the given scene
  127605. * @param scene Defines the scene to register the component in
  127606. */
  127607. constructor(scene: Scene);
  127608. /**
  127609. * Registers the component in a given scene
  127610. */
  127611. register(): void;
  127612. /**
  127613. * Return the list of active meshes
  127614. * @returns the list of active meshes
  127615. */
  127616. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127617. /**
  127618. * Return the list of active sub meshes
  127619. * @param mesh The mesh to get the candidates sub meshes from
  127620. * @returns the list of active sub meshes
  127621. */
  127622. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127623. private _tempRay;
  127624. /**
  127625. * Return the list of sub meshes intersecting with a given local ray
  127626. * @param mesh defines the mesh to find the submesh for
  127627. * @param localRay defines the ray in local space
  127628. * @returns the list of intersecting sub meshes
  127629. */
  127630. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127631. /**
  127632. * Return the list of sub meshes colliding with a collider
  127633. * @param mesh defines the mesh to find the submesh for
  127634. * @param collider defines the collider to evaluate the collision against
  127635. * @returns the list of colliding sub meshes
  127636. */
  127637. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127638. /**
  127639. * Rebuilds the elements related to this component in case of
  127640. * context lost for instance.
  127641. */
  127642. rebuild(): void;
  127643. /**
  127644. * Disposes the component and the associated ressources.
  127645. */
  127646. dispose(): void;
  127647. }
  127648. }
  127649. declare module BABYLON {
  127650. /**
  127651. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127652. */
  127653. export class Gizmo implements IDisposable {
  127654. /** The utility layer the gizmo will be added to */
  127655. gizmoLayer: UtilityLayerRenderer;
  127656. /**
  127657. * The root mesh of the gizmo
  127658. */
  127659. _rootMesh: Mesh;
  127660. private _attachedMesh;
  127661. /**
  127662. * Ratio for the scale of the gizmo (Default: 1)
  127663. */
  127664. scaleRatio: number;
  127665. /**
  127666. * If a custom mesh has been set (Default: false)
  127667. */
  127668. protected _customMeshSet: boolean;
  127669. /**
  127670. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127671. * * When set, interactions will be enabled
  127672. */
  127673. get attachedMesh(): Nullable<AbstractMesh>;
  127674. set attachedMesh(value: Nullable<AbstractMesh>);
  127675. /**
  127676. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127677. * @param mesh The mesh to replace the default mesh of the gizmo
  127678. */
  127679. setCustomMesh(mesh: Mesh): void;
  127680. /**
  127681. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127682. */
  127683. updateGizmoRotationToMatchAttachedMesh: boolean;
  127684. /**
  127685. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127686. */
  127687. updateGizmoPositionToMatchAttachedMesh: boolean;
  127688. /**
  127689. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127690. */
  127691. updateScale: boolean;
  127692. protected _interactionsEnabled: boolean;
  127693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127694. private _beforeRenderObserver;
  127695. private _tempVector;
  127696. /**
  127697. * Creates a gizmo
  127698. * @param gizmoLayer The utility layer the gizmo will be added to
  127699. */
  127700. constructor(
  127701. /** The utility layer the gizmo will be added to */
  127702. gizmoLayer?: UtilityLayerRenderer);
  127703. /**
  127704. * Updates the gizmo to match the attached mesh's position/rotation
  127705. */
  127706. protected _update(): void;
  127707. /**
  127708. * Disposes of the gizmo
  127709. */
  127710. dispose(): void;
  127711. }
  127712. }
  127713. declare module BABYLON {
  127714. /**
  127715. * Single plane drag gizmo
  127716. */
  127717. export class PlaneDragGizmo extends Gizmo {
  127718. /**
  127719. * Drag behavior responsible for the gizmos dragging interactions
  127720. */
  127721. dragBehavior: PointerDragBehavior;
  127722. private _pointerObserver;
  127723. /**
  127724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127725. */
  127726. snapDistance: number;
  127727. /**
  127728. * Event that fires each time the gizmo snaps to a new location.
  127729. * * snapDistance is the the change in distance
  127730. */
  127731. onSnapObservable: Observable<{
  127732. snapDistance: number;
  127733. }>;
  127734. private _plane;
  127735. private _coloredMaterial;
  127736. private _hoverMaterial;
  127737. private _isEnabled;
  127738. private _parent;
  127739. /** @hidden */
  127740. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127741. /** @hidden */
  127742. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127743. /**
  127744. * Creates a PlaneDragGizmo
  127745. * @param gizmoLayer The utility layer the gizmo will be added to
  127746. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127747. * @param color The color of the gizmo
  127748. */
  127749. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127751. /**
  127752. * If the gizmo is enabled
  127753. */
  127754. set isEnabled(value: boolean);
  127755. get isEnabled(): boolean;
  127756. /**
  127757. * Disposes of the gizmo
  127758. */
  127759. dispose(): void;
  127760. }
  127761. }
  127762. declare module BABYLON {
  127763. /**
  127764. * Gizmo that enables dragging a mesh along 3 axis
  127765. */
  127766. export class PositionGizmo extends Gizmo {
  127767. /**
  127768. * Internal gizmo used for interactions on the x axis
  127769. */
  127770. xGizmo: AxisDragGizmo;
  127771. /**
  127772. * Internal gizmo used for interactions on the y axis
  127773. */
  127774. yGizmo: AxisDragGizmo;
  127775. /**
  127776. * Internal gizmo used for interactions on the z axis
  127777. */
  127778. zGizmo: AxisDragGizmo;
  127779. /**
  127780. * Internal gizmo used for interactions on the yz plane
  127781. */
  127782. xPlaneGizmo: PlaneDragGizmo;
  127783. /**
  127784. * Internal gizmo used for interactions on the xz plane
  127785. */
  127786. yPlaneGizmo: PlaneDragGizmo;
  127787. /**
  127788. * Internal gizmo used for interactions on the xy plane
  127789. */
  127790. zPlaneGizmo: PlaneDragGizmo;
  127791. /**
  127792. * private variables
  127793. */
  127794. private _meshAttached;
  127795. private _updateGizmoRotationToMatchAttachedMesh;
  127796. private _snapDistance;
  127797. private _scaleRatio;
  127798. /** Fires an event when any of it's sub gizmos are dragged */
  127799. onDragStartObservable: Observable<unknown>;
  127800. /** Fires an event when any of it's sub gizmos are released from dragging */
  127801. onDragEndObservable: Observable<unknown>;
  127802. /**
  127803. * If set to true, planar drag is enabled
  127804. */
  127805. private _planarGizmoEnabled;
  127806. get attachedMesh(): Nullable<AbstractMesh>;
  127807. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127808. /**
  127809. * Creates a PositionGizmo
  127810. * @param gizmoLayer The utility layer the gizmo will be added to
  127811. */
  127812. constructor(gizmoLayer?: UtilityLayerRenderer);
  127813. /**
  127814. * If the planar drag gizmo is enabled
  127815. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127816. */
  127817. set planarGizmoEnabled(value: boolean);
  127818. get planarGizmoEnabled(): boolean;
  127819. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127820. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127821. /**
  127822. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127823. */
  127824. set snapDistance(value: number);
  127825. get snapDistance(): number;
  127826. /**
  127827. * Ratio for the scale of the gizmo (Default: 1)
  127828. */
  127829. set scaleRatio(value: number);
  127830. get scaleRatio(): number;
  127831. /**
  127832. * Disposes of the gizmo
  127833. */
  127834. dispose(): void;
  127835. /**
  127836. * CustomMeshes are not supported by this gizmo
  127837. * @param mesh The mesh to replace the default mesh of the gizmo
  127838. */
  127839. setCustomMesh(mesh: Mesh): void;
  127840. }
  127841. }
  127842. declare module BABYLON {
  127843. /**
  127844. * Single axis drag gizmo
  127845. */
  127846. export class AxisDragGizmo extends Gizmo {
  127847. /**
  127848. * Drag behavior responsible for the gizmos dragging interactions
  127849. */
  127850. dragBehavior: PointerDragBehavior;
  127851. private _pointerObserver;
  127852. /**
  127853. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127854. */
  127855. snapDistance: number;
  127856. /**
  127857. * Event that fires each time the gizmo snaps to a new location.
  127858. * * snapDistance is the the change in distance
  127859. */
  127860. onSnapObservable: Observable<{
  127861. snapDistance: number;
  127862. }>;
  127863. private _isEnabled;
  127864. private _parent;
  127865. private _arrow;
  127866. private _coloredMaterial;
  127867. private _hoverMaterial;
  127868. /** @hidden */
  127869. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127870. /** @hidden */
  127871. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127872. /**
  127873. * Creates an AxisDragGizmo
  127874. * @param gizmoLayer The utility layer the gizmo will be added to
  127875. * @param dragAxis The axis which the gizmo will be able to drag on
  127876. * @param color The color of the gizmo
  127877. */
  127878. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127879. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127880. /**
  127881. * If the gizmo is enabled
  127882. */
  127883. set isEnabled(value: boolean);
  127884. get isEnabled(): boolean;
  127885. /**
  127886. * Disposes of the gizmo
  127887. */
  127888. dispose(): void;
  127889. }
  127890. }
  127891. declare module BABYLON.Debug {
  127892. /**
  127893. * The Axes viewer will show 3 axes in a specific point in space
  127894. */
  127895. export class AxesViewer {
  127896. private _xAxis;
  127897. private _yAxis;
  127898. private _zAxis;
  127899. private _scaleLinesFactor;
  127900. private _instanced;
  127901. /**
  127902. * Gets the hosting scene
  127903. */
  127904. scene: Scene;
  127905. /**
  127906. * Gets or sets a number used to scale line length
  127907. */
  127908. scaleLines: number;
  127909. /** Gets the node hierarchy used to render x-axis */
  127910. get xAxis(): TransformNode;
  127911. /** Gets the node hierarchy used to render y-axis */
  127912. get yAxis(): TransformNode;
  127913. /** Gets the node hierarchy used to render z-axis */
  127914. get zAxis(): TransformNode;
  127915. /**
  127916. * Creates a new AxesViewer
  127917. * @param scene defines the hosting scene
  127918. * @param scaleLines defines a number used to scale line length (1 by default)
  127919. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127920. * @param xAxis defines the node hierarchy used to render the x-axis
  127921. * @param yAxis defines the node hierarchy used to render the y-axis
  127922. * @param zAxis defines the node hierarchy used to render the z-axis
  127923. */
  127924. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127925. /**
  127926. * Force the viewer to update
  127927. * @param position defines the position of the viewer
  127928. * @param xaxis defines the x axis of the viewer
  127929. * @param yaxis defines the y axis of the viewer
  127930. * @param zaxis defines the z axis of the viewer
  127931. */
  127932. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127933. /**
  127934. * Creates an instance of this axes viewer.
  127935. * @returns a new axes viewer with instanced meshes
  127936. */
  127937. createInstance(): AxesViewer;
  127938. /** Releases resources */
  127939. dispose(): void;
  127940. private static _SetRenderingGroupId;
  127941. }
  127942. }
  127943. declare module BABYLON.Debug {
  127944. /**
  127945. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127946. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127947. */
  127948. export class BoneAxesViewer extends AxesViewer {
  127949. /**
  127950. * Gets or sets the target mesh where to display the axes viewer
  127951. */
  127952. mesh: Nullable<Mesh>;
  127953. /**
  127954. * Gets or sets the target bone where to display the axes viewer
  127955. */
  127956. bone: Nullable<Bone>;
  127957. /** Gets current position */
  127958. pos: Vector3;
  127959. /** Gets direction of X axis */
  127960. xaxis: Vector3;
  127961. /** Gets direction of Y axis */
  127962. yaxis: Vector3;
  127963. /** Gets direction of Z axis */
  127964. zaxis: Vector3;
  127965. /**
  127966. * Creates a new BoneAxesViewer
  127967. * @param scene defines the hosting scene
  127968. * @param bone defines the target bone
  127969. * @param mesh defines the target mesh
  127970. * @param scaleLines defines a scaling factor for line length (1 by default)
  127971. */
  127972. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127973. /**
  127974. * Force the viewer to update
  127975. */
  127976. update(): void;
  127977. /** Releases resources */
  127978. dispose(): void;
  127979. }
  127980. }
  127981. declare module BABYLON {
  127982. /**
  127983. * Interface used to define scene explorer extensibility option
  127984. */
  127985. export interface IExplorerExtensibilityOption {
  127986. /**
  127987. * Define the option label
  127988. */
  127989. label: string;
  127990. /**
  127991. * Defines the action to execute on click
  127992. */
  127993. action: (entity: any) => void;
  127994. }
  127995. /**
  127996. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127997. */
  127998. export interface IExplorerExtensibilityGroup {
  127999. /**
  128000. * Defines a predicate to test if a given type mut be extended
  128001. */
  128002. predicate: (entity: any) => boolean;
  128003. /**
  128004. * Gets the list of options added to a type
  128005. */
  128006. entries: IExplorerExtensibilityOption[];
  128007. }
  128008. /**
  128009. * Interface used to define the options to use to create the Inspector
  128010. */
  128011. export interface IInspectorOptions {
  128012. /**
  128013. * Display in overlay mode (default: false)
  128014. */
  128015. overlay?: boolean;
  128016. /**
  128017. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128018. */
  128019. globalRoot?: HTMLElement;
  128020. /**
  128021. * Display the Scene explorer
  128022. */
  128023. showExplorer?: boolean;
  128024. /**
  128025. * Display the property inspector
  128026. */
  128027. showInspector?: boolean;
  128028. /**
  128029. * Display in embed mode (both panes on the right)
  128030. */
  128031. embedMode?: boolean;
  128032. /**
  128033. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128034. */
  128035. handleResize?: boolean;
  128036. /**
  128037. * Allow the panes to popup (default: true)
  128038. */
  128039. enablePopup?: boolean;
  128040. /**
  128041. * Allow the panes to be closed by users (default: true)
  128042. */
  128043. enableClose?: boolean;
  128044. /**
  128045. * Optional list of extensibility entries
  128046. */
  128047. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128048. /**
  128049. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128050. */
  128051. inspectorURL?: string;
  128052. /**
  128053. * Optional initial tab (default to DebugLayerTab.Properties)
  128054. */
  128055. initialTab?: DebugLayerTab;
  128056. }
  128057. interface Scene {
  128058. /**
  128059. * @hidden
  128060. * Backing field
  128061. */
  128062. _debugLayer: DebugLayer;
  128063. /**
  128064. * Gets the debug layer (aka Inspector) associated with the scene
  128065. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128066. */
  128067. debugLayer: DebugLayer;
  128068. }
  128069. /**
  128070. * Enum of inspector action tab
  128071. */
  128072. export enum DebugLayerTab {
  128073. /**
  128074. * Properties tag (default)
  128075. */
  128076. Properties = 0,
  128077. /**
  128078. * Debug tab
  128079. */
  128080. Debug = 1,
  128081. /**
  128082. * Statistics tab
  128083. */
  128084. Statistics = 2,
  128085. /**
  128086. * Tools tab
  128087. */
  128088. Tools = 3,
  128089. /**
  128090. * Settings tab
  128091. */
  128092. Settings = 4
  128093. }
  128094. /**
  128095. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128096. * what is happening in your scene
  128097. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128098. */
  128099. export class DebugLayer {
  128100. /**
  128101. * Define the url to get the inspector script from.
  128102. * By default it uses the babylonjs CDN.
  128103. * @ignoreNaming
  128104. */
  128105. static InspectorURL: string;
  128106. private _scene;
  128107. private BJSINSPECTOR;
  128108. private _onPropertyChangedObservable?;
  128109. /**
  128110. * Observable triggered when a property is changed through the inspector.
  128111. */
  128112. get onPropertyChangedObservable(): any;
  128113. /**
  128114. * Instantiates a new debug layer.
  128115. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128116. * what is happening in your scene
  128117. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128118. * @param scene Defines the scene to inspect
  128119. */
  128120. constructor(scene: Scene);
  128121. /** Creates the inspector window. */
  128122. private _createInspector;
  128123. /**
  128124. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128125. * @param entity defines the entity to select
  128126. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128127. */
  128128. select(entity: any, lineContainerTitles?: string | string[]): void;
  128129. /** Get the inspector from bundle or global */
  128130. private _getGlobalInspector;
  128131. /**
  128132. * Get if the inspector is visible or not.
  128133. * @returns true if visible otherwise, false
  128134. */
  128135. isVisible(): boolean;
  128136. /**
  128137. * Hide the inspector and close its window.
  128138. */
  128139. hide(): void;
  128140. /**
  128141. * Update the scene in the inspector
  128142. */
  128143. setAsActiveScene(): void;
  128144. /**
  128145. * Launch the debugLayer.
  128146. * @param config Define the configuration of the inspector
  128147. * @return a promise fulfilled when the debug layer is visible
  128148. */
  128149. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128150. }
  128151. }
  128152. declare module BABYLON {
  128153. /**
  128154. * Class containing static functions to help procedurally build meshes
  128155. */
  128156. export class BoxBuilder {
  128157. /**
  128158. * Creates a box mesh
  128159. * * The parameter `size` sets the size (float) of each box side (default 1)
  128160. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128161. * * 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)
  128162. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128166. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128167. * @param name defines the name of the mesh
  128168. * @param options defines the options used to create the mesh
  128169. * @param scene defines the hosting scene
  128170. * @returns the box mesh
  128171. */
  128172. static CreateBox(name: string, options: {
  128173. size?: number;
  128174. width?: number;
  128175. height?: number;
  128176. depth?: number;
  128177. faceUV?: Vector4[];
  128178. faceColors?: Color4[];
  128179. sideOrientation?: number;
  128180. frontUVs?: Vector4;
  128181. backUVs?: Vector4;
  128182. wrap?: boolean;
  128183. topBaseAt?: number;
  128184. bottomBaseAt?: number;
  128185. updatable?: boolean;
  128186. }, scene?: Nullable<Scene>): Mesh;
  128187. }
  128188. }
  128189. declare module BABYLON.Debug {
  128190. /**
  128191. * Used to show the physics impostor around the specific mesh
  128192. */
  128193. export class PhysicsViewer {
  128194. /** @hidden */
  128195. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128196. /** @hidden */
  128197. protected _meshes: Array<Nullable<AbstractMesh>>;
  128198. /** @hidden */
  128199. protected _scene: Nullable<Scene>;
  128200. /** @hidden */
  128201. protected _numMeshes: number;
  128202. /** @hidden */
  128203. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128204. private _renderFunction;
  128205. private _utilityLayer;
  128206. private _debugBoxMesh;
  128207. private _debugSphereMesh;
  128208. private _debugCylinderMesh;
  128209. private _debugMaterial;
  128210. private _debugMeshMeshes;
  128211. /**
  128212. * Creates a new PhysicsViewer
  128213. * @param scene defines the hosting scene
  128214. */
  128215. constructor(scene: Scene);
  128216. /** @hidden */
  128217. protected _updateDebugMeshes(): void;
  128218. /**
  128219. * Renders a specified physic impostor
  128220. * @param impostor defines the impostor to render
  128221. * @param targetMesh defines the mesh represented by the impostor
  128222. * @returns the new debug mesh used to render the impostor
  128223. */
  128224. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128225. /**
  128226. * Hides a specified physic impostor
  128227. * @param impostor defines the impostor to hide
  128228. */
  128229. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128230. private _getDebugMaterial;
  128231. private _getDebugBoxMesh;
  128232. private _getDebugSphereMesh;
  128233. private _getDebugCylinderMesh;
  128234. private _getDebugMeshMesh;
  128235. private _getDebugMesh;
  128236. /** Releases all resources */
  128237. dispose(): void;
  128238. }
  128239. }
  128240. declare module BABYLON {
  128241. /**
  128242. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128243. * in order to better appreciate the issue one might have.
  128244. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128245. */
  128246. export class RayHelper {
  128247. /**
  128248. * Defines the ray we are currently tryin to visualize.
  128249. */
  128250. ray: Nullable<Ray>;
  128251. private _renderPoints;
  128252. private _renderLine;
  128253. private _renderFunction;
  128254. private _scene;
  128255. private _updateToMeshFunction;
  128256. private _attachedToMesh;
  128257. private _meshSpaceDirection;
  128258. private _meshSpaceOrigin;
  128259. /**
  128260. * Helper function to create a colored helper in a scene in one line.
  128261. * @param ray Defines the ray we are currently tryin to visualize
  128262. * @param scene Defines the scene the ray is used in
  128263. * @param color Defines the color we want to see the ray in
  128264. * @returns The newly created ray helper.
  128265. */
  128266. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128267. /**
  128268. * Instantiate a new ray helper.
  128269. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128270. * in order to better appreciate the issue one might have.
  128271. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128272. * @param ray Defines the ray we are currently tryin to visualize
  128273. */
  128274. constructor(ray: Ray);
  128275. /**
  128276. * Shows the ray we are willing to debug.
  128277. * @param scene Defines the scene the ray needs to be rendered in
  128278. * @param color Defines the color the ray needs to be rendered in
  128279. */
  128280. show(scene: Scene, color?: Color3): void;
  128281. /**
  128282. * Hides the ray we are debugging.
  128283. */
  128284. hide(): void;
  128285. private _render;
  128286. /**
  128287. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128288. * @param mesh Defines the mesh we want the helper attached to
  128289. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128290. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128291. * @param length Defines the length of the ray
  128292. */
  128293. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128294. /**
  128295. * Detach the ray helper from the mesh it has previously been attached to.
  128296. */
  128297. detachFromMesh(): void;
  128298. private _updateToMesh;
  128299. /**
  128300. * Dispose the helper and release its associated resources.
  128301. */
  128302. dispose(): void;
  128303. }
  128304. }
  128305. declare module BABYLON.Debug {
  128306. /**
  128307. * Class used to render a debug view of a given skeleton
  128308. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128309. */
  128310. export class SkeletonViewer {
  128311. /** defines the skeleton to render */
  128312. skeleton: Skeleton;
  128313. /** defines the mesh attached to the skeleton */
  128314. mesh: AbstractMesh;
  128315. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128316. autoUpdateBonesMatrices: boolean;
  128317. /** defines the rendering group id to use with the viewer */
  128318. renderingGroupId: number;
  128319. /** Gets or sets the color used to render the skeleton */
  128320. color: Color3;
  128321. private _scene;
  128322. private _debugLines;
  128323. private _debugMesh;
  128324. private _isEnabled;
  128325. private _renderFunction;
  128326. private _utilityLayer;
  128327. /**
  128328. * Returns the mesh used to render the bones
  128329. */
  128330. get debugMesh(): Nullable<LinesMesh>;
  128331. /**
  128332. * Creates a new SkeletonViewer
  128333. * @param skeleton defines the skeleton to render
  128334. * @param mesh defines the mesh attached to the skeleton
  128335. * @param scene defines the hosting scene
  128336. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128337. * @param renderingGroupId defines the rendering group id to use with the viewer
  128338. */
  128339. constructor(
  128340. /** defines the skeleton to render */
  128341. skeleton: Skeleton,
  128342. /** defines the mesh attached to the skeleton */
  128343. mesh: AbstractMesh, scene: Scene,
  128344. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128345. autoUpdateBonesMatrices?: boolean,
  128346. /** defines the rendering group id to use with the viewer */
  128347. renderingGroupId?: number);
  128348. /** Gets or sets a boolean indicating if the viewer is enabled */
  128349. set isEnabled(value: boolean);
  128350. get isEnabled(): boolean;
  128351. private _getBonePosition;
  128352. private _getLinesForBonesWithLength;
  128353. private _getLinesForBonesNoLength;
  128354. /** Update the viewer to sync with current skeleton state */
  128355. update(): void;
  128356. /** Release associated resources */
  128357. dispose(): void;
  128358. }
  128359. }
  128360. declare module BABYLON {
  128361. /**
  128362. * Enum for Device Types
  128363. */
  128364. export enum DeviceType {
  128365. /** Generic */
  128366. Generic = 0,
  128367. /** Keyboard */
  128368. Keyboard = 1,
  128369. /** Mouse */
  128370. Mouse = 2,
  128371. /** Touch Pointers */
  128372. Touch = 3,
  128373. /** PS4 Dual Shock */
  128374. DualShock = 4,
  128375. /** Xbox */
  128376. Xbox = 5,
  128377. /** Switch Controller */
  128378. Switch = 6
  128379. }
  128380. /**
  128381. * Enum for All Pointers (Touch/Mouse)
  128382. */
  128383. export enum PointerInput {
  128384. /** Horizontal Axis */
  128385. Horizontal = 0,
  128386. /** Vertical Axis */
  128387. Vertical = 1,
  128388. /** Left Click or Touch */
  128389. LeftClick = 2,
  128390. /** Middle Click */
  128391. MiddleClick = 3,
  128392. /** Right Click */
  128393. RightClick = 4,
  128394. /** Browser Back */
  128395. BrowserBack = 5,
  128396. /** Browser Forward */
  128397. BrowserForward = 6
  128398. }
  128399. /**
  128400. * Enum for Dual Shock Gamepad
  128401. */
  128402. export enum DualShockInput {
  128403. /** Cross */
  128404. Cross = 0,
  128405. /** Circle */
  128406. Circle = 1,
  128407. /** Square */
  128408. Square = 2,
  128409. /** Triangle */
  128410. Triangle = 3,
  128411. /** L1 */
  128412. L1 = 4,
  128413. /** R1 */
  128414. R1 = 5,
  128415. /** L2 */
  128416. L2 = 6,
  128417. /** R2 */
  128418. R2 = 7,
  128419. /** Share */
  128420. Share = 8,
  128421. /** Options */
  128422. Options = 9,
  128423. /** L3 */
  128424. L3 = 10,
  128425. /** R3 */
  128426. R3 = 11,
  128427. /** DPadUp */
  128428. DPadUp = 12,
  128429. /** DPadDown */
  128430. DPadDown = 13,
  128431. /** DPadLeft */
  128432. DPadLeft = 14,
  128433. /** DRight */
  128434. DPadRight = 15,
  128435. /** Home */
  128436. Home = 16,
  128437. /** TouchPad */
  128438. TouchPad = 17,
  128439. /** LStickXAxis */
  128440. LStickXAxis = 18,
  128441. /** LStickYAxis */
  128442. LStickYAxis = 19,
  128443. /** RStickXAxis */
  128444. RStickXAxis = 20,
  128445. /** RStickYAxis */
  128446. RStickYAxis = 21
  128447. }
  128448. /**
  128449. * Enum for Xbox Gamepad
  128450. */
  128451. export enum XboxInput {
  128452. /** A */
  128453. A = 0,
  128454. /** B */
  128455. B = 1,
  128456. /** X */
  128457. X = 2,
  128458. /** Y */
  128459. Y = 3,
  128460. /** LB */
  128461. LB = 4,
  128462. /** RB */
  128463. RB = 5,
  128464. /** LT */
  128465. LT = 6,
  128466. /** RT */
  128467. RT = 7,
  128468. /** Back */
  128469. Back = 8,
  128470. /** Start */
  128471. Start = 9,
  128472. /** LS */
  128473. LS = 10,
  128474. /** RS */
  128475. RS = 11,
  128476. /** DPadUp */
  128477. DPadUp = 12,
  128478. /** DPadDown */
  128479. DPadDown = 13,
  128480. /** DPadLeft */
  128481. DPadLeft = 14,
  128482. /** DRight */
  128483. DPadRight = 15,
  128484. /** Home */
  128485. Home = 16,
  128486. /** LStickXAxis */
  128487. LStickXAxis = 17,
  128488. /** LStickYAxis */
  128489. LStickYAxis = 18,
  128490. /** RStickXAxis */
  128491. RStickXAxis = 19,
  128492. /** RStickYAxis */
  128493. RStickYAxis = 20
  128494. }
  128495. /**
  128496. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128497. */
  128498. export enum SwitchInput {
  128499. /** B */
  128500. B = 0,
  128501. /** A */
  128502. A = 1,
  128503. /** Y */
  128504. Y = 2,
  128505. /** X */
  128506. X = 3,
  128507. /** L */
  128508. L = 4,
  128509. /** R */
  128510. R = 5,
  128511. /** ZL */
  128512. ZL = 6,
  128513. /** ZR */
  128514. ZR = 7,
  128515. /** Minus */
  128516. Minus = 8,
  128517. /** Plus */
  128518. Plus = 9,
  128519. /** LS */
  128520. LS = 10,
  128521. /** RS */
  128522. RS = 11,
  128523. /** DPadUp */
  128524. DPadUp = 12,
  128525. /** DPadDown */
  128526. DPadDown = 13,
  128527. /** DPadLeft */
  128528. DPadLeft = 14,
  128529. /** DRight */
  128530. DPadRight = 15,
  128531. /** Home */
  128532. Home = 16,
  128533. /** Capture */
  128534. Capture = 17,
  128535. /** LStickXAxis */
  128536. LStickXAxis = 18,
  128537. /** LStickYAxis */
  128538. LStickYAxis = 19,
  128539. /** RStickXAxis */
  128540. RStickXAxis = 20,
  128541. /** RStickYAxis */
  128542. RStickYAxis = 21
  128543. }
  128544. }
  128545. declare module BABYLON {
  128546. /**
  128547. * This class will take all inputs from Keyboard, Pointer, and
  128548. * any Gamepads and provide a polling system that all devices
  128549. * will use. This class assumes that there will only be one
  128550. * pointer device and one keyboard.
  128551. */
  128552. export class DeviceInputSystem implements IDisposable {
  128553. /**
  128554. * Callback to be triggered when a device is connected
  128555. */
  128556. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128557. /**
  128558. * Callback to be triggered when a device is disconnected
  128559. */
  128560. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128561. /**
  128562. * Callback to be triggered when event driven input is updated
  128563. */
  128564. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128565. private _inputs;
  128566. private _gamepads;
  128567. private _keyboardActive;
  128568. private _pointerActive;
  128569. private _elementToAttachTo;
  128570. private _keyboardDownEvent;
  128571. private _keyboardUpEvent;
  128572. private _pointerMoveEvent;
  128573. private _pointerDownEvent;
  128574. private _pointerUpEvent;
  128575. private _gamepadConnectedEvent;
  128576. private _gamepadDisconnectedEvent;
  128577. private static _MAX_KEYCODES;
  128578. private static _MAX_POINTER_INPUTS;
  128579. private constructor();
  128580. /**
  128581. * Creates a new DeviceInputSystem instance
  128582. * @param engine Engine to pull input element from
  128583. * @returns The new instance
  128584. */
  128585. static Create(engine: Engine): DeviceInputSystem;
  128586. /**
  128587. * Checks for current device input value, given an id and input index
  128588. * @param deviceName Id of connected device
  128589. * @param inputIndex Index of device input
  128590. * @returns Current value of input
  128591. */
  128592. /**
  128593. * Checks for current device input value, given an id and input index
  128594. * @param deviceType Enum specifiying device type
  128595. * @param deviceSlot "Slot" or index that device is referenced in
  128596. * @param inputIndex Id of input to be checked
  128597. * @returns Current value of input
  128598. */
  128599. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128600. /**
  128601. * Dispose of all the eventlisteners
  128602. */
  128603. dispose(): void;
  128604. /**
  128605. * Add device and inputs to device array
  128606. * @param deviceType Enum specifiying device type
  128607. * @param deviceSlot "Slot" or index that device is referenced in
  128608. * @param numberOfInputs Number of input entries to create for given device
  128609. */
  128610. private _registerDevice;
  128611. /**
  128612. * Given a specific device name, remove that device from the device map
  128613. * @param deviceType Enum specifiying device type
  128614. * @param deviceSlot "Slot" or index that device is referenced in
  128615. */
  128616. private _unregisterDevice;
  128617. /**
  128618. * Handle all actions that come from keyboard interaction
  128619. */
  128620. private _handleKeyActions;
  128621. /**
  128622. * Handle all actions that come from pointer interaction
  128623. */
  128624. private _handlePointerActions;
  128625. /**
  128626. * Handle all actions that come from gamepad interaction
  128627. */
  128628. private _handleGamepadActions;
  128629. /**
  128630. * Update all non-event based devices with each frame
  128631. * @param deviceType Enum specifiying device type
  128632. * @param deviceSlot "Slot" or index that device is referenced in
  128633. * @param inputIndex Id of input to be checked
  128634. */
  128635. private _updateDevice;
  128636. /**
  128637. * Gets DeviceType from the device name
  128638. * @param deviceName Name of Device from DeviceInputSystem
  128639. * @returns DeviceType enum value
  128640. */
  128641. private _getGamepadDeviceType;
  128642. }
  128643. }
  128644. declare module BABYLON {
  128645. /**
  128646. * Type to handle enforcement of inputs
  128647. */
  128648. 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;
  128649. }
  128650. declare module BABYLON {
  128651. /**
  128652. * Class that handles all input for a specific device
  128653. */
  128654. export class DeviceSource<T extends DeviceType> {
  128655. /** Type of device */
  128656. readonly deviceType: DeviceType;
  128657. /** "Slot" or index that device is referenced in */
  128658. readonly deviceSlot: number;
  128659. /**
  128660. * Observable to handle device input changes per device
  128661. */
  128662. readonly onInputChangedObservable: Observable<{
  128663. inputIndex: DeviceInput<T>;
  128664. previousState: Nullable<number>;
  128665. currentState: Nullable<number>;
  128666. }>;
  128667. private readonly _deviceInputSystem;
  128668. /**
  128669. * Default Constructor
  128670. * @param deviceInputSystem Reference to DeviceInputSystem
  128671. * @param deviceType Type of device
  128672. * @param deviceSlot "Slot" or index that device is referenced in
  128673. */
  128674. constructor(deviceInputSystem: DeviceInputSystem,
  128675. /** Type of device */
  128676. deviceType: DeviceType,
  128677. /** "Slot" or index that device is referenced in */
  128678. deviceSlot?: number);
  128679. /**
  128680. * Get input for specific input
  128681. * @param inputIndex index of specific input on device
  128682. * @returns Input value from DeviceInputSystem
  128683. */
  128684. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128685. }
  128686. /**
  128687. * Class to keep track of devices
  128688. */
  128689. export class DeviceSourceManager implements IDisposable {
  128690. /**
  128691. * Observable to be triggered when before a device is connected
  128692. */
  128693. readonly onBeforeDeviceConnectedObservable: Observable<{
  128694. deviceType: DeviceType;
  128695. deviceSlot: number;
  128696. }>;
  128697. /**
  128698. * Observable to be triggered when before a device is disconnected
  128699. */
  128700. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128701. deviceType: DeviceType;
  128702. deviceSlot: number;
  128703. }>;
  128704. /**
  128705. * Observable to be triggered when after a device is connected
  128706. */
  128707. readonly onAfterDeviceConnectedObservable: Observable<{
  128708. deviceType: DeviceType;
  128709. deviceSlot: number;
  128710. }>;
  128711. /**
  128712. * Observable to be triggered when after a device is disconnected
  128713. */
  128714. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128715. deviceType: DeviceType;
  128716. deviceSlot: number;
  128717. }>;
  128718. private readonly _devices;
  128719. private readonly _firstDevice;
  128720. private readonly _deviceInputSystem;
  128721. /**
  128722. * Default Constructor
  128723. * @param engine engine to pull input element from
  128724. */
  128725. constructor(engine: Engine);
  128726. /**
  128727. * Gets a DeviceSource, given a type and slot
  128728. * @param deviceType Enum specifying device type
  128729. * @param deviceSlot "Slot" or index that device is referenced in
  128730. * @returns DeviceSource object
  128731. */
  128732. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128733. /**
  128734. * Gets an array of DeviceSource objects for a given device type
  128735. * @param deviceType Enum specifying device type
  128736. * @returns Array of DeviceSource objects
  128737. */
  128738. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128739. /**
  128740. * Dispose of DeviceInputSystem and other parts
  128741. */
  128742. dispose(): void;
  128743. /**
  128744. * Function to add device name to device list
  128745. * @param deviceType Enum specifying device type
  128746. * @param deviceSlot "Slot" or index that device is referenced in
  128747. */
  128748. private _addDevice;
  128749. /**
  128750. * Function to remove device name to device list
  128751. * @param deviceType Enum specifying device type
  128752. * @param deviceSlot "Slot" or index that device is referenced in
  128753. */
  128754. private _removeDevice;
  128755. /**
  128756. * Updates array storing first connected device of each type
  128757. * @param type Type of Device
  128758. */
  128759. private _updateFirstDevices;
  128760. }
  128761. }
  128762. declare module BABYLON {
  128763. /**
  128764. * Options to create the null engine
  128765. */
  128766. export class NullEngineOptions {
  128767. /**
  128768. * Render width (Default: 512)
  128769. */
  128770. renderWidth: number;
  128771. /**
  128772. * Render height (Default: 256)
  128773. */
  128774. renderHeight: number;
  128775. /**
  128776. * Texture size (Default: 512)
  128777. */
  128778. textureSize: number;
  128779. /**
  128780. * If delta time between frames should be constant
  128781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128782. */
  128783. deterministicLockstep: boolean;
  128784. /**
  128785. * Maximum about of steps between frames (Default: 4)
  128786. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128787. */
  128788. lockstepMaxSteps: number;
  128789. }
  128790. /**
  128791. * The null engine class provides support for headless version of babylon.js.
  128792. * This can be used in server side scenario or for testing purposes
  128793. */
  128794. export class NullEngine extends Engine {
  128795. private _options;
  128796. /**
  128797. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128798. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128799. * @returns true if engine is in deterministic lock step mode
  128800. */
  128801. isDeterministicLockStep(): boolean;
  128802. /**
  128803. * Gets the max steps when engine is running in deterministic lock step
  128804. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128805. * @returns the max steps
  128806. */
  128807. getLockstepMaxSteps(): number;
  128808. /**
  128809. * Gets the current hardware scaling level.
  128810. * By default the hardware scaling level is computed from the window device ratio.
  128811. * 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.
  128812. * @returns a number indicating the current hardware scaling level
  128813. */
  128814. getHardwareScalingLevel(): number;
  128815. constructor(options?: NullEngineOptions);
  128816. /**
  128817. * Creates a vertex buffer
  128818. * @param vertices the data for the vertex buffer
  128819. * @returns the new WebGL static buffer
  128820. */
  128821. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128822. /**
  128823. * Creates a new index buffer
  128824. * @param indices defines the content of the index buffer
  128825. * @param updatable defines if the index buffer must be updatable
  128826. * @returns a new webGL buffer
  128827. */
  128828. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128829. /**
  128830. * Clear the current render buffer or the current render target (if any is set up)
  128831. * @param color defines the color to use
  128832. * @param backBuffer defines if the back buffer must be cleared
  128833. * @param depth defines if the depth buffer must be cleared
  128834. * @param stencil defines if the stencil buffer must be cleared
  128835. */
  128836. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128837. /**
  128838. * Gets the current render width
  128839. * @param useScreen defines if screen size must be used (or the current render target if any)
  128840. * @returns a number defining the current render width
  128841. */
  128842. getRenderWidth(useScreen?: boolean): number;
  128843. /**
  128844. * Gets the current render height
  128845. * @param useScreen defines if screen size must be used (or the current render target if any)
  128846. * @returns a number defining the current render height
  128847. */
  128848. getRenderHeight(useScreen?: boolean): number;
  128849. /**
  128850. * Set the WebGL's viewport
  128851. * @param viewport defines the viewport element to be used
  128852. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128853. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128854. */
  128855. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128856. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128857. /**
  128858. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128859. * @param pipelineContext defines the pipeline context to use
  128860. * @param uniformsNames defines the list of uniform names
  128861. * @returns an array of webGL uniform locations
  128862. */
  128863. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128864. /**
  128865. * Gets the lsit of active attributes for a given webGL program
  128866. * @param pipelineContext defines the pipeline context to use
  128867. * @param attributesNames defines the list of attribute names to get
  128868. * @returns an array of indices indicating the offset of each attribute
  128869. */
  128870. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128871. /**
  128872. * Binds an effect to the webGL context
  128873. * @param effect defines the effect to bind
  128874. */
  128875. bindSamplers(effect: Effect): void;
  128876. /**
  128877. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128878. * @param effect defines the effect to activate
  128879. */
  128880. enableEffect(effect: Effect): void;
  128881. /**
  128882. * Set various states to the webGL context
  128883. * @param culling defines backface culling state
  128884. * @param zOffset defines the value to apply to zOffset (0 by default)
  128885. * @param force defines if states must be applied even if cache is up to date
  128886. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128887. */
  128888. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128889. /**
  128890. * Set the value of an uniform to an array of int32
  128891. * @param uniform defines the webGL uniform location where to store the value
  128892. * @param array defines the array of int32 to store
  128893. */
  128894. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128895. /**
  128896. * Set the value of an uniform to an array of int32 (stored as vec2)
  128897. * @param uniform defines the webGL uniform location where to store the value
  128898. * @param array defines the array of int32 to store
  128899. */
  128900. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128901. /**
  128902. * Set the value of an uniform to an array of int32 (stored as vec3)
  128903. * @param uniform defines the webGL uniform location where to store the value
  128904. * @param array defines the array of int32 to store
  128905. */
  128906. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128907. /**
  128908. * Set the value of an uniform to an array of int32 (stored as vec4)
  128909. * @param uniform defines the webGL uniform location where to store the value
  128910. * @param array defines the array of int32 to store
  128911. */
  128912. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128913. /**
  128914. * Set the value of an uniform to an array of float32
  128915. * @param uniform defines the webGL uniform location where to store the value
  128916. * @param array defines the array of float32 to store
  128917. */
  128918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128919. /**
  128920. * Set the value of an uniform to an array of float32 (stored as vec2)
  128921. * @param uniform defines the webGL uniform location where to store the value
  128922. * @param array defines the array of float32 to store
  128923. */
  128924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128925. /**
  128926. * Set the value of an uniform to an array of float32 (stored as vec3)
  128927. * @param uniform defines the webGL uniform location where to store the value
  128928. * @param array defines the array of float32 to store
  128929. */
  128930. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128931. /**
  128932. * Set the value of an uniform to an array of float32 (stored as vec4)
  128933. * @param uniform defines the webGL uniform location where to store the value
  128934. * @param array defines the array of float32 to store
  128935. */
  128936. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128937. /**
  128938. * Set the value of an uniform to an array of number
  128939. * @param uniform defines the webGL uniform location where to store the value
  128940. * @param array defines the array of number to store
  128941. */
  128942. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128943. /**
  128944. * Set the value of an uniform to an array of number (stored as vec2)
  128945. * @param uniform defines the webGL uniform location where to store the value
  128946. * @param array defines the array of number to store
  128947. */
  128948. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128949. /**
  128950. * Set the value of an uniform to an array of number (stored as vec3)
  128951. * @param uniform defines the webGL uniform location where to store the value
  128952. * @param array defines the array of number to store
  128953. */
  128954. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128955. /**
  128956. * Set the value of an uniform to an array of number (stored as vec4)
  128957. * @param uniform defines the webGL uniform location where to store the value
  128958. * @param array defines the array of number to store
  128959. */
  128960. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128961. /**
  128962. * Set the value of an uniform to an array of float32 (stored as matrices)
  128963. * @param uniform defines the webGL uniform location where to store the value
  128964. * @param matrices defines the array of float32 to store
  128965. */
  128966. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128967. /**
  128968. * Set the value of an uniform to a matrix (3x3)
  128969. * @param uniform defines the webGL uniform location where to store the value
  128970. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128971. */
  128972. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128973. /**
  128974. * Set the value of an uniform to a matrix (2x2)
  128975. * @param uniform defines the webGL uniform location where to store the value
  128976. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128977. */
  128978. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128979. /**
  128980. * Set the value of an uniform to a number (float)
  128981. * @param uniform defines the webGL uniform location where to store the value
  128982. * @param value defines the float number to store
  128983. */
  128984. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128985. /**
  128986. * Set the value of an uniform to a vec2
  128987. * @param uniform defines the webGL uniform location where to store the value
  128988. * @param x defines the 1st component of the value
  128989. * @param y defines the 2nd component of the value
  128990. */
  128991. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128992. /**
  128993. * Set the value of an uniform to a vec3
  128994. * @param uniform defines the webGL uniform location where to store the value
  128995. * @param x defines the 1st component of the value
  128996. * @param y defines the 2nd component of the value
  128997. * @param z defines the 3rd component of the value
  128998. */
  128999. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129000. /**
  129001. * Set the value of an uniform to a boolean
  129002. * @param uniform defines the webGL uniform location where to store the value
  129003. * @param bool defines the boolean to store
  129004. */
  129005. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129006. /**
  129007. * Set the value of an uniform to a vec4
  129008. * @param uniform defines the webGL uniform location where to store the value
  129009. * @param x defines the 1st component of the value
  129010. * @param y defines the 2nd component of the value
  129011. * @param z defines the 3rd component of the value
  129012. * @param w defines the 4th component of the value
  129013. */
  129014. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129015. /**
  129016. * Sets the current alpha mode
  129017. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129018. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129019. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129020. */
  129021. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129022. /**
  129023. * Bind webGl buffers directly to the webGL context
  129024. * @param vertexBuffers defines the vertex buffer to bind
  129025. * @param indexBuffer defines the index buffer to bind
  129026. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129027. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129028. * @param effect defines the effect associated with the vertex buffer
  129029. */
  129030. bindBuffers(vertexBuffers: {
  129031. [key: string]: VertexBuffer;
  129032. }, indexBuffer: DataBuffer, effect: Effect): void;
  129033. /**
  129034. * Force the entire cache to be cleared
  129035. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129036. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129037. */
  129038. wipeCaches(bruteForce?: boolean): void;
  129039. /**
  129040. * Send a draw order
  129041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129042. * @param indexStart defines the starting index
  129043. * @param indexCount defines the number of index to draw
  129044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129045. */
  129046. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129047. /**
  129048. * Draw a list of indexed primitives
  129049. * @param fillMode defines the primitive to use
  129050. * @param indexStart defines the starting index
  129051. * @param indexCount defines the number of index to draw
  129052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129053. */
  129054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129055. /**
  129056. * Draw a list of unindexed primitives
  129057. * @param fillMode defines the primitive to use
  129058. * @param verticesStart defines the index of first vertex to draw
  129059. * @param verticesCount defines the count of vertices to draw
  129060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129061. */
  129062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129063. /** @hidden */
  129064. _createTexture(): WebGLTexture;
  129065. /** @hidden */
  129066. _releaseTexture(texture: InternalTexture): void;
  129067. /**
  129068. * Usually called from Texture.ts.
  129069. * Passed information to create a WebGLTexture
  129070. * @param urlArg defines a value which contains one of the following:
  129071. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129072. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129073. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129074. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129075. * @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)
  129076. * @param scene needed for loading to the correct scene
  129077. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129078. * @param onLoad optional callback to be called upon successful completion
  129079. * @param onError optional callback to be called upon failure
  129080. * @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
  129081. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129082. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129083. * @param forcedExtension defines the extension to use to pick the right loader
  129084. * @param mimeType defines an optional mime type
  129085. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129086. */
  129087. 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;
  129088. /**
  129089. * Creates a new render target texture
  129090. * @param size defines the size of the texture
  129091. * @param options defines the options used to create the texture
  129092. * @returns a new render target texture stored in an InternalTexture
  129093. */
  129094. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129095. /**
  129096. * Update the sampling mode of a given texture
  129097. * @param samplingMode defines the required sampling mode
  129098. * @param texture defines the texture to update
  129099. */
  129100. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129101. /**
  129102. * Binds the frame buffer to the specified texture.
  129103. * @param texture The texture to render to or null for the default canvas
  129104. * @param faceIndex The face of the texture to render to in case of cube texture
  129105. * @param requiredWidth The width of the target to render to
  129106. * @param requiredHeight The height of the target to render to
  129107. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129108. * @param lodLevel defines le lod level to bind to the frame buffer
  129109. */
  129110. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129111. /**
  129112. * Unbind the current render target texture from the webGL context
  129113. * @param texture defines the render target texture to unbind
  129114. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129115. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129116. */
  129117. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129118. /**
  129119. * Creates a dynamic vertex buffer
  129120. * @param vertices the data for the dynamic vertex buffer
  129121. * @returns the new WebGL dynamic buffer
  129122. */
  129123. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129124. /**
  129125. * Update the content of a dynamic texture
  129126. * @param texture defines the texture to update
  129127. * @param canvas defines the canvas containing the source
  129128. * @param invertY defines if data must be stored with Y axis inverted
  129129. * @param premulAlpha defines if alpha is stored as premultiplied
  129130. * @param format defines the format of the data
  129131. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129132. */
  129133. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129134. /**
  129135. * Gets a boolean indicating if all created effects are ready
  129136. * @returns true if all effects are ready
  129137. */
  129138. areAllEffectsReady(): boolean;
  129139. /**
  129140. * @hidden
  129141. * Get the current error code of the webGL context
  129142. * @returns the error code
  129143. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129144. */
  129145. getError(): number;
  129146. /** @hidden */
  129147. _getUnpackAlignement(): number;
  129148. /** @hidden */
  129149. _unpackFlipY(value: boolean): void;
  129150. /**
  129151. * Update a dynamic index buffer
  129152. * @param indexBuffer defines the target index buffer
  129153. * @param indices defines the data to update
  129154. * @param offset defines the offset in the target index buffer where update should start
  129155. */
  129156. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129157. /**
  129158. * Updates a dynamic vertex buffer.
  129159. * @param vertexBuffer the vertex buffer to update
  129160. * @param vertices the data used to update the vertex buffer
  129161. * @param byteOffset the byte offset of the data (optional)
  129162. * @param byteLength the byte length of the data (optional)
  129163. */
  129164. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129165. /** @hidden */
  129166. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129167. /** @hidden */
  129168. _bindTexture(channel: number, texture: InternalTexture): void;
  129169. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129170. /**
  129171. * 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
  129172. */
  129173. releaseEffects(): void;
  129174. displayLoadingUI(): void;
  129175. hideLoadingUI(): void;
  129176. /** @hidden */
  129177. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129178. /** @hidden */
  129179. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129180. /** @hidden */
  129181. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129182. /** @hidden */
  129183. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129184. }
  129185. }
  129186. declare module BABYLON {
  129187. /**
  129188. * @hidden
  129189. **/
  129190. export class _TimeToken {
  129191. _startTimeQuery: Nullable<WebGLQuery>;
  129192. _endTimeQuery: Nullable<WebGLQuery>;
  129193. _timeElapsedQuery: Nullable<WebGLQuery>;
  129194. _timeElapsedQueryEnded: boolean;
  129195. }
  129196. }
  129197. declare module BABYLON {
  129198. /** @hidden */
  129199. export class _OcclusionDataStorage {
  129200. /** @hidden */
  129201. occlusionInternalRetryCounter: number;
  129202. /** @hidden */
  129203. isOcclusionQueryInProgress: boolean;
  129204. /** @hidden */
  129205. isOccluded: boolean;
  129206. /** @hidden */
  129207. occlusionRetryCount: number;
  129208. /** @hidden */
  129209. occlusionType: number;
  129210. /** @hidden */
  129211. occlusionQueryAlgorithmType: number;
  129212. }
  129213. interface Engine {
  129214. /**
  129215. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129216. * @return the new query
  129217. */
  129218. createQuery(): WebGLQuery;
  129219. /**
  129220. * Delete and release a webGL query
  129221. * @param query defines the query to delete
  129222. * @return the current engine
  129223. */
  129224. deleteQuery(query: WebGLQuery): Engine;
  129225. /**
  129226. * Check if a given query has resolved and got its value
  129227. * @param query defines the query to check
  129228. * @returns true if the query got its value
  129229. */
  129230. isQueryResultAvailable(query: WebGLQuery): boolean;
  129231. /**
  129232. * Gets the value of a given query
  129233. * @param query defines the query to check
  129234. * @returns the value of the query
  129235. */
  129236. getQueryResult(query: WebGLQuery): number;
  129237. /**
  129238. * Initiates an occlusion query
  129239. * @param algorithmType defines the algorithm to use
  129240. * @param query defines the query to use
  129241. * @returns the current engine
  129242. * @see https://doc.babylonjs.com/features/occlusionquery
  129243. */
  129244. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129245. /**
  129246. * Ends an occlusion query
  129247. * @see https://doc.babylonjs.com/features/occlusionquery
  129248. * @param algorithmType defines the algorithm to use
  129249. * @returns the current engine
  129250. */
  129251. endOcclusionQuery(algorithmType: number): Engine;
  129252. /**
  129253. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129254. * Please note that only one query can be issued at a time
  129255. * @returns a time token used to track the time span
  129256. */
  129257. startTimeQuery(): Nullable<_TimeToken>;
  129258. /**
  129259. * Ends a time query
  129260. * @param token defines the token used to measure the time span
  129261. * @returns the time spent (in ns)
  129262. */
  129263. endTimeQuery(token: _TimeToken): int;
  129264. /** @hidden */
  129265. _currentNonTimestampToken: Nullable<_TimeToken>;
  129266. /** @hidden */
  129267. _createTimeQuery(): WebGLQuery;
  129268. /** @hidden */
  129269. _deleteTimeQuery(query: WebGLQuery): void;
  129270. /** @hidden */
  129271. _getGlAlgorithmType(algorithmType: number): number;
  129272. /** @hidden */
  129273. _getTimeQueryResult(query: WebGLQuery): any;
  129274. /** @hidden */
  129275. _getTimeQueryAvailability(query: WebGLQuery): any;
  129276. }
  129277. interface AbstractMesh {
  129278. /**
  129279. * Backing filed
  129280. * @hidden
  129281. */
  129282. __occlusionDataStorage: _OcclusionDataStorage;
  129283. /**
  129284. * Access property
  129285. * @hidden
  129286. */
  129287. _occlusionDataStorage: _OcclusionDataStorage;
  129288. /**
  129289. * 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.
  129290. * The default value is -1 which means don't break the query and wait till the result
  129291. * @see https://doc.babylonjs.com/features/occlusionquery
  129292. */
  129293. occlusionRetryCount: number;
  129294. /**
  129295. * 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:
  129296. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129297. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129298. * * 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.
  129299. * @see https://doc.babylonjs.com/features/occlusionquery
  129300. */
  129301. occlusionType: number;
  129302. /**
  129303. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129304. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129305. * * 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.
  129306. * @see https://doc.babylonjs.com/features/occlusionquery
  129307. */
  129308. occlusionQueryAlgorithmType: number;
  129309. /**
  129310. * 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
  129311. * @see https://doc.babylonjs.com/features/occlusionquery
  129312. */
  129313. isOccluded: boolean;
  129314. /**
  129315. * Flag to check the progress status of the query
  129316. * @see https://doc.babylonjs.com/features/occlusionquery
  129317. */
  129318. isOcclusionQueryInProgress: boolean;
  129319. }
  129320. }
  129321. declare module BABYLON {
  129322. /** @hidden */
  129323. export var _forceTransformFeedbackToBundle: boolean;
  129324. interface Engine {
  129325. /**
  129326. * Creates a webGL transform feedback object
  129327. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129328. * @returns the webGL transform feedback object
  129329. */
  129330. createTransformFeedback(): WebGLTransformFeedback;
  129331. /**
  129332. * Delete a webGL transform feedback object
  129333. * @param value defines the webGL transform feedback object to delete
  129334. */
  129335. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129336. /**
  129337. * Bind a webGL transform feedback object to the webgl context
  129338. * @param value defines the webGL transform feedback object to bind
  129339. */
  129340. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129341. /**
  129342. * Begins a transform feedback operation
  129343. * @param usePoints defines if points or triangles must be used
  129344. */
  129345. beginTransformFeedback(usePoints: boolean): void;
  129346. /**
  129347. * Ends a transform feedback operation
  129348. */
  129349. endTransformFeedback(): void;
  129350. /**
  129351. * Specify the varyings to use with transform feedback
  129352. * @param program defines the associated webGL program
  129353. * @param value defines the list of strings representing the varying names
  129354. */
  129355. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129356. /**
  129357. * Bind a webGL buffer for a transform feedback operation
  129358. * @param value defines the webGL buffer to bind
  129359. */
  129360. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129361. }
  129362. }
  129363. declare module BABYLON {
  129364. /**
  129365. * Creation options of the multi render target texture.
  129366. */
  129367. export interface IMultiRenderTargetOptions {
  129368. /**
  129369. * Define if the texture needs to create mip maps after render.
  129370. */
  129371. generateMipMaps?: boolean;
  129372. /**
  129373. * Define the types of all the draw buffers we want to create
  129374. */
  129375. types?: number[];
  129376. /**
  129377. * Define the sampling modes of all the draw buffers we want to create
  129378. */
  129379. samplingModes?: number[];
  129380. /**
  129381. * Define if a depth buffer is required
  129382. */
  129383. generateDepthBuffer?: boolean;
  129384. /**
  129385. * Define if a stencil buffer is required
  129386. */
  129387. generateStencilBuffer?: boolean;
  129388. /**
  129389. * Define if a depth texture is required instead of a depth buffer
  129390. */
  129391. generateDepthTexture?: boolean;
  129392. /**
  129393. * Define the number of desired draw buffers
  129394. */
  129395. textureCount?: number;
  129396. /**
  129397. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129398. */
  129399. doNotChangeAspectRatio?: boolean;
  129400. /**
  129401. * Define the default type of the buffers we are creating
  129402. */
  129403. defaultType?: number;
  129404. }
  129405. /**
  129406. * A multi render target, like a render target provides the ability to render to a texture.
  129407. * Unlike the render target, it can render to several draw buffers in one draw.
  129408. * This is specially interesting in deferred rendering or for any effects requiring more than
  129409. * just one color from a single pass.
  129410. */
  129411. export class MultiRenderTarget extends RenderTargetTexture {
  129412. private _internalTextures;
  129413. private _textures;
  129414. private _multiRenderTargetOptions;
  129415. private _count;
  129416. /**
  129417. * Get if draw buffers are currently supported by the used hardware and browser.
  129418. */
  129419. get isSupported(): boolean;
  129420. /**
  129421. * Get the list of textures generated by the multi render target.
  129422. */
  129423. get textures(): Texture[];
  129424. /**
  129425. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129426. */
  129427. get count(): number;
  129428. /**
  129429. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129430. */
  129431. get depthTexture(): Texture;
  129432. /**
  129433. * Set the wrapping mode on U of all the textures we are rendering to.
  129434. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129435. */
  129436. set wrapU(wrap: number);
  129437. /**
  129438. * Set the wrapping mode on V of all the textures we are rendering to.
  129439. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129440. */
  129441. set wrapV(wrap: number);
  129442. /**
  129443. * Instantiate a new multi render target texture.
  129444. * A multi render target, like a render target provides the ability to render to a texture.
  129445. * Unlike the render target, it can render to several draw buffers in one draw.
  129446. * This is specially interesting in deferred rendering or for any effects requiring more than
  129447. * just one color from a single pass.
  129448. * @param name Define the name of the texture
  129449. * @param size Define the size of the buffers to render to
  129450. * @param count Define the number of target we are rendering into
  129451. * @param scene Define the scene the texture belongs to
  129452. * @param options Define the options used to create the multi render target
  129453. */
  129454. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129455. /** @hidden */
  129456. _rebuild(): void;
  129457. private _createInternalTextures;
  129458. private _createTextures;
  129459. /**
  129460. * Define the number of samples used if MSAA is enabled.
  129461. */
  129462. get samples(): number;
  129463. set samples(value: number);
  129464. /**
  129465. * Resize all the textures in the multi render target.
  129466. * Be carrefull as it will recreate all the data in the new texture.
  129467. * @param size Define the new size
  129468. */
  129469. resize(size: any): void;
  129470. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129471. /**
  129472. * Dispose the render targets and their associated resources
  129473. */
  129474. dispose(): void;
  129475. /**
  129476. * Release all the underlying texture used as draw buffers.
  129477. */
  129478. releaseInternalTextures(): void;
  129479. }
  129480. }
  129481. declare module BABYLON {
  129482. interface ThinEngine {
  129483. /**
  129484. * Unbind a list of render target textures from the webGL context
  129485. * This is used only when drawBuffer extension or webGL2 are active
  129486. * @param textures defines the render target textures to unbind
  129487. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129488. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129489. */
  129490. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129491. /**
  129492. * Create a multi render target texture
  129493. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129494. * @param size defines the size of the texture
  129495. * @param options defines the creation options
  129496. * @returns the cube texture as an InternalTexture
  129497. */
  129498. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129499. /**
  129500. * Update the sample count for a given multiple render target texture
  129501. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129502. * @param textures defines the textures to update
  129503. * @param samples defines the sample count to set
  129504. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129505. */
  129506. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129507. /**
  129508. * Select a subsets of attachments to draw to.
  129509. * @param attachments gl attachments
  129510. */
  129511. bindAttachments(attachments: number[]): void;
  129512. }
  129513. }
  129514. declare module BABYLON {
  129515. /**
  129516. * Class used to define an additional view for the engine
  129517. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129518. */
  129519. export class EngineView {
  129520. /** Defines the canvas where to render the view */
  129521. target: HTMLCanvasElement;
  129522. /** Defines an optional camera used to render the view (will use active camera else) */
  129523. camera?: Camera;
  129524. }
  129525. interface Engine {
  129526. /**
  129527. * Gets or sets the HTML element to use for attaching events
  129528. */
  129529. inputElement: Nullable<HTMLElement>;
  129530. /**
  129531. * Gets the current engine view
  129532. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129533. */
  129534. activeView: Nullable<EngineView>;
  129535. /** Gets or sets the list of views */
  129536. views: EngineView[];
  129537. /**
  129538. * Register a new child canvas
  129539. * @param canvas defines the canvas to register
  129540. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129541. * @returns the associated view
  129542. */
  129543. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129544. /**
  129545. * Remove a registered child canvas
  129546. * @param canvas defines the canvas to remove
  129547. * @returns the current engine
  129548. */
  129549. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129550. }
  129551. }
  129552. declare module BABYLON {
  129553. interface Engine {
  129554. /** @hidden */
  129555. _excludedCompressedTextures: string[];
  129556. /** @hidden */
  129557. _textureFormatInUse: string;
  129558. /**
  129559. * Gets the list of texture formats supported
  129560. */
  129561. readonly texturesSupported: Array<string>;
  129562. /**
  129563. * Gets the texture format in use
  129564. */
  129565. readonly textureFormatInUse: Nullable<string>;
  129566. /**
  129567. * Set the compressed texture extensions or file names to skip.
  129568. *
  129569. * @param skippedFiles defines the list of those texture files you want to skip
  129570. * Example: [".dds", ".env", "myfile.png"]
  129571. */
  129572. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129573. /**
  129574. * Set the compressed texture format to use, based on the formats you have, and the formats
  129575. * supported by the hardware / browser.
  129576. *
  129577. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129578. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129579. * to API arguments needed to compressed textures. This puts the burden on the container
  129580. * generator to house the arcane code for determining these for current & future formats.
  129581. *
  129582. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129583. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129584. *
  129585. * Note: The result of this call is not taken into account when a texture is base64.
  129586. *
  129587. * @param formatsAvailable defines the list of those format families you have created
  129588. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129589. *
  129590. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129591. * @returns The extension selected.
  129592. */
  129593. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129594. }
  129595. }
  129596. declare module BABYLON {
  129597. /**
  129598. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129599. */
  129600. export interface CubeMapInfo {
  129601. /**
  129602. * The pixel array for the front face.
  129603. * This is stored in format, left to right, up to down format.
  129604. */
  129605. front: Nullable<ArrayBufferView>;
  129606. /**
  129607. * The pixel array for the back face.
  129608. * This is stored in format, left to right, up to down format.
  129609. */
  129610. back: Nullable<ArrayBufferView>;
  129611. /**
  129612. * The pixel array for the left face.
  129613. * This is stored in format, left to right, up to down format.
  129614. */
  129615. left: Nullable<ArrayBufferView>;
  129616. /**
  129617. * The pixel array for the right face.
  129618. * This is stored in format, left to right, up to down format.
  129619. */
  129620. right: Nullable<ArrayBufferView>;
  129621. /**
  129622. * The pixel array for the up face.
  129623. * This is stored in format, left to right, up to down format.
  129624. */
  129625. up: Nullable<ArrayBufferView>;
  129626. /**
  129627. * The pixel array for the down face.
  129628. * This is stored in format, left to right, up to down format.
  129629. */
  129630. down: Nullable<ArrayBufferView>;
  129631. /**
  129632. * The size of the cubemap stored.
  129633. *
  129634. * Each faces will be size * size pixels.
  129635. */
  129636. size: number;
  129637. /**
  129638. * The format of the texture.
  129639. *
  129640. * RGBA, RGB.
  129641. */
  129642. format: number;
  129643. /**
  129644. * The type of the texture data.
  129645. *
  129646. * UNSIGNED_INT, FLOAT.
  129647. */
  129648. type: number;
  129649. /**
  129650. * Specifies whether the texture is in gamma space.
  129651. */
  129652. gammaSpace: boolean;
  129653. }
  129654. /**
  129655. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129656. */
  129657. export class PanoramaToCubeMapTools {
  129658. private static FACE_LEFT;
  129659. private static FACE_RIGHT;
  129660. private static FACE_FRONT;
  129661. private static FACE_BACK;
  129662. private static FACE_DOWN;
  129663. private static FACE_UP;
  129664. /**
  129665. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129666. *
  129667. * @param float32Array The source data.
  129668. * @param inputWidth The width of the input panorama.
  129669. * @param inputHeight The height of the input panorama.
  129670. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129671. * @return The cubemap data
  129672. */
  129673. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129674. private static CreateCubemapTexture;
  129675. private static CalcProjectionSpherical;
  129676. }
  129677. }
  129678. declare module BABYLON {
  129679. /**
  129680. * Helper class dealing with the extraction of spherical polynomial dataArray
  129681. * from a cube map.
  129682. */
  129683. export class CubeMapToSphericalPolynomialTools {
  129684. private static FileFaces;
  129685. /**
  129686. * Converts a texture to the according Spherical Polynomial data.
  129687. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129688. *
  129689. * @param texture The texture to extract the information from.
  129690. * @return The Spherical Polynomial data.
  129691. */
  129692. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129693. /**
  129694. * Converts a cubemap to the according Spherical Polynomial data.
  129695. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129696. *
  129697. * @param cubeInfo The Cube map to extract the information from.
  129698. * @return The Spherical Polynomial data.
  129699. */
  129700. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129701. }
  129702. }
  129703. declare module BABYLON {
  129704. interface BaseTexture {
  129705. /**
  129706. * Get the polynomial representation of the texture data.
  129707. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129708. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129709. */
  129710. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129711. }
  129712. }
  129713. declare module BABYLON {
  129714. /** @hidden */
  129715. export var rgbdEncodePixelShader: {
  129716. name: string;
  129717. shader: string;
  129718. };
  129719. }
  129720. declare module BABYLON {
  129721. /** @hidden */
  129722. export var rgbdDecodePixelShader: {
  129723. name: string;
  129724. shader: string;
  129725. };
  129726. }
  129727. declare module BABYLON {
  129728. /**
  129729. * Raw texture data and descriptor sufficient for WebGL texture upload
  129730. */
  129731. export interface EnvironmentTextureInfo {
  129732. /**
  129733. * Version of the environment map
  129734. */
  129735. version: number;
  129736. /**
  129737. * Width of image
  129738. */
  129739. width: number;
  129740. /**
  129741. * Irradiance information stored in the file.
  129742. */
  129743. irradiance: any;
  129744. /**
  129745. * Specular information stored in the file.
  129746. */
  129747. specular: any;
  129748. }
  129749. /**
  129750. * Defines One Image in the file. It requires only the position in the file
  129751. * as well as the length.
  129752. */
  129753. interface BufferImageData {
  129754. /**
  129755. * Length of the image data.
  129756. */
  129757. length: number;
  129758. /**
  129759. * Position of the data from the null terminator delimiting the end of the JSON.
  129760. */
  129761. position: number;
  129762. }
  129763. /**
  129764. * Defines the specular data enclosed in the file.
  129765. * This corresponds to the version 1 of the data.
  129766. */
  129767. export interface EnvironmentTextureSpecularInfoV1 {
  129768. /**
  129769. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129770. */
  129771. specularDataPosition?: number;
  129772. /**
  129773. * This contains all the images data needed to reconstruct the cubemap.
  129774. */
  129775. mipmaps: Array<BufferImageData>;
  129776. /**
  129777. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129778. */
  129779. lodGenerationScale: number;
  129780. }
  129781. /**
  129782. * Sets of helpers addressing the serialization and deserialization of environment texture
  129783. * stored in a BabylonJS env file.
  129784. * Those files are usually stored as .env files.
  129785. */
  129786. export class EnvironmentTextureTools {
  129787. /**
  129788. * Magic number identifying the env file.
  129789. */
  129790. private static _MagicBytes;
  129791. /**
  129792. * Gets the environment info from an env file.
  129793. * @param data The array buffer containing the .env bytes.
  129794. * @returns the environment file info (the json header) if successfully parsed.
  129795. */
  129796. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129797. /**
  129798. * Creates an environment texture from a loaded cube texture.
  129799. * @param texture defines the cube texture to convert in env file
  129800. * @return a promise containing the environment data if succesfull.
  129801. */
  129802. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129803. /**
  129804. * Creates a JSON representation of the spherical data.
  129805. * @param texture defines the texture containing the polynomials
  129806. * @return the JSON representation of the spherical info
  129807. */
  129808. private static _CreateEnvTextureIrradiance;
  129809. /**
  129810. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129811. * @param data the image data
  129812. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129813. * @return the views described by info providing access to the underlying buffer
  129814. */
  129815. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129816. /**
  129817. * Uploads the texture info contained in the env file to the GPU.
  129818. * @param texture defines the internal texture to upload to
  129819. * @param data defines the data to load
  129820. * @param info defines the texture info retrieved through the GetEnvInfo method
  129821. * @returns a promise
  129822. */
  129823. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129824. private static _OnImageReadyAsync;
  129825. /**
  129826. * Uploads the levels of image data to the GPU.
  129827. * @param texture defines the internal texture to upload to
  129828. * @param imageData defines the array buffer views of image data [mipmap][face]
  129829. * @returns a promise
  129830. */
  129831. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129832. /**
  129833. * Uploads spherical polynomials information to the texture.
  129834. * @param texture defines the texture we are trying to upload the information to
  129835. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129836. */
  129837. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129838. /** @hidden */
  129839. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129840. }
  129841. }
  129842. declare module BABYLON {
  129843. /**
  129844. * Class used to inline functions in shader code
  129845. */
  129846. export class ShaderCodeInliner {
  129847. private static readonly _RegexpFindFunctionNameAndType;
  129848. private _sourceCode;
  129849. private _functionDescr;
  129850. private _numMaxIterations;
  129851. /** Gets or sets the token used to mark the functions to inline */
  129852. inlineToken: string;
  129853. /** Gets or sets the debug mode */
  129854. debug: boolean;
  129855. /** Gets the code after the inlining process */
  129856. get code(): string;
  129857. /**
  129858. * Initializes the inliner
  129859. * @param sourceCode shader code source to inline
  129860. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129861. */
  129862. constructor(sourceCode: string, numMaxIterations?: number);
  129863. /**
  129864. * Start the processing of the shader code
  129865. */
  129866. processCode(): void;
  129867. private _collectFunctions;
  129868. private _processInlining;
  129869. private _extractBetweenMarkers;
  129870. private _skipWhitespaces;
  129871. private _removeComments;
  129872. private _replaceFunctionCallsByCode;
  129873. private _findBackward;
  129874. private _escapeRegExp;
  129875. private _replaceNames;
  129876. }
  129877. }
  129878. declare module BABYLON {
  129879. /**
  129880. * Container for accessors for natively-stored mesh data buffers.
  129881. */
  129882. class NativeDataBuffer extends DataBuffer {
  129883. /**
  129884. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129885. */
  129886. nativeIndexBuffer?: any;
  129887. /**
  129888. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129889. */
  129890. nativeVertexBuffer?: any;
  129891. }
  129892. /** @hidden */
  129893. class NativeTexture extends InternalTexture {
  129894. getInternalTexture(): InternalTexture;
  129895. getViewCount(): number;
  129896. }
  129897. /** @hidden */
  129898. export class NativeEngine extends Engine {
  129899. private readonly _native;
  129900. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129901. private readonly INVALID_HANDLE;
  129902. getHardwareScalingLevel(): number;
  129903. constructor();
  129904. dispose(): void;
  129905. /**
  129906. * Can be used to override the current requestAnimationFrame requester.
  129907. * @hidden
  129908. */
  129909. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129910. /**
  129911. * Override default engine behavior.
  129912. * @param color
  129913. * @param backBuffer
  129914. * @param depth
  129915. * @param stencil
  129916. */
  129917. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129918. /**
  129919. * Gets host document
  129920. * @returns the host document object
  129921. */
  129922. getHostDocument(): Nullable<Document>;
  129923. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129924. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129925. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129926. recordVertexArrayObject(vertexBuffers: {
  129927. [key: string]: VertexBuffer;
  129928. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129929. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129930. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129931. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129932. /**
  129933. * Draw a list of indexed primitives
  129934. * @param fillMode defines the primitive to use
  129935. * @param indexStart defines the starting index
  129936. * @param indexCount defines the number of index to draw
  129937. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129938. */
  129939. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129940. /**
  129941. * Draw a list of unindexed primitives
  129942. * @param fillMode defines the primitive to use
  129943. * @param verticesStart defines the index of first vertex to draw
  129944. * @param verticesCount defines the count of vertices to draw
  129945. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129946. */
  129947. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129948. createPipelineContext(): IPipelineContext;
  129949. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129950. /** @hidden */
  129951. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129952. /** @hidden */
  129953. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129954. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129955. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129956. protected _setProgram(program: WebGLProgram): void;
  129957. _releaseEffect(effect: Effect): void;
  129958. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129959. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129960. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129961. bindSamplers(effect: Effect): void;
  129962. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129963. getRenderWidth(useScreen?: boolean): number;
  129964. getRenderHeight(useScreen?: boolean): number;
  129965. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129966. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129967. /**
  129968. * Set the z offset to apply to current rendering
  129969. * @param value defines the offset to apply
  129970. */
  129971. setZOffset(value: number): void;
  129972. /**
  129973. * Gets the current value of the zOffset
  129974. * @returns the current zOffset state
  129975. */
  129976. getZOffset(): number;
  129977. /**
  129978. * Enable or disable depth buffering
  129979. * @param enable defines the state to set
  129980. */
  129981. setDepthBuffer(enable: boolean): void;
  129982. /**
  129983. * Gets a boolean indicating if depth writing is enabled
  129984. * @returns the current depth writing state
  129985. */
  129986. getDepthWrite(): boolean;
  129987. /**
  129988. * Enable or disable depth writing
  129989. * @param enable defines the state to set
  129990. */
  129991. setDepthWrite(enable: boolean): void;
  129992. /**
  129993. * Enable or disable color writing
  129994. * @param enable defines the state to set
  129995. */
  129996. setColorWrite(enable: boolean): void;
  129997. /**
  129998. * Gets a boolean indicating if color writing is enabled
  129999. * @returns the current color writing state
  130000. */
  130001. getColorWrite(): boolean;
  130002. /**
  130003. * Sets alpha constants used by some alpha blending modes
  130004. * @param r defines the red component
  130005. * @param g defines the green component
  130006. * @param b defines the blue component
  130007. * @param a defines the alpha component
  130008. */
  130009. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130010. /**
  130011. * Sets the current alpha mode
  130012. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130013. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130014. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130015. */
  130016. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130017. /**
  130018. * Gets the current alpha mode
  130019. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130020. * @returns the current alpha mode
  130021. */
  130022. getAlphaMode(): number;
  130023. setInt(uniform: WebGLUniformLocation, int: number): void;
  130024. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130025. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130026. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130027. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130028. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130029. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130030. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130031. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130032. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130033. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130034. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130035. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130036. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130037. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130038. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130039. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130040. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130041. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130042. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130043. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130044. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130045. wipeCaches(bruteForce?: boolean): void;
  130046. _createTexture(): WebGLTexture;
  130047. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130048. /**
  130049. * Usually called from Texture.ts.
  130050. * Passed information to create a WebGLTexture
  130051. * @param url defines a value which contains one of the following:
  130052. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130053. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130054. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130056. * @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)
  130057. * @param scene needed for loading to the correct scene
  130058. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130059. * @param onLoad optional callback to be called upon successful completion
  130060. * @param onError optional callback to be called upon failure
  130061. * @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
  130062. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130063. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130064. * @param forcedExtension defines the extension to use to pick the right loader
  130065. * @param mimeType defines an optional mime type
  130066. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130067. */
  130068. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  130069. /**
  130070. * Creates a cube texture
  130071. * @param rootUrl defines the url where the files to load is located
  130072. * @param scene defines the current scene
  130073. * @param files defines the list of files to load (1 per face)
  130074. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130075. * @param onLoad defines an optional callback raised when the texture is loaded
  130076. * @param onError defines an optional callback raised if there is an issue to load the texture
  130077. * @param format defines the format of the data
  130078. * @param forcedExtension defines the extension to use to pick the right loader
  130079. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130080. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130081. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130082. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130083. * @returns the cube texture as an InternalTexture
  130084. */
  130085. 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;
  130086. private _getSamplingFilter;
  130087. private static _GetNativeTextureFormat;
  130088. createRenderTargetTexture(size: number | {
  130089. width: number;
  130090. height: number;
  130091. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130092. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130093. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130094. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130095. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130096. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130097. /**
  130098. * Updates a dynamic vertex buffer.
  130099. * @param vertexBuffer the vertex buffer to update
  130100. * @param data the data used to update the vertex buffer
  130101. * @param byteOffset the byte offset of the data (optional)
  130102. * @param byteLength the byte length of the data (optional)
  130103. */
  130104. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130105. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130106. private _updateAnisotropicLevel;
  130107. private _getAddressMode;
  130108. /** @hidden */
  130109. _bindTexture(channel: number, texture: InternalTexture): void;
  130110. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130111. releaseEffects(): void;
  130112. /** @hidden */
  130113. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130114. /** @hidden */
  130115. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130116. /** @hidden */
  130117. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130118. /** @hidden */
  130119. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130120. }
  130121. }
  130122. declare module BABYLON {
  130123. /**
  130124. * Gather the list of clipboard event types as constants.
  130125. */
  130126. export class ClipboardEventTypes {
  130127. /**
  130128. * The clipboard event is fired when a copy command is active (pressed).
  130129. */
  130130. static readonly COPY: number;
  130131. /**
  130132. * The clipboard event is fired when a cut command is active (pressed).
  130133. */
  130134. static readonly CUT: number;
  130135. /**
  130136. * The clipboard event is fired when a paste command is active (pressed).
  130137. */
  130138. static readonly PASTE: number;
  130139. }
  130140. /**
  130141. * This class is used to store clipboard related info for the onClipboardObservable event.
  130142. */
  130143. export class ClipboardInfo {
  130144. /**
  130145. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130146. */
  130147. type: number;
  130148. /**
  130149. * Defines the related dom event
  130150. */
  130151. event: ClipboardEvent;
  130152. /**
  130153. *Creates an instance of ClipboardInfo.
  130154. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130155. * @param event Defines the related dom event
  130156. */
  130157. constructor(
  130158. /**
  130159. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130160. */
  130161. type: number,
  130162. /**
  130163. * Defines the related dom event
  130164. */
  130165. event: ClipboardEvent);
  130166. /**
  130167. * Get the clipboard event's type from the keycode.
  130168. * @param keyCode Defines the keyCode for the current keyboard event.
  130169. * @return {number}
  130170. */
  130171. static GetTypeFromCharacter(keyCode: number): number;
  130172. }
  130173. }
  130174. declare module BABYLON {
  130175. /**
  130176. * Google Daydream controller
  130177. */
  130178. export class DaydreamController extends WebVRController {
  130179. /**
  130180. * Base Url for the controller model.
  130181. */
  130182. static MODEL_BASE_URL: string;
  130183. /**
  130184. * File name for the controller model.
  130185. */
  130186. static MODEL_FILENAME: string;
  130187. /**
  130188. * Gamepad Id prefix used to identify Daydream Controller.
  130189. */
  130190. static readonly GAMEPAD_ID_PREFIX: string;
  130191. /**
  130192. * Creates a new DaydreamController from a gamepad
  130193. * @param vrGamepad the gamepad that the controller should be created from
  130194. */
  130195. constructor(vrGamepad: any);
  130196. /**
  130197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130198. * @param scene scene in which to add meshes
  130199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130200. */
  130201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130202. /**
  130203. * Called once for each button that changed state since the last frame
  130204. * @param buttonIdx Which button index changed
  130205. * @param state New state of the button
  130206. * @param changes Which properties on the state changed since last frame
  130207. */
  130208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130209. }
  130210. }
  130211. declare module BABYLON {
  130212. /**
  130213. * Gear VR Controller
  130214. */
  130215. export class GearVRController extends WebVRController {
  130216. /**
  130217. * Base Url for the controller model.
  130218. */
  130219. static MODEL_BASE_URL: string;
  130220. /**
  130221. * File name for the controller model.
  130222. */
  130223. static MODEL_FILENAME: string;
  130224. /**
  130225. * Gamepad Id prefix used to identify this controller.
  130226. */
  130227. static readonly GAMEPAD_ID_PREFIX: string;
  130228. private readonly _buttonIndexToObservableNameMap;
  130229. /**
  130230. * Creates a new GearVRController from a gamepad
  130231. * @param vrGamepad the gamepad that the controller should be created from
  130232. */
  130233. constructor(vrGamepad: any);
  130234. /**
  130235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130236. * @param scene scene in which to add meshes
  130237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130238. */
  130239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130240. /**
  130241. * Called once for each button that changed state since the last frame
  130242. * @param buttonIdx Which button index changed
  130243. * @param state New state of the button
  130244. * @param changes Which properties on the state changed since last frame
  130245. */
  130246. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130247. }
  130248. }
  130249. declare module BABYLON {
  130250. /**
  130251. * Generic Controller
  130252. */
  130253. export class GenericController extends WebVRController {
  130254. /**
  130255. * Base Url for the controller model.
  130256. */
  130257. static readonly MODEL_BASE_URL: string;
  130258. /**
  130259. * File name for the controller model.
  130260. */
  130261. static readonly MODEL_FILENAME: string;
  130262. /**
  130263. * Creates a new GenericController from a gamepad
  130264. * @param vrGamepad the gamepad that the controller should be created from
  130265. */
  130266. constructor(vrGamepad: any);
  130267. /**
  130268. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130269. * @param scene scene in which to add meshes
  130270. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130271. */
  130272. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130273. /**
  130274. * Called once for each button that changed state since the last frame
  130275. * @param buttonIdx Which button index changed
  130276. * @param state New state of the button
  130277. * @param changes Which properties on the state changed since last frame
  130278. */
  130279. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130280. }
  130281. }
  130282. declare module BABYLON {
  130283. /**
  130284. * Oculus Touch Controller
  130285. */
  130286. export class OculusTouchController extends WebVRController {
  130287. /**
  130288. * Base Url for the controller model.
  130289. */
  130290. static MODEL_BASE_URL: string;
  130291. /**
  130292. * File name for the left controller model.
  130293. */
  130294. static MODEL_LEFT_FILENAME: string;
  130295. /**
  130296. * File name for the right controller model.
  130297. */
  130298. static MODEL_RIGHT_FILENAME: string;
  130299. /**
  130300. * Base Url for the Quest controller model.
  130301. */
  130302. static QUEST_MODEL_BASE_URL: string;
  130303. /**
  130304. * @hidden
  130305. * If the controllers are running on a device that needs the updated Quest controller models
  130306. */
  130307. static _IsQuest: boolean;
  130308. /**
  130309. * Fired when the secondary trigger on this controller is modified
  130310. */
  130311. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130312. /**
  130313. * Fired when the thumb rest on this controller is modified
  130314. */
  130315. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130316. /**
  130317. * Creates a new OculusTouchController from a gamepad
  130318. * @param vrGamepad the gamepad that the controller should be created from
  130319. */
  130320. constructor(vrGamepad: any);
  130321. /**
  130322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130323. * @param scene scene in which to add meshes
  130324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130325. */
  130326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130327. /**
  130328. * Fired when the A button on this controller is modified
  130329. */
  130330. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130331. /**
  130332. * Fired when the B button on this controller is modified
  130333. */
  130334. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130335. /**
  130336. * Fired when the X button on this controller is modified
  130337. */
  130338. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130339. /**
  130340. * Fired when the Y button on this controller is modified
  130341. */
  130342. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130343. /**
  130344. * Called once for each button that changed state since the last frame
  130345. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130346. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130347. * 2) secondary trigger (same)
  130348. * 3) A (right) X (left), touch, pressed = value
  130349. * 4) B / Y
  130350. * 5) thumb rest
  130351. * @param buttonIdx Which button index changed
  130352. * @param state New state of the button
  130353. * @param changes Which properties on the state changed since last frame
  130354. */
  130355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130356. }
  130357. }
  130358. declare module BABYLON {
  130359. /**
  130360. * Vive Controller
  130361. */
  130362. export class ViveController extends WebVRController {
  130363. /**
  130364. * Base Url for the controller model.
  130365. */
  130366. static MODEL_BASE_URL: string;
  130367. /**
  130368. * File name for the controller model.
  130369. */
  130370. static MODEL_FILENAME: string;
  130371. /**
  130372. * Creates a new ViveController from a gamepad
  130373. * @param vrGamepad the gamepad that the controller should be created from
  130374. */
  130375. constructor(vrGamepad: any);
  130376. /**
  130377. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130378. * @param scene scene in which to add meshes
  130379. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130380. */
  130381. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130382. /**
  130383. * Fired when the left button on this controller is modified
  130384. */
  130385. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130386. /**
  130387. * Fired when the right button on this controller is modified
  130388. */
  130389. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130390. /**
  130391. * Fired when the menu button on this controller is modified
  130392. */
  130393. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130394. /**
  130395. * Called once for each button that changed state since the last frame
  130396. * Vive mapping:
  130397. * 0: touchpad
  130398. * 1: trigger
  130399. * 2: left AND right buttons
  130400. * 3: menu button
  130401. * @param buttonIdx Which button index changed
  130402. * @param state New state of the button
  130403. * @param changes Which properties on the state changed since last frame
  130404. */
  130405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130406. }
  130407. }
  130408. declare module BABYLON {
  130409. /**
  130410. * Defines the WindowsMotionController object that the state of the windows motion controller
  130411. */
  130412. export class WindowsMotionController extends WebVRController {
  130413. /**
  130414. * The base url used to load the left and right controller models
  130415. */
  130416. static MODEL_BASE_URL: string;
  130417. /**
  130418. * The name of the left controller model file
  130419. */
  130420. static MODEL_LEFT_FILENAME: string;
  130421. /**
  130422. * The name of the right controller model file
  130423. */
  130424. static MODEL_RIGHT_FILENAME: string;
  130425. /**
  130426. * The controller name prefix for this controller type
  130427. */
  130428. static readonly GAMEPAD_ID_PREFIX: string;
  130429. /**
  130430. * The controller id pattern for this controller type
  130431. */
  130432. private static readonly GAMEPAD_ID_PATTERN;
  130433. private _loadedMeshInfo;
  130434. protected readonly _mapping: {
  130435. buttons: string[];
  130436. buttonMeshNames: {
  130437. trigger: string;
  130438. menu: string;
  130439. grip: string;
  130440. thumbstick: string;
  130441. trackpad: string;
  130442. };
  130443. buttonObservableNames: {
  130444. trigger: string;
  130445. menu: string;
  130446. grip: string;
  130447. thumbstick: string;
  130448. trackpad: string;
  130449. };
  130450. axisMeshNames: string[];
  130451. pointingPoseMeshName: string;
  130452. };
  130453. /**
  130454. * Fired when the trackpad on this controller is clicked
  130455. */
  130456. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130457. /**
  130458. * Fired when the trackpad on this controller is modified
  130459. */
  130460. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130461. /**
  130462. * The current x and y values of this controller's trackpad
  130463. */
  130464. trackpad: StickValues;
  130465. /**
  130466. * Creates a new WindowsMotionController from a gamepad
  130467. * @param vrGamepad the gamepad that the controller should be created from
  130468. */
  130469. constructor(vrGamepad: any);
  130470. /**
  130471. * Fired when the trigger on this controller is modified
  130472. */
  130473. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130474. /**
  130475. * Fired when the menu button on this controller is modified
  130476. */
  130477. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130478. /**
  130479. * Fired when the grip button on this controller is modified
  130480. */
  130481. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130482. /**
  130483. * Fired when the thumbstick button on this controller is modified
  130484. */
  130485. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130486. /**
  130487. * Fired when the touchpad button on this controller is modified
  130488. */
  130489. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130490. /**
  130491. * Fired when the touchpad values on this controller are modified
  130492. */
  130493. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130494. protected _updateTrackpad(): void;
  130495. /**
  130496. * Called once per frame by the engine.
  130497. */
  130498. update(): void;
  130499. /**
  130500. * Called once for each button that changed state since the last frame
  130501. * @param buttonIdx Which button index changed
  130502. * @param state New state of the button
  130503. * @param changes Which properties on the state changed since last frame
  130504. */
  130505. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130506. /**
  130507. * Moves the buttons on the controller mesh based on their current state
  130508. * @param buttonName the name of the button to move
  130509. * @param buttonValue the value of the button which determines the buttons new position
  130510. */
  130511. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130512. /**
  130513. * Moves the axis on the controller mesh based on its current state
  130514. * @param axis the index of the axis
  130515. * @param axisValue the value of the axis which determines the meshes new position
  130516. * @hidden
  130517. */
  130518. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130519. /**
  130520. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130521. * @param scene scene in which to add meshes
  130522. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130523. */
  130524. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130525. /**
  130526. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130527. * can be transformed by button presses and axes values, based on this._mapping.
  130528. *
  130529. * @param scene scene in which the meshes exist
  130530. * @param meshes list of meshes that make up the controller model to process
  130531. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130532. */
  130533. private processModel;
  130534. private createMeshInfo;
  130535. /**
  130536. * Gets the ray of the controller in the direction the controller is pointing
  130537. * @param length the length the resulting ray should be
  130538. * @returns a ray in the direction the controller is pointing
  130539. */
  130540. getForwardRay(length?: number): Ray;
  130541. /**
  130542. * Disposes of the controller
  130543. */
  130544. dispose(): void;
  130545. }
  130546. /**
  130547. * This class represents a new windows motion controller in XR.
  130548. */
  130549. export class XRWindowsMotionController extends WindowsMotionController {
  130550. /**
  130551. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130552. */
  130553. protected readonly _mapping: {
  130554. buttons: string[];
  130555. buttonMeshNames: {
  130556. trigger: string;
  130557. menu: string;
  130558. grip: string;
  130559. thumbstick: string;
  130560. trackpad: string;
  130561. };
  130562. buttonObservableNames: {
  130563. trigger: string;
  130564. menu: string;
  130565. grip: string;
  130566. thumbstick: string;
  130567. trackpad: string;
  130568. };
  130569. axisMeshNames: string[];
  130570. pointingPoseMeshName: string;
  130571. };
  130572. /**
  130573. * Construct a new XR-Based windows motion controller
  130574. *
  130575. * @param gamepadInfo the gamepad object from the browser
  130576. */
  130577. constructor(gamepadInfo: any);
  130578. /**
  130579. * holds the thumbstick values (X,Y)
  130580. */
  130581. thumbstickValues: StickValues;
  130582. /**
  130583. * Fired when the thumbstick on this controller is clicked
  130584. */
  130585. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130586. /**
  130587. * Fired when the thumbstick on this controller is modified
  130588. */
  130589. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130590. /**
  130591. * Fired when the touchpad button on this controller is modified
  130592. */
  130593. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130594. /**
  130595. * Fired when the touchpad values on this controller are modified
  130596. */
  130597. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130598. /**
  130599. * Fired when the thumbstick button on this controller is modified
  130600. * here to prevent breaking changes
  130601. */
  130602. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130603. /**
  130604. * updating the thumbstick(!) and not the trackpad.
  130605. * This is named this way due to the difference between WebVR and XR and to avoid
  130606. * changing the parent class.
  130607. */
  130608. protected _updateTrackpad(): void;
  130609. /**
  130610. * Disposes the class with joy
  130611. */
  130612. dispose(): void;
  130613. }
  130614. }
  130615. declare module BABYLON {
  130616. /**
  130617. * Class containing static functions to help procedurally build meshes
  130618. */
  130619. export class PolyhedronBuilder {
  130620. /**
  130621. * Creates a polyhedron mesh
  130622. * * 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
  130623. * * The parameter `size` (positive float, default 1) sets the polygon size
  130624. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130625. * * 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`
  130626. * * 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
  130627. * * 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)`)
  130628. * * 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
  130629. * * 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
  130630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130633. * @param name defines the name of the mesh
  130634. * @param options defines the options used to create the mesh
  130635. * @param scene defines the hosting scene
  130636. * @returns the polyhedron mesh
  130637. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130638. */
  130639. static CreatePolyhedron(name: string, options: {
  130640. type?: number;
  130641. size?: number;
  130642. sizeX?: number;
  130643. sizeY?: number;
  130644. sizeZ?: number;
  130645. custom?: any;
  130646. faceUV?: Vector4[];
  130647. faceColors?: Color4[];
  130648. flat?: boolean;
  130649. updatable?: boolean;
  130650. sideOrientation?: number;
  130651. frontUVs?: Vector4;
  130652. backUVs?: Vector4;
  130653. }, scene?: Nullable<Scene>): Mesh;
  130654. }
  130655. }
  130656. declare module BABYLON {
  130657. /**
  130658. * Gizmo that enables scaling a mesh along 3 axis
  130659. */
  130660. export class ScaleGizmo extends Gizmo {
  130661. /**
  130662. * Internal gizmo used for interactions on the x axis
  130663. */
  130664. xGizmo: AxisScaleGizmo;
  130665. /**
  130666. * Internal gizmo used for interactions on the y axis
  130667. */
  130668. yGizmo: AxisScaleGizmo;
  130669. /**
  130670. * Internal gizmo used for interactions on the z axis
  130671. */
  130672. zGizmo: AxisScaleGizmo;
  130673. /**
  130674. * Internal gizmo used to scale all axis equally
  130675. */
  130676. uniformScaleGizmo: AxisScaleGizmo;
  130677. private _meshAttached;
  130678. private _updateGizmoRotationToMatchAttachedMesh;
  130679. private _snapDistance;
  130680. private _scaleRatio;
  130681. private _uniformScalingMesh;
  130682. private _octahedron;
  130683. private _sensitivity;
  130684. /** Fires an event when any of it's sub gizmos are dragged */
  130685. onDragStartObservable: Observable<unknown>;
  130686. /** Fires an event when any of it's sub gizmos are released from dragging */
  130687. onDragEndObservable: Observable<unknown>;
  130688. get attachedMesh(): Nullable<AbstractMesh>;
  130689. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130690. /**
  130691. * Creates a ScaleGizmo
  130692. * @param gizmoLayer The utility layer the gizmo will be added to
  130693. */
  130694. constructor(gizmoLayer?: UtilityLayerRenderer);
  130695. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130696. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130697. /**
  130698. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130699. */
  130700. set snapDistance(value: number);
  130701. get snapDistance(): number;
  130702. /**
  130703. * Ratio for the scale of the gizmo (Default: 1)
  130704. */
  130705. set scaleRatio(value: number);
  130706. get scaleRatio(): number;
  130707. /**
  130708. * Sensitivity factor for dragging (Default: 1)
  130709. */
  130710. set sensitivity(value: number);
  130711. get sensitivity(): number;
  130712. /**
  130713. * Disposes of the gizmo
  130714. */
  130715. dispose(): void;
  130716. }
  130717. }
  130718. declare module BABYLON {
  130719. /**
  130720. * Single axis scale gizmo
  130721. */
  130722. export class AxisScaleGizmo extends Gizmo {
  130723. /**
  130724. * Drag behavior responsible for the gizmos dragging interactions
  130725. */
  130726. dragBehavior: PointerDragBehavior;
  130727. private _pointerObserver;
  130728. /**
  130729. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130730. */
  130731. snapDistance: number;
  130732. /**
  130733. * Event that fires each time the gizmo snaps to a new location.
  130734. * * snapDistance is the the change in distance
  130735. */
  130736. onSnapObservable: Observable<{
  130737. snapDistance: number;
  130738. }>;
  130739. /**
  130740. * If the scaling operation should be done on all axis (default: false)
  130741. */
  130742. uniformScaling: boolean;
  130743. /**
  130744. * Custom sensitivity value for the drag strength
  130745. */
  130746. sensitivity: number;
  130747. private _isEnabled;
  130748. private _parent;
  130749. private _arrow;
  130750. private _coloredMaterial;
  130751. private _hoverMaterial;
  130752. /**
  130753. * Creates an AxisScaleGizmo
  130754. * @param gizmoLayer The utility layer the gizmo will be added to
  130755. * @param dragAxis The axis which the gizmo will be able to scale on
  130756. * @param color The color of the gizmo
  130757. */
  130758. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130759. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130760. /**
  130761. * If the gizmo is enabled
  130762. */
  130763. set isEnabled(value: boolean);
  130764. get isEnabled(): boolean;
  130765. /**
  130766. * Disposes of the gizmo
  130767. */
  130768. dispose(): void;
  130769. /**
  130770. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130771. * @param mesh The mesh to replace the default mesh of the gizmo
  130772. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130773. */
  130774. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130775. }
  130776. }
  130777. declare module BABYLON {
  130778. /**
  130779. * Bounding box gizmo
  130780. */
  130781. export class BoundingBoxGizmo extends Gizmo {
  130782. private _lineBoundingBox;
  130783. private _rotateSpheresParent;
  130784. private _scaleBoxesParent;
  130785. private _boundingDimensions;
  130786. private _renderObserver;
  130787. private _pointerObserver;
  130788. private _scaleDragSpeed;
  130789. private _tmpQuaternion;
  130790. private _tmpVector;
  130791. private _tmpRotationMatrix;
  130792. /**
  130793. * 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)
  130794. */
  130795. ignoreChildren: boolean;
  130796. /**
  130797. * 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)
  130798. */
  130799. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130800. /**
  130801. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130802. */
  130803. rotationSphereSize: number;
  130804. /**
  130805. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130806. */
  130807. scaleBoxSize: number;
  130808. /**
  130809. * 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)
  130810. */
  130811. fixedDragMeshScreenSize: boolean;
  130812. /**
  130813. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130814. */
  130815. fixedDragMeshScreenSizeDistanceFactor: number;
  130816. /**
  130817. * Fired when a rotation sphere or scale box is dragged
  130818. */
  130819. onDragStartObservable: Observable<{}>;
  130820. /**
  130821. * Fired when a scale box is dragged
  130822. */
  130823. onScaleBoxDragObservable: Observable<{}>;
  130824. /**
  130825. * Fired when a scale box drag is ended
  130826. */
  130827. onScaleBoxDragEndObservable: Observable<{}>;
  130828. /**
  130829. * Fired when a rotation sphere is dragged
  130830. */
  130831. onRotationSphereDragObservable: Observable<{}>;
  130832. /**
  130833. * Fired when a rotation sphere drag is ended
  130834. */
  130835. onRotationSphereDragEndObservable: Observable<{}>;
  130836. /**
  130837. * Relative bounding box pivot used when scaling the attached mesh. 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)
  130838. */
  130839. scalePivot: Nullable<Vector3>;
  130840. /**
  130841. * Mesh used as a pivot to rotate the attached mesh
  130842. */
  130843. private _anchorMesh;
  130844. private _existingMeshScale;
  130845. private _dragMesh;
  130846. private pointerDragBehavior;
  130847. private coloredMaterial;
  130848. private hoverColoredMaterial;
  130849. /**
  130850. * Sets the color of the bounding box gizmo
  130851. * @param color the color to set
  130852. */
  130853. setColor(color: Color3): void;
  130854. /**
  130855. * Creates an BoundingBoxGizmo
  130856. * @param gizmoLayer The utility layer the gizmo will be added to
  130857. * @param color The color of the gizmo
  130858. */
  130859. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130861. private _selectNode;
  130862. /**
  130863. * Updates the bounding box information for the Gizmo
  130864. */
  130865. updateBoundingBox(): void;
  130866. private _updateRotationSpheres;
  130867. private _updateScaleBoxes;
  130868. /**
  130869. * Enables rotation on the specified axis and disables rotation on the others
  130870. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130871. */
  130872. setEnabledRotationAxis(axis: string): void;
  130873. /**
  130874. * Enables/disables scaling
  130875. * @param enable if scaling should be enabled
  130876. * @param homogeneousScaling defines if scaling should only be homogeneous
  130877. */
  130878. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130879. private _updateDummy;
  130880. /**
  130881. * Enables a pointer drag behavior on the bounding box of the gizmo
  130882. */
  130883. enableDragBehavior(): void;
  130884. /**
  130885. * Disposes of the gizmo
  130886. */
  130887. dispose(): void;
  130888. /**
  130889. * 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)
  130890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130891. * @returns the bounding box mesh with the passed in mesh as a child
  130892. */
  130893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130894. /**
  130895. * CustomMeshes are not supported by this gizmo
  130896. * @param mesh The mesh to replace the default mesh of the gizmo
  130897. */
  130898. setCustomMesh(mesh: Mesh): void;
  130899. }
  130900. }
  130901. declare module BABYLON {
  130902. /**
  130903. * Single plane rotation gizmo
  130904. */
  130905. export class PlaneRotationGizmo extends Gizmo {
  130906. /**
  130907. * Drag behavior responsible for the gizmos dragging interactions
  130908. */
  130909. dragBehavior: PointerDragBehavior;
  130910. private _pointerObserver;
  130911. /**
  130912. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130913. */
  130914. snapDistance: number;
  130915. /**
  130916. * Event that fires each time the gizmo snaps to a new location.
  130917. * * snapDistance is the the change in distance
  130918. */
  130919. onSnapObservable: Observable<{
  130920. snapDistance: number;
  130921. }>;
  130922. private _isEnabled;
  130923. private _parent;
  130924. /**
  130925. * Creates a PlaneRotationGizmo
  130926. * @param gizmoLayer The utility layer the gizmo will be added to
  130927. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130928. * @param color The color of the gizmo
  130929. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130930. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130931. */
  130932. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130934. /**
  130935. * If the gizmo is enabled
  130936. */
  130937. set isEnabled(value: boolean);
  130938. get isEnabled(): boolean;
  130939. /**
  130940. * Disposes of the gizmo
  130941. */
  130942. dispose(): void;
  130943. }
  130944. }
  130945. declare module BABYLON {
  130946. /**
  130947. * Gizmo that enables rotating a mesh along 3 axis
  130948. */
  130949. export class RotationGizmo extends Gizmo {
  130950. /**
  130951. * Internal gizmo used for interactions on the x axis
  130952. */
  130953. xGizmo: PlaneRotationGizmo;
  130954. /**
  130955. * Internal gizmo used for interactions on the y axis
  130956. */
  130957. yGizmo: PlaneRotationGizmo;
  130958. /**
  130959. * Internal gizmo used for interactions on the z axis
  130960. */
  130961. zGizmo: PlaneRotationGizmo;
  130962. /** Fires an event when any of it's sub gizmos are dragged */
  130963. onDragStartObservable: Observable<unknown>;
  130964. /** Fires an event when any of it's sub gizmos are released from dragging */
  130965. onDragEndObservable: Observable<unknown>;
  130966. private _meshAttached;
  130967. get attachedMesh(): Nullable<AbstractMesh>;
  130968. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130969. /**
  130970. * Creates a RotationGizmo
  130971. * @param gizmoLayer The utility layer the gizmo will be added to
  130972. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130973. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130974. */
  130975. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130976. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130977. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130978. /**
  130979. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130980. */
  130981. set snapDistance(value: number);
  130982. get snapDistance(): number;
  130983. /**
  130984. * Ratio for the scale of the gizmo (Default: 1)
  130985. */
  130986. set scaleRatio(value: number);
  130987. get scaleRatio(): number;
  130988. /**
  130989. * Disposes of the gizmo
  130990. */
  130991. dispose(): void;
  130992. /**
  130993. * CustomMeshes are not supported by this gizmo
  130994. * @param mesh The mesh to replace the default mesh of the gizmo
  130995. */
  130996. setCustomMesh(mesh: Mesh): void;
  130997. }
  130998. }
  130999. declare module BABYLON {
  131000. /**
  131001. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131002. */
  131003. export class GizmoManager implements IDisposable {
  131004. private scene;
  131005. /**
  131006. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131007. */
  131008. gizmos: {
  131009. positionGizmo: Nullable<PositionGizmo>;
  131010. rotationGizmo: Nullable<RotationGizmo>;
  131011. scaleGizmo: Nullable<ScaleGizmo>;
  131012. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131013. };
  131014. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131015. clearGizmoOnEmptyPointerEvent: boolean;
  131016. /** Fires an event when the manager is attached to a mesh */
  131017. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131018. private _gizmosEnabled;
  131019. private _pointerObserver;
  131020. private _attachedMesh;
  131021. private _boundingBoxColor;
  131022. private _defaultUtilityLayer;
  131023. private _defaultKeepDepthUtilityLayer;
  131024. /**
  131025. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131026. */
  131027. boundingBoxDragBehavior: SixDofDragBehavior;
  131028. /**
  131029. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131030. */
  131031. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131032. /**
  131033. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131034. */
  131035. usePointerToAttachGizmos: boolean;
  131036. /**
  131037. * Utility layer that the bounding box gizmo belongs to
  131038. */
  131039. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131040. /**
  131041. * Utility layer that all gizmos besides bounding box belong to
  131042. */
  131043. get utilityLayer(): UtilityLayerRenderer;
  131044. /**
  131045. * Instatiates a gizmo manager
  131046. * @param scene the scene to overlay the gizmos on top of
  131047. */
  131048. constructor(scene: Scene);
  131049. /**
  131050. * Attaches a set of gizmos to the specified mesh
  131051. * @param mesh The mesh the gizmo's should be attached to
  131052. */
  131053. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131054. /**
  131055. * If the position gizmo is enabled
  131056. */
  131057. set positionGizmoEnabled(value: boolean);
  131058. get positionGizmoEnabled(): boolean;
  131059. /**
  131060. * If the rotation gizmo is enabled
  131061. */
  131062. set rotationGizmoEnabled(value: boolean);
  131063. get rotationGizmoEnabled(): boolean;
  131064. /**
  131065. * If the scale gizmo is enabled
  131066. */
  131067. set scaleGizmoEnabled(value: boolean);
  131068. get scaleGizmoEnabled(): boolean;
  131069. /**
  131070. * If the boundingBox gizmo is enabled
  131071. */
  131072. set boundingBoxGizmoEnabled(value: boolean);
  131073. get boundingBoxGizmoEnabled(): boolean;
  131074. /**
  131075. * Disposes of the gizmo manager
  131076. */
  131077. dispose(): void;
  131078. }
  131079. }
  131080. declare module BABYLON {
  131081. /**
  131082. * A directional light is defined by a direction (what a surprise!).
  131083. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131084. * 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.
  131085. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131086. */
  131087. export class DirectionalLight extends ShadowLight {
  131088. private _shadowFrustumSize;
  131089. /**
  131090. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131091. */
  131092. get shadowFrustumSize(): number;
  131093. /**
  131094. * Specifies a fix frustum size for the shadow generation.
  131095. */
  131096. set shadowFrustumSize(value: number);
  131097. private _shadowOrthoScale;
  131098. /**
  131099. * Gets the shadow projection scale against the optimal computed one.
  131100. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131101. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131102. */
  131103. get shadowOrthoScale(): number;
  131104. /**
  131105. * Sets the shadow projection scale against the optimal computed one.
  131106. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131107. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131108. */
  131109. set shadowOrthoScale(value: number);
  131110. /**
  131111. * Automatically compute the projection matrix to best fit (including all the casters)
  131112. * on each frame.
  131113. */
  131114. autoUpdateExtends: boolean;
  131115. /**
  131116. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131117. * on each frame. autoUpdateExtends must be set to true for this to work
  131118. */
  131119. autoCalcShadowZBounds: boolean;
  131120. private _orthoLeft;
  131121. private _orthoRight;
  131122. private _orthoTop;
  131123. private _orthoBottom;
  131124. /**
  131125. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131126. * The directional light is emitted from everywhere in the given direction.
  131127. * It can cast shadows.
  131128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131129. * @param name The friendly name of the light
  131130. * @param direction The direction of the light
  131131. * @param scene The scene the light belongs to
  131132. */
  131133. constructor(name: string, direction: Vector3, scene: Scene);
  131134. /**
  131135. * Returns the string "DirectionalLight".
  131136. * @return The class name
  131137. */
  131138. getClassName(): string;
  131139. /**
  131140. * Returns the integer 1.
  131141. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131142. */
  131143. getTypeID(): number;
  131144. /**
  131145. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131146. * Returns the DirectionalLight Shadow projection matrix.
  131147. */
  131148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131149. /**
  131150. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131151. * Returns the DirectionalLight Shadow projection matrix.
  131152. */
  131153. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131154. /**
  131155. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131156. * Returns the DirectionalLight Shadow projection matrix.
  131157. */
  131158. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131159. protected _buildUniformLayout(): void;
  131160. /**
  131161. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131162. * @param effect The effect to update
  131163. * @param lightIndex The index of the light in the effect to update
  131164. * @returns The directional light
  131165. */
  131166. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131167. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131168. /**
  131169. * Gets the minZ used for shadow according to both the scene and the light.
  131170. *
  131171. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131172. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131173. * @param activeCamera The camera we are returning the min for
  131174. * @returns the depth min z
  131175. */
  131176. getDepthMinZ(activeCamera: Camera): number;
  131177. /**
  131178. * Gets the maxZ used for shadow according to both the scene and the light.
  131179. *
  131180. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131181. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131182. * @param activeCamera The camera we are returning the max for
  131183. * @returns the depth max z
  131184. */
  131185. getDepthMaxZ(activeCamera: Camera): number;
  131186. /**
  131187. * Prepares the list of defines specific to the light type.
  131188. * @param defines the list of defines
  131189. * @param lightIndex defines the index of the light for the effect
  131190. */
  131191. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131192. }
  131193. }
  131194. declare module BABYLON {
  131195. /**
  131196. * Class containing static functions to help procedurally build meshes
  131197. */
  131198. export class HemisphereBuilder {
  131199. /**
  131200. * Creates a hemisphere mesh
  131201. * @param name defines the name of the mesh
  131202. * @param options defines the options used to create the mesh
  131203. * @param scene defines the hosting scene
  131204. * @returns the hemisphere mesh
  131205. */
  131206. static CreateHemisphere(name: string, options: {
  131207. segments?: number;
  131208. diameter?: number;
  131209. sideOrientation?: number;
  131210. }, scene: any): Mesh;
  131211. }
  131212. }
  131213. declare module BABYLON {
  131214. /**
  131215. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131216. * These values define a cone of light starting from the position, emitting toward the direction.
  131217. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131218. * and the exponent defines the speed of the decay of the light with distance (reach).
  131219. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131220. */
  131221. export class SpotLight extends ShadowLight {
  131222. private _angle;
  131223. private _innerAngle;
  131224. private _cosHalfAngle;
  131225. private _lightAngleScale;
  131226. private _lightAngleOffset;
  131227. /**
  131228. * Gets the cone angle of the spot light in Radians.
  131229. */
  131230. get angle(): number;
  131231. /**
  131232. * Sets the cone angle of the spot light in Radians.
  131233. */
  131234. set angle(value: number);
  131235. /**
  131236. * Only used in gltf falloff mode, this defines the angle where
  131237. * the directional falloff will start before cutting at angle which could be seen
  131238. * as outer angle.
  131239. */
  131240. get innerAngle(): number;
  131241. /**
  131242. * Only used in gltf falloff mode, this defines the angle where
  131243. * the directional falloff will start before cutting at angle which could be seen
  131244. * as outer angle.
  131245. */
  131246. set innerAngle(value: number);
  131247. private _shadowAngleScale;
  131248. /**
  131249. * Allows scaling the angle of the light for shadow generation only.
  131250. */
  131251. get shadowAngleScale(): number;
  131252. /**
  131253. * Allows scaling the angle of the light for shadow generation only.
  131254. */
  131255. set shadowAngleScale(value: number);
  131256. /**
  131257. * The light decay speed with the distance from the emission spot.
  131258. */
  131259. exponent: number;
  131260. private _projectionTextureMatrix;
  131261. /**
  131262. * Allows reading the projecton texture
  131263. */
  131264. get projectionTextureMatrix(): Matrix;
  131265. protected _projectionTextureLightNear: number;
  131266. /**
  131267. * Gets the near clip of the Spotlight for texture projection.
  131268. */
  131269. get projectionTextureLightNear(): number;
  131270. /**
  131271. * Sets the near clip of the Spotlight for texture projection.
  131272. */
  131273. set projectionTextureLightNear(value: number);
  131274. protected _projectionTextureLightFar: number;
  131275. /**
  131276. * Gets the far clip of the Spotlight for texture projection.
  131277. */
  131278. get projectionTextureLightFar(): number;
  131279. /**
  131280. * Sets the far clip of the Spotlight for texture projection.
  131281. */
  131282. set projectionTextureLightFar(value: number);
  131283. protected _projectionTextureUpDirection: Vector3;
  131284. /**
  131285. * Gets the Up vector of the Spotlight for texture projection.
  131286. */
  131287. get projectionTextureUpDirection(): Vector3;
  131288. /**
  131289. * Sets the Up vector of the Spotlight for texture projection.
  131290. */
  131291. set projectionTextureUpDirection(value: Vector3);
  131292. private _projectionTexture;
  131293. /**
  131294. * Gets the projection texture of the light.
  131295. */
  131296. get projectionTexture(): Nullable<BaseTexture>;
  131297. /**
  131298. * Sets the projection texture of the light.
  131299. */
  131300. set projectionTexture(value: Nullable<BaseTexture>);
  131301. private _projectionTextureViewLightDirty;
  131302. private _projectionTextureProjectionLightDirty;
  131303. private _projectionTextureDirty;
  131304. private _projectionTextureViewTargetVector;
  131305. private _projectionTextureViewLightMatrix;
  131306. private _projectionTextureProjectionLightMatrix;
  131307. private _projectionTextureScalingMatrix;
  131308. /**
  131309. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131310. * It can cast shadows.
  131311. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131312. * @param name The light friendly name
  131313. * @param position The position of the spot light in the scene
  131314. * @param direction The direction of the light in the scene
  131315. * @param angle The cone angle of the light in Radians
  131316. * @param exponent The light decay speed with the distance from the emission spot
  131317. * @param scene The scene the lights belongs to
  131318. */
  131319. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131320. /**
  131321. * Returns the string "SpotLight".
  131322. * @returns the class name
  131323. */
  131324. getClassName(): string;
  131325. /**
  131326. * Returns the integer 2.
  131327. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131328. */
  131329. getTypeID(): number;
  131330. /**
  131331. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131332. */
  131333. protected _setDirection(value: Vector3): void;
  131334. /**
  131335. * Overrides the position setter to recompute the projection texture view light Matrix.
  131336. */
  131337. protected _setPosition(value: Vector3): void;
  131338. /**
  131339. * 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.
  131340. * Returns the SpotLight.
  131341. */
  131342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131343. protected _computeProjectionTextureViewLightMatrix(): void;
  131344. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131345. /**
  131346. * Main function for light texture projection matrix computing.
  131347. */
  131348. protected _computeProjectionTextureMatrix(): void;
  131349. protected _buildUniformLayout(): void;
  131350. private _computeAngleValues;
  131351. /**
  131352. * Sets the passed Effect "effect" with the Light textures.
  131353. * @param effect The effect to update
  131354. * @param lightIndex The index of the light in the effect to update
  131355. * @returns The light
  131356. */
  131357. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131358. /**
  131359. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131360. * @param effect The effect to update
  131361. * @param lightIndex The index of the light in the effect to update
  131362. * @returns The spot light
  131363. */
  131364. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131365. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131366. /**
  131367. * Disposes the light and the associated resources.
  131368. */
  131369. dispose(): void;
  131370. /**
  131371. * Prepares the list of defines specific to the light type.
  131372. * @param defines the list of defines
  131373. * @param lightIndex defines the index of the light for the effect
  131374. */
  131375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131376. }
  131377. }
  131378. declare module BABYLON {
  131379. /**
  131380. * Gizmo that enables viewing a light
  131381. */
  131382. export class LightGizmo extends Gizmo {
  131383. private _lightMesh;
  131384. private _material;
  131385. private _cachedPosition;
  131386. private _cachedForward;
  131387. private _attachedMeshParent;
  131388. /**
  131389. * Creates a LightGizmo
  131390. * @param gizmoLayer The utility layer the gizmo will be added to
  131391. */
  131392. constructor(gizmoLayer?: UtilityLayerRenderer);
  131393. private _light;
  131394. /**
  131395. * The light that the gizmo is attached to
  131396. */
  131397. set light(light: Nullable<Light>);
  131398. get light(): Nullable<Light>;
  131399. /**
  131400. * Gets the material used to render the light gizmo
  131401. */
  131402. get material(): StandardMaterial;
  131403. /**
  131404. * @hidden
  131405. * Updates the gizmo to match the attached mesh's position/rotation
  131406. */
  131407. protected _update(): void;
  131408. private static _Scale;
  131409. /**
  131410. * Creates the lines for a light mesh
  131411. */
  131412. private static _CreateLightLines;
  131413. /**
  131414. * Disposes of the light gizmo
  131415. */
  131416. dispose(): void;
  131417. private static _CreateHemisphericLightMesh;
  131418. private static _CreatePointLightMesh;
  131419. private static _CreateSpotLightMesh;
  131420. private static _CreateDirectionalLightMesh;
  131421. }
  131422. }
  131423. declare module BABYLON {
  131424. /** @hidden */
  131425. export var backgroundFragmentDeclaration: {
  131426. name: string;
  131427. shader: string;
  131428. };
  131429. }
  131430. declare module BABYLON {
  131431. /** @hidden */
  131432. export var backgroundUboDeclaration: {
  131433. name: string;
  131434. shader: string;
  131435. };
  131436. }
  131437. declare module BABYLON {
  131438. /** @hidden */
  131439. export var backgroundPixelShader: {
  131440. name: string;
  131441. shader: string;
  131442. };
  131443. }
  131444. declare module BABYLON {
  131445. /** @hidden */
  131446. export var backgroundVertexDeclaration: {
  131447. name: string;
  131448. shader: string;
  131449. };
  131450. }
  131451. declare module BABYLON {
  131452. /** @hidden */
  131453. export var backgroundVertexShader: {
  131454. name: string;
  131455. shader: string;
  131456. };
  131457. }
  131458. declare module BABYLON {
  131459. /**
  131460. * Background material used to create an efficient environement around your scene.
  131461. */
  131462. export class BackgroundMaterial extends PushMaterial {
  131463. /**
  131464. * Standard reflectance value at parallel view angle.
  131465. */
  131466. static StandardReflectance0: number;
  131467. /**
  131468. * Standard reflectance value at grazing angle.
  131469. */
  131470. static StandardReflectance90: number;
  131471. protected _primaryColor: Color3;
  131472. /**
  131473. * Key light Color (multiply against the environement texture)
  131474. */
  131475. primaryColor: Color3;
  131476. protected __perceptualColor: Nullable<Color3>;
  131477. /**
  131478. * Experimental Internal Use Only.
  131479. *
  131480. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131481. * This acts as a helper to set the primary color to a more "human friendly" value.
  131482. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131483. * output color as close as possible from the chosen value.
  131484. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131485. * part of lighting setup.)
  131486. */
  131487. get _perceptualColor(): Nullable<Color3>;
  131488. set _perceptualColor(value: Nullable<Color3>);
  131489. protected _primaryColorShadowLevel: float;
  131490. /**
  131491. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131492. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131493. */
  131494. get primaryColorShadowLevel(): float;
  131495. set primaryColorShadowLevel(value: float);
  131496. protected _primaryColorHighlightLevel: float;
  131497. /**
  131498. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131499. * The primary color is used at the level chosen to define what the white area would look.
  131500. */
  131501. get primaryColorHighlightLevel(): float;
  131502. set primaryColorHighlightLevel(value: float);
  131503. protected _reflectionTexture: Nullable<BaseTexture>;
  131504. /**
  131505. * Reflection Texture used in the material.
  131506. * Should be author in a specific way for the best result (refer to the documentation).
  131507. */
  131508. reflectionTexture: Nullable<BaseTexture>;
  131509. protected _reflectionBlur: float;
  131510. /**
  131511. * Reflection Texture level of blur.
  131512. *
  131513. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131514. * texture twice.
  131515. */
  131516. reflectionBlur: float;
  131517. protected _diffuseTexture: Nullable<BaseTexture>;
  131518. /**
  131519. * Diffuse Texture used in the material.
  131520. * Should be author in a specific way for the best result (refer to the documentation).
  131521. */
  131522. diffuseTexture: Nullable<BaseTexture>;
  131523. protected _shadowLights: Nullable<IShadowLight[]>;
  131524. /**
  131525. * Specify the list of lights casting shadow on the material.
  131526. * All scene shadow lights will be included if null.
  131527. */
  131528. shadowLights: Nullable<IShadowLight[]>;
  131529. protected _shadowLevel: float;
  131530. /**
  131531. * Helps adjusting the shadow to a softer level if required.
  131532. * 0 means black shadows and 1 means no shadows.
  131533. */
  131534. shadowLevel: float;
  131535. protected _sceneCenter: Vector3;
  131536. /**
  131537. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131538. * It is usually zero but might be interesting to modify according to your setup.
  131539. */
  131540. sceneCenter: Vector3;
  131541. protected _opacityFresnel: boolean;
  131542. /**
  131543. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131544. * This helps ensuring a nice transition when the camera goes under the ground.
  131545. */
  131546. opacityFresnel: boolean;
  131547. protected _reflectionFresnel: boolean;
  131548. /**
  131549. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131550. * This helps adding a mirror texture on the ground.
  131551. */
  131552. reflectionFresnel: boolean;
  131553. protected _reflectionFalloffDistance: number;
  131554. /**
  131555. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131556. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131557. */
  131558. reflectionFalloffDistance: number;
  131559. protected _reflectionAmount: number;
  131560. /**
  131561. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131562. */
  131563. reflectionAmount: number;
  131564. protected _reflectionReflectance0: number;
  131565. /**
  131566. * This specifies the weight of the reflection at grazing angle.
  131567. */
  131568. reflectionReflectance0: number;
  131569. protected _reflectionReflectance90: number;
  131570. /**
  131571. * This specifies the weight of the reflection at a perpendicular point of view.
  131572. */
  131573. reflectionReflectance90: number;
  131574. /**
  131575. * Sets the reflection reflectance fresnel values according to the default standard
  131576. * empirically know to work well :-)
  131577. */
  131578. set reflectionStandardFresnelWeight(value: number);
  131579. protected _useRGBColor: boolean;
  131580. /**
  131581. * Helps to directly use the maps channels instead of their level.
  131582. */
  131583. useRGBColor: boolean;
  131584. protected _enableNoise: boolean;
  131585. /**
  131586. * This helps reducing the banding effect that could occur on the background.
  131587. */
  131588. enableNoise: boolean;
  131589. /**
  131590. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131591. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131592. * Recommended to be keep at 1.0 except for special cases.
  131593. */
  131594. get fovMultiplier(): number;
  131595. set fovMultiplier(value: number);
  131596. private _fovMultiplier;
  131597. /**
  131598. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131599. */
  131600. useEquirectangularFOV: boolean;
  131601. private _maxSimultaneousLights;
  131602. /**
  131603. * Number of Simultaneous lights allowed on the material.
  131604. */
  131605. maxSimultaneousLights: int;
  131606. private _shadowOnly;
  131607. /**
  131608. * Make the material only render shadows
  131609. */
  131610. shadowOnly: boolean;
  131611. /**
  131612. * Default configuration related to image processing available in the Background Material.
  131613. */
  131614. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131615. /**
  131616. * Keep track of the image processing observer to allow dispose and replace.
  131617. */
  131618. private _imageProcessingObserver;
  131619. /**
  131620. * Attaches a new image processing configuration to the PBR Material.
  131621. * @param configuration (if null the scene configuration will be use)
  131622. */
  131623. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131624. /**
  131625. * Gets the image processing configuration used either in this material.
  131626. */
  131627. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131628. /**
  131629. * Sets the Default image processing configuration used either in the this material.
  131630. *
  131631. * If sets to null, the scene one is in use.
  131632. */
  131633. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131634. /**
  131635. * Gets wether the color curves effect is enabled.
  131636. */
  131637. get cameraColorCurvesEnabled(): boolean;
  131638. /**
  131639. * Sets wether the color curves effect is enabled.
  131640. */
  131641. set cameraColorCurvesEnabled(value: boolean);
  131642. /**
  131643. * Gets wether the color grading effect is enabled.
  131644. */
  131645. get cameraColorGradingEnabled(): boolean;
  131646. /**
  131647. * Gets wether the color grading effect is enabled.
  131648. */
  131649. set cameraColorGradingEnabled(value: boolean);
  131650. /**
  131651. * Gets wether tonemapping is enabled or not.
  131652. */
  131653. get cameraToneMappingEnabled(): boolean;
  131654. /**
  131655. * Sets wether tonemapping is enabled or not
  131656. */
  131657. set cameraToneMappingEnabled(value: boolean);
  131658. /**
  131659. * The camera exposure used on this material.
  131660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131661. * This corresponds to a photographic exposure.
  131662. */
  131663. get cameraExposure(): float;
  131664. /**
  131665. * The camera exposure used on this material.
  131666. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131667. * This corresponds to a photographic exposure.
  131668. */
  131669. set cameraExposure(value: float);
  131670. /**
  131671. * Gets The camera contrast used on this material.
  131672. */
  131673. get cameraContrast(): float;
  131674. /**
  131675. * Sets The camera contrast used on this material.
  131676. */
  131677. set cameraContrast(value: float);
  131678. /**
  131679. * Gets the Color Grading 2D Lookup Texture.
  131680. */
  131681. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131682. /**
  131683. * Sets the Color Grading 2D Lookup Texture.
  131684. */
  131685. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131686. /**
  131687. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131688. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131689. * 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;
  131690. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131691. */
  131692. get cameraColorCurves(): Nullable<ColorCurves>;
  131693. /**
  131694. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131695. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131696. * 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;
  131697. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131698. */
  131699. set cameraColorCurves(value: Nullable<ColorCurves>);
  131700. /**
  131701. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131702. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131703. */
  131704. switchToBGR: boolean;
  131705. private _renderTargets;
  131706. private _reflectionControls;
  131707. private _white;
  131708. private _primaryShadowColor;
  131709. private _primaryHighlightColor;
  131710. /**
  131711. * Instantiates a Background Material in the given scene
  131712. * @param name The friendly name of the material
  131713. * @param scene The scene to add the material to
  131714. */
  131715. constructor(name: string, scene: Scene);
  131716. /**
  131717. * Gets a boolean indicating that current material needs to register RTT
  131718. */
  131719. get hasRenderTargetTextures(): boolean;
  131720. /**
  131721. * The entire material has been created in order to prevent overdraw.
  131722. * @returns false
  131723. */
  131724. needAlphaTesting(): boolean;
  131725. /**
  131726. * The entire material has been created in order to prevent overdraw.
  131727. * @returns true if blending is enable
  131728. */
  131729. needAlphaBlending(): boolean;
  131730. /**
  131731. * Checks wether the material is ready to be rendered for a given mesh.
  131732. * @param mesh The mesh to render
  131733. * @param subMesh The submesh to check against
  131734. * @param useInstances Specify wether or not the material is used with instances
  131735. * @returns true if all the dependencies are ready (Textures, Effects...)
  131736. */
  131737. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131738. /**
  131739. * Compute the primary color according to the chosen perceptual color.
  131740. */
  131741. private _computePrimaryColorFromPerceptualColor;
  131742. /**
  131743. * Compute the highlights and shadow colors according to their chosen levels.
  131744. */
  131745. private _computePrimaryColors;
  131746. /**
  131747. * Build the uniform buffer used in the material.
  131748. */
  131749. buildUniformLayout(): void;
  131750. /**
  131751. * Unbind the material.
  131752. */
  131753. unbind(): void;
  131754. /**
  131755. * Bind only the world matrix to the material.
  131756. * @param world The world matrix to bind.
  131757. */
  131758. bindOnlyWorldMatrix(world: Matrix): void;
  131759. /**
  131760. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131761. * @param world The world matrix to bind.
  131762. * @param subMesh The submesh to bind for.
  131763. */
  131764. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131765. /**
  131766. * Checks to see if a texture is used in the material.
  131767. * @param texture - Base texture to use.
  131768. * @returns - Boolean specifying if a texture is used in the material.
  131769. */
  131770. hasTexture(texture: BaseTexture): boolean;
  131771. /**
  131772. * Dispose the material.
  131773. * @param forceDisposeEffect Force disposal of the associated effect.
  131774. * @param forceDisposeTextures Force disposal of the associated textures.
  131775. */
  131776. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131777. /**
  131778. * Clones the material.
  131779. * @param name The cloned name.
  131780. * @returns The cloned material.
  131781. */
  131782. clone(name: string): BackgroundMaterial;
  131783. /**
  131784. * Serializes the current material to its JSON representation.
  131785. * @returns The JSON representation.
  131786. */
  131787. serialize(): any;
  131788. /**
  131789. * Gets the class name of the material
  131790. * @returns "BackgroundMaterial"
  131791. */
  131792. getClassName(): string;
  131793. /**
  131794. * Parse a JSON input to create back a background material.
  131795. * @param source The JSON data to parse
  131796. * @param scene The scene to create the parsed material in
  131797. * @param rootUrl The root url of the assets the material depends upon
  131798. * @returns the instantiated BackgroundMaterial.
  131799. */
  131800. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131801. }
  131802. }
  131803. declare module BABYLON {
  131804. /**
  131805. * Represents the different options available during the creation of
  131806. * a Environment helper.
  131807. *
  131808. * This can control the default ground, skybox and image processing setup of your scene.
  131809. */
  131810. export interface IEnvironmentHelperOptions {
  131811. /**
  131812. * Specifies whether or not to create a ground.
  131813. * True by default.
  131814. */
  131815. createGround: boolean;
  131816. /**
  131817. * Specifies the ground size.
  131818. * 15 by default.
  131819. */
  131820. groundSize: number;
  131821. /**
  131822. * The texture used on the ground for the main color.
  131823. * Comes from the BabylonJS CDN by default.
  131824. *
  131825. * Remarks: Can be either a texture or a url.
  131826. */
  131827. groundTexture: string | BaseTexture;
  131828. /**
  131829. * The color mixed in the ground texture by default.
  131830. * BabylonJS clearColor by default.
  131831. */
  131832. groundColor: Color3;
  131833. /**
  131834. * Specifies the ground opacity.
  131835. * 1 by default.
  131836. */
  131837. groundOpacity: number;
  131838. /**
  131839. * Enables the ground to receive shadows.
  131840. * True by default.
  131841. */
  131842. enableGroundShadow: boolean;
  131843. /**
  131844. * Helps preventing the shadow to be fully black on the ground.
  131845. * 0.5 by default.
  131846. */
  131847. groundShadowLevel: number;
  131848. /**
  131849. * Creates a mirror texture attach to the ground.
  131850. * false by default.
  131851. */
  131852. enableGroundMirror: boolean;
  131853. /**
  131854. * Specifies the ground mirror size ratio.
  131855. * 0.3 by default as the default kernel is 64.
  131856. */
  131857. groundMirrorSizeRatio: number;
  131858. /**
  131859. * Specifies the ground mirror blur kernel size.
  131860. * 64 by default.
  131861. */
  131862. groundMirrorBlurKernel: number;
  131863. /**
  131864. * Specifies the ground mirror visibility amount.
  131865. * 1 by default
  131866. */
  131867. groundMirrorAmount: number;
  131868. /**
  131869. * Specifies the ground mirror reflectance weight.
  131870. * This uses the standard weight of the background material to setup the fresnel effect
  131871. * of the mirror.
  131872. * 1 by default.
  131873. */
  131874. groundMirrorFresnelWeight: number;
  131875. /**
  131876. * Specifies the ground mirror Falloff distance.
  131877. * This can helps reducing the size of the reflection.
  131878. * 0 by Default.
  131879. */
  131880. groundMirrorFallOffDistance: number;
  131881. /**
  131882. * Specifies the ground mirror texture type.
  131883. * Unsigned Int by Default.
  131884. */
  131885. groundMirrorTextureType: number;
  131886. /**
  131887. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131888. * the shown objects.
  131889. */
  131890. groundYBias: number;
  131891. /**
  131892. * Specifies whether or not to create a skybox.
  131893. * True by default.
  131894. */
  131895. createSkybox: boolean;
  131896. /**
  131897. * Specifies the skybox size.
  131898. * 20 by default.
  131899. */
  131900. skyboxSize: number;
  131901. /**
  131902. * The texture used on the skybox for the main color.
  131903. * Comes from the BabylonJS CDN by default.
  131904. *
  131905. * Remarks: Can be either a texture or a url.
  131906. */
  131907. skyboxTexture: string | BaseTexture;
  131908. /**
  131909. * The color mixed in the skybox texture by default.
  131910. * BabylonJS clearColor by default.
  131911. */
  131912. skyboxColor: Color3;
  131913. /**
  131914. * The background rotation around the Y axis of the scene.
  131915. * This helps aligning the key lights of your scene with the background.
  131916. * 0 by default.
  131917. */
  131918. backgroundYRotation: number;
  131919. /**
  131920. * Compute automatically the size of the elements to best fit with the scene.
  131921. */
  131922. sizeAuto: boolean;
  131923. /**
  131924. * Default position of the rootMesh if autoSize is not true.
  131925. */
  131926. rootPosition: Vector3;
  131927. /**
  131928. * Sets up the image processing in the scene.
  131929. * true by default.
  131930. */
  131931. setupImageProcessing: boolean;
  131932. /**
  131933. * The texture used as your environment texture in the scene.
  131934. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131935. *
  131936. * Remarks: Can be either a texture or a url.
  131937. */
  131938. environmentTexture: string | BaseTexture;
  131939. /**
  131940. * The value of the exposure to apply to the scene.
  131941. * 0.6 by default if setupImageProcessing is true.
  131942. */
  131943. cameraExposure: number;
  131944. /**
  131945. * The value of the contrast to apply to the scene.
  131946. * 1.6 by default if setupImageProcessing is true.
  131947. */
  131948. cameraContrast: number;
  131949. /**
  131950. * Specifies whether or not tonemapping should be enabled in the scene.
  131951. * true by default if setupImageProcessing is true.
  131952. */
  131953. toneMappingEnabled: boolean;
  131954. }
  131955. /**
  131956. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131957. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131958. * It also helps with the default setup of your imageProcessing configuration.
  131959. */
  131960. export class EnvironmentHelper {
  131961. /**
  131962. * Default ground texture URL.
  131963. */
  131964. private static _groundTextureCDNUrl;
  131965. /**
  131966. * Default skybox texture URL.
  131967. */
  131968. private static _skyboxTextureCDNUrl;
  131969. /**
  131970. * Default environment texture URL.
  131971. */
  131972. private static _environmentTextureCDNUrl;
  131973. /**
  131974. * Creates the default options for the helper.
  131975. */
  131976. private static _getDefaultOptions;
  131977. private _rootMesh;
  131978. /**
  131979. * Gets the root mesh created by the helper.
  131980. */
  131981. get rootMesh(): Mesh;
  131982. private _skybox;
  131983. /**
  131984. * Gets the skybox created by the helper.
  131985. */
  131986. get skybox(): Nullable<Mesh>;
  131987. private _skyboxTexture;
  131988. /**
  131989. * Gets the skybox texture created by the helper.
  131990. */
  131991. get skyboxTexture(): Nullable<BaseTexture>;
  131992. private _skyboxMaterial;
  131993. /**
  131994. * Gets the skybox material created by the helper.
  131995. */
  131996. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131997. private _ground;
  131998. /**
  131999. * Gets the ground mesh created by the helper.
  132000. */
  132001. get ground(): Nullable<Mesh>;
  132002. private _groundTexture;
  132003. /**
  132004. * Gets the ground texture created by the helper.
  132005. */
  132006. get groundTexture(): Nullable<BaseTexture>;
  132007. private _groundMirror;
  132008. /**
  132009. * Gets the ground mirror created by the helper.
  132010. */
  132011. get groundMirror(): Nullable<MirrorTexture>;
  132012. /**
  132013. * Gets the ground mirror render list to helps pushing the meshes
  132014. * you wish in the ground reflection.
  132015. */
  132016. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132017. private _groundMaterial;
  132018. /**
  132019. * Gets the ground material created by the helper.
  132020. */
  132021. get groundMaterial(): Nullable<BackgroundMaterial>;
  132022. /**
  132023. * Stores the creation options.
  132024. */
  132025. private readonly _scene;
  132026. private _options;
  132027. /**
  132028. * This observable will be notified with any error during the creation of the environment,
  132029. * mainly texture creation errors.
  132030. */
  132031. onErrorObservable: Observable<{
  132032. message?: string;
  132033. exception?: any;
  132034. }>;
  132035. /**
  132036. * constructor
  132037. * @param options Defines the options we want to customize the helper
  132038. * @param scene The scene to add the material to
  132039. */
  132040. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132041. /**
  132042. * Updates the background according to the new options
  132043. * @param options
  132044. */
  132045. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132046. /**
  132047. * Sets the primary color of all the available elements.
  132048. * @param color the main color to affect to the ground and the background
  132049. */
  132050. setMainColor(color: Color3): void;
  132051. /**
  132052. * Setup the image processing according to the specified options.
  132053. */
  132054. private _setupImageProcessing;
  132055. /**
  132056. * Setup the environment texture according to the specified options.
  132057. */
  132058. private _setupEnvironmentTexture;
  132059. /**
  132060. * Setup the background according to the specified options.
  132061. */
  132062. private _setupBackground;
  132063. /**
  132064. * Get the scene sizes according to the setup.
  132065. */
  132066. private _getSceneSize;
  132067. /**
  132068. * Setup the ground according to the specified options.
  132069. */
  132070. private _setupGround;
  132071. /**
  132072. * Setup the ground material according to the specified options.
  132073. */
  132074. private _setupGroundMaterial;
  132075. /**
  132076. * Setup the ground diffuse texture according to the specified options.
  132077. */
  132078. private _setupGroundDiffuseTexture;
  132079. /**
  132080. * Setup the ground mirror texture according to the specified options.
  132081. */
  132082. private _setupGroundMirrorTexture;
  132083. /**
  132084. * Setup the ground to receive the mirror texture.
  132085. */
  132086. private _setupMirrorInGroundMaterial;
  132087. /**
  132088. * Setup the skybox according to the specified options.
  132089. */
  132090. private _setupSkybox;
  132091. /**
  132092. * Setup the skybox material according to the specified options.
  132093. */
  132094. private _setupSkyboxMaterial;
  132095. /**
  132096. * Setup the skybox reflection texture according to the specified options.
  132097. */
  132098. private _setupSkyboxReflectionTexture;
  132099. private _errorHandler;
  132100. /**
  132101. * Dispose all the elements created by the Helper.
  132102. */
  132103. dispose(): void;
  132104. }
  132105. }
  132106. declare module BABYLON {
  132107. /**
  132108. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132109. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132110. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132111. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132112. */
  132113. export class PhotoDome extends TransformNode {
  132114. /**
  132115. * Define the image as a Monoscopic panoramic 360 image.
  132116. */
  132117. static readonly MODE_MONOSCOPIC: number;
  132118. /**
  132119. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132120. */
  132121. static readonly MODE_TOPBOTTOM: number;
  132122. /**
  132123. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132124. */
  132125. static readonly MODE_SIDEBYSIDE: number;
  132126. private _useDirectMapping;
  132127. /**
  132128. * The texture being displayed on the sphere
  132129. */
  132130. protected _photoTexture: Texture;
  132131. /**
  132132. * Gets or sets the texture being displayed on the sphere
  132133. */
  132134. get photoTexture(): Texture;
  132135. set photoTexture(value: Texture);
  132136. /**
  132137. * Observable raised when an error occured while loading the 360 image
  132138. */
  132139. onLoadErrorObservable: Observable<string>;
  132140. /**
  132141. * The skybox material
  132142. */
  132143. protected _material: BackgroundMaterial;
  132144. /**
  132145. * The surface used for the skybox
  132146. */
  132147. protected _mesh: Mesh;
  132148. /**
  132149. * Gets the mesh used for the skybox.
  132150. */
  132151. get mesh(): Mesh;
  132152. /**
  132153. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132154. * Also see the options.resolution property.
  132155. */
  132156. get fovMultiplier(): number;
  132157. set fovMultiplier(value: number);
  132158. private _imageMode;
  132159. /**
  132160. * Gets or set the current video mode for the video. It can be:
  132161. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132162. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132163. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132164. */
  132165. get imageMode(): number;
  132166. set imageMode(value: number);
  132167. /**
  132168. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132169. * @param name Element's name, child elements will append suffixes for their own names.
  132170. * @param urlsOfPhoto defines the url of the photo to display
  132171. * @param options defines an object containing optional or exposed sub element properties
  132172. * @param onError defines a callback called when an error occured while loading the texture
  132173. */
  132174. constructor(name: string, urlOfPhoto: string, options: {
  132175. resolution?: number;
  132176. size?: number;
  132177. useDirectMapping?: boolean;
  132178. faceForward?: boolean;
  132179. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132180. private _onBeforeCameraRenderObserver;
  132181. private _changeImageMode;
  132182. /**
  132183. * Releases resources associated with this node.
  132184. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132185. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132186. */
  132187. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132188. }
  132189. }
  132190. declare module BABYLON {
  132191. /**
  132192. * Class used to host RGBD texture specific utilities
  132193. */
  132194. export class RGBDTextureTools {
  132195. /**
  132196. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132197. * @param texture the texture to expand.
  132198. */
  132199. static ExpandRGBDTexture(texture: Texture): void;
  132200. }
  132201. }
  132202. declare module BABYLON {
  132203. /**
  132204. * Class used to host texture specific utilities
  132205. */
  132206. export class BRDFTextureTools {
  132207. /**
  132208. * Prevents texture cache collision
  132209. */
  132210. private static _instanceNumber;
  132211. /**
  132212. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132213. * @param scene defines the hosting scene
  132214. * @returns the environment BRDF texture
  132215. */
  132216. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132217. private static _environmentBRDFBase64Texture;
  132218. }
  132219. }
  132220. declare module BABYLON {
  132221. /**
  132222. * @hidden
  132223. */
  132224. export interface IMaterialClearCoatDefines {
  132225. CLEARCOAT: boolean;
  132226. CLEARCOAT_DEFAULTIOR: boolean;
  132227. CLEARCOAT_TEXTURE: boolean;
  132228. CLEARCOAT_TEXTUREDIRECTUV: number;
  132229. CLEARCOAT_BUMP: boolean;
  132230. CLEARCOAT_BUMPDIRECTUV: number;
  132231. CLEARCOAT_TINT: boolean;
  132232. CLEARCOAT_TINT_TEXTURE: boolean;
  132233. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132234. /** @hidden */
  132235. _areTexturesDirty: boolean;
  132236. }
  132237. /**
  132238. * Define the code related to the clear coat parameters of the pbr material.
  132239. */
  132240. export class PBRClearCoatConfiguration {
  132241. /**
  132242. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132243. * The default fits with a polyurethane material.
  132244. */
  132245. private static readonly _DefaultIndexOfRefraction;
  132246. private _isEnabled;
  132247. /**
  132248. * Defines if the clear coat is enabled in the material.
  132249. */
  132250. isEnabled: boolean;
  132251. /**
  132252. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132253. */
  132254. intensity: number;
  132255. /**
  132256. * Defines the clear coat layer roughness.
  132257. */
  132258. roughness: number;
  132259. private _indexOfRefraction;
  132260. /**
  132261. * Defines the index of refraction of the clear coat.
  132262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132263. * The default fits with a polyurethane material.
  132264. * Changing the default value is more performance intensive.
  132265. */
  132266. indexOfRefraction: number;
  132267. private _texture;
  132268. /**
  132269. * Stores the clear coat values in a texture.
  132270. */
  132271. texture: Nullable<BaseTexture>;
  132272. private _bumpTexture;
  132273. /**
  132274. * Define the clear coat specific bump texture.
  132275. */
  132276. bumpTexture: Nullable<BaseTexture>;
  132277. private _isTintEnabled;
  132278. /**
  132279. * Defines if the clear coat tint is enabled in the material.
  132280. */
  132281. isTintEnabled: boolean;
  132282. /**
  132283. * Defines the clear coat tint of the material.
  132284. * This is only use if tint is enabled
  132285. */
  132286. tintColor: Color3;
  132287. /**
  132288. * Defines the distance at which the tint color should be found in the
  132289. * clear coat media.
  132290. * This is only use if tint is enabled
  132291. */
  132292. tintColorAtDistance: number;
  132293. /**
  132294. * Defines the clear coat layer thickness.
  132295. * This is only use if tint is enabled
  132296. */
  132297. tintThickness: number;
  132298. private _tintTexture;
  132299. /**
  132300. * Stores the clear tint values in a texture.
  132301. * rgb is tint
  132302. * a is a thickness factor
  132303. */
  132304. tintTexture: Nullable<BaseTexture>;
  132305. /** @hidden */
  132306. private _internalMarkAllSubMeshesAsTexturesDirty;
  132307. /** @hidden */
  132308. _markAllSubMeshesAsTexturesDirty(): void;
  132309. /**
  132310. * Instantiate a new istance of clear coat configuration.
  132311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132312. */
  132313. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132314. /**
  132315. * Gets wehter the submesh is ready to be used or not.
  132316. * @param defines the list of "defines" to update.
  132317. * @param scene defines the scene the material belongs to.
  132318. * @param engine defines the engine the material belongs to.
  132319. * @param disableBumpMap defines wether the material disables bump or not.
  132320. * @returns - boolean indicating that the submesh is ready or not.
  132321. */
  132322. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132323. /**
  132324. * Checks to see if a texture is used in the material.
  132325. * @param defines the list of "defines" to update.
  132326. * @param scene defines the scene to the material belongs to.
  132327. */
  132328. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132329. /**
  132330. * Binds the material data.
  132331. * @param uniformBuffer defines the Uniform buffer to fill in.
  132332. * @param scene defines the scene the material belongs to.
  132333. * @param engine defines the engine the material belongs to.
  132334. * @param disableBumpMap defines wether the material disables bump or not.
  132335. * @param isFrozen defines wether the material is frozen or not.
  132336. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132337. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132338. */
  132339. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132340. /**
  132341. * Checks to see if a texture is used in the material.
  132342. * @param texture - Base texture to use.
  132343. * @returns - Boolean specifying if a texture is used in the material.
  132344. */
  132345. hasTexture(texture: BaseTexture): boolean;
  132346. /**
  132347. * Returns an array of the actively used textures.
  132348. * @param activeTextures Array of BaseTextures
  132349. */
  132350. getActiveTextures(activeTextures: BaseTexture[]): void;
  132351. /**
  132352. * Returns the animatable textures.
  132353. * @param animatables Array of animatable textures.
  132354. */
  132355. getAnimatables(animatables: IAnimatable[]): void;
  132356. /**
  132357. * Disposes the resources of the material.
  132358. * @param forceDisposeTextures - Forces the disposal of all textures.
  132359. */
  132360. dispose(forceDisposeTextures?: boolean): void;
  132361. /**
  132362. * Get the current class name of the texture useful for serialization or dynamic coding.
  132363. * @returns "PBRClearCoatConfiguration"
  132364. */
  132365. getClassName(): string;
  132366. /**
  132367. * Add fallbacks to the effect fallbacks list.
  132368. * @param defines defines the Base texture to use.
  132369. * @param fallbacks defines the current fallback list.
  132370. * @param currentRank defines the current fallback rank.
  132371. * @returns the new fallback rank.
  132372. */
  132373. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132374. /**
  132375. * Add the required uniforms to the current list.
  132376. * @param uniforms defines the current uniform list.
  132377. */
  132378. static AddUniforms(uniforms: string[]): void;
  132379. /**
  132380. * Add the required samplers to the current list.
  132381. * @param samplers defines the current sampler list.
  132382. */
  132383. static AddSamplers(samplers: string[]): void;
  132384. /**
  132385. * Add the required uniforms to the current buffer.
  132386. * @param uniformBuffer defines the current uniform buffer.
  132387. */
  132388. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132389. /**
  132390. * Makes a duplicate of the current configuration into another one.
  132391. * @param clearCoatConfiguration define the config where to copy the info
  132392. */
  132393. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132394. /**
  132395. * Serializes this clear coat configuration.
  132396. * @returns - An object with the serialized config.
  132397. */
  132398. serialize(): any;
  132399. /**
  132400. * Parses a anisotropy Configuration from a serialized object.
  132401. * @param source - Serialized object.
  132402. * @param scene Defines the scene we are parsing for
  132403. * @param rootUrl Defines the rootUrl to load from
  132404. */
  132405. parse(source: any, scene: Scene, rootUrl: string): void;
  132406. }
  132407. }
  132408. declare module BABYLON {
  132409. /**
  132410. * @hidden
  132411. */
  132412. export interface IMaterialAnisotropicDefines {
  132413. ANISOTROPIC: boolean;
  132414. ANISOTROPIC_TEXTURE: boolean;
  132415. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132416. MAINUV1: boolean;
  132417. _areTexturesDirty: boolean;
  132418. _needUVs: boolean;
  132419. }
  132420. /**
  132421. * Define the code related to the anisotropic parameters of the pbr material.
  132422. */
  132423. export class PBRAnisotropicConfiguration {
  132424. private _isEnabled;
  132425. /**
  132426. * Defines if the anisotropy is enabled in the material.
  132427. */
  132428. isEnabled: boolean;
  132429. /**
  132430. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132431. */
  132432. intensity: number;
  132433. /**
  132434. * Defines if the effect is along the tangents, bitangents or in between.
  132435. * By default, the effect is "strectching" the highlights along the tangents.
  132436. */
  132437. direction: Vector2;
  132438. private _texture;
  132439. /**
  132440. * Stores the anisotropy values in a texture.
  132441. * rg is direction (like normal from -1 to 1)
  132442. * b is a intensity
  132443. */
  132444. texture: Nullable<BaseTexture>;
  132445. /** @hidden */
  132446. private _internalMarkAllSubMeshesAsTexturesDirty;
  132447. /** @hidden */
  132448. _markAllSubMeshesAsTexturesDirty(): void;
  132449. /**
  132450. * Instantiate a new istance of anisotropy configuration.
  132451. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132452. */
  132453. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132454. /**
  132455. * Specifies that the submesh is ready to be used.
  132456. * @param defines the list of "defines" to update.
  132457. * @param scene defines the scene the material belongs to.
  132458. * @returns - boolean indicating that the submesh is ready or not.
  132459. */
  132460. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132461. /**
  132462. * Checks to see if a texture is used in the material.
  132463. * @param defines the list of "defines" to update.
  132464. * @param mesh the mesh we are preparing the defines for.
  132465. * @param scene defines the scene the material belongs to.
  132466. */
  132467. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132468. /**
  132469. * Binds the material data.
  132470. * @param uniformBuffer defines the Uniform buffer to fill in.
  132471. * @param scene defines the scene the material belongs to.
  132472. * @param isFrozen defines wether the material is frozen or not.
  132473. */
  132474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132475. /**
  132476. * Checks to see if a texture is used in the material.
  132477. * @param texture - Base texture to use.
  132478. * @returns - Boolean specifying if a texture is used in the material.
  132479. */
  132480. hasTexture(texture: BaseTexture): boolean;
  132481. /**
  132482. * Returns an array of the actively used textures.
  132483. * @param activeTextures Array of BaseTextures
  132484. */
  132485. getActiveTextures(activeTextures: BaseTexture[]): void;
  132486. /**
  132487. * Returns the animatable textures.
  132488. * @param animatables Array of animatable textures.
  132489. */
  132490. getAnimatables(animatables: IAnimatable[]): void;
  132491. /**
  132492. * Disposes the resources of the material.
  132493. * @param forceDisposeTextures - Forces the disposal of all textures.
  132494. */
  132495. dispose(forceDisposeTextures?: boolean): void;
  132496. /**
  132497. * Get the current class name of the texture useful for serialization or dynamic coding.
  132498. * @returns "PBRAnisotropicConfiguration"
  132499. */
  132500. getClassName(): string;
  132501. /**
  132502. * Add fallbacks to the effect fallbacks list.
  132503. * @param defines defines the Base texture to use.
  132504. * @param fallbacks defines the current fallback list.
  132505. * @param currentRank defines the current fallback rank.
  132506. * @returns the new fallback rank.
  132507. */
  132508. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132509. /**
  132510. * Add the required uniforms to the current list.
  132511. * @param uniforms defines the current uniform list.
  132512. */
  132513. static AddUniforms(uniforms: string[]): void;
  132514. /**
  132515. * Add the required uniforms to the current buffer.
  132516. * @param uniformBuffer defines the current uniform buffer.
  132517. */
  132518. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132519. /**
  132520. * Add the required samplers to the current list.
  132521. * @param samplers defines the current sampler list.
  132522. */
  132523. static AddSamplers(samplers: string[]): void;
  132524. /**
  132525. * Makes a duplicate of the current configuration into another one.
  132526. * @param anisotropicConfiguration define the config where to copy the info
  132527. */
  132528. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132529. /**
  132530. * Serializes this anisotropy configuration.
  132531. * @returns - An object with the serialized config.
  132532. */
  132533. serialize(): any;
  132534. /**
  132535. * Parses a anisotropy Configuration from a serialized object.
  132536. * @param source - Serialized object.
  132537. * @param scene Defines the scene we are parsing for
  132538. * @param rootUrl Defines the rootUrl to load from
  132539. */
  132540. parse(source: any, scene: Scene, rootUrl: string): void;
  132541. }
  132542. }
  132543. declare module BABYLON {
  132544. /**
  132545. * @hidden
  132546. */
  132547. export interface IMaterialBRDFDefines {
  132548. BRDF_V_HEIGHT_CORRELATED: boolean;
  132549. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132550. SPHERICAL_HARMONICS: boolean;
  132551. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132552. /** @hidden */
  132553. _areMiscDirty: boolean;
  132554. }
  132555. /**
  132556. * Define the code related to the BRDF parameters of the pbr material.
  132557. */
  132558. export class PBRBRDFConfiguration {
  132559. /**
  132560. * Default value used for the energy conservation.
  132561. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132562. */
  132563. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132564. /**
  132565. * Default value used for the Smith Visibility Height Correlated mode.
  132566. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132567. */
  132568. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132569. /**
  132570. * Default value used for the IBL diffuse part.
  132571. * This can help switching back to the polynomials mode globally which is a tiny bit
  132572. * less GPU intensive at the drawback of a lower quality.
  132573. */
  132574. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132575. /**
  132576. * Default value used for activating energy conservation for the specular workflow.
  132577. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132578. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132579. */
  132580. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132581. private _useEnergyConservation;
  132582. /**
  132583. * Defines if the material uses energy conservation.
  132584. */
  132585. useEnergyConservation: boolean;
  132586. private _useSmithVisibilityHeightCorrelated;
  132587. /**
  132588. * LEGACY Mode set to false
  132589. * Defines if the material uses height smith correlated visibility term.
  132590. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132591. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132592. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132593. * Not relying on height correlated will also disable energy conservation.
  132594. */
  132595. useSmithVisibilityHeightCorrelated: boolean;
  132596. private _useSphericalHarmonics;
  132597. /**
  132598. * LEGACY Mode set to false
  132599. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132600. * diffuse part of the IBL.
  132601. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132602. * to the ground truth.
  132603. */
  132604. useSphericalHarmonics: boolean;
  132605. private _useSpecularGlossinessInputEnergyConservation;
  132606. /**
  132607. * Defines if the material uses energy conservation, when the specular workflow is active.
  132608. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132609. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132610. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132611. */
  132612. useSpecularGlossinessInputEnergyConservation: boolean;
  132613. /** @hidden */
  132614. private _internalMarkAllSubMeshesAsMiscDirty;
  132615. /** @hidden */
  132616. _markAllSubMeshesAsMiscDirty(): void;
  132617. /**
  132618. * Instantiate a new istance of clear coat configuration.
  132619. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132620. */
  132621. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132622. /**
  132623. * Checks to see if a texture is used in the material.
  132624. * @param defines the list of "defines" to update.
  132625. */
  132626. prepareDefines(defines: IMaterialBRDFDefines): void;
  132627. /**
  132628. * Get the current class name of the texture useful for serialization or dynamic coding.
  132629. * @returns "PBRClearCoatConfiguration"
  132630. */
  132631. getClassName(): string;
  132632. /**
  132633. * Makes a duplicate of the current configuration into another one.
  132634. * @param brdfConfiguration define the config where to copy the info
  132635. */
  132636. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132637. /**
  132638. * Serializes this BRDF configuration.
  132639. * @returns - An object with the serialized config.
  132640. */
  132641. serialize(): any;
  132642. /**
  132643. * Parses a anisotropy Configuration from a serialized object.
  132644. * @param source - Serialized object.
  132645. * @param scene Defines the scene we are parsing for
  132646. * @param rootUrl Defines the rootUrl to load from
  132647. */
  132648. parse(source: any, scene: Scene, rootUrl: string): void;
  132649. }
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * @hidden
  132654. */
  132655. export interface IMaterialSheenDefines {
  132656. SHEEN: boolean;
  132657. SHEEN_TEXTURE: boolean;
  132658. SHEEN_TEXTUREDIRECTUV: number;
  132659. SHEEN_LINKWITHALBEDO: boolean;
  132660. SHEEN_ROUGHNESS: boolean;
  132661. SHEEN_ALBEDOSCALING: boolean;
  132662. /** @hidden */
  132663. _areTexturesDirty: boolean;
  132664. }
  132665. /**
  132666. * Define the code related to the Sheen parameters of the pbr material.
  132667. */
  132668. export class PBRSheenConfiguration {
  132669. private _isEnabled;
  132670. /**
  132671. * Defines if the material uses sheen.
  132672. */
  132673. isEnabled: boolean;
  132674. private _linkSheenWithAlbedo;
  132675. /**
  132676. * Defines if the sheen is linked to the sheen color.
  132677. */
  132678. linkSheenWithAlbedo: boolean;
  132679. /**
  132680. * Defines the sheen intensity.
  132681. */
  132682. intensity: number;
  132683. /**
  132684. * Defines the sheen color.
  132685. */
  132686. color: Color3;
  132687. private _texture;
  132688. /**
  132689. * Stores the sheen tint values in a texture.
  132690. * rgb is tint
  132691. * a is a intensity or roughness if roughness has been defined
  132692. */
  132693. texture: Nullable<BaseTexture>;
  132694. private _roughness;
  132695. /**
  132696. * Defines the sheen roughness.
  132697. * It is not taken into account if linkSheenWithAlbedo is true.
  132698. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132699. */
  132700. roughness: Nullable<number>;
  132701. private _albedoScaling;
  132702. /**
  132703. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132704. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132705. * making it easier to setup and tweak the effect
  132706. */
  132707. albedoScaling: boolean;
  132708. /** @hidden */
  132709. private _internalMarkAllSubMeshesAsTexturesDirty;
  132710. /** @hidden */
  132711. _markAllSubMeshesAsTexturesDirty(): void;
  132712. /**
  132713. * Instantiate a new istance of clear coat configuration.
  132714. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132715. */
  132716. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132717. /**
  132718. * Specifies that the submesh is ready to be used.
  132719. * @param defines the list of "defines" to update.
  132720. * @param scene defines the scene the material belongs to.
  132721. * @returns - boolean indicating that the submesh is ready or not.
  132722. */
  132723. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132724. /**
  132725. * Checks to see if a texture is used in the material.
  132726. * @param defines the list of "defines" to update.
  132727. * @param scene defines the scene the material belongs to.
  132728. */
  132729. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132730. /**
  132731. * Binds the material data.
  132732. * @param uniformBuffer defines the Uniform buffer to fill in.
  132733. * @param scene defines the scene the material belongs to.
  132734. * @param isFrozen defines wether the material is frozen or not.
  132735. */
  132736. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132737. /**
  132738. * Checks to see if a texture is used in the material.
  132739. * @param texture - Base texture to use.
  132740. * @returns - Boolean specifying if a texture is used in the material.
  132741. */
  132742. hasTexture(texture: BaseTexture): boolean;
  132743. /**
  132744. * Returns an array of the actively used textures.
  132745. * @param activeTextures Array of BaseTextures
  132746. */
  132747. getActiveTextures(activeTextures: BaseTexture[]): void;
  132748. /**
  132749. * Returns the animatable textures.
  132750. * @param animatables Array of animatable textures.
  132751. */
  132752. getAnimatables(animatables: IAnimatable[]): void;
  132753. /**
  132754. * Disposes the resources of the material.
  132755. * @param forceDisposeTextures - Forces the disposal of all textures.
  132756. */
  132757. dispose(forceDisposeTextures?: boolean): void;
  132758. /**
  132759. * Get the current class name of the texture useful for serialization or dynamic coding.
  132760. * @returns "PBRSheenConfiguration"
  132761. */
  132762. getClassName(): string;
  132763. /**
  132764. * Add fallbacks to the effect fallbacks list.
  132765. * @param defines defines the Base texture to use.
  132766. * @param fallbacks defines the current fallback list.
  132767. * @param currentRank defines the current fallback rank.
  132768. * @returns the new fallback rank.
  132769. */
  132770. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132771. /**
  132772. * Add the required uniforms to the current list.
  132773. * @param uniforms defines the current uniform list.
  132774. */
  132775. static AddUniforms(uniforms: string[]): void;
  132776. /**
  132777. * Add the required uniforms to the current buffer.
  132778. * @param uniformBuffer defines the current uniform buffer.
  132779. */
  132780. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132781. /**
  132782. * Add the required samplers to the current list.
  132783. * @param samplers defines the current sampler list.
  132784. */
  132785. static AddSamplers(samplers: string[]): void;
  132786. /**
  132787. * Makes a duplicate of the current configuration into another one.
  132788. * @param sheenConfiguration define the config where to copy the info
  132789. */
  132790. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132791. /**
  132792. * Serializes this BRDF configuration.
  132793. * @returns - An object with the serialized config.
  132794. */
  132795. serialize(): any;
  132796. /**
  132797. * Parses a anisotropy Configuration from a serialized object.
  132798. * @param source - Serialized object.
  132799. * @param scene Defines the scene we are parsing for
  132800. * @param rootUrl Defines the rootUrl to load from
  132801. */
  132802. parse(source: any, scene: Scene, rootUrl: string): void;
  132803. }
  132804. }
  132805. declare module BABYLON {
  132806. /**
  132807. * @hidden
  132808. */
  132809. export interface IMaterialSubSurfaceDefines {
  132810. SUBSURFACE: boolean;
  132811. SS_REFRACTION: boolean;
  132812. SS_TRANSLUCENCY: boolean;
  132813. SS_SCATTERING: boolean;
  132814. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132815. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132816. SS_REFRACTIONMAP_3D: boolean;
  132817. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132818. SS_LODINREFRACTIONALPHA: boolean;
  132819. SS_GAMMAREFRACTION: boolean;
  132820. SS_RGBDREFRACTION: boolean;
  132821. SS_LINEARSPECULARREFRACTION: boolean;
  132822. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132823. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132824. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132825. /** @hidden */
  132826. _areTexturesDirty: boolean;
  132827. }
  132828. /**
  132829. * Define the code related to the sub surface parameters of the pbr material.
  132830. */
  132831. export class PBRSubSurfaceConfiguration {
  132832. private _isRefractionEnabled;
  132833. /**
  132834. * Defines if the refraction is enabled in the material.
  132835. */
  132836. isRefractionEnabled: boolean;
  132837. private _isTranslucencyEnabled;
  132838. /**
  132839. * Defines if the translucency is enabled in the material.
  132840. */
  132841. isTranslucencyEnabled: boolean;
  132842. private _isScatteringEnabled;
  132843. /**
  132844. * Defines if the sub surface scattering is enabled in the material.
  132845. */
  132846. isScatteringEnabled: boolean;
  132847. private _scatteringDiffusionProfileIndex;
  132848. /**
  132849. * Diffusion profile for subsurface scattering.
  132850. * Useful for better scattering in the skins or foliages.
  132851. */
  132852. get scatteringDiffusionProfile(): Nullable<Color3>;
  132853. set scatteringDiffusionProfile(c: Nullable<Color3>);
  132854. /**
  132855. * Defines the refraction intensity of the material.
  132856. * The refraction when enabled replaces the Diffuse part of the material.
  132857. * The intensity helps transitionning between diffuse and refraction.
  132858. */
  132859. refractionIntensity: number;
  132860. /**
  132861. * Defines the translucency intensity of the material.
  132862. * When translucency has been enabled, this defines how much of the "translucency"
  132863. * is addded to the diffuse part of the material.
  132864. */
  132865. translucencyIntensity: number;
  132866. /**
  132867. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132868. */
  132869. useAlbedoToTintRefraction: boolean;
  132870. private _thicknessTexture;
  132871. /**
  132872. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132873. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132874. * 0 would mean minimumThickness
  132875. * 1 would mean maximumThickness
  132876. * The other channels might be use as a mask to vary the different effects intensity.
  132877. */
  132878. thicknessTexture: Nullable<BaseTexture>;
  132879. private _refractionTexture;
  132880. /**
  132881. * Defines the texture to use for refraction.
  132882. */
  132883. refractionTexture: Nullable<BaseTexture>;
  132884. private _indexOfRefraction;
  132885. /**
  132886. * Index of refraction of the material base layer.
  132887. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132888. *
  132889. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132890. *
  132891. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132892. */
  132893. indexOfRefraction: number;
  132894. private _volumeIndexOfRefraction;
  132895. /**
  132896. * Index of refraction of the material's volume.
  132897. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132898. *
  132899. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132900. * the volume will use the same IOR as the surface.
  132901. */
  132902. get volumeIndexOfRefraction(): number;
  132903. set volumeIndexOfRefraction(value: number);
  132904. private _invertRefractionY;
  132905. /**
  132906. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132907. */
  132908. invertRefractionY: boolean;
  132909. private _linkRefractionWithTransparency;
  132910. /**
  132911. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132912. * Materials half opaque for instance using refraction could benefit from this control.
  132913. */
  132914. linkRefractionWithTransparency: boolean;
  132915. /**
  132916. * Defines the minimum thickness stored in the thickness map.
  132917. * If no thickness map is defined, this value will be used to simulate thickness.
  132918. */
  132919. minimumThickness: number;
  132920. /**
  132921. * Defines the maximum thickness stored in the thickness map.
  132922. */
  132923. maximumThickness: number;
  132924. /**
  132925. * Defines the volume tint of the material.
  132926. * This is used for both translucency and scattering.
  132927. */
  132928. tintColor: Color3;
  132929. /**
  132930. * Defines the distance at which the tint color should be found in the media.
  132931. * This is used for refraction only.
  132932. */
  132933. tintColorAtDistance: number;
  132934. /**
  132935. * Defines how far each channel transmit through the media.
  132936. * It is defined as a color to simplify it selection.
  132937. */
  132938. diffusionDistance: Color3;
  132939. private _useMaskFromThicknessTexture;
  132940. /**
  132941. * Stores the intensity of the different subsurface effects in the thickness texture.
  132942. * * the green channel is the translucency intensity.
  132943. * * the blue channel is the scattering intensity.
  132944. * * the alpha channel is the refraction intensity.
  132945. */
  132946. useMaskFromThicknessTexture: boolean;
  132947. private _scene;
  132948. /** @hidden */
  132949. private _internalMarkAllSubMeshesAsTexturesDirty;
  132950. private _internalMarkScenePrePassDirty;
  132951. /** @hidden */
  132952. _markAllSubMeshesAsTexturesDirty(): void;
  132953. /** @hidden */
  132954. _markScenePrePassDirty(): void;
  132955. /**
  132956. * Instantiate a new istance of sub surface configuration.
  132957. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132958. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  132959. * @param scene The scene
  132960. */
  132961. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  132962. /**
  132963. * Gets wehter the submesh is ready to be used or not.
  132964. * @param defines the list of "defines" to update.
  132965. * @param scene defines the scene the material belongs to.
  132966. * @returns - boolean indicating that the submesh is ready or not.
  132967. */
  132968. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132969. /**
  132970. * Checks to see if a texture is used in the material.
  132971. * @param defines the list of "defines" to update.
  132972. * @param scene defines the scene to the material belongs to.
  132973. */
  132974. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132975. /**
  132976. * Binds the material data.
  132977. * @param uniformBuffer defines the Uniform buffer to fill in.
  132978. * @param scene defines the scene the material belongs to.
  132979. * @param engine defines the engine the material belongs to.
  132980. * @param isFrozen defines whether the material is frozen or not.
  132981. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132982. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132983. */
  132984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132985. /**
  132986. * Unbinds the material from the mesh.
  132987. * @param activeEffect defines the effect that should be unbound from.
  132988. * @returns true if unbound, otherwise false
  132989. */
  132990. unbind(activeEffect: Effect): boolean;
  132991. /**
  132992. * Returns the texture used for refraction or null if none is used.
  132993. * @param scene defines the scene the material belongs to.
  132994. * @returns - Refraction texture if present. If no refraction texture and refraction
  132995. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132996. */
  132997. private _getRefractionTexture;
  132998. /**
  132999. * Returns true if alpha blending should be disabled.
  133000. */
  133001. get disableAlphaBlending(): boolean;
  133002. /**
  133003. * Fills the list of render target textures.
  133004. * @param renderTargets the list of render targets to update
  133005. */
  133006. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133007. /**
  133008. * Checks to see if a texture is used in the material.
  133009. * @param texture - Base texture to use.
  133010. * @returns - Boolean specifying if a texture is used in the material.
  133011. */
  133012. hasTexture(texture: BaseTexture): boolean;
  133013. /**
  133014. * Gets a boolean indicating that current material needs to register RTT
  133015. * @returns true if this uses a render target otherwise false.
  133016. */
  133017. hasRenderTargetTextures(): boolean;
  133018. /**
  133019. * Returns an array of the actively used textures.
  133020. * @param activeTextures Array of BaseTextures
  133021. */
  133022. getActiveTextures(activeTextures: BaseTexture[]): void;
  133023. /**
  133024. * Returns the animatable textures.
  133025. * @param animatables Array of animatable textures.
  133026. */
  133027. getAnimatables(animatables: IAnimatable[]): void;
  133028. /**
  133029. * Disposes the resources of the material.
  133030. * @param forceDisposeTextures - Forces the disposal of all textures.
  133031. */
  133032. dispose(forceDisposeTextures?: boolean): void;
  133033. /**
  133034. * Get the current class name of the texture useful for serialization or dynamic coding.
  133035. * @returns "PBRSubSurfaceConfiguration"
  133036. */
  133037. getClassName(): string;
  133038. /**
  133039. * Add fallbacks to the effect fallbacks list.
  133040. * @param defines defines the Base texture to use.
  133041. * @param fallbacks defines the current fallback list.
  133042. * @param currentRank defines the current fallback rank.
  133043. * @returns the new fallback rank.
  133044. */
  133045. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133046. /**
  133047. * Add the required uniforms to the current list.
  133048. * @param uniforms defines the current uniform list.
  133049. */
  133050. static AddUniforms(uniforms: string[]): void;
  133051. /**
  133052. * Add the required samplers to the current list.
  133053. * @param samplers defines the current sampler list.
  133054. */
  133055. static AddSamplers(samplers: string[]): void;
  133056. /**
  133057. * Add the required uniforms to the current buffer.
  133058. * @param uniformBuffer defines the current uniform buffer.
  133059. */
  133060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133061. /**
  133062. * Makes a duplicate of the current configuration into another one.
  133063. * @param configuration define the config where to copy the info
  133064. */
  133065. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133066. /**
  133067. * Serializes this Sub Surface configuration.
  133068. * @returns - An object with the serialized config.
  133069. */
  133070. serialize(): any;
  133071. /**
  133072. * Parses a anisotropy Configuration from a serialized object.
  133073. * @param source - Serialized object.
  133074. * @param scene Defines the scene we are parsing for
  133075. * @param rootUrl Defines the rootUrl to load from
  133076. */
  133077. parse(source: any, scene: Scene, rootUrl: string): void;
  133078. }
  133079. }
  133080. declare module BABYLON {
  133081. /** @hidden */
  133082. export var prePassDeclaration: {
  133083. name: string;
  133084. shader: string;
  133085. };
  133086. }
  133087. declare module BABYLON {
  133088. /** @hidden */
  133089. export var pbrFragmentDeclaration: {
  133090. name: string;
  133091. shader: string;
  133092. };
  133093. }
  133094. declare module BABYLON {
  133095. /** @hidden */
  133096. export var pbrUboDeclaration: {
  133097. name: string;
  133098. shader: string;
  133099. };
  133100. }
  133101. declare module BABYLON {
  133102. /** @hidden */
  133103. export var pbrFragmentExtraDeclaration: {
  133104. name: string;
  133105. shader: string;
  133106. };
  133107. }
  133108. declare module BABYLON {
  133109. /** @hidden */
  133110. export var pbrFragmentSamplersDeclaration: {
  133111. name: string;
  133112. shader: string;
  133113. };
  133114. }
  133115. declare module BABYLON {
  133116. /** @hidden */
  133117. export var subSurfaceScatteringFunctions: {
  133118. name: string;
  133119. shader: string;
  133120. };
  133121. }
  133122. declare module BABYLON {
  133123. /** @hidden */
  133124. export var importanceSampling: {
  133125. name: string;
  133126. shader: string;
  133127. };
  133128. }
  133129. declare module BABYLON {
  133130. /** @hidden */
  133131. export var pbrHelperFunctions: {
  133132. name: string;
  133133. shader: string;
  133134. };
  133135. }
  133136. declare module BABYLON {
  133137. /** @hidden */
  133138. export var harmonicsFunctions: {
  133139. name: string;
  133140. shader: string;
  133141. };
  133142. }
  133143. declare module BABYLON {
  133144. /** @hidden */
  133145. export var pbrDirectLightingSetupFunctions: {
  133146. name: string;
  133147. shader: string;
  133148. };
  133149. }
  133150. declare module BABYLON {
  133151. /** @hidden */
  133152. export var pbrDirectLightingFalloffFunctions: {
  133153. name: string;
  133154. shader: string;
  133155. };
  133156. }
  133157. declare module BABYLON {
  133158. /** @hidden */
  133159. export var pbrBRDFFunctions: {
  133160. name: string;
  133161. shader: string;
  133162. };
  133163. }
  133164. declare module BABYLON {
  133165. /** @hidden */
  133166. export var hdrFilteringFunctions: {
  133167. name: string;
  133168. shader: string;
  133169. };
  133170. }
  133171. declare module BABYLON {
  133172. /** @hidden */
  133173. export var pbrDirectLightingFunctions: {
  133174. name: string;
  133175. shader: string;
  133176. };
  133177. }
  133178. declare module BABYLON {
  133179. /** @hidden */
  133180. export var pbrIBLFunctions: {
  133181. name: string;
  133182. shader: string;
  133183. };
  133184. }
  133185. declare module BABYLON {
  133186. /** @hidden */
  133187. export var pbrBlockAlbedoOpacity: {
  133188. name: string;
  133189. shader: string;
  133190. };
  133191. }
  133192. declare module BABYLON {
  133193. /** @hidden */
  133194. export var pbrBlockReflectivity: {
  133195. name: string;
  133196. shader: string;
  133197. };
  133198. }
  133199. declare module BABYLON {
  133200. /** @hidden */
  133201. export var pbrBlockAmbientOcclusion: {
  133202. name: string;
  133203. shader: string;
  133204. };
  133205. }
  133206. declare module BABYLON {
  133207. /** @hidden */
  133208. export var pbrBlockAlphaFresnel: {
  133209. name: string;
  133210. shader: string;
  133211. };
  133212. }
  133213. declare module BABYLON {
  133214. /** @hidden */
  133215. export var pbrBlockAnisotropic: {
  133216. name: string;
  133217. shader: string;
  133218. };
  133219. }
  133220. declare module BABYLON {
  133221. /** @hidden */
  133222. export var pbrBlockReflection: {
  133223. name: string;
  133224. shader: string;
  133225. };
  133226. }
  133227. declare module BABYLON {
  133228. /** @hidden */
  133229. export var pbrBlockSheen: {
  133230. name: string;
  133231. shader: string;
  133232. };
  133233. }
  133234. declare module BABYLON {
  133235. /** @hidden */
  133236. export var pbrBlockClearcoat: {
  133237. name: string;
  133238. shader: string;
  133239. };
  133240. }
  133241. declare module BABYLON {
  133242. /** @hidden */
  133243. export var pbrBlockSubSurface: {
  133244. name: string;
  133245. shader: string;
  133246. };
  133247. }
  133248. declare module BABYLON {
  133249. /** @hidden */
  133250. export var pbrBlockNormalGeometric: {
  133251. name: string;
  133252. shader: string;
  133253. };
  133254. }
  133255. declare module BABYLON {
  133256. /** @hidden */
  133257. export var pbrBlockNormalFinal: {
  133258. name: string;
  133259. shader: string;
  133260. };
  133261. }
  133262. declare module BABYLON {
  133263. /** @hidden */
  133264. export var pbrBlockGeometryInfo: {
  133265. name: string;
  133266. shader: string;
  133267. };
  133268. }
  133269. declare module BABYLON {
  133270. /** @hidden */
  133271. export var pbrBlockReflectance0: {
  133272. name: string;
  133273. shader: string;
  133274. };
  133275. }
  133276. declare module BABYLON {
  133277. /** @hidden */
  133278. export var pbrBlockReflectance: {
  133279. name: string;
  133280. shader: string;
  133281. };
  133282. }
  133283. declare module BABYLON {
  133284. /** @hidden */
  133285. export var pbrBlockDirectLighting: {
  133286. name: string;
  133287. shader: string;
  133288. };
  133289. }
  133290. declare module BABYLON {
  133291. /** @hidden */
  133292. export var pbrBlockFinalLitComponents: {
  133293. name: string;
  133294. shader: string;
  133295. };
  133296. }
  133297. declare module BABYLON {
  133298. /** @hidden */
  133299. export var pbrBlockFinalUnlitComponents: {
  133300. name: string;
  133301. shader: string;
  133302. };
  133303. }
  133304. declare module BABYLON {
  133305. /** @hidden */
  133306. export var pbrBlockFinalColorComposition: {
  133307. name: string;
  133308. shader: string;
  133309. };
  133310. }
  133311. declare module BABYLON {
  133312. /** @hidden */
  133313. export var pbrBlockImageProcessing: {
  133314. name: string;
  133315. shader: string;
  133316. };
  133317. }
  133318. declare module BABYLON {
  133319. /** @hidden */
  133320. export var pbrDebug: {
  133321. name: string;
  133322. shader: string;
  133323. };
  133324. }
  133325. declare module BABYLON {
  133326. /** @hidden */
  133327. export var pbrPixelShader: {
  133328. name: string;
  133329. shader: string;
  133330. };
  133331. }
  133332. declare module BABYLON {
  133333. /** @hidden */
  133334. export var pbrVertexDeclaration: {
  133335. name: string;
  133336. shader: string;
  133337. };
  133338. }
  133339. declare module BABYLON {
  133340. /** @hidden */
  133341. export var pbrVertexShader: {
  133342. name: string;
  133343. shader: string;
  133344. };
  133345. }
  133346. declare module BABYLON {
  133347. /**
  133348. * Manages the defines for the PBR Material.
  133349. * @hidden
  133350. */
  133351. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133352. PBR: boolean;
  133353. NUM_SAMPLES: string;
  133354. REALTIME_FILTERING: boolean;
  133355. MAINUV1: boolean;
  133356. MAINUV2: boolean;
  133357. UV1: boolean;
  133358. UV2: boolean;
  133359. ALBEDO: boolean;
  133360. GAMMAALBEDO: boolean;
  133361. ALBEDODIRECTUV: number;
  133362. VERTEXCOLOR: boolean;
  133363. DETAIL: boolean;
  133364. DETAILDIRECTUV: number;
  133365. DETAIL_NORMALBLENDMETHOD: number;
  133366. AMBIENT: boolean;
  133367. AMBIENTDIRECTUV: number;
  133368. AMBIENTINGRAYSCALE: boolean;
  133369. OPACITY: boolean;
  133370. VERTEXALPHA: boolean;
  133371. OPACITYDIRECTUV: number;
  133372. OPACITYRGB: boolean;
  133373. ALPHATEST: boolean;
  133374. DEPTHPREPASS: boolean;
  133375. ALPHABLEND: boolean;
  133376. ALPHAFROMALBEDO: boolean;
  133377. ALPHATESTVALUE: string;
  133378. SPECULAROVERALPHA: boolean;
  133379. RADIANCEOVERALPHA: boolean;
  133380. ALPHAFRESNEL: boolean;
  133381. LINEARALPHAFRESNEL: boolean;
  133382. PREMULTIPLYALPHA: boolean;
  133383. EMISSIVE: boolean;
  133384. EMISSIVEDIRECTUV: number;
  133385. REFLECTIVITY: boolean;
  133386. REFLECTIVITYDIRECTUV: number;
  133387. SPECULARTERM: boolean;
  133388. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133389. MICROSURFACEAUTOMATIC: boolean;
  133390. LODBASEDMICROSFURACE: boolean;
  133391. MICROSURFACEMAP: boolean;
  133392. MICROSURFACEMAPDIRECTUV: number;
  133393. METALLICWORKFLOW: boolean;
  133394. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133395. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133396. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133397. AOSTOREINMETALMAPRED: boolean;
  133398. METALLIC_REFLECTANCE: boolean;
  133399. METALLIC_REFLECTANCEDIRECTUV: number;
  133400. ENVIRONMENTBRDF: boolean;
  133401. ENVIRONMENTBRDF_RGBD: boolean;
  133402. NORMAL: boolean;
  133403. TANGENT: boolean;
  133404. BUMP: boolean;
  133405. BUMPDIRECTUV: number;
  133406. OBJECTSPACE_NORMALMAP: boolean;
  133407. PARALLAX: boolean;
  133408. PARALLAXOCCLUSION: boolean;
  133409. NORMALXYSCALE: boolean;
  133410. LIGHTMAP: boolean;
  133411. LIGHTMAPDIRECTUV: number;
  133412. USELIGHTMAPASSHADOWMAP: boolean;
  133413. GAMMALIGHTMAP: boolean;
  133414. RGBDLIGHTMAP: boolean;
  133415. REFLECTION: boolean;
  133416. REFLECTIONMAP_3D: boolean;
  133417. REFLECTIONMAP_SPHERICAL: boolean;
  133418. REFLECTIONMAP_PLANAR: boolean;
  133419. REFLECTIONMAP_CUBIC: boolean;
  133420. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133421. REFLECTIONMAP_PROJECTION: boolean;
  133422. REFLECTIONMAP_SKYBOX: boolean;
  133423. REFLECTIONMAP_EXPLICIT: boolean;
  133424. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133425. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133426. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133427. INVERTCUBICMAP: boolean;
  133428. USESPHERICALFROMREFLECTIONMAP: boolean;
  133429. USEIRRADIANCEMAP: boolean;
  133430. SPHERICAL_HARMONICS: boolean;
  133431. USESPHERICALINVERTEX: boolean;
  133432. REFLECTIONMAP_OPPOSITEZ: boolean;
  133433. LODINREFLECTIONALPHA: boolean;
  133434. GAMMAREFLECTION: boolean;
  133435. RGBDREFLECTION: boolean;
  133436. LINEARSPECULARREFLECTION: boolean;
  133437. RADIANCEOCCLUSION: boolean;
  133438. HORIZONOCCLUSION: boolean;
  133439. INSTANCES: boolean;
  133440. THIN_INSTANCES: boolean;
  133441. PREPASS: boolean;
  133442. SCENE_MRT_COUNT: number;
  133443. NUM_BONE_INFLUENCERS: number;
  133444. BonesPerMesh: number;
  133445. BONETEXTURE: boolean;
  133446. NONUNIFORMSCALING: boolean;
  133447. MORPHTARGETS: boolean;
  133448. MORPHTARGETS_NORMAL: boolean;
  133449. MORPHTARGETS_TANGENT: boolean;
  133450. MORPHTARGETS_UV: boolean;
  133451. NUM_MORPH_INFLUENCERS: number;
  133452. IMAGEPROCESSING: boolean;
  133453. VIGNETTE: boolean;
  133454. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133455. VIGNETTEBLENDMODEOPAQUE: boolean;
  133456. TONEMAPPING: boolean;
  133457. TONEMAPPING_ACES: boolean;
  133458. CONTRAST: boolean;
  133459. COLORCURVES: boolean;
  133460. COLORGRADING: boolean;
  133461. COLORGRADING3D: boolean;
  133462. SAMPLER3DGREENDEPTH: boolean;
  133463. SAMPLER3DBGRMAP: boolean;
  133464. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133465. EXPOSURE: boolean;
  133466. MULTIVIEW: boolean;
  133467. USEPHYSICALLIGHTFALLOFF: boolean;
  133468. USEGLTFLIGHTFALLOFF: boolean;
  133469. TWOSIDEDLIGHTING: boolean;
  133470. SHADOWFLOAT: boolean;
  133471. CLIPPLANE: boolean;
  133472. CLIPPLANE2: boolean;
  133473. CLIPPLANE3: boolean;
  133474. CLIPPLANE4: boolean;
  133475. CLIPPLANE5: boolean;
  133476. CLIPPLANE6: boolean;
  133477. POINTSIZE: boolean;
  133478. FOG: boolean;
  133479. LOGARITHMICDEPTH: boolean;
  133480. FORCENORMALFORWARD: boolean;
  133481. SPECULARAA: boolean;
  133482. CLEARCOAT: boolean;
  133483. CLEARCOAT_DEFAULTIOR: boolean;
  133484. CLEARCOAT_TEXTURE: boolean;
  133485. CLEARCOAT_TEXTUREDIRECTUV: number;
  133486. CLEARCOAT_BUMP: boolean;
  133487. CLEARCOAT_BUMPDIRECTUV: number;
  133488. CLEARCOAT_TINT: boolean;
  133489. CLEARCOAT_TINT_TEXTURE: boolean;
  133490. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133491. ANISOTROPIC: boolean;
  133492. ANISOTROPIC_TEXTURE: boolean;
  133493. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133494. BRDF_V_HEIGHT_CORRELATED: boolean;
  133495. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133496. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133497. SHEEN: boolean;
  133498. SHEEN_TEXTURE: boolean;
  133499. SHEEN_TEXTUREDIRECTUV: number;
  133500. SHEEN_LINKWITHALBEDO: boolean;
  133501. SHEEN_ROUGHNESS: boolean;
  133502. SHEEN_ALBEDOSCALING: boolean;
  133503. SUBSURFACE: boolean;
  133504. SS_REFRACTION: boolean;
  133505. SS_TRANSLUCENCY: boolean;
  133506. SS_SCATTERING: boolean;
  133507. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133508. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133509. SS_REFRACTIONMAP_3D: boolean;
  133510. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133511. SS_LODINREFRACTIONALPHA: boolean;
  133512. SS_GAMMAREFRACTION: boolean;
  133513. SS_RGBDREFRACTION: boolean;
  133514. SS_LINEARSPECULARREFRACTION: boolean;
  133515. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133516. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133517. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133518. UNLIT: boolean;
  133519. DEBUGMODE: number;
  133520. /**
  133521. * Initializes the PBR Material defines.
  133522. */
  133523. constructor();
  133524. /**
  133525. * Resets the PBR Material defines.
  133526. */
  133527. reset(): void;
  133528. }
  133529. /**
  133530. * The Physically based material base class of BJS.
  133531. *
  133532. * This offers the main features of a standard PBR material.
  133533. * For more information, please refer to the documentation :
  133534. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133535. */
  133536. export abstract class PBRBaseMaterial extends PushMaterial {
  133537. /**
  133538. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133539. */
  133540. static readonly PBRMATERIAL_OPAQUE: number;
  133541. /**
  133542. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133543. */
  133544. static readonly PBRMATERIAL_ALPHATEST: number;
  133545. /**
  133546. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133547. */
  133548. static readonly PBRMATERIAL_ALPHABLEND: number;
  133549. /**
  133550. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133551. * They are also discarded below the alpha cutoff threshold to improve performances.
  133552. */
  133553. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133554. /**
  133555. * Defines the default value of how much AO map is occluding the analytical lights
  133556. * (point spot...).
  133557. */
  133558. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133559. /**
  133560. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133561. */
  133562. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133563. /**
  133564. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133565. * to enhance interoperability with other engines.
  133566. */
  133567. static readonly LIGHTFALLOFF_GLTF: number;
  133568. /**
  133569. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133570. * to enhance interoperability with other materials.
  133571. */
  133572. static readonly LIGHTFALLOFF_STANDARD: number;
  133573. /**
  133574. * Intensity of the direct lights e.g. the four lights available in your scene.
  133575. * This impacts both the direct diffuse and specular highlights.
  133576. */
  133577. protected _directIntensity: number;
  133578. /**
  133579. * Intensity of the emissive part of the material.
  133580. * This helps controlling the emissive effect without modifying the emissive color.
  133581. */
  133582. protected _emissiveIntensity: number;
  133583. /**
  133584. * Intensity of the environment e.g. how much the environment will light the object
  133585. * either through harmonics for rough material or through the refelction for shiny ones.
  133586. */
  133587. protected _environmentIntensity: number;
  133588. /**
  133589. * This is a special control allowing the reduction of the specular highlights coming from the
  133590. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133591. */
  133592. protected _specularIntensity: number;
  133593. /**
  133594. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133595. */
  133596. private _lightingInfos;
  133597. /**
  133598. * Debug Control allowing disabling the bump map on this material.
  133599. */
  133600. protected _disableBumpMap: boolean;
  133601. /**
  133602. * AKA Diffuse Texture in standard nomenclature.
  133603. */
  133604. protected _albedoTexture: Nullable<BaseTexture>;
  133605. /**
  133606. * AKA Occlusion Texture in other nomenclature.
  133607. */
  133608. protected _ambientTexture: Nullable<BaseTexture>;
  133609. /**
  133610. * AKA Occlusion Texture Intensity in other nomenclature.
  133611. */
  133612. protected _ambientTextureStrength: number;
  133613. /**
  133614. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133615. * 1 means it completely occludes it
  133616. * 0 mean it has no impact
  133617. */
  133618. protected _ambientTextureImpactOnAnalyticalLights: number;
  133619. /**
  133620. * Stores the alpha values in a texture.
  133621. */
  133622. protected _opacityTexture: Nullable<BaseTexture>;
  133623. /**
  133624. * Stores the reflection values in a texture.
  133625. */
  133626. protected _reflectionTexture: Nullable<BaseTexture>;
  133627. /**
  133628. * Stores the emissive values in a texture.
  133629. */
  133630. protected _emissiveTexture: Nullable<BaseTexture>;
  133631. /**
  133632. * AKA Specular texture in other nomenclature.
  133633. */
  133634. protected _reflectivityTexture: Nullable<BaseTexture>;
  133635. /**
  133636. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133637. */
  133638. protected _metallicTexture: Nullable<BaseTexture>;
  133639. /**
  133640. * Specifies the metallic scalar of the metallic/roughness workflow.
  133641. * Can also be used to scale the metalness values of the metallic texture.
  133642. */
  133643. protected _metallic: Nullable<number>;
  133644. /**
  133645. * Specifies the roughness scalar of the metallic/roughness workflow.
  133646. * Can also be used to scale the roughness values of the metallic texture.
  133647. */
  133648. protected _roughness: Nullable<number>;
  133649. /**
  133650. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133651. * By default the indexOfrefraction is used to compute F0;
  133652. *
  133653. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133654. *
  133655. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133656. * F90 = metallicReflectanceColor;
  133657. */
  133658. protected _metallicF0Factor: number;
  133659. /**
  133660. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133661. * By default the F90 is always 1;
  133662. *
  133663. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133664. *
  133665. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133666. * F90 = metallicReflectanceColor;
  133667. */
  133668. protected _metallicReflectanceColor: Color3;
  133669. /**
  133670. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133671. * This is multiply against the scalar values defined in the material.
  133672. */
  133673. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133674. /**
  133675. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133676. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133677. */
  133678. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133679. /**
  133680. * Stores surface normal data used to displace a mesh in a texture.
  133681. */
  133682. protected _bumpTexture: Nullable<BaseTexture>;
  133683. /**
  133684. * Stores the pre-calculated light information of a mesh in a texture.
  133685. */
  133686. protected _lightmapTexture: Nullable<BaseTexture>;
  133687. /**
  133688. * The color of a material in ambient lighting.
  133689. */
  133690. protected _ambientColor: Color3;
  133691. /**
  133692. * AKA Diffuse Color in other nomenclature.
  133693. */
  133694. protected _albedoColor: Color3;
  133695. /**
  133696. * AKA Specular Color in other nomenclature.
  133697. */
  133698. protected _reflectivityColor: Color3;
  133699. /**
  133700. * The color applied when light is reflected from a material.
  133701. */
  133702. protected _reflectionColor: Color3;
  133703. /**
  133704. * The color applied when light is emitted from a material.
  133705. */
  133706. protected _emissiveColor: Color3;
  133707. /**
  133708. * AKA Glossiness in other nomenclature.
  133709. */
  133710. protected _microSurface: number;
  133711. /**
  133712. * Specifies that the material will use the light map as a show map.
  133713. */
  133714. protected _useLightmapAsShadowmap: boolean;
  133715. /**
  133716. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133717. * makes the reflect vector face the model (under horizon).
  133718. */
  133719. protected _useHorizonOcclusion: boolean;
  133720. /**
  133721. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133722. * too much the area relying on ambient texture to define their ambient occlusion.
  133723. */
  133724. protected _useRadianceOcclusion: boolean;
  133725. /**
  133726. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133727. */
  133728. protected _useAlphaFromAlbedoTexture: boolean;
  133729. /**
  133730. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133731. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133732. */
  133733. protected _useSpecularOverAlpha: boolean;
  133734. /**
  133735. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133736. */
  133737. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133738. /**
  133739. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133740. */
  133741. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133742. /**
  133743. * Specifies if the metallic texture contains the roughness information in its green channel.
  133744. */
  133745. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133746. /**
  133747. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133748. */
  133749. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133750. /**
  133751. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133752. */
  133753. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133754. /**
  133755. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133756. */
  133757. protected _useAmbientInGrayScale: boolean;
  133758. /**
  133759. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133760. * The material will try to infer what glossiness each pixel should be.
  133761. */
  133762. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133763. /**
  133764. * Defines the falloff type used in this material.
  133765. * It by default is Physical.
  133766. */
  133767. protected _lightFalloff: number;
  133768. /**
  133769. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133770. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133771. */
  133772. protected _useRadianceOverAlpha: boolean;
  133773. /**
  133774. * Allows using an object space normal map (instead of tangent space).
  133775. */
  133776. protected _useObjectSpaceNormalMap: boolean;
  133777. /**
  133778. * Allows using the bump map in parallax mode.
  133779. */
  133780. protected _useParallax: boolean;
  133781. /**
  133782. * Allows using the bump map in parallax occlusion mode.
  133783. */
  133784. protected _useParallaxOcclusion: boolean;
  133785. /**
  133786. * Controls the scale bias of the parallax mode.
  133787. */
  133788. protected _parallaxScaleBias: number;
  133789. /**
  133790. * If sets to true, disables all the lights affecting the material.
  133791. */
  133792. protected _disableLighting: boolean;
  133793. /**
  133794. * Number of Simultaneous lights allowed on the material.
  133795. */
  133796. protected _maxSimultaneousLights: number;
  133797. /**
  133798. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133799. */
  133800. protected _invertNormalMapX: boolean;
  133801. /**
  133802. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133803. */
  133804. protected _invertNormalMapY: boolean;
  133805. /**
  133806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133807. */
  133808. protected _twoSidedLighting: boolean;
  133809. /**
  133810. * Defines the alpha limits in alpha test mode.
  133811. */
  133812. protected _alphaCutOff: number;
  133813. /**
  133814. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133815. */
  133816. protected _forceAlphaTest: boolean;
  133817. /**
  133818. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133819. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133820. */
  133821. protected _useAlphaFresnel: boolean;
  133822. /**
  133823. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133824. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133825. */
  133826. protected _useLinearAlphaFresnel: boolean;
  133827. /**
  133828. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133829. * from cos thetav and roughness:
  133830. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133831. */
  133832. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133833. /**
  133834. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133835. */
  133836. protected _forceIrradianceInFragment: boolean;
  133837. private _realTimeFiltering;
  133838. /**
  133839. * Enables realtime filtering on the texture.
  133840. */
  133841. get realTimeFiltering(): boolean;
  133842. set realTimeFiltering(b: boolean);
  133843. private _realTimeFilteringQuality;
  133844. /**
  133845. * Quality switch for realtime filtering
  133846. */
  133847. get realTimeFilteringQuality(): number;
  133848. set realTimeFilteringQuality(n: number);
  133849. /**
  133850. * Should this material render to several textures at once
  133851. */
  133852. get shouldRenderToMRT(): boolean;
  133853. /**
  133854. * Force normal to face away from face.
  133855. */
  133856. protected _forceNormalForward: boolean;
  133857. /**
  133858. * Enables specular anti aliasing in the PBR shader.
  133859. * It will both interacts on the Geometry for analytical and IBL lighting.
  133860. * It also prefilter the roughness map based on the bump values.
  133861. */
  133862. protected _enableSpecularAntiAliasing: boolean;
  133863. /**
  133864. * Default configuration related to image processing available in the PBR Material.
  133865. */
  133866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133867. /**
  133868. * Keep track of the image processing observer to allow dispose and replace.
  133869. */
  133870. private _imageProcessingObserver;
  133871. /**
  133872. * Attaches a new image processing configuration to the PBR Material.
  133873. * @param configuration
  133874. */
  133875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133876. /**
  133877. * Stores the available render targets.
  133878. */
  133879. private _renderTargets;
  133880. /**
  133881. * Sets the global ambient color for the material used in lighting calculations.
  133882. */
  133883. private _globalAmbientColor;
  133884. /**
  133885. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133886. */
  133887. private _useLogarithmicDepth;
  133888. /**
  133889. * If set to true, no lighting calculations will be applied.
  133890. */
  133891. private _unlit;
  133892. private _debugMode;
  133893. /**
  133894. * @hidden
  133895. * This is reserved for the inspector.
  133896. * Defines the material debug mode.
  133897. * It helps seeing only some components of the material while troubleshooting.
  133898. */
  133899. debugMode: number;
  133900. /**
  133901. * @hidden
  133902. * This is reserved for the inspector.
  133903. * Specify from where on screen the debug mode should start.
  133904. * The value goes from -1 (full screen) to 1 (not visible)
  133905. * It helps with side by side comparison against the final render
  133906. * This defaults to -1
  133907. */
  133908. private debugLimit;
  133909. /**
  133910. * @hidden
  133911. * This is reserved for the inspector.
  133912. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133913. * You can use the factor to better multiply the final value.
  133914. */
  133915. private debugFactor;
  133916. /**
  133917. * Defines the clear coat layer parameters for the material.
  133918. */
  133919. readonly clearCoat: PBRClearCoatConfiguration;
  133920. /**
  133921. * Defines the anisotropic parameters for the material.
  133922. */
  133923. readonly anisotropy: PBRAnisotropicConfiguration;
  133924. /**
  133925. * Defines the BRDF parameters for the material.
  133926. */
  133927. readonly brdf: PBRBRDFConfiguration;
  133928. /**
  133929. * Defines the Sheen parameters for the material.
  133930. */
  133931. readonly sheen: PBRSheenConfiguration;
  133932. /**
  133933. * Defines the SubSurface parameters for the material.
  133934. */
  133935. readonly subSurface: PBRSubSurfaceConfiguration;
  133936. /**
  133937. * Defines the detail map parameters for the material.
  133938. */
  133939. readonly detailMap: DetailMapConfiguration;
  133940. protected _rebuildInParallel: boolean;
  133941. /**
  133942. * Instantiates a new PBRMaterial instance.
  133943. *
  133944. * @param name The material name
  133945. * @param scene The scene the material will be use in.
  133946. */
  133947. constructor(name: string, scene: Scene);
  133948. /**
  133949. * Gets a boolean indicating that current material needs to register RTT
  133950. */
  133951. get hasRenderTargetTextures(): boolean;
  133952. /**
  133953. * Gets the name of the material class.
  133954. */
  133955. getClassName(): string;
  133956. /**
  133957. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133958. */
  133959. get useLogarithmicDepth(): boolean;
  133960. /**
  133961. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133962. */
  133963. set useLogarithmicDepth(value: boolean);
  133964. /**
  133965. * Returns true if alpha blending should be disabled.
  133966. */
  133967. protected get _disableAlphaBlending(): boolean;
  133968. /**
  133969. * Specifies whether or not this material should be rendered in alpha blend mode.
  133970. */
  133971. needAlphaBlending(): boolean;
  133972. /**
  133973. * Specifies whether or not this material should be rendered in alpha test mode.
  133974. */
  133975. needAlphaTesting(): boolean;
  133976. /**
  133977. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133978. */
  133979. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133980. /**
  133981. * Gets the texture used for the alpha test.
  133982. */
  133983. getAlphaTestTexture(): Nullable<BaseTexture>;
  133984. /**
  133985. * Specifies that the submesh is ready to be used.
  133986. * @param mesh - BJS mesh.
  133987. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133988. * @param useInstances - Specifies that instances should be used.
  133989. * @returns - boolean indicating that the submesh is ready or not.
  133990. */
  133991. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133992. /**
  133993. * Specifies if the material uses metallic roughness workflow.
  133994. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133995. */
  133996. isMetallicWorkflow(): boolean;
  133997. private _prepareEffect;
  133998. private _prepareDefines;
  133999. /**
  134000. * Force shader compilation
  134001. */
  134002. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134003. /**
  134004. * Initializes the uniform buffer layout for the shader.
  134005. */
  134006. buildUniformLayout(): void;
  134007. /**
  134008. * Unbinds the material from the mesh
  134009. */
  134010. unbind(): void;
  134011. /**
  134012. * Binds the submesh data.
  134013. * @param world - The world matrix.
  134014. * @param mesh - The BJS mesh.
  134015. * @param subMesh - A submesh of the BJS mesh.
  134016. */
  134017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134018. /**
  134019. * Returns the animatable textures.
  134020. * @returns - Array of animatable textures.
  134021. */
  134022. getAnimatables(): IAnimatable[];
  134023. /**
  134024. * Returns the texture used for reflections.
  134025. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134026. */
  134027. private _getReflectionTexture;
  134028. /**
  134029. * Returns an array of the actively used textures.
  134030. * @returns - Array of BaseTextures
  134031. */
  134032. getActiveTextures(): BaseTexture[];
  134033. /**
  134034. * Checks to see if a texture is used in the material.
  134035. * @param texture - Base texture to use.
  134036. * @returns - Boolean specifying if a texture is used in the material.
  134037. */
  134038. hasTexture(texture: BaseTexture): boolean;
  134039. /**
  134040. * Disposes the resources of the material.
  134041. * @param forceDisposeEffect - Forces the disposal of effects.
  134042. * @param forceDisposeTextures - Forces the disposal of all textures.
  134043. */
  134044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134045. }
  134046. }
  134047. declare module BABYLON {
  134048. /**
  134049. * The Physically based material of BJS.
  134050. *
  134051. * This offers the main features of a standard PBR material.
  134052. * For more information, please refer to the documentation :
  134053. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134054. */
  134055. export class PBRMaterial extends PBRBaseMaterial {
  134056. /**
  134057. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134058. */
  134059. static readonly PBRMATERIAL_OPAQUE: number;
  134060. /**
  134061. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134062. */
  134063. static readonly PBRMATERIAL_ALPHATEST: number;
  134064. /**
  134065. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134066. */
  134067. static readonly PBRMATERIAL_ALPHABLEND: number;
  134068. /**
  134069. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134070. * They are also discarded below the alpha cutoff threshold to improve performances.
  134071. */
  134072. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134073. /**
  134074. * Defines the default value of how much AO map is occluding the analytical lights
  134075. * (point spot...).
  134076. */
  134077. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134078. /**
  134079. * Intensity of the direct lights e.g. the four lights available in your scene.
  134080. * This impacts both the direct diffuse and specular highlights.
  134081. */
  134082. directIntensity: number;
  134083. /**
  134084. * Intensity of the emissive part of the material.
  134085. * This helps controlling the emissive effect without modifying the emissive color.
  134086. */
  134087. emissiveIntensity: number;
  134088. /**
  134089. * Intensity of the environment e.g. how much the environment will light the object
  134090. * either through harmonics for rough material or through the refelction for shiny ones.
  134091. */
  134092. environmentIntensity: number;
  134093. /**
  134094. * This is a special control allowing the reduction of the specular highlights coming from the
  134095. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134096. */
  134097. specularIntensity: number;
  134098. /**
  134099. * Debug Control allowing disabling the bump map on this material.
  134100. */
  134101. disableBumpMap: boolean;
  134102. /**
  134103. * AKA Diffuse Texture in standard nomenclature.
  134104. */
  134105. albedoTexture: BaseTexture;
  134106. /**
  134107. * AKA Occlusion Texture in other nomenclature.
  134108. */
  134109. ambientTexture: BaseTexture;
  134110. /**
  134111. * AKA Occlusion Texture Intensity in other nomenclature.
  134112. */
  134113. ambientTextureStrength: number;
  134114. /**
  134115. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134116. * 1 means it completely occludes it
  134117. * 0 mean it has no impact
  134118. */
  134119. ambientTextureImpactOnAnalyticalLights: number;
  134120. /**
  134121. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134122. */
  134123. opacityTexture: BaseTexture;
  134124. /**
  134125. * Stores the reflection values in a texture.
  134126. */
  134127. reflectionTexture: Nullable<BaseTexture>;
  134128. /**
  134129. * Stores the emissive values in a texture.
  134130. */
  134131. emissiveTexture: BaseTexture;
  134132. /**
  134133. * AKA Specular texture in other nomenclature.
  134134. */
  134135. reflectivityTexture: BaseTexture;
  134136. /**
  134137. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134138. */
  134139. metallicTexture: BaseTexture;
  134140. /**
  134141. * Specifies the metallic scalar of the metallic/roughness workflow.
  134142. * Can also be used to scale the metalness values of the metallic texture.
  134143. */
  134144. metallic: Nullable<number>;
  134145. /**
  134146. * Specifies the roughness scalar of the metallic/roughness workflow.
  134147. * Can also be used to scale the roughness values of the metallic texture.
  134148. */
  134149. roughness: Nullable<number>;
  134150. /**
  134151. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134152. * By default the indexOfrefraction is used to compute F0;
  134153. *
  134154. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134155. *
  134156. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134157. * F90 = metallicReflectanceColor;
  134158. */
  134159. metallicF0Factor: number;
  134160. /**
  134161. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134162. * By default the F90 is always 1;
  134163. *
  134164. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134165. *
  134166. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134167. * F90 = metallicReflectanceColor;
  134168. */
  134169. metallicReflectanceColor: Color3;
  134170. /**
  134171. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134172. * This is multiply against the scalar values defined in the material.
  134173. */
  134174. metallicReflectanceTexture: Nullable<BaseTexture>;
  134175. /**
  134176. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134177. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134178. */
  134179. microSurfaceTexture: BaseTexture;
  134180. /**
  134181. * Stores surface normal data used to displace a mesh in a texture.
  134182. */
  134183. bumpTexture: BaseTexture;
  134184. /**
  134185. * Stores the pre-calculated light information of a mesh in a texture.
  134186. */
  134187. lightmapTexture: BaseTexture;
  134188. /**
  134189. * Stores the refracted light information in a texture.
  134190. */
  134191. get refractionTexture(): Nullable<BaseTexture>;
  134192. set refractionTexture(value: Nullable<BaseTexture>);
  134193. /**
  134194. * The color of a material in ambient lighting.
  134195. */
  134196. ambientColor: Color3;
  134197. /**
  134198. * AKA Diffuse Color in other nomenclature.
  134199. */
  134200. albedoColor: Color3;
  134201. /**
  134202. * AKA Specular Color in other nomenclature.
  134203. */
  134204. reflectivityColor: Color3;
  134205. /**
  134206. * The color reflected from the material.
  134207. */
  134208. reflectionColor: Color3;
  134209. /**
  134210. * The color emitted from the material.
  134211. */
  134212. emissiveColor: Color3;
  134213. /**
  134214. * AKA Glossiness in other nomenclature.
  134215. */
  134216. microSurface: number;
  134217. /**
  134218. * Index of refraction of the material base layer.
  134219. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134220. *
  134221. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134222. *
  134223. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134224. */
  134225. get indexOfRefraction(): number;
  134226. set indexOfRefraction(value: number);
  134227. /**
  134228. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134229. */
  134230. get invertRefractionY(): boolean;
  134231. set invertRefractionY(value: boolean);
  134232. /**
  134233. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134234. * Materials half opaque for instance using refraction could benefit from this control.
  134235. */
  134236. get linkRefractionWithTransparency(): boolean;
  134237. set linkRefractionWithTransparency(value: boolean);
  134238. /**
  134239. * If true, the light map contains occlusion information instead of lighting info.
  134240. */
  134241. useLightmapAsShadowmap: boolean;
  134242. /**
  134243. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134244. */
  134245. useAlphaFromAlbedoTexture: boolean;
  134246. /**
  134247. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134248. */
  134249. forceAlphaTest: boolean;
  134250. /**
  134251. * Defines the alpha limits in alpha test mode.
  134252. */
  134253. alphaCutOff: number;
  134254. /**
  134255. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134256. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134257. */
  134258. useSpecularOverAlpha: boolean;
  134259. /**
  134260. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134261. */
  134262. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134263. /**
  134264. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134265. */
  134266. useRoughnessFromMetallicTextureAlpha: boolean;
  134267. /**
  134268. * Specifies if the metallic texture contains the roughness information in its green channel.
  134269. */
  134270. useRoughnessFromMetallicTextureGreen: boolean;
  134271. /**
  134272. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134273. */
  134274. useMetallnessFromMetallicTextureBlue: boolean;
  134275. /**
  134276. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134277. */
  134278. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134279. /**
  134280. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134281. */
  134282. useAmbientInGrayScale: boolean;
  134283. /**
  134284. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134285. * The material will try to infer what glossiness each pixel should be.
  134286. */
  134287. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134288. /**
  134289. * BJS is using an harcoded light falloff based on a manually sets up range.
  134290. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134291. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134292. */
  134293. get usePhysicalLightFalloff(): boolean;
  134294. /**
  134295. * BJS is using an harcoded light falloff based on a manually sets up range.
  134296. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134297. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134298. */
  134299. set usePhysicalLightFalloff(value: boolean);
  134300. /**
  134301. * In order to support the falloff compatibility with gltf, a special mode has been added
  134302. * to reproduce the gltf light falloff.
  134303. */
  134304. get useGLTFLightFalloff(): boolean;
  134305. /**
  134306. * In order to support the falloff compatibility with gltf, a special mode has been added
  134307. * to reproduce the gltf light falloff.
  134308. */
  134309. set useGLTFLightFalloff(value: boolean);
  134310. /**
  134311. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134312. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134313. */
  134314. useRadianceOverAlpha: boolean;
  134315. /**
  134316. * Allows using an object space normal map (instead of tangent space).
  134317. */
  134318. useObjectSpaceNormalMap: boolean;
  134319. /**
  134320. * Allows using the bump map in parallax mode.
  134321. */
  134322. useParallax: boolean;
  134323. /**
  134324. * Allows using the bump map in parallax occlusion mode.
  134325. */
  134326. useParallaxOcclusion: boolean;
  134327. /**
  134328. * Controls the scale bias of the parallax mode.
  134329. */
  134330. parallaxScaleBias: number;
  134331. /**
  134332. * If sets to true, disables all the lights affecting the material.
  134333. */
  134334. disableLighting: boolean;
  134335. /**
  134336. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134337. */
  134338. forceIrradianceInFragment: boolean;
  134339. /**
  134340. * Number of Simultaneous lights allowed on the material.
  134341. */
  134342. maxSimultaneousLights: number;
  134343. /**
  134344. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134345. */
  134346. invertNormalMapX: boolean;
  134347. /**
  134348. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134349. */
  134350. invertNormalMapY: boolean;
  134351. /**
  134352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134353. */
  134354. twoSidedLighting: boolean;
  134355. /**
  134356. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134357. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134358. */
  134359. useAlphaFresnel: boolean;
  134360. /**
  134361. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134362. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134363. */
  134364. useLinearAlphaFresnel: boolean;
  134365. /**
  134366. * Let user defines the brdf lookup texture used for IBL.
  134367. * A default 8bit version is embedded but you could point at :
  134368. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134369. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134370. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134371. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134372. */
  134373. environmentBRDFTexture: Nullable<BaseTexture>;
  134374. /**
  134375. * Force normal to face away from face.
  134376. */
  134377. forceNormalForward: boolean;
  134378. /**
  134379. * Enables specular anti aliasing in the PBR shader.
  134380. * It will both interacts on the Geometry for analytical and IBL lighting.
  134381. * It also prefilter the roughness map based on the bump values.
  134382. */
  134383. enableSpecularAntiAliasing: boolean;
  134384. /**
  134385. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134386. * makes the reflect vector face the model (under horizon).
  134387. */
  134388. useHorizonOcclusion: boolean;
  134389. /**
  134390. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134391. * too much the area relying on ambient texture to define their ambient occlusion.
  134392. */
  134393. useRadianceOcclusion: boolean;
  134394. /**
  134395. * If set to true, no lighting calculations will be applied.
  134396. */
  134397. unlit: boolean;
  134398. /**
  134399. * Gets the image processing configuration used either in this material.
  134400. */
  134401. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134402. /**
  134403. * Sets the Default image processing configuration used either in the this material.
  134404. *
  134405. * If sets to null, the scene one is in use.
  134406. */
  134407. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134408. /**
  134409. * Gets wether the color curves effect is enabled.
  134410. */
  134411. get cameraColorCurvesEnabled(): boolean;
  134412. /**
  134413. * Sets wether the color curves effect is enabled.
  134414. */
  134415. set cameraColorCurvesEnabled(value: boolean);
  134416. /**
  134417. * Gets wether the color grading effect is enabled.
  134418. */
  134419. get cameraColorGradingEnabled(): boolean;
  134420. /**
  134421. * Gets wether the color grading effect is enabled.
  134422. */
  134423. set cameraColorGradingEnabled(value: boolean);
  134424. /**
  134425. * Gets wether tonemapping is enabled or not.
  134426. */
  134427. get cameraToneMappingEnabled(): boolean;
  134428. /**
  134429. * Sets wether tonemapping is enabled or not
  134430. */
  134431. set cameraToneMappingEnabled(value: boolean);
  134432. /**
  134433. * The camera exposure used on this material.
  134434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134435. * This corresponds to a photographic exposure.
  134436. */
  134437. get cameraExposure(): number;
  134438. /**
  134439. * The camera exposure used on this material.
  134440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134441. * This corresponds to a photographic exposure.
  134442. */
  134443. set cameraExposure(value: number);
  134444. /**
  134445. * Gets The camera contrast used on this material.
  134446. */
  134447. get cameraContrast(): number;
  134448. /**
  134449. * Sets The camera contrast used on this material.
  134450. */
  134451. set cameraContrast(value: number);
  134452. /**
  134453. * Gets the Color Grading 2D Lookup Texture.
  134454. */
  134455. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134456. /**
  134457. * Sets the Color Grading 2D Lookup Texture.
  134458. */
  134459. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134460. /**
  134461. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134462. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134463. * 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;
  134464. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134465. */
  134466. get cameraColorCurves(): Nullable<ColorCurves>;
  134467. /**
  134468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134470. * 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;
  134471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134472. */
  134473. set cameraColorCurves(value: Nullable<ColorCurves>);
  134474. /**
  134475. * Instantiates a new PBRMaterial instance.
  134476. *
  134477. * @param name The material name
  134478. * @param scene The scene the material will be use in.
  134479. */
  134480. constructor(name: string, scene: Scene);
  134481. /**
  134482. * Returns the name of this material class.
  134483. */
  134484. getClassName(): string;
  134485. /**
  134486. * Makes a duplicate of the current material.
  134487. * @param name - name to use for the new material.
  134488. */
  134489. clone(name: string): PBRMaterial;
  134490. /**
  134491. * Serializes this PBR Material.
  134492. * @returns - An object with the serialized material.
  134493. */
  134494. serialize(): any;
  134495. /**
  134496. * Parses a PBR Material from a serialized object.
  134497. * @param source - Serialized object.
  134498. * @param scene - BJS scene instance.
  134499. * @param rootUrl - url for the scene object
  134500. * @returns - PBRMaterial
  134501. */
  134502. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134503. }
  134504. }
  134505. declare module BABYLON {
  134506. /**
  134507. * Direct draw surface info
  134508. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134509. */
  134510. export interface DDSInfo {
  134511. /**
  134512. * Width of the texture
  134513. */
  134514. width: number;
  134515. /**
  134516. * Width of the texture
  134517. */
  134518. height: number;
  134519. /**
  134520. * Number of Mipmaps for the texture
  134521. * @see https://en.wikipedia.org/wiki/Mipmap
  134522. */
  134523. mipmapCount: number;
  134524. /**
  134525. * If the textures format is a known fourCC format
  134526. * @see https://www.fourcc.org/
  134527. */
  134528. isFourCC: boolean;
  134529. /**
  134530. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134531. */
  134532. isRGB: boolean;
  134533. /**
  134534. * If the texture is a lumincance format
  134535. */
  134536. isLuminance: boolean;
  134537. /**
  134538. * If this is a cube texture
  134539. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134540. */
  134541. isCube: boolean;
  134542. /**
  134543. * If the texture is a compressed format eg. FOURCC_DXT1
  134544. */
  134545. isCompressed: boolean;
  134546. /**
  134547. * The dxgiFormat of the texture
  134548. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134549. */
  134550. dxgiFormat: number;
  134551. /**
  134552. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134553. */
  134554. textureType: number;
  134555. /**
  134556. * Sphericle polynomial created for the dds texture
  134557. */
  134558. sphericalPolynomial?: SphericalPolynomial;
  134559. }
  134560. /**
  134561. * Class used to provide DDS decompression tools
  134562. */
  134563. export class DDSTools {
  134564. /**
  134565. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134566. */
  134567. static StoreLODInAlphaChannel: boolean;
  134568. /**
  134569. * Gets DDS information from an array buffer
  134570. * @param data defines the array buffer view to read data from
  134571. * @returns the DDS information
  134572. */
  134573. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134574. private static _FloatView;
  134575. private static _Int32View;
  134576. private static _ToHalfFloat;
  134577. private static _FromHalfFloat;
  134578. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134579. private static _GetHalfFloatRGBAArrayBuffer;
  134580. private static _GetFloatRGBAArrayBuffer;
  134581. private static _GetFloatAsUIntRGBAArrayBuffer;
  134582. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134583. private static _GetRGBAArrayBuffer;
  134584. private static _ExtractLongWordOrder;
  134585. private static _GetRGBArrayBuffer;
  134586. private static _GetLuminanceArrayBuffer;
  134587. /**
  134588. * Uploads DDS Levels to a Babylon Texture
  134589. * @hidden
  134590. */
  134591. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134592. }
  134593. interface ThinEngine {
  134594. /**
  134595. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134596. * @param rootUrl defines the url where the file to load is located
  134597. * @param scene defines the current scene
  134598. * @param lodScale defines scale to apply to the mip map selection
  134599. * @param lodOffset defines offset to apply to the mip map selection
  134600. * @param onLoad defines an optional callback raised when the texture is loaded
  134601. * @param onError defines an optional callback raised if there is an issue to load the texture
  134602. * @param format defines the format of the data
  134603. * @param forcedExtension defines the extension to use to pick the right loader
  134604. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134605. * @returns the cube texture as an InternalTexture
  134606. */
  134607. 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;
  134608. }
  134609. }
  134610. declare module BABYLON {
  134611. /**
  134612. * Implementation of the DDS Texture Loader.
  134613. * @hidden
  134614. */
  134615. export class _DDSTextureLoader implements IInternalTextureLoader {
  134616. /**
  134617. * Defines wether the loader supports cascade loading the different faces.
  134618. */
  134619. readonly supportCascades: boolean;
  134620. /**
  134621. * This returns if the loader support the current file information.
  134622. * @param extension defines the file extension of the file being loaded
  134623. * @returns true if the loader can load the specified file
  134624. */
  134625. canLoad(extension: string): boolean;
  134626. /**
  134627. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134628. * @param data contains the texture data
  134629. * @param texture defines the BabylonJS internal texture
  134630. * @param createPolynomials will be true if polynomials have been requested
  134631. * @param onLoad defines the callback to trigger once the texture is ready
  134632. * @param onError defines the callback to trigger in case of error
  134633. */
  134634. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134635. /**
  134636. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134637. * @param data contains the texture data
  134638. * @param texture defines the BabylonJS internal texture
  134639. * @param callback defines the method to call once ready to upload
  134640. */
  134641. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134642. }
  134643. }
  134644. declare module BABYLON {
  134645. /**
  134646. * Implementation of the ENV Texture Loader.
  134647. * @hidden
  134648. */
  134649. export class _ENVTextureLoader implements IInternalTextureLoader {
  134650. /**
  134651. * Defines wether the loader supports cascade loading the different faces.
  134652. */
  134653. readonly supportCascades: boolean;
  134654. /**
  134655. * This returns if the loader support the current file information.
  134656. * @param extension defines the file extension of the file being loaded
  134657. * @returns true if the loader can load the specified file
  134658. */
  134659. canLoad(extension: string): boolean;
  134660. /**
  134661. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134662. * @param data contains the texture data
  134663. * @param texture defines the BabylonJS internal texture
  134664. * @param createPolynomials will be true if polynomials have been requested
  134665. * @param onLoad defines the callback to trigger once the texture is ready
  134666. * @param onError defines the callback to trigger in case of error
  134667. */
  134668. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134669. /**
  134670. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134671. * @param data contains the texture data
  134672. * @param texture defines the BabylonJS internal texture
  134673. * @param callback defines the method to call once ready to upload
  134674. */
  134675. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134676. }
  134677. }
  134678. declare module BABYLON {
  134679. /**
  134680. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134681. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134682. */
  134683. export class KhronosTextureContainer {
  134684. /** contents of the KTX container file */
  134685. data: ArrayBufferView;
  134686. private static HEADER_LEN;
  134687. private static COMPRESSED_2D;
  134688. private static COMPRESSED_3D;
  134689. private static TEX_2D;
  134690. private static TEX_3D;
  134691. /**
  134692. * Gets the openGL type
  134693. */
  134694. glType: number;
  134695. /**
  134696. * Gets the openGL type size
  134697. */
  134698. glTypeSize: number;
  134699. /**
  134700. * Gets the openGL format
  134701. */
  134702. glFormat: number;
  134703. /**
  134704. * Gets the openGL internal format
  134705. */
  134706. glInternalFormat: number;
  134707. /**
  134708. * Gets the base internal format
  134709. */
  134710. glBaseInternalFormat: number;
  134711. /**
  134712. * Gets image width in pixel
  134713. */
  134714. pixelWidth: number;
  134715. /**
  134716. * Gets image height in pixel
  134717. */
  134718. pixelHeight: number;
  134719. /**
  134720. * Gets image depth in pixels
  134721. */
  134722. pixelDepth: number;
  134723. /**
  134724. * Gets the number of array elements
  134725. */
  134726. numberOfArrayElements: number;
  134727. /**
  134728. * Gets the number of faces
  134729. */
  134730. numberOfFaces: number;
  134731. /**
  134732. * Gets the number of mipmap levels
  134733. */
  134734. numberOfMipmapLevels: number;
  134735. /**
  134736. * Gets the bytes of key value data
  134737. */
  134738. bytesOfKeyValueData: number;
  134739. /**
  134740. * Gets the load type
  134741. */
  134742. loadType: number;
  134743. /**
  134744. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134745. */
  134746. isInvalid: boolean;
  134747. /**
  134748. * Creates a new KhronosTextureContainer
  134749. * @param data contents of the KTX container file
  134750. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134751. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134752. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134753. */
  134754. constructor(
  134755. /** contents of the KTX container file */
  134756. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134757. /**
  134758. * Uploads KTX content to a Babylon Texture.
  134759. * It is assumed that the texture has already been created & is currently bound
  134760. * @hidden
  134761. */
  134762. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134763. private _upload2DCompressedLevels;
  134764. /**
  134765. * Checks if the given data starts with a KTX file identifier.
  134766. * @param data the data to check
  134767. * @returns true if the data is a KTX file or false otherwise
  134768. */
  134769. static IsValid(data: ArrayBufferView): boolean;
  134770. }
  134771. }
  134772. declare module BABYLON {
  134773. /**
  134774. * Class for loading KTX2 files
  134775. * !!! Experimental Extension Subject to Changes !!!
  134776. * @hidden
  134777. */
  134778. export class KhronosTextureContainer2 {
  134779. private static _ModulePromise;
  134780. private static _TranscodeFormat;
  134781. constructor(engine: ThinEngine);
  134782. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134783. private _determineTranscodeFormat;
  134784. /**
  134785. * Checks if the given data starts with a KTX2 file identifier.
  134786. * @param data the data to check
  134787. * @returns true if the data is a KTX2 file or false otherwise
  134788. */
  134789. static IsValid(data: ArrayBufferView): boolean;
  134790. }
  134791. }
  134792. declare module BABYLON {
  134793. /**
  134794. * Implementation of the KTX Texture Loader.
  134795. * @hidden
  134796. */
  134797. export class _KTXTextureLoader implements IInternalTextureLoader {
  134798. /**
  134799. * Defines wether the loader supports cascade loading the different faces.
  134800. */
  134801. readonly supportCascades: boolean;
  134802. /**
  134803. * This returns if the loader support the current file information.
  134804. * @param extension defines the file extension of the file being loaded
  134805. * @param mimeType defines the optional mime type of the file being loaded
  134806. * @returns true if the loader can load the specified file
  134807. */
  134808. canLoad(extension: string, mimeType?: string): boolean;
  134809. /**
  134810. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134811. * @param data contains the texture data
  134812. * @param texture defines the BabylonJS internal texture
  134813. * @param createPolynomials will be true if polynomials have been requested
  134814. * @param onLoad defines the callback to trigger once the texture is ready
  134815. * @param onError defines the callback to trigger in case of error
  134816. */
  134817. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134818. /**
  134819. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134820. * @param data contains the texture data
  134821. * @param texture defines the BabylonJS internal texture
  134822. * @param callback defines the method to call once ready to upload
  134823. */
  134824. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134825. }
  134826. }
  134827. declare module BABYLON {
  134828. /** @hidden */
  134829. export var _forceSceneHelpersToBundle: boolean;
  134830. interface Scene {
  134831. /**
  134832. * Creates a default light for the scene.
  134833. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134834. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134835. */
  134836. createDefaultLight(replace?: boolean): void;
  134837. /**
  134838. * Creates a default camera for the scene.
  134839. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134840. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134841. * @param replace has default false, when true replaces the active camera in the scene
  134842. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134843. */
  134844. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134845. /**
  134846. * Creates a default camera and a default light.
  134847. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134848. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134849. * @param replace has the default false, when true replaces the active camera/light in the scene
  134850. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134851. */
  134852. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134853. /**
  134854. * Creates a new sky box
  134855. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134856. * @param environmentTexture defines the texture to use as environment texture
  134857. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134858. * @param scale defines the overall scale of the skybox
  134859. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134860. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134861. * @returns a new mesh holding the sky box
  134862. */
  134863. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134864. /**
  134865. * Creates a new environment
  134866. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134867. * @param options defines the options you can use to configure the environment
  134868. * @returns the new EnvironmentHelper
  134869. */
  134870. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134871. /**
  134872. * Creates a new VREXperienceHelper
  134873. * @see https://doc.babylonjs.com/how_to/webvr_helper
  134874. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134875. * @returns a new VREXperienceHelper
  134876. */
  134877. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134878. /**
  134879. * Creates a new WebXRDefaultExperience
  134880. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  134881. * @param options experience options
  134882. * @returns a promise for a new WebXRDefaultExperience
  134883. */
  134884. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134885. }
  134886. }
  134887. declare module BABYLON {
  134888. /**
  134889. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134890. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134891. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134892. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134893. */
  134894. export class VideoDome extends TransformNode {
  134895. /**
  134896. * Define the video source as a Monoscopic panoramic 360 video.
  134897. */
  134898. static readonly MODE_MONOSCOPIC: number;
  134899. /**
  134900. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134901. */
  134902. static readonly MODE_TOPBOTTOM: number;
  134903. /**
  134904. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134905. */
  134906. static readonly MODE_SIDEBYSIDE: number;
  134907. private _halfDome;
  134908. private _useDirectMapping;
  134909. /**
  134910. * The video texture being displayed on the sphere
  134911. */
  134912. protected _videoTexture: VideoTexture;
  134913. /**
  134914. * Gets the video texture being displayed on the sphere
  134915. */
  134916. get videoTexture(): VideoTexture;
  134917. /**
  134918. * The skybox material
  134919. */
  134920. protected _material: BackgroundMaterial;
  134921. /**
  134922. * The surface used for the skybox
  134923. */
  134924. protected _mesh: Mesh;
  134925. /**
  134926. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134927. */
  134928. private _halfDomeMask;
  134929. /**
  134930. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134931. * Also see the options.resolution property.
  134932. */
  134933. get fovMultiplier(): number;
  134934. set fovMultiplier(value: number);
  134935. private _videoMode;
  134936. /**
  134937. * Gets or set the current video mode for the video. It can be:
  134938. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134939. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134940. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134941. */
  134942. get videoMode(): number;
  134943. set videoMode(value: number);
  134944. /**
  134945. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134946. *
  134947. */
  134948. get halfDome(): boolean;
  134949. /**
  134950. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134951. */
  134952. set halfDome(enabled: boolean);
  134953. /**
  134954. * Oberserver used in Stereoscopic VR Mode.
  134955. */
  134956. private _onBeforeCameraRenderObserver;
  134957. /**
  134958. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134959. * @param name Element's name, child elements will append suffixes for their own names.
  134960. * @param urlsOrVideo defines the url(s) or the video element to use
  134961. * @param options An object containing optional or exposed sub element properties
  134962. */
  134963. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134964. resolution?: number;
  134965. clickToPlay?: boolean;
  134966. autoPlay?: boolean;
  134967. loop?: boolean;
  134968. size?: number;
  134969. poster?: string;
  134970. faceForward?: boolean;
  134971. useDirectMapping?: boolean;
  134972. halfDomeMode?: boolean;
  134973. }, scene: Scene);
  134974. private _changeVideoMode;
  134975. /**
  134976. * Releases resources associated with this node.
  134977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134979. */
  134980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134981. }
  134982. }
  134983. declare module BABYLON {
  134984. /**
  134985. * This class can be used to get instrumentation data from a Babylon engine
  134986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134987. */
  134988. export class EngineInstrumentation implements IDisposable {
  134989. /**
  134990. * Define the instrumented engine.
  134991. */
  134992. engine: Engine;
  134993. private _captureGPUFrameTime;
  134994. private _gpuFrameTimeToken;
  134995. private _gpuFrameTime;
  134996. private _captureShaderCompilationTime;
  134997. private _shaderCompilationTime;
  134998. private _onBeginFrameObserver;
  134999. private _onEndFrameObserver;
  135000. private _onBeforeShaderCompilationObserver;
  135001. private _onAfterShaderCompilationObserver;
  135002. /**
  135003. * Gets the perf counter used for GPU frame time
  135004. */
  135005. get gpuFrameTimeCounter(): PerfCounter;
  135006. /**
  135007. * Gets the GPU frame time capture status
  135008. */
  135009. get captureGPUFrameTime(): boolean;
  135010. /**
  135011. * Enable or disable the GPU frame time capture
  135012. */
  135013. set captureGPUFrameTime(value: boolean);
  135014. /**
  135015. * Gets the perf counter used for shader compilation time
  135016. */
  135017. get shaderCompilationTimeCounter(): PerfCounter;
  135018. /**
  135019. * Gets the shader compilation time capture status
  135020. */
  135021. get captureShaderCompilationTime(): boolean;
  135022. /**
  135023. * Enable or disable the shader compilation time capture
  135024. */
  135025. set captureShaderCompilationTime(value: boolean);
  135026. /**
  135027. * Instantiates a new engine instrumentation.
  135028. * This class can be used to get instrumentation data from a Babylon engine
  135029. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135030. * @param engine Defines the engine to instrument
  135031. */
  135032. constructor(
  135033. /**
  135034. * Define the instrumented engine.
  135035. */
  135036. engine: Engine);
  135037. /**
  135038. * Dispose and release associated resources.
  135039. */
  135040. dispose(): void;
  135041. }
  135042. }
  135043. declare module BABYLON {
  135044. /**
  135045. * This class can be used to get instrumentation data from a Babylon engine
  135046. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135047. */
  135048. export class SceneInstrumentation implements IDisposable {
  135049. /**
  135050. * Defines the scene to instrument
  135051. */
  135052. scene: Scene;
  135053. private _captureActiveMeshesEvaluationTime;
  135054. private _activeMeshesEvaluationTime;
  135055. private _captureRenderTargetsRenderTime;
  135056. private _renderTargetsRenderTime;
  135057. private _captureFrameTime;
  135058. private _frameTime;
  135059. private _captureRenderTime;
  135060. private _renderTime;
  135061. private _captureInterFrameTime;
  135062. private _interFrameTime;
  135063. private _captureParticlesRenderTime;
  135064. private _particlesRenderTime;
  135065. private _captureSpritesRenderTime;
  135066. private _spritesRenderTime;
  135067. private _capturePhysicsTime;
  135068. private _physicsTime;
  135069. private _captureAnimationsTime;
  135070. private _animationsTime;
  135071. private _captureCameraRenderTime;
  135072. private _cameraRenderTime;
  135073. private _onBeforeActiveMeshesEvaluationObserver;
  135074. private _onAfterActiveMeshesEvaluationObserver;
  135075. private _onBeforeRenderTargetsRenderObserver;
  135076. private _onAfterRenderTargetsRenderObserver;
  135077. private _onAfterRenderObserver;
  135078. private _onBeforeDrawPhaseObserver;
  135079. private _onAfterDrawPhaseObserver;
  135080. private _onBeforeAnimationsObserver;
  135081. private _onBeforeParticlesRenderingObserver;
  135082. private _onAfterParticlesRenderingObserver;
  135083. private _onBeforeSpritesRenderingObserver;
  135084. private _onAfterSpritesRenderingObserver;
  135085. private _onBeforePhysicsObserver;
  135086. private _onAfterPhysicsObserver;
  135087. private _onAfterAnimationsObserver;
  135088. private _onBeforeCameraRenderObserver;
  135089. private _onAfterCameraRenderObserver;
  135090. /**
  135091. * Gets the perf counter used for active meshes evaluation time
  135092. */
  135093. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135094. /**
  135095. * Gets the active meshes evaluation time capture status
  135096. */
  135097. get captureActiveMeshesEvaluationTime(): boolean;
  135098. /**
  135099. * Enable or disable the active meshes evaluation time capture
  135100. */
  135101. set captureActiveMeshesEvaluationTime(value: boolean);
  135102. /**
  135103. * Gets the perf counter used for render targets render time
  135104. */
  135105. get renderTargetsRenderTimeCounter(): PerfCounter;
  135106. /**
  135107. * Gets the render targets render time capture status
  135108. */
  135109. get captureRenderTargetsRenderTime(): boolean;
  135110. /**
  135111. * Enable or disable the render targets render time capture
  135112. */
  135113. set captureRenderTargetsRenderTime(value: boolean);
  135114. /**
  135115. * Gets the perf counter used for particles render time
  135116. */
  135117. get particlesRenderTimeCounter(): PerfCounter;
  135118. /**
  135119. * Gets the particles render time capture status
  135120. */
  135121. get captureParticlesRenderTime(): boolean;
  135122. /**
  135123. * Enable or disable the particles render time capture
  135124. */
  135125. set captureParticlesRenderTime(value: boolean);
  135126. /**
  135127. * Gets the perf counter used for sprites render time
  135128. */
  135129. get spritesRenderTimeCounter(): PerfCounter;
  135130. /**
  135131. * Gets the sprites render time capture status
  135132. */
  135133. get captureSpritesRenderTime(): boolean;
  135134. /**
  135135. * Enable or disable the sprites render time capture
  135136. */
  135137. set captureSpritesRenderTime(value: boolean);
  135138. /**
  135139. * Gets the perf counter used for physics time
  135140. */
  135141. get physicsTimeCounter(): PerfCounter;
  135142. /**
  135143. * Gets the physics time capture status
  135144. */
  135145. get capturePhysicsTime(): boolean;
  135146. /**
  135147. * Enable or disable the physics time capture
  135148. */
  135149. set capturePhysicsTime(value: boolean);
  135150. /**
  135151. * Gets the perf counter used for animations time
  135152. */
  135153. get animationsTimeCounter(): PerfCounter;
  135154. /**
  135155. * Gets the animations time capture status
  135156. */
  135157. get captureAnimationsTime(): boolean;
  135158. /**
  135159. * Enable or disable the animations time capture
  135160. */
  135161. set captureAnimationsTime(value: boolean);
  135162. /**
  135163. * Gets the perf counter used for frame time capture
  135164. */
  135165. get frameTimeCounter(): PerfCounter;
  135166. /**
  135167. * Gets the frame time capture status
  135168. */
  135169. get captureFrameTime(): boolean;
  135170. /**
  135171. * Enable or disable the frame time capture
  135172. */
  135173. set captureFrameTime(value: boolean);
  135174. /**
  135175. * Gets the perf counter used for inter-frames time capture
  135176. */
  135177. get interFrameTimeCounter(): PerfCounter;
  135178. /**
  135179. * Gets the inter-frames time capture status
  135180. */
  135181. get captureInterFrameTime(): boolean;
  135182. /**
  135183. * Enable or disable the inter-frames time capture
  135184. */
  135185. set captureInterFrameTime(value: boolean);
  135186. /**
  135187. * Gets the perf counter used for render time capture
  135188. */
  135189. get renderTimeCounter(): PerfCounter;
  135190. /**
  135191. * Gets the render time capture status
  135192. */
  135193. get captureRenderTime(): boolean;
  135194. /**
  135195. * Enable or disable the render time capture
  135196. */
  135197. set captureRenderTime(value: boolean);
  135198. /**
  135199. * Gets the perf counter used for camera render time capture
  135200. */
  135201. get cameraRenderTimeCounter(): PerfCounter;
  135202. /**
  135203. * Gets the camera render time capture status
  135204. */
  135205. get captureCameraRenderTime(): boolean;
  135206. /**
  135207. * Enable or disable the camera render time capture
  135208. */
  135209. set captureCameraRenderTime(value: boolean);
  135210. /**
  135211. * Gets the perf counter used for draw calls
  135212. */
  135213. get drawCallsCounter(): PerfCounter;
  135214. /**
  135215. * Instantiates a new scene instrumentation.
  135216. * This class can be used to get instrumentation data from a Babylon engine
  135217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135218. * @param scene Defines the scene to instrument
  135219. */
  135220. constructor(
  135221. /**
  135222. * Defines the scene to instrument
  135223. */
  135224. scene: Scene);
  135225. /**
  135226. * Dispose and release associated resources.
  135227. */
  135228. dispose(): void;
  135229. }
  135230. }
  135231. declare module BABYLON {
  135232. /** @hidden */
  135233. export var glowMapGenerationPixelShader: {
  135234. name: string;
  135235. shader: string;
  135236. };
  135237. }
  135238. declare module BABYLON {
  135239. /** @hidden */
  135240. export var glowMapGenerationVertexShader: {
  135241. name: string;
  135242. shader: string;
  135243. };
  135244. }
  135245. declare module BABYLON {
  135246. /**
  135247. * Effect layer options. This helps customizing the behaviour
  135248. * of the effect layer.
  135249. */
  135250. export interface IEffectLayerOptions {
  135251. /**
  135252. * Multiplication factor apply to the canvas size to compute the render target size
  135253. * used to generated the objects (the smaller the faster).
  135254. */
  135255. mainTextureRatio: number;
  135256. /**
  135257. * Enforces a fixed size texture to ensure effect stability across devices.
  135258. */
  135259. mainTextureFixedSize?: number;
  135260. /**
  135261. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135262. */
  135263. alphaBlendingMode: number;
  135264. /**
  135265. * The camera attached to the layer.
  135266. */
  135267. camera: Nullable<Camera>;
  135268. /**
  135269. * The rendering group to draw the layer in.
  135270. */
  135271. renderingGroupId: number;
  135272. }
  135273. /**
  135274. * The effect layer Helps adding post process effect blended with the main pass.
  135275. *
  135276. * This can be for instance use to generate glow or higlight effects on the scene.
  135277. *
  135278. * The effect layer class can not be used directly and is intented to inherited from to be
  135279. * customized per effects.
  135280. */
  135281. export abstract class EffectLayer {
  135282. private _vertexBuffers;
  135283. private _indexBuffer;
  135284. private _cachedDefines;
  135285. private _effectLayerMapGenerationEffect;
  135286. private _effectLayerOptions;
  135287. private _mergeEffect;
  135288. protected _scene: Scene;
  135289. protected _engine: Engine;
  135290. protected _maxSize: number;
  135291. protected _mainTextureDesiredSize: ISize;
  135292. protected _mainTexture: RenderTargetTexture;
  135293. protected _shouldRender: boolean;
  135294. protected _postProcesses: PostProcess[];
  135295. protected _textures: BaseTexture[];
  135296. protected _emissiveTextureAndColor: {
  135297. texture: Nullable<BaseTexture>;
  135298. color: Color4;
  135299. };
  135300. /**
  135301. * The name of the layer
  135302. */
  135303. name: string;
  135304. /**
  135305. * The clear color of the texture used to generate the glow map.
  135306. */
  135307. neutralColor: Color4;
  135308. /**
  135309. * Specifies whether the highlight layer is enabled or not.
  135310. */
  135311. isEnabled: boolean;
  135312. /**
  135313. * Gets the camera attached to the layer.
  135314. */
  135315. get camera(): Nullable<Camera>;
  135316. /**
  135317. * Gets the rendering group id the layer should render in.
  135318. */
  135319. get renderingGroupId(): number;
  135320. set renderingGroupId(renderingGroupId: number);
  135321. /**
  135322. * An event triggered when the effect layer has been disposed.
  135323. */
  135324. onDisposeObservable: Observable<EffectLayer>;
  135325. /**
  135326. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135327. */
  135328. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135329. /**
  135330. * An event triggered when the generated texture is being merged in the scene.
  135331. */
  135332. onBeforeComposeObservable: Observable<EffectLayer>;
  135333. /**
  135334. * An event triggered when the mesh is rendered into the effect render target.
  135335. */
  135336. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135337. /**
  135338. * An event triggered after the mesh has been rendered into the effect render target.
  135339. */
  135340. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135341. /**
  135342. * An event triggered when the generated texture has been merged in the scene.
  135343. */
  135344. onAfterComposeObservable: Observable<EffectLayer>;
  135345. /**
  135346. * An event triggered when the efffect layer changes its size.
  135347. */
  135348. onSizeChangedObservable: Observable<EffectLayer>;
  135349. /** @hidden */
  135350. static _SceneComponentInitialization: (scene: Scene) => void;
  135351. /**
  135352. * Instantiates a new effect Layer and references it in the scene.
  135353. * @param name The name of the layer
  135354. * @param scene The scene to use the layer in
  135355. */
  135356. constructor(
  135357. /** The Friendly of the effect in the scene */
  135358. name: string, scene: Scene);
  135359. /**
  135360. * Get the effect name of the layer.
  135361. * @return The effect name
  135362. */
  135363. abstract getEffectName(): string;
  135364. /**
  135365. * Checks for the readiness of the element composing the layer.
  135366. * @param subMesh the mesh to check for
  135367. * @param useInstances specify whether or not to use instances to render the mesh
  135368. * @return true if ready otherwise, false
  135369. */
  135370. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135371. /**
  135372. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135373. * @returns true if the effect requires stencil during the main canvas render pass.
  135374. */
  135375. abstract needStencil(): boolean;
  135376. /**
  135377. * Create the merge effect. This is the shader use to blit the information back
  135378. * to the main canvas at the end of the scene rendering.
  135379. * @returns The effect containing the shader used to merge the effect on the main canvas
  135380. */
  135381. protected abstract _createMergeEffect(): Effect;
  135382. /**
  135383. * Creates the render target textures and post processes used in the effect layer.
  135384. */
  135385. protected abstract _createTextureAndPostProcesses(): void;
  135386. /**
  135387. * Implementation specific of rendering the generating effect on the main canvas.
  135388. * @param effect The effect used to render through
  135389. */
  135390. protected abstract _internalRender(effect: Effect): void;
  135391. /**
  135392. * Sets the required values for both the emissive texture and and the main color.
  135393. */
  135394. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135395. /**
  135396. * Free any resources and references associated to a mesh.
  135397. * Internal use
  135398. * @param mesh The mesh to free.
  135399. */
  135400. abstract _disposeMesh(mesh: Mesh): void;
  135401. /**
  135402. * Serializes this layer (Glow or Highlight for example)
  135403. * @returns a serialized layer object
  135404. */
  135405. abstract serialize?(): any;
  135406. /**
  135407. * Initializes the effect layer with the required options.
  135408. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135409. */
  135410. protected _init(options: Partial<IEffectLayerOptions>): void;
  135411. /**
  135412. * Generates the index buffer of the full screen quad blending to the main canvas.
  135413. */
  135414. private _generateIndexBuffer;
  135415. /**
  135416. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135417. */
  135418. private _generateVertexBuffer;
  135419. /**
  135420. * Sets the main texture desired size which is the closest power of two
  135421. * of the engine canvas size.
  135422. */
  135423. private _setMainTextureSize;
  135424. /**
  135425. * Creates the main texture for the effect layer.
  135426. */
  135427. protected _createMainTexture(): void;
  135428. /**
  135429. * Adds specific effects defines.
  135430. * @param defines The defines to add specifics to.
  135431. */
  135432. protected _addCustomEffectDefines(defines: string[]): void;
  135433. /**
  135434. * Checks for the readiness of the element composing the layer.
  135435. * @param subMesh the mesh to check for
  135436. * @param useInstances specify whether or not to use instances to render the mesh
  135437. * @param emissiveTexture the associated emissive texture used to generate the glow
  135438. * @return true if ready otherwise, false
  135439. */
  135440. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135441. /**
  135442. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135443. */
  135444. render(): void;
  135445. /**
  135446. * Determine if a given mesh will be used in the current effect.
  135447. * @param mesh mesh to test
  135448. * @returns true if the mesh will be used
  135449. */
  135450. hasMesh(mesh: AbstractMesh): boolean;
  135451. /**
  135452. * Returns true if the layer contains information to display, otherwise false.
  135453. * @returns true if the glow layer should be rendered
  135454. */
  135455. shouldRender(): boolean;
  135456. /**
  135457. * Returns true if the mesh should render, otherwise false.
  135458. * @param mesh The mesh to render
  135459. * @returns true if it should render otherwise false
  135460. */
  135461. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135462. /**
  135463. * Returns true if the mesh can be rendered, otherwise false.
  135464. * @param mesh The mesh to render
  135465. * @param material The material used on the mesh
  135466. * @returns true if it can be rendered otherwise false
  135467. */
  135468. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135469. /**
  135470. * Returns true if the mesh should render, otherwise false.
  135471. * @param mesh The mesh to render
  135472. * @returns true if it should render otherwise false
  135473. */
  135474. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135475. /**
  135476. * Renders the submesh passed in parameter to the generation map.
  135477. */
  135478. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135479. /**
  135480. * Defines whether the current material of the mesh should be use to render the effect.
  135481. * @param mesh defines the current mesh to render
  135482. */
  135483. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135484. /**
  135485. * Rebuild the required buffers.
  135486. * @hidden Internal use only.
  135487. */
  135488. _rebuild(): void;
  135489. /**
  135490. * Dispose only the render target textures and post process.
  135491. */
  135492. private _disposeTextureAndPostProcesses;
  135493. /**
  135494. * Dispose the highlight layer and free resources.
  135495. */
  135496. dispose(): void;
  135497. /**
  135498. * Gets the class name of the effect layer
  135499. * @returns the string with the class name of the effect layer
  135500. */
  135501. getClassName(): string;
  135502. /**
  135503. * Creates an effect layer from parsed effect layer data
  135504. * @param parsedEffectLayer defines effect layer data
  135505. * @param scene defines the current scene
  135506. * @param rootUrl defines the root URL containing the effect layer information
  135507. * @returns a parsed effect Layer
  135508. */
  135509. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135510. }
  135511. }
  135512. declare module BABYLON {
  135513. interface AbstractScene {
  135514. /**
  135515. * The list of effect layers (highlights/glow) added to the scene
  135516. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135517. * @see https://doc.babylonjs.com/how_to/glow_layer
  135518. */
  135519. effectLayers: Array<EffectLayer>;
  135520. /**
  135521. * Removes the given effect layer from this scene.
  135522. * @param toRemove defines the effect layer to remove
  135523. * @returns the index of the removed effect layer
  135524. */
  135525. removeEffectLayer(toRemove: EffectLayer): number;
  135526. /**
  135527. * Adds the given effect layer to this scene
  135528. * @param newEffectLayer defines the effect layer to add
  135529. */
  135530. addEffectLayer(newEffectLayer: EffectLayer): void;
  135531. }
  135532. /**
  135533. * Defines the layer scene component responsible to manage any effect layers
  135534. * in a given scene.
  135535. */
  135536. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135537. /**
  135538. * The component name helpfull to identify the component in the list of scene components.
  135539. */
  135540. readonly name: string;
  135541. /**
  135542. * The scene the component belongs to.
  135543. */
  135544. scene: Scene;
  135545. private _engine;
  135546. private _renderEffects;
  135547. private _needStencil;
  135548. private _previousStencilState;
  135549. /**
  135550. * Creates a new instance of the component for the given scene
  135551. * @param scene Defines the scene to register the component in
  135552. */
  135553. constructor(scene: Scene);
  135554. /**
  135555. * Registers the component in a given scene
  135556. */
  135557. register(): void;
  135558. /**
  135559. * Rebuilds the elements related to this component in case of
  135560. * context lost for instance.
  135561. */
  135562. rebuild(): void;
  135563. /**
  135564. * Serializes the component data to the specified json object
  135565. * @param serializationObject The object to serialize to
  135566. */
  135567. serialize(serializationObject: any): void;
  135568. /**
  135569. * Adds all the elements from the container to the scene
  135570. * @param container the container holding the elements
  135571. */
  135572. addFromContainer(container: AbstractScene): void;
  135573. /**
  135574. * Removes all the elements in the container from the scene
  135575. * @param container contains the elements to remove
  135576. * @param dispose if the removed element should be disposed (default: false)
  135577. */
  135578. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135579. /**
  135580. * Disposes the component and the associated ressources.
  135581. */
  135582. dispose(): void;
  135583. private _isReadyForMesh;
  135584. private _renderMainTexture;
  135585. private _setStencil;
  135586. private _setStencilBack;
  135587. private _draw;
  135588. private _drawCamera;
  135589. private _drawRenderingGroup;
  135590. }
  135591. }
  135592. declare module BABYLON {
  135593. /** @hidden */
  135594. export var glowMapMergePixelShader: {
  135595. name: string;
  135596. shader: string;
  135597. };
  135598. }
  135599. declare module BABYLON {
  135600. /** @hidden */
  135601. export var glowMapMergeVertexShader: {
  135602. name: string;
  135603. shader: string;
  135604. };
  135605. }
  135606. declare module BABYLON {
  135607. interface AbstractScene {
  135608. /**
  135609. * Return a the first highlight layer of the scene with a given name.
  135610. * @param name The name of the highlight layer to look for.
  135611. * @return The highlight layer if found otherwise null.
  135612. */
  135613. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135614. }
  135615. /**
  135616. * Glow layer options. This helps customizing the behaviour
  135617. * of the glow layer.
  135618. */
  135619. export interface IGlowLayerOptions {
  135620. /**
  135621. * Multiplication factor apply to the canvas size to compute the render target size
  135622. * used to generated the glowing objects (the smaller the faster).
  135623. */
  135624. mainTextureRatio: number;
  135625. /**
  135626. * Enforces a fixed size texture to ensure resize independant blur.
  135627. */
  135628. mainTextureFixedSize?: number;
  135629. /**
  135630. * How big is the kernel of the blur texture.
  135631. */
  135632. blurKernelSize: number;
  135633. /**
  135634. * The camera attached to the layer.
  135635. */
  135636. camera: Nullable<Camera>;
  135637. /**
  135638. * Enable MSAA by chosing the number of samples.
  135639. */
  135640. mainTextureSamples?: number;
  135641. /**
  135642. * The rendering group to draw the layer in.
  135643. */
  135644. renderingGroupId: number;
  135645. }
  135646. /**
  135647. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135648. *
  135649. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135650. *
  135651. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135652. */
  135653. export class GlowLayer extends EffectLayer {
  135654. /**
  135655. * Effect Name of the layer.
  135656. */
  135657. static readonly EffectName: string;
  135658. /**
  135659. * The default blur kernel size used for the glow.
  135660. */
  135661. static DefaultBlurKernelSize: number;
  135662. /**
  135663. * The default texture size ratio used for the glow.
  135664. */
  135665. static DefaultTextureRatio: number;
  135666. /**
  135667. * Sets the kernel size of the blur.
  135668. */
  135669. set blurKernelSize(value: number);
  135670. /**
  135671. * Gets the kernel size of the blur.
  135672. */
  135673. get blurKernelSize(): number;
  135674. /**
  135675. * Sets the glow intensity.
  135676. */
  135677. set intensity(value: number);
  135678. /**
  135679. * Gets the glow intensity.
  135680. */
  135681. get intensity(): number;
  135682. private _options;
  135683. private _intensity;
  135684. private _horizontalBlurPostprocess1;
  135685. private _verticalBlurPostprocess1;
  135686. private _horizontalBlurPostprocess2;
  135687. private _verticalBlurPostprocess2;
  135688. private _blurTexture1;
  135689. private _blurTexture2;
  135690. private _postProcesses1;
  135691. private _postProcesses2;
  135692. private _includedOnlyMeshes;
  135693. private _excludedMeshes;
  135694. private _meshesUsingTheirOwnMaterials;
  135695. /**
  135696. * Callback used to let the user override the color selection on a per mesh basis
  135697. */
  135698. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135699. /**
  135700. * Callback used to let the user override the texture selection on a per mesh basis
  135701. */
  135702. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135703. /**
  135704. * Instantiates a new glow Layer and references it to the scene.
  135705. * @param name The name of the layer
  135706. * @param scene The scene to use the layer in
  135707. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135708. */
  135709. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135710. /**
  135711. * Get the effect name of the layer.
  135712. * @return The effect name
  135713. */
  135714. getEffectName(): string;
  135715. /**
  135716. * Create the merge effect. This is the shader use to blit the information back
  135717. * to the main canvas at the end of the scene rendering.
  135718. */
  135719. protected _createMergeEffect(): Effect;
  135720. /**
  135721. * Creates the render target textures and post processes used in the glow layer.
  135722. */
  135723. protected _createTextureAndPostProcesses(): void;
  135724. /**
  135725. * Checks for the readiness of the element composing the layer.
  135726. * @param subMesh the mesh to check for
  135727. * @param useInstances specify wether or not to use instances to render the mesh
  135728. * @param emissiveTexture the associated emissive texture used to generate the glow
  135729. * @return true if ready otherwise, false
  135730. */
  135731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135732. /**
  135733. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135734. */
  135735. needStencil(): boolean;
  135736. /**
  135737. * Returns true if the mesh can be rendered, otherwise false.
  135738. * @param mesh The mesh to render
  135739. * @param material The material used on the mesh
  135740. * @returns true if it can be rendered otherwise false
  135741. */
  135742. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135743. /**
  135744. * Implementation specific of rendering the generating effect on the main canvas.
  135745. * @param effect The effect used to render through
  135746. */
  135747. protected _internalRender(effect: Effect): void;
  135748. /**
  135749. * Sets the required values for both the emissive texture and and the main color.
  135750. */
  135751. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135752. /**
  135753. * Returns true if the mesh should render, otherwise false.
  135754. * @param mesh The mesh to render
  135755. * @returns true if it should render otherwise false
  135756. */
  135757. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135758. /**
  135759. * Adds specific effects defines.
  135760. * @param defines The defines to add specifics to.
  135761. */
  135762. protected _addCustomEffectDefines(defines: string[]): void;
  135763. /**
  135764. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135765. * @param mesh The mesh to exclude from the glow layer
  135766. */
  135767. addExcludedMesh(mesh: Mesh): void;
  135768. /**
  135769. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135770. * @param mesh The mesh to remove
  135771. */
  135772. removeExcludedMesh(mesh: Mesh): void;
  135773. /**
  135774. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135775. * @param mesh The mesh to include in the glow layer
  135776. */
  135777. addIncludedOnlyMesh(mesh: Mesh): void;
  135778. /**
  135779. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135780. * @param mesh The mesh to remove
  135781. */
  135782. removeIncludedOnlyMesh(mesh: Mesh): void;
  135783. /**
  135784. * Determine if a given mesh will be used in the glow layer
  135785. * @param mesh The mesh to test
  135786. * @returns true if the mesh will be highlighted by the current glow layer
  135787. */
  135788. hasMesh(mesh: AbstractMesh): boolean;
  135789. /**
  135790. * Defines whether the current material of the mesh should be use to render the effect.
  135791. * @param mesh defines the current mesh to render
  135792. */
  135793. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135794. /**
  135795. * Add a mesh to be rendered through its own material and not with emissive only.
  135796. * @param mesh The mesh for which we need to use its material
  135797. */
  135798. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135799. /**
  135800. * Remove a mesh from being rendered through its own material and not with emissive only.
  135801. * @param mesh The mesh for which we need to not use its material
  135802. */
  135803. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135804. /**
  135805. * Free any resources and references associated to a mesh.
  135806. * Internal use
  135807. * @param mesh The mesh to free.
  135808. * @hidden
  135809. */
  135810. _disposeMesh(mesh: Mesh): void;
  135811. /**
  135812. * Gets the class name of the effect layer
  135813. * @returns the string with the class name of the effect layer
  135814. */
  135815. getClassName(): string;
  135816. /**
  135817. * Serializes this glow layer
  135818. * @returns a serialized glow layer object
  135819. */
  135820. serialize(): any;
  135821. /**
  135822. * Creates a Glow Layer from parsed glow layer data
  135823. * @param parsedGlowLayer defines glow layer data
  135824. * @param scene defines the current scene
  135825. * @param rootUrl defines the root URL containing the glow layer information
  135826. * @returns a parsed Glow Layer
  135827. */
  135828. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135829. }
  135830. }
  135831. declare module BABYLON {
  135832. /** @hidden */
  135833. export var glowBlurPostProcessPixelShader: {
  135834. name: string;
  135835. shader: string;
  135836. };
  135837. }
  135838. declare module BABYLON {
  135839. interface AbstractScene {
  135840. /**
  135841. * Return a the first highlight layer of the scene with a given name.
  135842. * @param name The name of the highlight layer to look for.
  135843. * @return The highlight layer if found otherwise null.
  135844. */
  135845. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135846. }
  135847. /**
  135848. * Highlight layer options. This helps customizing the behaviour
  135849. * of the highlight layer.
  135850. */
  135851. export interface IHighlightLayerOptions {
  135852. /**
  135853. * Multiplication factor apply to the canvas size to compute the render target size
  135854. * used to generated the glowing objects (the smaller the faster).
  135855. */
  135856. mainTextureRatio: number;
  135857. /**
  135858. * Enforces a fixed size texture to ensure resize independant blur.
  135859. */
  135860. mainTextureFixedSize?: number;
  135861. /**
  135862. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135863. * of the picture to blur (the smaller the faster).
  135864. */
  135865. blurTextureSizeRatio: number;
  135866. /**
  135867. * How big in texel of the blur texture is the vertical blur.
  135868. */
  135869. blurVerticalSize: number;
  135870. /**
  135871. * How big in texel of the blur texture is the horizontal blur.
  135872. */
  135873. blurHorizontalSize: number;
  135874. /**
  135875. * Alpha blending mode used to apply the blur. Default is combine.
  135876. */
  135877. alphaBlendingMode: number;
  135878. /**
  135879. * The camera attached to the layer.
  135880. */
  135881. camera: Nullable<Camera>;
  135882. /**
  135883. * Should we display highlight as a solid stroke?
  135884. */
  135885. isStroke?: boolean;
  135886. /**
  135887. * The rendering group to draw the layer in.
  135888. */
  135889. renderingGroupId: number;
  135890. }
  135891. /**
  135892. * The highlight layer Helps adding a glow effect around a mesh.
  135893. *
  135894. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135895. * glowy meshes to your scene.
  135896. *
  135897. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135898. */
  135899. export class HighlightLayer extends EffectLayer {
  135900. name: string;
  135901. /**
  135902. * Effect Name of the highlight layer.
  135903. */
  135904. static readonly EffectName: string;
  135905. /**
  135906. * The neutral color used during the preparation of the glow effect.
  135907. * This is black by default as the blend operation is a blend operation.
  135908. */
  135909. static NeutralColor: Color4;
  135910. /**
  135911. * Stencil value used for glowing meshes.
  135912. */
  135913. static GlowingMeshStencilReference: number;
  135914. /**
  135915. * Stencil value used for the other meshes in the scene.
  135916. */
  135917. static NormalMeshStencilReference: number;
  135918. /**
  135919. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135920. */
  135921. innerGlow: boolean;
  135922. /**
  135923. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135924. */
  135925. outerGlow: boolean;
  135926. /**
  135927. * Specifies the horizontal size of the blur.
  135928. */
  135929. set blurHorizontalSize(value: number);
  135930. /**
  135931. * Specifies the vertical size of the blur.
  135932. */
  135933. set blurVerticalSize(value: number);
  135934. /**
  135935. * Gets the horizontal size of the blur.
  135936. */
  135937. get blurHorizontalSize(): number;
  135938. /**
  135939. * Gets the vertical size of the blur.
  135940. */
  135941. get blurVerticalSize(): number;
  135942. /**
  135943. * An event triggered when the highlight layer is being blurred.
  135944. */
  135945. onBeforeBlurObservable: Observable<HighlightLayer>;
  135946. /**
  135947. * An event triggered when the highlight layer has been blurred.
  135948. */
  135949. onAfterBlurObservable: Observable<HighlightLayer>;
  135950. private _instanceGlowingMeshStencilReference;
  135951. private _options;
  135952. private _downSamplePostprocess;
  135953. private _horizontalBlurPostprocess;
  135954. private _verticalBlurPostprocess;
  135955. private _blurTexture;
  135956. private _meshes;
  135957. private _excludedMeshes;
  135958. /**
  135959. * Instantiates a new highlight Layer and references it to the scene..
  135960. * @param name The name of the layer
  135961. * @param scene The scene to use the layer in
  135962. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135963. */
  135964. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135965. /**
  135966. * Get the effect name of the layer.
  135967. * @return The effect name
  135968. */
  135969. getEffectName(): string;
  135970. /**
  135971. * Create the merge effect. This is the shader use to blit the information back
  135972. * to the main canvas at the end of the scene rendering.
  135973. */
  135974. protected _createMergeEffect(): Effect;
  135975. /**
  135976. * Creates the render target textures and post processes used in the highlight layer.
  135977. */
  135978. protected _createTextureAndPostProcesses(): void;
  135979. /**
  135980. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135981. */
  135982. needStencil(): boolean;
  135983. /**
  135984. * Checks for the readiness of the element composing the layer.
  135985. * @param subMesh the mesh to check for
  135986. * @param useInstances specify wether or not to use instances to render the mesh
  135987. * @param emissiveTexture the associated emissive texture used to generate the glow
  135988. * @return true if ready otherwise, false
  135989. */
  135990. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135991. /**
  135992. * Implementation specific of rendering the generating effect on the main canvas.
  135993. * @param effect The effect used to render through
  135994. */
  135995. protected _internalRender(effect: Effect): void;
  135996. /**
  135997. * Returns true if the layer contains information to display, otherwise false.
  135998. */
  135999. shouldRender(): boolean;
  136000. /**
  136001. * Returns true if the mesh should render, otherwise false.
  136002. * @param mesh The mesh to render
  136003. * @returns true if it should render otherwise false
  136004. */
  136005. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136006. /**
  136007. * Returns true if the mesh can be rendered, otherwise false.
  136008. * @param mesh The mesh to render
  136009. * @param material The material used on the mesh
  136010. * @returns true if it can be rendered otherwise false
  136011. */
  136012. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136013. /**
  136014. * Adds specific effects defines.
  136015. * @param defines The defines to add specifics to.
  136016. */
  136017. protected _addCustomEffectDefines(defines: string[]): void;
  136018. /**
  136019. * Sets the required values for both the emissive texture and and the main color.
  136020. */
  136021. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136022. /**
  136023. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136024. * @param mesh The mesh to exclude from the highlight layer
  136025. */
  136026. addExcludedMesh(mesh: Mesh): void;
  136027. /**
  136028. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136029. * @param mesh The mesh to highlight
  136030. */
  136031. removeExcludedMesh(mesh: Mesh): void;
  136032. /**
  136033. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136034. * @param mesh mesh to test
  136035. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136036. */
  136037. hasMesh(mesh: AbstractMesh): boolean;
  136038. /**
  136039. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136040. * @param mesh The mesh to highlight
  136041. * @param color The color of the highlight
  136042. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136043. */
  136044. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136045. /**
  136046. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136047. * @param mesh The mesh to highlight
  136048. */
  136049. removeMesh(mesh: Mesh): void;
  136050. /**
  136051. * Remove all the meshes currently referenced in the highlight layer
  136052. */
  136053. removeAllMeshes(): void;
  136054. /**
  136055. * Force the stencil to the normal expected value for none glowing parts
  136056. */
  136057. private _defaultStencilReference;
  136058. /**
  136059. * Free any resources and references associated to a mesh.
  136060. * Internal use
  136061. * @param mesh The mesh to free.
  136062. * @hidden
  136063. */
  136064. _disposeMesh(mesh: Mesh): void;
  136065. /**
  136066. * Dispose the highlight layer and free resources.
  136067. */
  136068. dispose(): void;
  136069. /**
  136070. * Gets the class name of the effect layer
  136071. * @returns the string with the class name of the effect layer
  136072. */
  136073. getClassName(): string;
  136074. /**
  136075. * Serializes this Highlight layer
  136076. * @returns a serialized Highlight layer object
  136077. */
  136078. serialize(): any;
  136079. /**
  136080. * Creates a Highlight layer from parsed Highlight layer data
  136081. * @param parsedHightlightLayer defines the Highlight layer data
  136082. * @param scene defines the current scene
  136083. * @param rootUrl defines the root URL containing the Highlight layer information
  136084. * @returns a parsed Highlight layer
  136085. */
  136086. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136087. }
  136088. }
  136089. declare module BABYLON {
  136090. interface AbstractScene {
  136091. /**
  136092. * The list of layers (background and foreground) of the scene
  136093. */
  136094. layers: Array<Layer>;
  136095. }
  136096. /**
  136097. * Defines the layer scene component responsible to manage any layers
  136098. * in a given scene.
  136099. */
  136100. export class LayerSceneComponent implements ISceneComponent {
  136101. /**
  136102. * The component name helpfull to identify the component in the list of scene components.
  136103. */
  136104. readonly name: string;
  136105. /**
  136106. * The scene the component belongs to.
  136107. */
  136108. scene: Scene;
  136109. private _engine;
  136110. /**
  136111. * Creates a new instance of the component for the given scene
  136112. * @param scene Defines the scene to register the component in
  136113. */
  136114. constructor(scene: Scene);
  136115. /**
  136116. * Registers the component in a given scene
  136117. */
  136118. register(): void;
  136119. /**
  136120. * Rebuilds the elements related to this component in case of
  136121. * context lost for instance.
  136122. */
  136123. rebuild(): void;
  136124. /**
  136125. * Disposes the component and the associated ressources.
  136126. */
  136127. dispose(): void;
  136128. private _draw;
  136129. private _drawCameraPredicate;
  136130. private _drawCameraBackground;
  136131. private _drawCameraForeground;
  136132. private _drawRenderTargetPredicate;
  136133. private _drawRenderTargetBackground;
  136134. private _drawRenderTargetForeground;
  136135. /**
  136136. * Adds all the elements from the container to the scene
  136137. * @param container the container holding the elements
  136138. */
  136139. addFromContainer(container: AbstractScene): void;
  136140. /**
  136141. * Removes all the elements in the container from the scene
  136142. * @param container contains the elements to remove
  136143. * @param dispose if the removed element should be disposed (default: false)
  136144. */
  136145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136146. }
  136147. }
  136148. declare module BABYLON {
  136149. /** @hidden */
  136150. export var layerPixelShader: {
  136151. name: string;
  136152. shader: string;
  136153. };
  136154. }
  136155. declare module BABYLON {
  136156. /** @hidden */
  136157. export var layerVertexShader: {
  136158. name: string;
  136159. shader: string;
  136160. };
  136161. }
  136162. declare module BABYLON {
  136163. /**
  136164. * This represents a full screen 2d layer.
  136165. * This can be useful to display a picture in the background of your scene for instance.
  136166. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136167. */
  136168. export class Layer {
  136169. /**
  136170. * Define the name of the layer.
  136171. */
  136172. name: string;
  136173. /**
  136174. * Define the texture the layer should display.
  136175. */
  136176. texture: Nullable<Texture>;
  136177. /**
  136178. * Is the layer in background or foreground.
  136179. */
  136180. isBackground: boolean;
  136181. /**
  136182. * Define the color of the layer (instead of texture).
  136183. */
  136184. color: Color4;
  136185. /**
  136186. * Define the scale of the layer in order to zoom in out of the texture.
  136187. */
  136188. scale: Vector2;
  136189. /**
  136190. * Define an offset for the layer in order to shift the texture.
  136191. */
  136192. offset: Vector2;
  136193. /**
  136194. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136195. */
  136196. alphaBlendingMode: number;
  136197. /**
  136198. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136199. * Alpha test will not mix with the background color in case of transparency.
  136200. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136201. */
  136202. alphaTest: boolean;
  136203. /**
  136204. * Define a mask to restrict the layer to only some of the scene cameras.
  136205. */
  136206. layerMask: number;
  136207. /**
  136208. * Define the list of render target the layer is visible into.
  136209. */
  136210. renderTargetTextures: RenderTargetTexture[];
  136211. /**
  136212. * Define if the layer is only used in renderTarget or if it also
  136213. * renders in the main frame buffer of the canvas.
  136214. */
  136215. renderOnlyInRenderTargetTextures: boolean;
  136216. private _scene;
  136217. private _vertexBuffers;
  136218. private _indexBuffer;
  136219. private _effect;
  136220. private _previousDefines;
  136221. /**
  136222. * An event triggered when the layer is disposed.
  136223. */
  136224. onDisposeObservable: Observable<Layer>;
  136225. private _onDisposeObserver;
  136226. /**
  136227. * Back compatibility with callback before the onDisposeObservable existed.
  136228. * The set callback will be triggered when the layer has been disposed.
  136229. */
  136230. set onDispose(callback: () => void);
  136231. /**
  136232. * An event triggered before rendering the scene
  136233. */
  136234. onBeforeRenderObservable: Observable<Layer>;
  136235. private _onBeforeRenderObserver;
  136236. /**
  136237. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136238. * The set callback will be triggered just before rendering the layer.
  136239. */
  136240. set onBeforeRender(callback: () => void);
  136241. /**
  136242. * An event triggered after rendering the scene
  136243. */
  136244. onAfterRenderObservable: Observable<Layer>;
  136245. private _onAfterRenderObserver;
  136246. /**
  136247. * Back compatibility with callback before the onAfterRenderObservable existed.
  136248. * The set callback will be triggered just after rendering the layer.
  136249. */
  136250. set onAfterRender(callback: () => void);
  136251. /**
  136252. * Instantiates a new layer.
  136253. * This represents a full screen 2d layer.
  136254. * This can be useful to display a picture in the background of your scene for instance.
  136255. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136256. * @param name Define the name of the layer in the scene
  136257. * @param imgUrl Define the url of the texture to display in the layer
  136258. * @param scene Define the scene the layer belongs to
  136259. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136260. * @param color Defines a color for the layer
  136261. */
  136262. constructor(
  136263. /**
  136264. * Define the name of the layer.
  136265. */
  136266. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136267. private _createIndexBuffer;
  136268. /** @hidden */
  136269. _rebuild(): void;
  136270. /**
  136271. * Renders the layer in the scene.
  136272. */
  136273. render(): void;
  136274. /**
  136275. * Disposes and releases the associated ressources.
  136276. */
  136277. dispose(): void;
  136278. }
  136279. }
  136280. declare module BABYLON {
  136281. /** @hidden */
  136282. export var lensFlarePixelShader: {
  136283. name: string;
  136284. shader: string;
  136285. };
  136286. }
  136287. declare module BABYLON {
  136288. /** @hidden */
  136289. export var lensFlareVertexShader: {
  136290. name: string;
  136291. shader: string;
  136292. };
  136293. }
  136294. declare module BABYLON {
  136295. /**
  136296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136297. * It is usually composed of several `lensFlare`.
  136298. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136299. */
  136300. export class LensFlareSystem {
  136301. /**
  136302. * Define the name of the lens flare system
  136303. */
  136304. name: string;
  136305. /**
  136306. * List of lens flares used in this system.
  136307. */
  136308. lensFlares: LensFlare[];
  136309. /**
  136310. * Define a limit from the border the lens flare can be visible.
  136311. */
  136312. borderLimit: number;
  136313. /**
  136314. * Define a viewport border we do not want to see the lens flare in.
  136315. */
  136316. viewportBorder: number;
  136317. /**
  136318. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136319. */
  136320. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136321. /**
  136322. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136323. */
  136324. layerMask: number;
  136325. /**
  136326. * Define the id of the lens flare system in the scene.
  136327. * (equal to name by default)
  136328. */
  136329. id: string;
  136330. private _scene;
  136331. private _emitter;
  136332. private _vertexBuffers;
  136333. private _indexBuffer;
  136334. private _effect;
  136335. private _positionX;
  136336. private _positionY;
  136337. private _isEnabled;
  136338. /** @hidden */
  136339. static _SceneComponentInitialization: (scene: Scene) => void;
  136340. /**
  136341. * Instantiates a lens flare system.
  136342. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136343. * It is usually composed of several `lensFlare`.
  136344. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136345. * @param name Define the name of the lens flare system in the scene
  136346. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136347. * @param scene Define the scene the lens flare system belongs to
  136348. */
  136349. constructor(
  136350. /**
  136351. * Define the name of the lens flare system
  136352. */
  136353. name: string, emitter: any, scene: Scene);
  136354. /**
  136355. * Define if the lens flare system is enabled.
  136356. */
  136357. get isEnabled(): boolean;
  136358. set isEnabled(value: boolean);
  136359. /**
  136360. * Get the scene the effects belongs to.
  136361. * @returns the scene holding the lens flare system
  136362. */
  136363. getScene(): Scene;
  136364. /**
  136365. * Get the emitter of the lens flare system.
  136366. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136367. * @returns the emitter of the lens flare system
  136368. */
  136369. getEmitter(): any;
  136370. /**
  136371. * Set the emitter of the lens flare system.
  136372. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136373. * @param newEmitter Define the new emitter of the system
  136374. */
  136375. setEmitter(newEmitter: any): void;
  136376. /**
  136377. * Get the lens flare system emitter position.
  136378. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136379. * @returns the position
  136380. */
  136381. getEmitterPosition(): Vector3;
  136382. /**
  136383. * @hidden
  136384. */
  136385. computeEffectivePosition(globalViewport: Viewport): boolean;
  136386. /** @hidden */
  136387. _isVisible(): boolean;
  136388. /**
  136389. * @hidden
  136390. */
  136391. render(): boolean;
  136392. /**
  136393. * Dispose and release the lens flare with its associated resources.
  136394. */
  136395. dispose(): void;
  136396. /**
  136397. * Parse a lens flare system from a JSON repressentation
  136398. * @param parsedLensFlareSystem Define the JSON to parse
  136399. * @param scene Define the scene the parsed system should be instantiated in
  136400. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136401. * @returns the parsed system
  136402. */
  136403. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136404. /**
  136405. * Serialize the current Lens Flare System into a JSON representation.
  136406. * @returns the serialized JSON
  136407. */
  136408. serialize(): any;
  136409. }
  136410. }
  136411. declare module BABYLON {
  136412. /**
  136413. * This represents one of the lens effect in a `lensFlareSystem`.
  136414. * It controls one of the indiviual texture used in the effect.
  136415. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136416. */
  136417. export class LensFlare {
  136418. /**
  136419. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136420. */
  136421. size: number;
  136422. /**
  136423. * 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.
  136424. */
  136425. position: number;
  136426. /**
  136427. * Define the lens color.
  136428. */
  136429. color: Color3;
  136430. /**
  136431. * Define the lens texture.
  136432. */
  136433. texture: Nullable<Texture>;
  136434. /**
  136435. * Define the alpha mode to render this particular lens.
  136436. */
  136437. alphaMode: number;
  136438. private _system;
  136439. /**
  136440. * Creates a new Lens Flare.
  136441. * This represents one of the lens effect in a `lensFlareSystem`.
  136442. * It controls one of the indiviual texture used in the effect.
  136443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136444. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136445. * @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.
  136446. * @param color Define the lens color
  136447. * @param imgUrl Define the lens texture url
  136448. * @param system Define the `lensFlareSystem` this flare is part of
  136449. * @returns The newly created Lens Flare
  136450. */
  136451. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136452. /**
  136453. * Instantiates a new Lens Flare.
  136454. * This represents one of the lens effect in a `lensFlareSystem`.
  136455. * It controls one of the indiviual texture used in the effect.
  136456. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136457. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136458. * @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.
  136459. * @param color Define the lens color
  136460. * @param imgUrl Define the lens texture url
  136461. * @param system Define the `lensFlareSystem` this flare is part of
  136462. */
  136463. constructor(
  136464. /**
  136465. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136466. */
  136467. size: number,
  136468. /**
  136469. * 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.
  136470. */
  136471. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136472. /**
  136473. * Dispose and release the lens flare with its associated resources.
  136474. */
  136475. dispose(): void;
  136476. }
  136477. }
  136478. declare module BABYLON {
  136479. interface AbstractScene {
  136480. /**
  136481. * The list of lens flare system added to the scene
  136482. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136483. */
  136484. lensFlareSystems: Array<LensFlareSystem>;
  136485. /**
  136486. * Removes the given lens flare system from this scene.
  136487. * @param toRemove The lens flare system to remove
  136488. * @returns The index of the removed lens flare system
  136489. */
  136490. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136491. /**
  136492. * Adds the given lens flare system to this scene
  136493. * @param newLensFlareSystem The lens flare system to add
  136494. */
  136495. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136496. /**
  136497. * Gets a lens flare system using its name
  136498. * @param name defines the name to look for
  136499. * @returns the lens flare system or null if not found
  136500. */
  136501. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136502. /**
  136503. * Gets a lens flare system using its id
  136504. * @param id defines the id to look for
  136505. * @returns the lens flare system or null if not found
  136506. */
  136507. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136508. }
  136509. /**
  136510. * Defines the lens flare scene component responsible to manage any lens flares
  136511. * in a given scene.
  136512. */
  136513. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136514. /**
  136515. * The component name helpfull to identify the component in the list of scene components.
  136516. */
  136517. readonly name: string;
  136518. /**
  136519. * The scene the component belongs to.
  136520. */
  136521. scene: Scene;
  136522. /**
  136523. * Creates a new instance of the component for the given scene
  136524. * @param scene Defines the scene to register the component in
  136525. */
  136526. constructor(scene: Scene);
  136527. /**
  136528. * Registers the component in a given scene
  136529. */
  136530. register(): void;
  136531. /**
  136532. * Rebuilds the elements related to this component in case of
  136533. * context lost for instance.
  136534. */
  136535. rebuild(): void;
  136536. /**
  136537. * Adds all the elements from the container to the scene
  136538. * @param container the container holding the elements
  136539. */
  136540. addFromContainer(container: AbstractScene): void;
  136541. /**
  136542. * Removes all the elements in the container from the scene
  136543. * @param container contains the elements to remove
  136544. * @param dispose if the removed element should be disposed (default: false)
  136545. */
  136546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136547. /**
  136548. * Serializes the component data to the specified json object
  136549. * @param serializationObject The object to serialize to
  136550. */
  136551. serialize(serializationObject: any): void;
  136552. /**
  136553. * Disposes the component and the associated ressources.
  136554. */
  136555. dispose(): void;
  136556. private _draw;
  136557. }
  136558. }
  136559. declare module BABYLON {
  136560. /** @hidden */
  136561. export var depthPixelShader: {
  136562. name: string;
  136563. shader: string;
  136564. };
  136565. }
  136566. declare module BABYLON {
  136567. /** @hidden */
  136568. export var depthVertexShader: {
  136569. name: string;
  136570. shader: string;
  136571. };
  136572. }
  136573. declare module BABYLON {
  136574. /**
  136575. * This represents a depth renderer in Babylon.
  136576. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136577. */
  136578. export class DepthRenderer {
  136579. private _scene;
  136580. private _depthMap;
  136581. private _effect;
  136582. private readonly _storeNonLinearDepth;
  136583. private readonly _clearColor;
  136584. /** Get if the depth renderer is using packed depth or not */
  136585. readonly isPacked: boolean;
  136586. private _cachedDefines;
  136587. private _camera;
  136588. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136589. enabled: boolean;
  136590. /**
  136591. * Specifiess that the depth renderer will only be used within
  136592. * the camera it is created for.
  136593. * This can help forcing its rendering during the camera processing.
  136594. */
  136595. useOnlyInActiveCamera: boolean;
  136596. /** @hidden */
  136597. static _SceneComponentInitialization: (scene: Scene) => void;
  136598. /**
  136599. * Instantiates a depth renderer
  136600. * @param scene The scene the renderer belongs to
  136601. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136602. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136603. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136604. */
  136605. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136606. /**
  136607. * Creates the depth rendering effect and checks if the effect is ready.
  136608. * @param subMesh The submesh to be used to render the depth map of
  136609. * @param useInstances If multiple world instances should be used
  136610. * @returns if the depth renderer is ready to render the depth map
  136611. */
  136612. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136613. /**
  136614. * Gets the texture which the depth map will be written to.
  136615. * @returns The depth map texture
  136616. */
  136617. getDepthMap(): RenderTargetTexture;
  136618. /**
  136619. * Disposes of the depth renderer.
  136620. */
  136621. dispose(): void;
  136622. }
  136623. }
  136624. declare module BABYLON {
  136625. /** @hidden */
  136626. export var minmaxReduxPixelShader: {
  136627. name: string;
  136628. shader: string;
  136629. };
  136630. }
  136631. declare module BABYLON {
  136632. /**
  136633. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136634. * and maximum values from all values of the texture.
  136635. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136636. * The source values are read from the red channel of the texture.
  136637. */
  136638. export class MinMaxReducer {
  136639. /**
  136640. * Observable triggered when the computation has been performed
  136641. */
  136642. onAfterReductionPerformed: Observable<{
  136643. min: number;
  136644. max: number;
  136645. }>;
  136646. protected _camera: Camera;
  136647. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136648. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136649. protected _postProcessManager: PostProcessManager;
  136650. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136651. protected _forceFullscreenViewport: boolean;
  136652. /**
  136653. * Creates a min/max reducer
  136654. * @param camera The camera to use for the post processes
  136655. */
  136656. constructor(camera: Camera);
  136657. /**
  136658. * Gets the texture used to read the values from.
  136659. */
  136660. get sourceTexture(): Nullable<RenderTargetTexture>;
  136661. /**
  136662. * Sets the source texture to read the values from.
  136663. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136664. * because in such textures '1' value must not be taken into account to compute the maximum
  136665. * as this value is used to clear the texture.
  136666. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136667. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136668. * @param depthRedux Indicates if the texture is a depth texture or not
  136669. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136670. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136671. */
  136672. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136673. /**
  136674. * Defines the refresh rate of the computation.
  136675. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136676. */
  136677. get refreshRate(): number;
  136678. set refreshRate(value: number);
  136679. protected _activated: boolean;
  136680. /**
  136681. * Gets the activation status of the reducer
  136682. */
  136683. get activated(): boolean;
  136684. /**
  136685. * Activates the reduction computation.
  136686. * When activated, the observers registered in onAfterReductionPerformed are
  136687. * called after the compuation is performed
  136688. */
  136689. activate(): void;
  136690. /**
  136691. * Deactivates the reduction computation.
  136692. */
  136693. deactivate(): void;
  136694. /**
  136695. * Disposes the min/max reducer
  136696. * @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.
  136697. */
  136698. dispose(disposeAll?: boolean): void;
  136699. }
  136700. }
  136701. declare module BABYLON {
  136702. /**
  136703. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136704. */
  136705. export class DepthReducer extends MinMaxReducer {
  136706. private _depthRenderer;
  136707. private _depthRendererId;
  136708. /**
  136709. * Gets the depth renderer used for the computation.
  136710. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136711. */
  136712. get depthRenderer(): Nullable<DepthRenderer>;
  136713. /**
  136714. * Creates a depth reducer
  136715. * @param camera The camera used to render the depth texture
  136716. */
  136717. constructor(camera: Camera);
  136718. /**
  136719. * Sets the depth renderer to use to generate the depth map
  136720. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136721. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136722. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136723. */
  136724. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136725. /** @hidden */
  136726. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136727. /**
  136728. * Activates the reduction computation.
  136729. * When activated, the observers registered in onAfterReductionPerformed are
  136730. * called after the compuation is performed
  136731. */
  136732. activate(): void;
  136733. /**
  136734. * Deactivates the reduction computation.
  136735. */
  136736. deactivate(): void;
  136737. /**
  136738. * Disposes the depth reducer
  136739. * @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.
  136740. */
  136741. dispose(disposeAll?: boolean): void;
  136742. }
  136743. }
  136744. declare module BABYLON {
  136745. /**
  136746. * A CSM implementation allowing casting shadows on large scenes.
  136747. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136748. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136749. */
  136750. export class CascadedShadowGenerator extends ShadowGenerator {
  136751. private static readonly frustumCornersNDCSpace;
  136752. /**
  136753. * Name of the CSM class
  136754. */
  136755. static CLASSNAME: string;
  136756. /**
  136757. * Defines the default number of cascades used by the CSM.
  136758. */
  136759. static readonly DEFAULT_CASCADES_COUNT: number;
  136760. /**
  136761. * Defines the minimum number of cascades used by the CSM.
  136762. */
  136763. static readonly MIN_CASCADES_COUNT: number;
  136764. /**
  136765. * Defines the maximum number of cascades used by the CSM.
  136766. */
  136767. static readonly MAX_CASCADES_COUNT: number;
  136768. protected _validateFilter(filter: number): number;
  136769. /**
  136770. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136771. */
  136772. penumbraDarkness: number;
  136773. private _numCascades;
  136774. /**
  136775. * Gets or set the number of cascades used by the CSM.
  136776. */
  136777. get numCascades(): number;
  136778. set numCascades(value: number);
  136779. /**
  136780. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136781. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136782. */
  136783. stabilizeCascades: boolean;
  136784. private _freezeShadowCastersBoundingInfo;
  136785. private _freezeShadowCastersBoundingInfoObservable;
  136786. /**
  136787. * Enables or disables the shadow casters bounding info computation.
  136788. * If your shadow casters don't move, you can disable this feature.
  136789. * If it is enabled, the bounding box computation is done every frame.
  136790. */
  136791. get freezeShadowCastersBoundingInfo(): boolean;
  136792. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136793. private _scbiMin;
  136794. private _scbiMax;
  136795. protected _computeShadowCastersBoundingInfo(): void;
  136796. protected _shadowCastersBoundingInfo: BoundingInfo;
  136797. /**
  136798. * Gets or sets the shadow casters bounding info.
  136799. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136800. * so that the system won't overwrite the bounds you provide
  136801. */
  136802. get shadowCastersBoundingInfo(): BoundingInfo;
  136803. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136804. protected _breaksAreDirty: boolean;
  136805. protected _minDistance: number;
  136806. protected _maxDistance: number;
  136807. /**
  136808. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136809. *
  136810. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136811. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136812. * @param min minimal distance for the breaks (default to 0.)
  136813. * @param max maximal distance for the breaks (default to 1.)
  136814. */
  136815. setMinMaxDistance(min: number, max: number): void;
  136816. /** Gets the minimal distance used in the cascade break computation */
  136817. get minDistance(): number;
  136818. /** Gets the maximal distance used in the cascade break computation */
  136819. get maxDistance(): number;
  136820. /**
  136821. * Gets the class name of that object
  136822. * @returns "CascadedShadowGenerator"
  136823. */
  136824. getClassName(): string;
  136825. private _cascadeMinExtents;
  136826. private _cascadeMaxExtents;
  136827. /**
  136828. * Gets a cascade minimum extents
  136829. * @param cascadeIndex index of the cascade
  136830. * @returns the minimum cascade extents
  136831. */
  136832. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136833. /**
  136834. * Gets a cascade maximum extents
  136835. * @param cascadeIndex index of the cascade
  136836. * @returns the maximum cascade extents
  136837. */
  136838. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136839. private _cascades;
  136840. private _currentLayer;
  136841. private _viewSpaceFrustumsZ;
  136842. private _viewMatrices;
  136843. private _projectionMatrices;
  136844. private _transformMatrices;
  136845. private _transformMatricesAsArray;
  136846. private _frustumLengths;
  136847. private _lightSizeUVCorrection;
  136848. private _depthCorrection;
  136849. private _frustumCornersWorldSpace;
  136850. private _frustumCenter;
  136851. private _shadowCameraPos;
  136852. private _shadowMaxZ;
  136853. /**
  136854. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136855. * It defaults to camera.maxZ
  136856. */
  136857. get shadowMaxZ(): number;
  136858. /**
  136859. * Sets the shadow max z distance.
  136860. */
  136861. set shadowMaxZ(value: number);
  136862. protected _debug: boolean;
  136863. /**
  136864. * Gets or sets the debug flag.
  136865. * When enabled, the cascades are materialized by different colors on the screen.
  136866. */
  136867. get debug(): boolean;
  136868. set debug(dbg: boolean);
  136869. private _depthClamp;
  136870. /**
  136871. * Gets or sets the depth clamping value.
  136872. *
  136873. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136874. * to account for the shadow casters far away.
  136875. *
  136876. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136877. */
  136878. get depthClamp(): boolean;
  136879. set depthClamp(value: boolean);
  136880. private _cascadeBlendPercentage;
  136881. /**
  136882. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136883. * It defaults to 0.1 (10% blending).
  136884. */
  136885. get cascadeBlendPercentage(): number;
  136886. set cascadeBlendPercentage(value: number);
  136887. private _lambda;
  136888. /**
  136889. * Gets or set the lambda parameter.
  136890. * This parameter is used to split the camera frustum and create the cascades.
  136891. * 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.
  136892. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136893. */
  136894. get lambda(): number;
  136895. set lambda(value: number);
  136896. /**
  136897. * Gets the view matrix corresponding to a given cascade
  136898. * @param cascadeNum cascade to retrieve the view matrix from
  136899. * @returns the cascade view matrix
  136900. */
  136901. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136902. /**
  136903. * Gets the projection matrix corresponding to a given cascade
  136904. * @param cascadeNum cascade to retrieve the projection matrix from
  136905. * @returns the cascade projection matrix
  136906. */
  136907. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136908. /**
  136909. * Gets the transformation matrix corresponding to a given cascade
  136910. * @param cascadeNum cascade to retrieve the transformation matrix from
  136911. * @returns the cascade transformation matrix
  136912. */
  136913. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136914. private _depthRenderer;
  136915. /**
  136916. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136917. *
  136918. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136919. *
  136920. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136921. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136922. * @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
  136923. */
  136924. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136925. private _depthReducer;
  136926. private _autoCalcDepthBounds;
  136927. /**
  136928. * Gets or sets the autoCalcDepthBounds property.
  136929. *
  136930. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136931. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136932. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136933. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136934. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136935. */
  136936. get autoCalcDepthBounds(): boolean;
  136937. set autoCalcDepthBounds(value: boolean);
  136938. /**
  136939. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136940. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136941. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136942. * for setting the refresh rate on the renderer yourself!
  136943. */
  136944. get autoCalcDepthBoundsRefreshRate(): number;
  136945. set autoCalcDepthBoundsRefreshRate(value: number);
  136946. /**
  136947. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136948. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136949. * you change the camera near/far planes!
  136950. */
  136951. splitFrustum(): void;
  136952. private _splitFrustum;
  136953. private _computeMatrices;
  136954. private _computeFrustumInWorldSpace;
  136955. private _computeCascadeFrustum;
  136956. /**
  136957. * Support test.
  136958. */
  136959. static get IsSupported(): boolean;
  136960. /** @hidden */
  136961. static _SceneComponentInitialization: (scene: Scene) => void;
  136962. /**
  136963. * Creates a Cascaded Shadow Generator object.
  136964. * A ShadowGenerator is the required tool to use the shadows.
  136965. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136966. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136967. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136968. * @param light The directional light object generating the shadows.
  136969. * @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.
  136970. */
  136971. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136972. protected _initializeGenerator(): void;
  136973. protected _createTargetRenderTexture(): void;
  136974. protected _initializeShadowMap(): void;
  136975. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136976. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136977. /**
  136978. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136979. * @param defines Defines of the material we want to update
  136980. * @param lightIndex Index of the light in the enabled light list of the material
  136981. */
  136982. prepareDefines(defines: any, lightIndex: number): void;
  136983. /**
  136984. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136985. * defined in the generator but impacting the effect).
  136986. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136987. * @param effect The effect we are binfing the information for
  136988. */
  136989. bindShadowLight(lightIndex: string, effect: Effect): void;
  136990. /**
  136991. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136992. * (eq to view projection * shadow projection matrices)
  136993. * @returns The transform matrix used to create the shadow map
  136994. */
  136995. getTransformMatrix(): Matrix;
  136996. /**
  136997. * Disposes the ShadowGenerator.
  136998. * Returns nothing.
  136999. */
  137000. dispose(): void;
  137001. /**
  137002. * Serializes the shadow generator setup to a json object.
  137003. * @returns The serialized JSON object
  137004. */
  137005. serialize(): any;
  137006. /**
  137007. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137008. * @param parsedShadowGenerator The JSON object to parse
  137009. * @param scene The scene to create the shadow map for
  137010. * @returns The parsed shadow generator
  137011. */
  137012. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137013. }
  137014. }
  137015. declare module BABYLON {
  137016. /**
  137017. * Defines the shadow generator component responsible to manage any shadow generators
  137018. * in a given scene.
  137019. */
  137020. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137021. /**
  137022. * The component name helpfull to identify the component in the list of scene components.
  137023. */
  137024. readonly name: string;
  137025. /**
  137026. * The scene the component belongs to.
  137027. */
  137028. scene: Scene;
  137029. /**
  137030. * Creates a new instance of the component for the given scene
  137031. * @param scene Defines the scene to register the component in
  137032. */
  137033. constructor(scene: Scene);
  137034. /**
  137035. * Registers the component in a given scene
  137036. */
  137037. register(): void;
  137038. /**
  137039. * Rebuilds the elements related to this component in case of
  137040. * context lost for instance.
  137041. */
  137042. rebuild(): void;
  137043. /**
  137044. * Serializes the component data to the specified json object
  137045. * @param serializationObject The object to serialize to
  137046. */
  137047. serialize(serializationObject: any): void;
  137048. /**
  137049. * Adds all the elements from the container to the scene
  137050. * @param container the container holding the elements
  137051. */
  137052. addFromContainer(container: AbstractScene): void;
  137053. /**
  137054. * Removes all the elements in the container from the scene
  137055. * @param container contains the elements to remove
  137056. * @param dispose if the removed element should be disposed (default: false)
  137057. */
  137058. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137059. /**
  137060. * Rebuilds the elements related to this component in case of
  137061. * context lost for instance.
  137062. */
  137063. dispose(): void;
  137064. private _gatherRenderTargets;
  137065. }
  137066. }
  137067. declare module BABYLON {
  137068. /**
  137069. * A point light is a light defined by an unique point in world space.
  137070. * The light is emitted in every direction from this point.
  137071. * A good example of a point light is a standard light bulb.
  137072. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137073. */
  137074. export class PointLight extends ShadowLight {
  137075. private _shadowAngle;
  137076. /**
  137077. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137078. * This specifies what angle the shadow will use to be created.
  137079. *
  137080. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137081. */
  137082. get shadowAngle(): number;
  137083. /**
  137084. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137085. * This specifies what angle the shadow will use to be created.
  137086. *
  137087. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137088. */
  137089. set shadowAngle(value: number);
  137090. /**
  137091. * Gets the direction if it has been set.
  137092. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137093. */
  137094. get direction(): Vector3;
  137095. /**
  137096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137097. */
  137098. set direction(value: Vector3);
  137099. /**
  137100. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137101. * A PointLight emits the light in every direction.
  137102. * It can cast shadows.
  137103. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137104. * ```javascript
  137105. * var pointLight = new PointLight("pl", camera.position, scene);
  137106. * ```
  137107. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137108. * @param name The light friendly name
  137109. * @param position The position of the point light in the scene
  137110. * @param scene The scene the lights belongs to
  137111. */
  137112. constructor(name: string, position: Vector3, scene: Scene);
  137113. /**
  137114. * Returns the string "PointLight"
  137115. * @returns the class name
  137116. */
  137117. getClassName(): string;
  137118. /**
  137119. * Returns the integer 0.
  137120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137121. */
  137122. getTypeID(): number;
  137123. /**
  137124. * Specifies wether or not the shadowmap should be a cube texture.
  137125. * @returns true if the shadowmap needs to be a cube texture.
  137126. */
  137127. needCube(): boolean;
  137128. /**
  137129. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137130. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137131. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137132. */
  137133. getShadowDirection(faceIndex?: number): Vector3;
  137134. /**
  137135. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137136. * - fov = PI / 2
  137137. * - aspect ratio : 1.0
  137138. * - z-near and far equal to the active camera minZ and maxZ.
  137139. * Returns the PointLight.
  137140. */
  137141. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137142. protected _buildUniformLayout(): void;
  137143. /**
  137144. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137145. * @param effect The effect to update
  137146. * @param lightIndex The index of the light in the effect to update
  137147. * @returns The point light
  137148. */
  137149. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137150. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137151. /**
  137152. * Prepares the list of defines specific to the light type.
  137153. * @param defines the list of defines
  137154. * @param lightIndex defines the index of the light for the effect
  137155. */
  137156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137157. }
  137158. }
  137159. declare module BABYLON {
  137160. /**
  137161. * Header information of HDR texture files.
  137162. */
  137163. export interface HDRInfo {
  137164. /**
  137165. * The height of the texture in pixels.
  137166. */
  137167. height: number;
  137168. /**
  137169. * The width of the texture in pixels.
  137170. */
  137171. width: number;
  137172. /**
  137173. * The index of the beginning of the data in the binary file.
  137174. */
  137175. dataPosition: number;
  137176. }
  137177. /**
  137178. * This groups tools to convert HDR texture to native colors array.
  137179. */
  137180. export class HDRTools {
  137181. private static Ldexp;
  137182. private static Rgbe2float;
  137183. private static readStringLine;
  137184. /**
  137185. * Reads header information from an RGBE texture stored in a native array.
  137186. * More information on this format are available here:
  137187. * https://en.wikipedia.org/wiki/RGBE_image_format
  137188. *
  137189. * @param uint8array The binary file stored in native array.
  137190. * @return The header information.
  137191. */
  137192. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137193. /**
  137194. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137195. * This RGBE texture needs to store the information as a panorama.
  137196. *
  137197. * More information on this format are available here:
  137198. * https://en.wikipedia.org/wiki/RGBE_image_format
  137199. *
  137200. * @param buffer The binary file stored in an array buffer.
  137201. * @param size The expected size of the extracted cubemap.
  137202. * @return The Cube Map information.
  137203. */
  137204. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137205. /**
  137206. * Returns the pixels data extracted from an RGBE texture.
  137207. * This pixels will be stored left to right up to down in the R G B order in one array.
  137208. *
  137209. * More information on this format are available here:
  137210. * https://en.wikipedia.org/wiki/RGBE_image_format
  137211. *
  137212. * @param uint8array The binary file stored in an array buffer.
  137213. * @param hdrInfo The header information of the file.
  137214. * @return The pixels data in RGB right to left up to down order.
  137215. */
  137216. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137217. private static RGBE_ReadPixels_RLE;
  137218. }
  137219. }
  137220. declare module BABYLON {
  137221. /**
  137222. * Effect Render Options
  137223. */
  137224. export interface IEffectRendererOptions {
  137225. /**
  137226. * Defines the vertices positions.
  137227. */
  137228. positions?: number[];
  137229. /**
  137230. * Defines the indices.
  137231. */
  137232. indices?: number[];
  137233. }
  137234. /**
  137235. * Helper class to render one or more effects.
  137236. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137237. */
  137238. export class EffectRenderer {
  137239. private engine;
  137240. private static _DefaultOptions;
  137241. private _vertexBuffers;
  137242. private _indexBuffer;
  137243. private _fullscreenViewport;
  137244. /**
  137245. * Creates an effect renderer
  137246. * @param engine the engine to use for rendering
  137247. * @param options defines the options of the effect renderer
  137248. */
  137249. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137250. /**
  137251. * Sets the current viewport in normalized coordinates 0-1
  137252. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137253. */
  137254. setViewport(viewport?: Viewport): void;
  137255. /**
  137256. * Binds the embedded attributes buffer to the effect.
  137257. * @param effect Defines the effect to bind the attributes for
  137258. */
  137259. bindBuffers(effect: Effect): void;
  137260. /**
  137261. * Sets the current effect wrapper to use during draw.
  137262. * The effect needs to be ready before calling this api.
  137263. * This also sets the default full screen position attribute.
  137264. * @param effectWrapper Defines the effect to draw with
  137265. */
  137266. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137267. /**
  137268. * Restores engine states
  137269. */
  137270. restoreStates(): void;
  137271. /**
  137272. * Draws a full screen quad.
  137273. */
  137274. draw(): void;
  137275. private isRenderTargetTexture;
  137276. /**
  137277. * renders one or more effects to a specified texture
  137278. * @param effectWrapper the effect to renderer
  137279. * @param outputTexture texture to draw to, if null it will render to the screen.
  137280. */
  137281. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137282. /**
  137283. * Disposes of the effect renderer
  137284. */
  137285. dispose(): void;
  137286. }
  137287. /**
  137288. * Options to create an EffectWrapper
  137289. */
  137290. interface EffectWrapperCreationOptions {
  137291. /**
  137292. * Engine to use to create the effect
  137293. */
  137294. engine: ThinEngine;
  137295. /**
  137296. * Fragment shader for the effect
  137297. */
  137298. fragmentShader: string;
  137299. /**
  137300. * Use the shader store instead of direct source code
  137301. */
  137302. useShaderStore?: boolean;
  137303. /**
  137304. * Vertex shader for the effect
  137305. */
  137306. vertexShader?: string;
  137307. /**
  137308. * Attributes to use in the shader
  137309. */
  137310. attributeNames?: Array<string>;
  137311. /**
  137312. * Uniforms to use in the shader
  137313. */
  137314. uniformNames?: Array<string>;
  137315. /**
  137316. * Texture sampler names to use in the shader
  137317. */
  137318. samplerNames?: Array<string>;
  137319. /**
  137320. * Defines to use in the shader
  137321. */
  137322. defines?: Array<string>;
  137323. /**
  137324. * Callback when effect is compiled
  137325. */
  137326. onCompiled?: Nullable<(effect: Effect) => void>;
  137327. /**
  137328. * The friendly name of the effect displayed in Spector.
  137329. */
  137330. name?: string;
  137331. }
  137332. /**
  137333. * Wraps an effect to be used for rendering
  137334. */
  137335. export class EffectWrapper {
  137336. /**
  137337. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137338. */
  137339. onApplyObservable: Observable<{}>;
  137340. /**
  137341. * The underlying effect
  137342. */
  137343. effect: Effect;
  137344. /**
  137345. * Creates an effect to be renderer
  137346. * @param creationOptions options to create the effect
  137347. */
  137348. constructor(creationOptions: EffectWrapperCreationOptions);
  137349. /**
  137350. * Disposes of the effect wrapper
  137351. */
  137352. dispose(): void;
  137353. }
  137354. }
  137355. declare module BABYLON {
  137356. /** @hidden */
  137357. export var hdrFilteringVertexShader: {
  137358. name: string;
  137359. shader: string;
  137360. };
  137361. }
  137362. declare module BABYLON {
  137363. /** @hidden */
  137364. export var hdrFilteringPixelShader: {
  137365. name: string;
  137366. shader: string;
  137367. };
  137368. }
  137369. declare module BABYLON {
  137370. /**
  137371. * Options for texture filtering
  137372. */
  137373. interface IHDRFilteringOptions {
  137374. /**
  137375. * Scales pixel intensity for the input HDR map.
  137376. */
  137377. hdrScale?: number;
  137378. /**
  137379. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137380. */
  137381. quality?: number;
  137382. }
  137383. /**
  137384. * Filters HDR maps to get correct renderings of PBR reflections
  137385. */
  137386. export class HDRFiltering {
  137387. private _engine;
  137388. private _effectRenderer;
  137389. private _effectWrapper;
  137390. private _lodGenerationOffset;
  137391. private _lodGenerationScale;
  137392. /**
  137393. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137394. * you care about baking speed.
  137395. */
  137396. quality: number;
  137397. /**
  137398. * Scales pixel intensity for the input HDR map.
  137399. */
  137400. hdrScale: number;
  137401. /**
  137402. * Instantiates HDR filter for reflection maps
  137403. *
  137404. * @param engine Thin engine
  137405. * @param options Options
  137406. */
  137407. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137408. private _createRenderTarget;
  137409. private _prefilterInternal;
  137410. private _createEffect;
  137411. /**
  137412. * Get a value indicating if the filter is ready to be used
  137413. * @param texture Texture to filter
  137414. * @returns true if the filter is ready
  137415. */
  137416. isReady(texture: BaseTexture): boolean;
  137417. /**
  137418. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137419. * Prefiltering will be invoked at the end of next rendering pass.
  137420. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137421. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137422. * @param texture Texture to filter
  137423. * @param onFinished Callback when filtering is done
  137424. * @return Promise called when prefiltering is done
  137425. */
  137426. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137427. }
  137428. }
  137429. declare module BABYLON {
  137430. /**
  137431. * This represents a texture coming from an HDR input.
  137432. *
  137433. * The only supported format is currently panorama picture stored in RGBE format.
  137434. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137435. */
  137436. export class HDRCubeTexture extends BaseTexture {
  137437. private static _facesMapping;
  137438. private _generateHarmonics;
  137439. private _noMipmap;
  137440. private _prefilterOnLoad;
  137441. private _textureMatrix;
  137442. private _size;
  137443. private _onLoad;
  137444. private _onError;
  137445. /**
  137446. * The texture URL.
  137447. */
  137448. url: string;
  137449. /**
  137450. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137451. */
  137452. coordinatesMode: number;
  137453. protected _isBlocking: boolean;
  137454. /**
  137455. * Sets wether or not the texture is blocking during loading.
  137456. */
  137457. set isBlocking(value: boolean);
  137458. /**
  137459. * Gets wether or not the texture is blocking during loading.
  137460. */
  137461. get isBlocking(): boolean;
  137462. protected _rotationY: number;
  137463. /**
  137464. * Sets texture matrix rotation angle around Y axis in radians.
  137465. */
  137466. set rotationY(value: number);
  137467. /**
  137468. * Gets texture matrix rotation angle around Y axis radians.
  137469. */
  137470. get rotationY(): number;
  137471. /**
  137472. * Gets or sets the center of the bounding box associated with the cube texture
  137473. * It must define where the camera used to render the texture was set
  137474. */
  137475. boundingBoxPosition: Vector3;
  137476. private _boundingBoxSize;
  137477. /**
  137478. * Gets or sets the size of the bounding box associated with the cube texture
  137479. * When defined, the cubemap will switch to local mode
  137480. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137481. * @example https://www.babylonjs-playground.com/#RNASML
  137482. */
  137483. set boundingBoxSize(value: Vector3);
  137484. get boundingBoxSize(): Vector3;
  137485. /**
  137486. * Instantiates an HDRTexture from the following parameters.
  137487. *
  137488. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137489. * @param sceneOrEngine The scene or engine the texture will be used in
  137490. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137491. * @param noMipmap Forces to not generate the mipmap if true
  137492. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137493. * @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)
  137494. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137495. */
  137496. 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>);
  137497. /**
  137498. * Get the current class name of the texture useful for serialization or dynamic coding.
  137499. * @returns "HDRCubeTexture"
  137500. */
  137501. getClassName(): string;
  137502. /**
  137503. * Occurs when the file is raw .hdr file.
  137504. */
  137505. private loadTexture;
  137506. clone(): HDRCubeTexture;
  137507. delayLoad(): void;
  137508. /**
  137509. * Get the texture reflection matrix used to rotate/transform the reflection.
  137510. * @returns the reflection matrix
  137511. */
  137512. getReflectionTextureMatrix(): Matrix;
  137513. /**
  137514. * Set the texture reflection matrix used to rotate/transform the reflection.
  137515. * @param value Define the reflection matrix to set
  137516. */
  137517. setReflectionTextureMatrix(value: Matrix): void;
  137518. /**
  137519. * Parses a JSON representation of an HDR Texture in order to create the texture
  137520. * @param parsedTexture Define the JSON representation
  137521. * @param scene Define the scene the texture should be created in
  137522. * @param rootUrl Define the root url in case we need to load relative dependencies
  137523. * @returns the newly created texture after parsing
  137524. */
  137525. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137526. serialize(): any;
  137527. }
  137528. }
  137529. declare module BABYLON {
  137530. /**
  137531. * Class used to control physics engine
  137532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137533. */
  137534. export class PhysicsEngine implements IPhysicsEngine {
  137535. private _physicsPlugin;
  137536. /**
  137537. * Global value used to control the smallest number supported by the simulation
  137538. */
  137539. static Epsilon: number;
  137540. private _impostors;
  137541. private _joints;
  137542. private _subTimeStep;
  137543. /**
  137544. * Gets the gravity vector used by the simulation
  137545. */
  137546. gravity: Vector3;
  137547. /**
  137548. * Factory used to create the default physics plugin.
  137549. * @returns The default physics plugin
  137550. */
  137551. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137552. /**
  137553. * Creates a new Physics Engine
  137554. * @param gravity defines the gravity vector used by the simulation
  137555. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137556. */
  137557. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137558. /**
  137559. * Sets the gravity vector used by the simulation
  137560. * @param gravity defines the gravity vector to use
  137561. */
  137562. setGravity(gravity: Vector3): void;
  137563. /**
  137564. * Set the time step of the physics engine.
  137565. * Default is 1/60.
  137566. * To slow it down, enter 1/600 for example.
  137567. * To speed it up, 1/30
  137568. * @param newTimeStep defines the new timestep to apply to this world.
  137569. */
  137570. setTimeStep(newTimeStep?: number): void;
  137571. /**
  137572. * Get the time step of the physics engine.
  137573. * @returns the current time step
  137574. */
  137575. getTimeStep(): number;
  137576. /**
  137577. * Set the sub time step of the physics engine.
  137578. * Default is 0 meaning there is no sub steps
  137579. * To increase physics resolution precision, set a small value (like 1 ms)
  137580. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137581. */
  137582. setSubTimeStep(subTimeStep?: number): void;
  137583. /**
  137584. * Get the sub time step of the physics engine.
  137585. * @returns the current sub time step
  137586. */
  137587. getSubTimeStep(): number;
  137588. /**
  137589. * Release all resources
  137590. */
  137591. dispose(): void;
  137592. /**
  137593. * Gets the name of the current physics plugin
  137594. * @returns the name of the plugin
  137595. */
  137596. getPhysicsPluginName(): string;
  137597. /**
  137598. * Adding a new impostor for the impostor tracking.
  137599. * This will be done by the impostor itself.
  137600. * @param impostor the impostor to add
  137601. */
  137602. addImpostor(impostor: PhysicsImpostor): void;
  137603. /**
  137604. * Remove an impostor from the engine.
  137605. * This impostor and its mesh will not longer be updated by the physics engine.
  137606. * @param impostor the impostor to remove
  137607. */
  137608. removeImpostor(impostor: PhysicsImpostor): void;
  137609. /**
  137610. * Add a joint to the physics engine
  137611. * @param mainImpostor defines the main impostor to which the joint is added.
  137612. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137613. * @param joint defines the joint that will connect both impostors.
  137614. */
  137615. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137616. /**
  137617. * Removes a joint from the simulation
  137618. * @param mainImpostor defines the impostor used with the joint
  137619. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137620. * @param joint defines the joint to remove
  137621. */
  137622. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137623. /**
  137624. * Called by the scene. No need to call it.
  137625. * @param delta defines the timespam between frames
  137626. */
  137627. _step(delta: number): void;
  137628. /**
  137629. * Gets the current plugin used to run the simulation
  137630. * @returns current plugin
  137631. */
  137632. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137633. /**
  137634. * Gets the list of physic impostors
  137635. * @returns an array of PhysicsImpostor
  137636. */
  137637. getImpostors(): Array<PhysicsImpostor>;
  137638. /**
  137639. * Gets the impostor for a physics enabled object
  137640. * @param object defines the object impersonated by the impostor
  137641. * @returns the PhysicsImpostor or null if not found
  137642. */
  137643. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137644. /**
  137645. * Gets the impostor for a physics body object
  137646. * @param body defines physics body used by the impostor
  137647. * @returns the PhysicsImpostor or null if not found
  137648. */
  137649. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137650. /**
  137651. * Does a raycast in the physics world
  137652. * @param from when should the ray start?
  137653. * @param to when should the ray end?
  137654. * @returns PhysicsRaycastResult
  137655. */
  137656. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137657. }
  137658. }
  137659. declare module BABYLON {
  137660. /** @hidden */
  137661. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137662. private _useDeltaForWorldStep;
  137663. world: any;
  137664. name: string;
  137665. private _physicsMaterials;
  137666. private _fixedTimeStep;
  137667. private _cannonRaycastResult;
  137668. private _raycastResult;
  137669. private _physicsBodysToRemoveAfterStep;
  137670. private _firstFrame;
  137671. BJSCANNON: any;
  137672. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137673. setGravity(gravity: Vector3): void;
  137674. setTimeStep(timeStep: number): void;
  137675. getTimeStep(): number;
  137676. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137677. private _removeMarkedPhysicsBodiesFromWorld;
  137678. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137679. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137680. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137681. private _processChildMeshes;
  137682. removePhysicsBody(impostor: PhysicsImpostor): void;
  137683. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137684. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137685. private _addMaterial;
  137686. private _checkWithEpsilon;
  137687. private _createShape;
  137688. private _createHeightmap;
  137689. private _minus90X;
  137690. private _plus90X;
  137691. private _tmpPosition;
  137692. private _tmpDeltaPosition;
  137693. private _tmpUnityRotation;
  137694. private _updatePhysicsBodyTransformation;
  137695. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137696. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137697. isSupported(): boolean;
  137698. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137699. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137700. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137701. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137702. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137703. getBodyMass(impostor: PhysicsImpostor): number;
  137704. getBodyFriction(impostor: PhysicsImpostor): number;
  137705. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137706. getBodyRestitution(impostor: PhysicsImpostor): number;
  137707. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137708. sleepBody(impostor: PhysicsImpostor): void;
  137709. wakeUpBody(impostor: PhysicsImpostor): void;
  137710. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137711. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137712. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137714. getRadius(impostor: PhysicsImpostor): number;
  137715. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137716. dispose(): void;
  137717. private _extendNamespace;
  137718. /**
  137719. * Does a raycast in the physics world
  137720. * @param from when should the ray start?
  137721. * @param to when should the ray end?
  137722. * @returns PhysicsRaycastResult
  137723. */
  137724. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137725. }
  137726. }
  137727. declare module BABYLON {
  137728. /** @hidden */
  137729. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137730. private _useDeltaForWorldStep;
  137731. world: any;
  137732. name: string;
  137733. BJSOIMO: any;
  137734. private _raycastResult;
  137735. private _fixedTimeStep;
  137736. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137737. setGravity(gravity: Vector3): void;
  137738. setTimeStep(timeStep: number): void;
  137739. getTimeStep(): number;
  137740. private _tmpImpostorsArray;
  137741. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137742. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137743. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137744. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137745. private _tmpPositionVector;
  137746. removePhysicsBody(impostor: PhysicsImpostor): void;
  137747. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137748. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137749. isSupported(): boolean;
  137750. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137756. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137757. getBodyMass(impostor: PhysicsImpostor): number;
  137758. getBodyFriction(impostor: PhysicsImpostor): number;
  137759. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137760. getBodyRestitution(impostor: PhysicsImpostor): number;
  137761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137762. sleepBody(impostor: PhysicsImpostor): void;
  137763. wakeUpBody(impostor: PhysicsImpostor): void;
  137764. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137765. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137768. getRadius(impostor: PhysicsImpostor): number;
  137769. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137770. dispose(): void;
  137771. /**
  137772. * Does a raycast in the physics world
  137773. * @param from when should the ray start?
  137774. * @param to when should the ray end?
  137775. * @returns PhysicsRaycastResult
  137776. */
  137777. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137778. }
  137779. }
  137780. declare module BABYLON {
  137781. /**
  137782. * Class containing static functions to help procedurally build meshes
  137783. */
  137784. export class RibbonBuilder {
  137785. /**
  137786. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137787. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137788. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137789. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137790. * * 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
  137791. * * 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
  137792. * * 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
  137793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137795. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137796. * * 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
  137797. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137798. * * 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
  137799. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137801. * @param name defines the name of the mesh
  137802. * @param options defines the options used to create the mesh
  137803. * @param scene defines the hosting scene
  137804. * @returns the ribbon mesh
  137805. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137806. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137807. */
  137808. static CreateRibbon(name: string, options: {
  137809. pathArray: Vector3[][];
  137810. closeArray?: boolean;
  137811. closePath?: boolean;
  137812. offset?: number;
  137813. updatable?: boolean;
  137814. sideOrientation?: number;
  137815. frontUVs?: Vector4;
  137816. backUVs?: Vector4;
  137817. instance?: Mesh;
  137818. invertUV?: boolean;
  137819. uvs?: Vector2[];
  137820. colors?: Color4[];
  137821. }, scene?: Nullable<Scene>): Mesh;
  137822. }
  137823. }
  137824. declare module BABYLON {
  137825. /**
  137826. * Class containing static functions to help procedurally build meshes
  137827. */
  137828. export class ShapeBuilder {
  137829. /**
  137830. * 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.
  137831. * * 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.
  137832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137833. * * 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.
  137834. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137835. * * 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
  137836. * * 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
  137837. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137842. * @param name defines the name of the mesh
  137843. * @param options defines the options used to create the mesh
  137844. * @param scene defines the hosting scene
  137845. * @returns the extruded shape mesh
  137846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137848. */
  137849. static ExtrudeShape(name: string, options: {
  137850. shape: Vector3[];
  137851. path: Vector3[];
  137852. scale?: number;
  137853. rotation?: number;
  137854. cap?: number;
  137855. updatable?: boolean;
  137856. sideOrientation?: number;
  137857. frontUVs?: Vector4;
  137858. backUVs?: Vector4;
  137859. instance?: Mesh;
  137860. invertUV?: boolean;
  137861. }, scene?: Nullable<Scene>): Mesh;
  137862. /**
  137863. * Creates an custom extruded shape mesh.
  137864. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137865. * * 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.
  137866. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137867. * * 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
  137868. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137869. * * 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
  137870. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137871. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137872. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137873. * * 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
  137874. * * 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
  137875. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137880. * @param name defines the name of the mesh
  137881. * @param options defines the options used to create the mesh
  137882. * @param scene defines the hosting scene
  137883. * @returns the custom extruded shape mesh
  137884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137887. */
  137888. static ExtrudeShapeCustom(name: string, options: {
  137889. shape: Vector3[];
  137890. path: Vector3[];
  137891. scaleFunction?: any;
  137892. rotationFunction?: any;
  137893. ribbonCloseArray?: boolean;
  137894. ribbonClosePath?: boolean;
  137895. cap?: number;
  137896. updatable?: boolean;
  137897. sideOrientation?: number;
  137898. frontUVs?: Vector4;
  137899. backUVs?: Vector4;
  137900. instance?: Mesh;
  137901. invertUV?: boolean;
  137902. }, scene?: Nullable<Scene>): Mesh;
  137903. private static _ExtrudeShapeGeneric;
  137904. }
  137905. }
  137906. declare module BABYLON {
  137907. /**
  137908. * AmmoJS Physics plugin
  137909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137910. * @see https://github.com/kripken/ammo.js/
  137911. */
  137912. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137913. private _useDeltaForWorldStep;
  137914. /**
  137915. * Reference to the Ammo library
  137916. */
  137917. bjsAMMO: any;
  137918. /**
  137919. * Created ammoJS world which physics bodies are added to
  137920. */
  137921. world: any;
  137922. /**
  137923. * Name of the plugin
  137924. */
  137925. name: string;
  137926. private _timeStep;
  137927. private _fixedTimeStep;
  137928. private _maxSteps;
  137929. private _tmpQuaternion;
  137930. private _tmpAmmoTransform;
  137931. private _tmpAmmoQuaternion;
  137932. private _tmpAmmoConcreteContactResultCallback;
  137933. private _collisionConfiguration;
  137934. private _dispatcher;
  137935. private _overlappingPairCache;
  137936. private _solver;
  137937. private _softBodySolver;
  137938. private _tmpAmmoVectorA;
  137939. private _tmpAmmoVectorB;
  137940. private _tmpAmmoVectorC;
  137941. private _tmpAmmoVectorD;
  137942. private _tmpContactCallbackResult;
  137943. private _tmpAmmoVectorRCA;
  137944. private _tmpAmmoVectorRCB;
  137945. private _raycastResult;
  137946. private static readonly DISABLE_COLLISION_FLAG;
  137947. private static readonly KINEMATIC_FLAG;
  137948. private static readonly DISABLE_DEACTIVATION_FLAG;
  137949. /**
  137950. * Initializes the ammoJS plugin
  137951. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137952. * @param ammoInjection can be used to inject your own ammo reference
  137953. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137954. */
  137955. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137956. /**
  137957. * Sets the gravity of the physics world (m/(s^2))
  137958. * @param gravity Gravity to set
  137959. */
  137960. setGravity(gravity: Vector3): void;
  137961. /**
  137962. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137963. * @param timeStep timestep to use in seconds
  137964. */
  137965. setTimeStep(timeStep: number): void;
  137966. /**
  137967. * 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)
  137968. * @param fixedTimeStep fixedTimeStep to use in seconds
  137969. */
  137970. setFixedTimeStep(fixedTimeStep: number): void;
  137971. /**
  137972. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137973. * @param maxSteps the maximum number of steps by the physics engine per frame
  137974. */
  137975. setMaxSteps(maxSteps: number): void;
  137976. /**
  137977. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137978. * @returns the current timestep in seconds
  137979. */
  137980. getTimeStep(): number;
  137981. /**
  137982. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137983. */
  137984. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137985. private _isImpostorInContact;
  137986. private _isImpostorPairInContact;
  137987. private _stepSimulation;
  137988. /**
  137989. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137990. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137991. * After the step the babylon meshes are set to the position of the physics imposters
  137992. * @param delta amount of time to step forward
  137993. * @param impostors array of imposters to update before/after the step
  137994. */
  137995. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137996. /**
  137997. * Update babylon mesh to match physics world object
  137998. * @param impostor imposter to match
  137999. */
  138000. private _afterSoftStep;
  138001. /**
  138002. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138003. * @param impostor imposter to match
  138004. */
  138005. private _ropeStep;
  138006. /**
  138007. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138008. * @param impostor imposter to match
  138009. */
  138010. private _softbodyOrClothStep;
  138011. private _tmpMatrix;
  138012. /**
  138013. * Applies an impulse on the imposter
  138014. * @param impostor imposter to apply impulse to
  138015. * @param force amount of force to be applied to the imposter
  138016. * @param contactPoint the location to apply the impulse on the imposter
  138017. */
  138018. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138019. /**
  138020. * Applies a force on the imposter
  138021. * @param impostor imposter to apply force
  138022. * @param force amount of force to be applied to the imposter
  138023. * @param contactPoint the location to apply the force on the imposter
  138024. */
  138025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138026. /**
  138027. * Creates a physics body using the plugin
  138028. * @param impostor the imposter to create the physics body on
  138029. */
  138030. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138031. /**
  138032. * Removes the physics body from the imposter and disposes of the body's memory
  138033. * @param impostor imposter to remove the physics body from
  138034. */
  138035. removePhysicsBody(impostor: PhysicsImpostor): void;
  138036. /**
  138037. * Generates a joint
  138038. * @param impostorJoint the imposter joint to create the joint with
  138039. */
  138040. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138041. /**
  138042. * Removes a joint
  138043. * @param impostorJoint the imposter joint to remove the joint from
  138044. */
  138045. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138046. private _addMeshVerts;
  138047. /**
  138048. * Initialise the soft body vertices to match its object's (mesh) vertices
  138049. * Softbody vertices (nodes) are in world space and to match this
  138050. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138051. * @param impostor to create the softbody for
  138052. */
  138053. private _softVertexData;
  138054. /**
  138055. * Create an impostor's soft body
  138056. * @param impostor to create the softbody for
  138057. */
  138058. private _createSoftbody;
  138059. /**
  138060. * Create cloth for an impostor
  138061. * @param impostor to create the softbody for
  138062. */
  138063. private _createCloth;
  138064. /**
  138065. * Create rope for an impostor
  138066. * @param impostor to create the softbody for
  138067. */
  138068. private _createRope;
  138069. /**
  138070. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138071. * @param impostor to create the custom physics shape for
  138072. */
  138073. private _createCustom;
  138074. private _addHullVerts;
  138075. private _createShape;
  138076. /**
  138077. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138078. * @param impostor imposter containing the physics body and babylon object
  138079. */
  138080. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138081. /**
  138082. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138083. * @param impostor imposter containing the physics body and babylon object
  138084. * @param newPosition new position
  138085. * @param newRotation new rotation
  138086. */
  138087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138088. /**
  138089. * If this plugin is supported
  138090. * @returns true if its supported
  138091. */
  138092. isSupported(): boolean;
  138093. /**
  138094. * Sets the linear velocity of the physics body
  138095. * @param impostor imposter to set the velocity on
  138096. * @param velocity velocity to set
  138097. */
  138098. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138099. /**
  138100. * Sets the angular velocity of the physics body
  138101. * @param impostor imposter to set the velocity on
  138102. * @param velocity velocity to set
  138103. */
  138104. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138105. /**
  138106. * gets the linear velocity
  138107. * @param impostor imposter to get linear velocity from
  138108. * @returns linear velocity
  138109. */
  138110. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138111. /**
  138112. * gets the angular velocity
  138113. * @param impostor imposter to get angular velocity from
  138114. * @returns angular velocity
  138115. */
  138116. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138117. /**
  138118. * Sets the mass of physics body
  138119. * @param impostor imposter to set the mass on
  138120. * @param mass mass to set
  138121. */
  138122. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138123. /**
  138124. * Gets the mass of the physics body
  138125. * @param impostor imposter to get the mass from
  138126. * @returns mass
  138127. */
  138128. getBodyMass(impostor: PhysicsImpostor): number;
  138129. /**
  138130. * Gets friction of the impostor
  138131. * @param impostor impostor to get friction from
  138132. * @returns friction value
  138133. */
  138134. getBodyFriction(impostor: PhysicsImpostor): number;
  138135. /**
  138136. * Sets friction of the impostor
  138137. * @param impostor impostor to set friction on
  138138. * @param friction friction value
  138139. */
  138140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138141. /**
  138142. * Gets restitution of the impostor
  138143. * @param impostor impostor to get restitution from
  138144. * @returns restitution value
  138145. */
  138146. getBodyRestitution(impostor: PhysicsImpostor): number;
  138147. /**
  138148. * Sets resitution of the impostor
  138149. * @param impostor impostor to set resitution on
  138150. * @param restitution resitution value
  138151. */
  138152. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138153. /**
  138154. * Gets pressure inside the impostor
  138155. * @param impostor impostor to get pressure from
  138156. * @returns pressure value
  138157. */
  138158. getBodyPressure(impostor: PhysicsImpostor): number;
  138159. /**
  138160. * Sets pressure inside a soft body impostor
  138161. * Cloth and rope must remain 0 pressure
  138162. * @param impostor impostor to set pressure on
  138163. * @param pressure pressure value
  138164. */
  138165. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138166. /**
  138167. * Gets stiffness of the impostor
  138168. * @param impostor impostor to get stiffness from
  138169. * @returns pressure value
  138170. */
  138171. getBodyStiffness(impostor: PhysicsImpostor): number;
  138172. /**
  138173. * Sets stiffness of the impostor
  138174. * @param impostor impostor to set stiffness on
  138175. * @param stiffness stiffness value from 0 to 1
  138176. */
  138177. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138178. /**
  138179. * Gets velocityIterations of the impostor
  138180. * @param impostor impostor to get velocity iterations from
  138181. * @returns velocityIterations value
  138182. */
  138183. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138184. /**
  138185. * Sets velocityIterations of the impostor
  138186. * @param impostor impostor to set velocity iterations on
  138187. * @param velocityIterations velocityIterations value
  138188. */
  138189. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138190. /**
  138191. * Gets positionIterations of the impostor
  138192. * @param impostor impostor to get position iterations from
  138193. * @returns positionIterations value
  138194. */
  138195. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138196. /**
  138197. * Sets positionIterations of the impostor
  138198. * @param impostor impostor to set position on
  138199. * @param positionIterations positionIterations value
  138200. */
  138201. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138202. /**
  138203. * Append an anchor to a cloth object
  138204. * @param impostor is the cloth impostor to add anchor to
  138205. * @param otherImpostor is the rigid impostor to anchor to
  138206. * @param width ratio across width from 0 to 1
  138207. * @param height ratio up height from 0 to 1
  138208. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138209. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138210. */
  138211. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138212. /**
  138213. * Append an hook to a rope object
  138214. * @param impostor is the rope impostor to add hook to
  138215. * @param otherImpostor is the rigid impostor to hook to
  138216. * @param length ratio along the rope from 0 to 1
  138217. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138218. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138219. */
  138220. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138221. /**
  138222. * Sleeps the physics body and stops it from being active
  138223. * @param impostor impostor to sleep
  138224. */
  138225. sleepBody(impostor: PhysicsImpostor): void;
  138226. /**
  138227. * Activates the physics body
  138228. * @param impostor impostor to activate
  138229. */
  138230. wakeUpBody(impostor: PhysicsImpostor): void;
  138231. /**
  138232. * Updates the distance parameters of the joint
  138233. * @param joint joint to update
  138234. * @param maxDistance maximum distance of the joint
  138235. * @param minDistance minimum distance of the joint
  138236. */
  138237. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138238. /**
  138239. * Sets a motor on the joint
  138240. * @param joint joint to set motor on
  138241. * @param speed speed of the motor
  138242. * @param maxForce maximum force of the motor
  138243. * @param motorIndex index of the motor
  138244. */
  138245. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138246. /**
  138247. * Sets the motors limit
  138248. * @param joint joint to set limit on
  138249. * @param upperLimit upper limit
  138250. * @param lowerLimit lower limit
  138251. */
  138252. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138253. /**
  138254. * Syncs the position and rotation of a mesh with the impostor
  138255. * @param mesh mesh to sync
  138256. * @param impostor impostor to update the mesh with
  138257. */
  138258. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138259. /**
  138260. * Gets the radius of the impostor
  138261. * @param impostor impostor to get radius from
  138262. * @returns the radius
  138263. */
  138264. getRadius(impostor: PhysicsImpostor): number;
  138265. /**
  138266. * Gets the box size of the impostor
  138267. * @param impostor impostor to get box size from
  138268. * @param result the resulting box size
  138269. */
  138270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138271. /**
  138272. * Disposes of the impostor
  138273. */
  138274. dispose(): void;
  138275. /**
  138276. * Does a raycast in the physics world
  138277. * @param from when should the ray start?
  138278. * @param to when should the ray end?
  138279. * @returns PhysicsRaycastResult
  138280. */
  138281. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138282. }
  138283. }
  138284. declare module BABYLON {
  138285. interface AbstractScene {
  138286. /**
  138287. * The list of reflection probes added to the scene
  138288. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138289. */
  138290. reflectionProbes: Array<ReflectionProbe>;
  138291. /**
  138292. * Removes the given reflection probe from this scene.
  138293. * @param toRemove The reflection probe to remove
  138294. * @returns The index of the removed reflection probe
  138295. */
  138296. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138297. /**
  138298. * Adds the given reflection probe to this scene.
  138299. * @param newReflectionProbe The reflection probe to add
  138300. */
  138301. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138302. }
  138303. /**
  138304. * Class used to generate realtime reflection / refraction cube textures
  138305. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138306. */
  138307. export class ReflectionProbe {
  138308. /** defines the name of the probe */
  138309. name: string;
  138310. private _scene;
  138311. private _renderTargetTexture;
  138312. private _projectionMatrix;
  138313. private _viewMatrix;
  138314. private _target;
  138315. private _add;
  138316. private _attachedMesh;
  138317. private _invertYAxis;
  138318. /** Gets or sets probe position (center of the cube map) */
  138319. position: Vector3;
  138320. /**
  138321. * Creates a new reflection probe
  138322. * @param name defines the name of the probe
  138323. * @param size defines the texture resolution (for each face)
  138324. * @param scene defines the hosting scene
  138325. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138326. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138327. */
  138328. constructor(
  138329. /** defines the name of the probe */
  138330. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138331. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138332. get samples(): number;
  138333. set samples(value: number);
  138334. /** Gets or sets the refresh rate to use (on every frame by default) */
  138335. get refreshRate(): number;
  138336. set refreshRate(value: number);
  138337. /**
  138338. * Gets the hosting scene
  138339. * @returns a Scene
  138340. */
  138341. getScene(): Scene;
  138342. /** Gets the internal CubeTexture used to render to */
  138343. get cubeTexture(): RenderTargetTexture;
  138344. /** Gets the list of meshes to render */
  138345. get renderList(): Nullable<AbstractMesh[]>;
  138346. /**
  138347. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138348. * @param mesh defines the mesh to attach to
  138349. */
  138350. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138351. /**
  138352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138353. * @param renderingGroupId The rendering group id corresponding to its index
  138354. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138355. */
  138356. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138357. /**
  138358. * Clean all associated resources
  138359. */
  138360. dispose(): void;
  138361. /**
  138362. * Converts the reflection probe information to a readable string for debug purpose.
  138363. * @param fullDetails Supports for multiple levels of logging within scene loading
  138364. * @returns the human readable reflection probe info
  138365. */
  138366. toString(fullDetails?: boolean): string;
  138367. /**
  138368. * Get the class name of the relfection probe.
  138369. * @returns "ReflectionProbe"
  138370. */
  138371. getClassName(): string;
  138372. /**
  138373. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138374. * @returns The JSON representation of the texture
  138375. */
  138376. serialize(): any;
  138377. /**
  138378. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138379. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138380. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138381. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138382. * @returns The parsed reflection probe if successful
  138383. */
  138384. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138385. }
  138386. }
  138387. declare module BABYLON {
  138388. /** @hidden */
  138389. export var _BabylonLoaderRegistered: boolean;
  138390. /**
  138391. * Helps setting up some configuration for the babylon file loader.
  138392. */
  138393. export class BabylonFileLoaderConfiguration {
  138394. /**
  138395. * The loader does not allow injecting custom physix engine into the plugins.
  138396. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138397. * So you could set this variable to your engine import to make it work.
  138398. */
  138399. static LoaderInjectedPhysicsEngine: any;
  138400. }
  138401. }
  138402. declare module BABYLON {
  138403. /**
  138404. * The Physically based simple base material of BJS.
  138405. *
  138406. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138407. * It is used as the base class for both the specGloss and metalRough conventions.
  138408. */
  138409. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138410. /**
  138411. * Number of Simultaneous lights allowed on the material.
  138412. */
  138413. maxSimultaneousLights: number;
  138414. /**
  138415. * If sets to true, disables all the lights affecting the material.
  138416. */
  138417. disableLighting: boolean;
  138418. /**
  138419. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138420. */
  138421. environmentTexture: BaseTexture;
  138422. /**
  138423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138424. */
  138425. invertNormalMapX: boolean;
  138426. /**
  138427. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138428. */
  138429. invertNormalMapY: boolean;
  138430. /**
  138431. * Normal map used in the model.
  138432. */
  138433. normalTexture: BaseTexture;
  138434. /**
  138435. * Emissivie color used to self-illuminate the model.
  138436. */
  138437. emissiveColor: Color3;
  138438. /**
  138439. * Emissivie texture used to self-illuminate the model.
  138440. */
  138441. emissiveTexture: BaseTexture;
  138442. /**
  138443. * Occlusion Channel Strenght.
  138444. */
  138445. occlusionStrength: number;
  138446. /**
  138447. * Occlusion Texture of the material (adding extra occlusion effects).
  138448. */
  138449. occlusionTexture: BaseTexture;
  138450. /**
  138451. * Defines the alpha limits in alpha test mode.
  138452. */
  138453. alphaCutOff: number;
  138454. /**
  138455. * Gets the current double sided mode.
  138456. */
  138457. get doubleSided(): boolean;
  138458. /**
  138459. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138460. */
  138461. set doubleSided(value: boolean);
  138462. /**
  138463. * Stores the pre-calculated light information of a mesh in a texture.
  138464. */
  138465. lightmapTexture: BaseTexture;
  138466. /**
  138467. * If true, the light map contains occlusion information instead of lighting info.
  138468. */
  138469. useLightmapAsShadowmap: boolean;
  138470. /**
  138471. * Instantiates a new PBRMaterial instance.
  138472. *
  138473. * @param name The material name
  138474. * @param scene The scene the material will be use in.
  138475. */
  138476. constructor(name: string, scene: Scene);
  138477. getClassName(): string;
  138478. }
  138479. }
  138480. declare module BABYLON {
  138481. /**
  138482. * The PBR material of BJS following the metal roughness convention.
  138483. *
  138484. * This fits to the PBR convention in the GLTF definition:
  138485. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138486. */
  138487. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138488. /**
  138489. * The base color has two different interpretations depending on the value of metalness.
  138490. * When the material is a metal, the base color is the specific measured reflectance value
  138491. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138492. * of the material.
  138493. */
  138494. baseColor: Color3;
  138495. /**
  138496. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138497. * well as opacity information in the alpha channel.
  138498. */
  138499. baseTexture: BaseTexture;
  138500. /**
  138501. * Specifies the metallic scalar value of the material.
  138502. * Can also be used to scale the metalness values of the metallic texture.
  138503. */
  138504. metallic: number;
  138505. /**
  138506. * Specifies the roughness scalar value of the material.
  138507. * Can also be used to scale the roughness values of the metallic texture.
  138508. */
  138509. roughness: number;
  138510. /**
  138511. * Texture containing both the metallic value in the B channel and the
  138512. * roughness value in the G channel to keep better precision.
  138513. */
  138514. metallicRoughnessTexture: BaseTexture;
  138515. /**
  138516. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138517. *
  138518. * @param name The material name
  138519. * @param scene The scene the material will be use in.
  138520. */
  138521. constructor(name: string, scene: Scene);
  138522. /**
  138523. * Return the currrent class name of the material.
  138524. */
  138525. getClassName(): string;
  138526. /**
  138527. * Makes a duplicate of the current material.
  138528. * @param name - name to use for the new material.
  138529. */
  138530. clone(name: string): PBRMetallicRoughnessMaterial;
  138531. /**
  138532. * Serialize the material to a parsable JSON object.
  138533. */
  138534. serialize(): any;
  138535. /**
  138536. * Parses a JSON object correponding to the serialize function.
  138537. */
  138538. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138539. }
  138540. }
  138541. declare module BABYLON {
  138542. /**
  138543. * The PBR material of BJS following the specular glossiness convention.
  138544. *
  138545. * This fits to the PBR convention in the GLTF definition:
  138546. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138547. */
  138548. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138549. /**
  138550. * Specifies the diffuse color of the material.
  138551. */
  138552. diffuseColor: Color3;
  138553. /**
  138554. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138555. * channel.
  138556. */
  138557. diffuseTexture: BaseTexture;
  138558. /**
  138559. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138560. */
  138561. specularColor: Color3;
  138562. /**
  138563. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138564. */
  138565. glossiness: number;
  138566. /**
  138567. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138568. */
  138569. specularGlossinessTexture: BaseTexture;
  138570. /**
  138571. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138572. *
  138573. * @param name The material name
  138574. * @param scene The scene the material will be use in.
  138575. */
  138576. constructor(name: string, scene: Scene);
  138577. /**
  138578. * Return the currrent class name of the material.
  138579. */
  138580. getClassName(): string;
  138581. /**
  138582. * Makes a duplicate of the current material.
  138583. * @param name - name to use for the new material.
  138584. */
  138585. clone(name: string): PBRSpecularGlossinessMaterial;
  138586. /**
  138587. * Serialize the material to a parsable JSON object.
  138588. */
  138589. serialize(): any;
  138590. /**
  138591. * Parses a JSON object correponding to the serialize function.
  138592. */
  138593. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138594. }
  138595. }
  138596. declare module BABYLON {
  138597. /**
  138598. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138599. * It can help converting any input color in a desired output one. This can then be used to create effects
  138600. * from sepia, black and white to sixties or futuristic rendering...
  138601. *
  138602. * The only supported format is currently 3dl.
  138603. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138604. */
  138605. export class ColorGradingTexture extends BaseTexture {
  138606. /**
  138607. * The texture URL.
  138608. */
  138609. url: string;
  138610. /**
  138611. * Empty line regex stored for GC.
  138612. */
  138613. private static _noneEmptyLineRegex;
  138614. private _textureMatrix;
  138615. private _onLoad;
  138616. /**
  138617. * Instantiates a ColorGradingTexture from the following parameters.
  138618. *
  138619. * @param url The location of the color gradind data (currently only supporting 3dl)
  138620. * @param sceneOrEngine The scene or engine the texture will be used in
  138621. * @param onLoad defines a callback triggered when the texture has been loaded
  138622. */
  138623. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138624. /**
  138625. * Fires the onload event from the constructor if requested.
  138626. */
  138627. private _triggerOnLoad;
  138628. /**
  138629. * Returns the texture matrix used in most of the material.
  138630. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138631. */
  138632. getTextureMatrix(): Matrix;
  138633. /**
  138634. * Occurs when the file being loaded is a .3dl LUT file.
  138635. */
  138636. private load3dlTexture;
  138637. /**
  138638. * Starts the loading process of the texture.
  138639. */
  138640. private loadTexture;
  138641. /**
  138642. * Clones the color gradind texture.
  138643. */
  138644. clone(): ColorGradingTexture;
  138645. /**
  138646. * Called during delayed load for textures.
  138647. */
  138648. delayLoad(): void;
  138649. /**
  138650. * Parses a color grading texture serialized by Babylon.
  138651. * @param parsedTexture The texture information being parsedTexture
  138652. * @param scene The scene to load the texture in
  138653. * @param rootUrl The root url of the data assets to load
  138654. * @return A color gradind texture
  138655. */
  138656. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138657. /**
  138658. * Serializes the LUT texture to json format.
  138659. */
  138660. serialize(): any;
  138661. }
  138662. }
  138663. declare module BABYLON {
  138664. /**
  138665. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138666. */
  138667. export class EquiRectangularCubeTexture extends BaseTexture {
  138668. /** The six faces of the cube. */
  138669. private static _FacesMapping;
  138670. private _noMipmap;
  138671. private _onLoad;
  138672. private _onError;
  138673. /** The size of the cubemap. */
  138674. private _size;
  138675. /** The buffer of the image. */
  138676. private _buffer;
  138677. /** The width of the input image. */
  138678. private _width;
  138679. /** The height of the input image. */
  138680. private _height;
  138681. /** The URL to the image. */
  138682. url: string;
  138683. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138684. coordinatesMode: number;
  138685. /**
  138686. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138687. * @param url The location of the image
  138688. * @param scene The scene the texture will be used in
  138689. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138690. * @param noMipmap Forces to not generate the mipmap if true
  138691. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138692. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138693. * @param onLoad — defines a callback called when texture is loaded
  138694. * @param onError — defines a callback called if there is an error
  138695. */
  138696. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138697. /**
  138698. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138699. */
  138700. private loadImage;
  138701. /**
  138702. * Convert the image buffer into a cubemap and create a CubeTexture.
  138703. */
  138704. private loadTexture;
  138705. /**
  138706. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138707. * @param buffer The ArrayBuffer that should be converted.
  138708. * @returns The buffer as Float32Array.
  138709. */
  138710. private getFloat32ArrayFromArrayBuffer;
  138711. /**
  138712. * Get the current class name of the texture useful for serialization or dynamic coding.
  138713. * @returns "EquiRectangularCubeTexture"
  138714. */
  138715. getClassName(): string;
  138716. /**
  138717. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138718. * @returns A clone of the current EquiRectangularCubeTexture.
  138719. */
  138720. clone(): EquiRectangularCubeTexture;
  138721. }
  138722. }
  138723. declare module BABYLON {
  138724. /**
  138725. * Defines the options related to the creation of an HtmlElementTexture
  138726. */
  138727. export interface IHtmlElementTextureOptions {
  138728. /**
  138729. * Defines wether mip maps should be created or not.
  138730. */
  138731. generateMipMaps?: boolean;
  138732. /**
  138733. * Defines the sampling mode of the texture.
  138734. */
  138735. samplingMode?: number;
  138736. /**
  138737. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138738. */
  138739. engine: Nullable<ThinEngine>;
  138740. /**
  138741. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138742. */
  138743. scene: Nullable<Scene>;
  138744. }
  138745. /**
  138746. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138747. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138748. * is automatically managed.
  138749. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138750. * in your application.
  138751. *
  138752. * As the update is not automatic, you need to call them manually.
  138753. */
  138754. export class HtmlElementTexture extends BaseTexture {
  138755. /**
  138756. * The texture URL.
  138757. */
  138758. element: HTMLVideoElement | HTMLCanvasElement;
  138759. private static readonly DefaultOptions;
  138760. private _textureMatrix;
  138761. private _isVideo;
  138762. private _generateMipMaps;
  138763. private _samplingMode;
  138764. /**
  138765. * Instantiates a HtmlElementTexture from the following parameters.
  138766. *
  138767. * @param name Defines the name of the texture
  138768. * @param element Defines the video or canvas the texture is filled with
  138769. * @param options Defines the other none mandatory texture creation options
  138770. */
  138771. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138772. private _createInternalTexture;
  138773. /**
  138774. * Returns the texture matrix used in most of the material.
  138775. */
  138776. getTextureMatrix(): Matrix;
  138777. /**
  138778. * Updates the content of the texture.
  138779. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138780. */
  138781. update(invertY?: Nullable<boolean>): void;
  138782. }
  138783. }
  138784. declare module BABYLON {
  138785. /**
  138786. * Based on jsTGALoader - Javascript loader for TGA file
  138787. * By Vincent Thibault
  138788. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138789. */
  138790. export class TGATools {
  138791. private static _TYPE_INDEXED;
  138792. private static _TYPE_RGB;
  138793. private static _TYPE_GREY;
  138794. private static _TYPE_RLE_INDEXED;
  138795. private static _TYPE_RLE_RGB;
  138796. private static _TYPE_RLE_GREY;
  138797. private static _ORIGIN_MASK;
  138798. private static _ORIGIN_SHIFT;
  138799. private static _ORIGIN_BL;
  138800. private static _ORIGIN_BR;
  138801. private static _ORIGIN_UL;
  138802. private static _ORIGIN_UR;
  138803. /**
  138804. * Gets the header of a TGA file
  138805. * @param data defines the TGA data
  138806. * @returns the header
  138807. */
  138808. static GetTGAHeader(data: Uint8Array): any;
  138809. /**
  138810. * Uploads TGA content to a Babylon Texture
  138811. * @hidden
  138812. */
  138813. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138814. /** @hidden */
  138815. 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;
  138816. /** @hidden */
  138817. 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;
  138818. /** @hidden */
  138819. 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;
  138820. /** @hidden */
  138821. 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;
  138822. /** @hidden */
  138823. 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;
  138824. /** @hidden */
  138825. 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;
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /**
  138830. * Implementation of the TGA Texture Loader.
  138831. * @hidden
  138832. */
  138833. export class _TGATextureLoader implements IInternalTextureLoader {
  138834. /**
  138835. * Defines wether the loader supports cascade loading the different faces.
  138836. */
  138837. readonly supportCascades: boolean;
  138838. /**
  138839. * This returns if the loader support the current file information.
  138840. * @param extension defines the file extension of the file being loaded
  138841. * @returns true if the loader can load the specified file
  138842. */
  138843. canLoad(extension: string): boolean;
  138844. /**
  138845. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138846. * @param data contains the texture data
  138847. * @param texture defines the BabylonJS internal texture
  138848. * @param createPolynomials will be true if polynomials have been requested
  138849. * @param onLoad defines the callback to trigger once the texture is ready
  138850. * @param onError defines the callback to trigger in case of error
  138851. */
  138852. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138853. /**
  138854. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138855. * @param data contains the texture data
  138856. * @param texture defines the BabylonJS internal texture
  138857. * @param callback defines the method to call once ready to upload
  138858. */
  138859. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138860. }
  138861. }
  138862. declare module BABYLON {
  138863. /**
  138864. * Info about the .basis files
  138865. */
  138866. class BasisFileInfo {
  138867. /**
  138868. * If the file has alpha
  138869. */
  138870. hasAlpha: boolean;
  138871. /**
  138872. * Info about each image of the basis file
  138873. */
  138874. images: Array<{
  138875. levels: Array<{
  138876. width: number;
  138877. height: number;
  138878. transcodedPixels: ArrayBufferView;
  138879. }>;
  138880. }>;
  138881. }
  138882. /**
  138883. * Result of transcoding a basis file
  138884. */
  138885. class TranscodeResult {
  138886. /**
  138887. * Info about the .basis file
  138888. */
  138889. fileInfo: BasisFileInfo;
  138890. /**
  138891. * Format to use when loading the file
  138892. */
  138893. format: number;
  138894. }
  138895. /**
  138896. * Configuration options for the Basis transcoder
  138897. */
  138898. export class BasisTranscodeConfiguration {
  138899. /**
  138900. * Supported compression formats used to determine the supported output format of the transcoder
  138901. */
  138902. supportedCompressionFormats?: {
  138903. /**
  138904. * etc1 compression format
  138905. */
  138906. etc1?: boolean;
  138907. /**
  138908. * s3tc compression format
  138909. */
  138910. s3tc?: boolean;
  138911. /**
  138912. * pvrtc compression format
  138913. */
  138914. pvrtc?: boolean;
  138915. /**
  138916. * etc2 compression format
  138917. */
  138918. etc2?: boolean;
  138919. };
  138920. /**
  138921. * If mipmap levels should be loaded for transcoded images (Default: true)
  138922. */
  138923. loadMipmapLevels?: boolean;
  138924. /**
  138925. * Index of a single image to load (Default: all images)
  138926. */
  138927. loadSingleImage?: number;
  138928. }
  138929. /**
  138930. * Used to load .Basis files
  138931. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138932. */
  138933. export class BasisTools {
  138934. private static _IgnoreSupportedFormats;
  138935. /**
  138936. * URL to use when loading the basis transcoder
  138937. */
  138938. static JSModuleURL: string;
  138939. /**
  138940. * URL to use when loading the wasm module for the transcoder
  138941. */
  138942. static WasmModuleURL: string;
  138943. /**
  138944. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138945. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138946. * @returns internal format corresponding to the Basis format
  138947. */
  138948. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138949. private static _WorkerPromise;
  138950. private static _Worker;
  138951. private static _actionId;
  138952. private static _CreateWorkerAsync;
  138953. /**
  138954. * Transcodes a loaded image file to compressed pixel data
  138955. * @param data image data to transcode
  138956. * @param config configuration options for the transcoding
  138957. * @returns a promise resulting in the transcoded image
  138958. */
  138959. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138960. /**
  138961. * Loads a texture from the transcode result
  138962. * @param texture texture load to
  138963. * @param transcodeResult the result of transcoding the basis file to load from
  138964. */
  138965. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138966. }
  138967. }
  138968. declare module BABYLON {
  138969. /**
  138970. * Loader for .basis file format
  138971. */
  138972. export class _BasisTextureLoader implements IInternalTextureLoader {
  138973. /**
  138974. * Defines whether the loader supports cascade loading the different faces.
  138975. */
  138976. readonly supportCascades: boolean;
  138977. /**
  138978. * This returns if the loader support the current file information.
  138979. * @param extension defines the file extension of the file being loaded
  138980. * @returns true if the loader can load the specified file
  138981. */
  138982. canLoad(extension: string): boolean;
  138983. /**
  138984. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138985. * @param data contains the texture data
  138986. * @param texture defines the BabylonJS internal texture
  138987. * @param createPolynomials will be true if polynomials have been requested
  138988. * @param onLoad defines the callback to trigger once the texture is ready
  138989. * @param onError defines the callback to trigger in case of error
  138990. */
  138991. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138992. /**
  138993. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138994. * @param data contains the texture data
  138995. * @param texture defines the BabylonJS internal texture
  138996. * @param callback defines the method to call once ready to upload
  138997. */
  138998. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138999. }
  139000. }
  139001. declare module BABYLON {
  139002. /**
  139003. * Defines the basic options interface of a TexturePacker Frame
  139004. */
  139005. export interface ITexturePackerFrame {
  139006. /**
  139007. * The frame ID
  139008. */
  139009. id: number;
  139010. /**
  139011. * The frames Scale
  139012. */
  139013. scale: Vector2;
  139014. /**
  139015. * The Frames offset
  139016. */
  139017. offset: Vector2;
  139018. }
  139019. /**
  139020. * This is a support class for frame Data on texture packer sets.
  139021. */
  139022. export class TexturePackerFrame implements ITexturePackerFrame {
  139023. /**
  139024. * The frame ID
  139025. */
  139026. id: number;
  139027. /**
  139028. * The frames Scale
  139029. */
  139030. scale: Vector2;
  139031. /**
  139032. * The Frames offset
  139033. */
  139034. offset: Vector2;
  139035. /**
  139036. * Initializes a texture package frame.
  139037. * @param id The numerical frame identifier
  139038. * @param scale Scalar Vector2 for UV frame
  139039. * @param offset Vector2 for the frame position in UV units.
  139040. * @returns TexturePackerFrame
  139041. */
  139042. constructor(id: number, scale: Vector2, offset: Vector2);
  139043. }
  139044. }
  139045. declare module BABYLON {
  139046. /**
  139047. * Defines the basic options interface of a TexturePacker
  139048. */
  139049. export interface ITexturePackerOptions {
  139050. /**
  139051. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139052. */
  139053. map?: string[];
  139054. /**
  139055. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139056. */
  139057. uvsIn?: string;
  139058. /**
  139059. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139060. */
  139061. uvsOut?: string;
  139062. /**
  139063. * number representing the layout style. Defaults to LAYOUT_STRIP
  139064. */
  139065. layout?: number;
  139066. /**
  139067. * number of columns if using custom column count layout(2). This defaults to 4.
  139068. */
  139069. colnum?: number;
  139070. /**
  139071. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139072. */
  139073. updateInputMeshes?: boolean;
  139074. /**
  139075. * boolean flag to dispose all the source textures. Defaults to true.
  139076. */
  139077. disposeSources?: boolean;
  139078. /**
  139079. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139080. */
  139081. fillBlanks?: boolean;
  139082. /**
  139083. * string value representing the context fill style color. Defaults to 'black'.
  139084. */
  139085. customFillColor?: string;
  139086. /**
  139087. * Width and Height Value of each Frame in the TexturePacker Sets
  139088. */
  139089. frameSize?: number;
  139090. /**
  139091. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139092. */
  139093. paddingRatio?: number;
  139094. /**
  139095. * Number that declares the fill method for the padding gutter.
  139096. */
  139097. paddingMode?: number;
  139098. /**
  139099. * If in SUBUV_COLOR padding mode what color to use.
  139100. */
  139101. paddingColor?: Color3 | Color4;
  139102. }
  139103. /**
  139104. * Defines the basic interface of a TexturePacker JSON File
  139105. */
  139106. export interface ITexturePackerJSON {
  139107. /**
  139108. * The frame ID
  139109. */
  139110. name: string;
  139111. /**
  139112. * The base64 channel data
  139113. */
  139114. sets: any;
  139115. /**
  139116. * The options of the Packer
  139117. */
  139118. options: ITexturePackerOptions;
  139119. /**
  139120. * The frame data of the Packer
  139121. */
  139122. frames: Array<number>;
  139123. }
  139124. /**
  139125. * This is a support class that generates a series of packed texture sets.
  139126. * @see https://doc.babylonjs.com/babylon101/materials
  139127. */
  139128. export class TexturePacker {
  139129. /** Packer Layout Constant 0 */
  139130. static readonly LAYOUT_STRIP: number;
  139131. /** Packer Layout Constant 1 */
  139132. static readonly LAYOUT_POWER2: number;
  139133. /** Packer Layout Constant 2 */
  139134. static readonly LAYOUT_COLNUM: number;
  139135. /** Packer Layout Constant 0 */
  139136. static readonly SUBUV_WRAP: number;
  139137. /** Packer Layout Constant 1 */
  139138. static readonly SUBUV_EXTEND: number;
  139139. /** Packer Layout Constant 2 */
  139140. static readonly SUBUV_COLOR: number;
  139141. /** The Name of the Texture Package */
  139142. name: string;
  139143. /** The scene scope of the TexturePacker */
  139144. scene: Scene;
  139145. /** The Meshes to target */
  139146. meshes: AbstractMesh[];
  139147. /** Arguments passed with the Constructor */
  139148. options: ITexturePackerOptions;
  139149. /** The promise that is started upon initialization */
  139150. promise: Nullable<Promise<TexturePacker | string>>;
  139151. /** The Container object for the channel sets that are generated */
  139152. sets: object;
  139153. /** The Container array for the frames that are generated */
  139154. frames: TexturePackerFrame[];
  139155. /** The expected number of textures the system is parsing. */
  139156. private _expecting;
  139157. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139158. private _paddingValue;
  139159. /**
  139160. * Initializes a texture package series from an array of meshes or a single mesh.
  139161. * @param name The name of the package
  139162. * @param meshes The target meshes to compose the package from
  139163. * @param options The arguments that texture packer should follow while building.
  139164. * @param scene The scene which the textures are scoped to.
  139165. * @returns TexturePacker
  139166. */
  139167. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139168. /**
  139169. * Starts the package process
  139170. * @param resolve The promises resolution function
  139171. * @returns TexturePacker
  139172. */
  139173. private _createFrames;
  139174. /**
  139175. * Calculates the Size of the Channel Sets
  139176. * @returns Vector2
  139177. */
  139178. private _calculateSize;
  139179. /**
  139180. * Calculates the UV data for the frames.
  139181. * @param baseSize the base frameSize
  139182. * @param padding the base frame padding
  139183. * @param dtSize size of the Dynamic Texture for that channel
  139184. * @param dtUnits is 1/dtSize
  139185. * @param update flag to update the input meshes
  139186. */
  139187. private _calculateMeshUVFrames;
  139188. /**
  139189. * Calculates the frames Offset.
  139190. * @param index of the frame
  139191. * @returns Vector2
  139192. */
  139193. private _getFrameOffset;
  139194. /**
  139195. * Updates a Mesh to the frame data
  139196. * @param mesh that is the target
  139197. * @param frameID or the frame index
  139198. */
  139199. private _updateMeshUV;
  139200. /**
  139201. * Updates a Meshes materials to use the texture packer channels
  139202. * @param m is the mesh to target
  139203. * @param force all channels on the packer to be set.
  139204. */
  139205. private _updateTextureReferences;
  139206. /**
  139207. * Public method to set a Mesh to a frame
  139208. * @param m that is the target
  139209. * @param frameID or the frame index
  139210. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139211. */
  139212. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139213. /**
  139214. * Starts the async promise to compile the texture packer.
  139215. * @returns Promise<void>
  139216. */
  139217. processAsync(): Promise<void>;
  139218. /**
  139219. * Disposes all textures associated with this packer
  139220. */
  139221. dispose(): void;
  139222. /**
  139223. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139224. * @param imageType is the image type to use.
  139225. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139226. */
  139227. download(imageType?: string, quality?: number): void;
  139228. /**
  139229. * Public method to load a texturePacker JSON file.
  139230. * @param data of the JSON file in string format.
  139231. */
  139232. updateFromJSON(data: string): void;
  139233. }
  139234. }
  139235. declare module BABYLON {
  139236. /**
  139237. * 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.
  139238. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139239. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139240. */
  139241. export class CustomProceduralTexture extends ProceduralTexture {
  139242. private _animate;
  139243. private _time;
  139244. private _config;
  139245. private _texturePath;
  139246. /**
  139247. * Instantiates a new Custom Procedural Texture.
  139248. * 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.
  139249. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139250. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139251. * @param name Define the name of the texture
  139252. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139253. * @param size Define the size of the texture to create
  139254. * @param scene Define the scene the texture belongs to
  139255. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139256. * @param generateMipMaps Define if the texture should creates mip maps or not
  139257. */
  139258. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139259. private _loadJson;
  139260. /**
  139261. * Is the texture ready to be used ? (rendered at least once)
  139262. * @returns true if ready, otherwise, false.
  139263. */
  139264. isReady(): boolean;
  139265. /**
  139266. * Render the texture to its associated render target.
  139267. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139268. */
  139269. render(useCameraPostProcess?: boolean): void;
  139270. /**
  139271. * Update the list of dependant textures samplers in the shader.
  139272. */
  139273. updateTextures(): void;
  139274. /**
  139275. * Update the uniform values of the procedural texture in the shader.
  139276. */
  139277. updateShaderUniforms(): void;
  139278. /**
  139279. * Define if the texture animates or not.
  139280. */
  139281. get animate(): boolean;
  139282. set animate(value: boolean);
  139283. }
  139284. }
  139285. declare module BABYLON {
  139286. /** @hidden */
  139287. export var noisePixelShader: {
  139288. name: string;
  139289. shader: string;
  139290. };
  139291. }
  139292. declare module BABYLON {
  139293. /**
  139294. * Class used to generate noise procedural textures
  139295. */
  139296. export class NoiseProceduralTexture extends ProceduralTexture {
  139297. private _time;
  139298. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139299. brightness: number;
  139300. /** Defines the number of octaves to process */
  139301. octaves: number;
  139302. /** Defines the level of persistence (0.8 by default) */
  139303. persistence: number;
  139304. /** Gets or sets animation speed factor (default is 1) */
  139305. animationSpeedFactor: number;
  139306. /**
  139307. * Creates a new NoiseProceduralTexture
  139308. * @param name defines the name fo the texture
  139309. * @param size defines the size of the texture (default is 256)
  139310. * @param scene defines the hosting scene
  139311. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139312. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139313. */
  139314. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139315. private _updateShaderUniforms;
  139316. protected _getDefines(): string;
  139317. /** Generate the current state of the procedural texture */
  139318. render(useCameraPostProcess?: boolean): void;
  139319. /**
  139320. * Serializes this noise procedural texture
  139321. * @returns a serialized noise procedural texture object
  139322. */
  139323. serialize(): any;
  139324. /**
  139325. * Clone the texture.
  139326. * @returns the cloned texture
  139327. */
  139328. clone(): NoiseProceduralTexture;
  139329. /**
  139330. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139331. * @param parsedTexture defines parsed texture data
  139332. * @param scene defines the current scene
  139333. * @param rootUrl defines the root URL containing noise procedural texture information
  139334. * @returns a parsed NoiseProceduralTexture
  139335. */
  139336. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139337. }
  139338. }
  139339. declare module BABYLON {
  139340. /**
  139341. * Raw cube texture where the raw buffers are passed in
  139342. */
  139343. export class RawCubeTexture extends CubeTexture {
  139344. /**
  139345. * Creates a cube texture where the raw buffers are passed in.
  139346. * @param scene defines the scene the texture is attached to
  139347. * @param data defines the array of data to use to create each face
  139348. * @param size defines the size of the textures
  139349. * @param format defines the format of the data
  139350. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139351. * @param generateMipMaps defines if the engine should generate the mip levels
  139352. * @param invertY defines if data must be stored with Y axis inverted
  139353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139354. * @param compression defines the compression used (null by default)
  139355. */
  139356. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139357. /**
  139358. * Updates the raw cube texture.
  139359. * @param data defines the data to store
  139360. * @param format defines the data format
  139361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139362. * @param invertY defines if data must be stored with Y axis inverted
  139363. * @param compression defines the compression used (null by default)
  139364. * @param level defines which level of the texture to update
  139365. */
  139366. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139367. /**
  139368. * Updates a raw cube texture with RGBD encoded data.
  139369. * @param data defines the array of data [mipmap][face] to use to create each face
  139370. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139371. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139372. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139373. * @returns a promsie that resolves when the operation is complete
  139374. */
  139375. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139376. /**
  139377. * Clones the raw cube texture.
  139378. * @return a new cube texture
  139379. */
  139380. clone(): CubeTexture;
  139381. /** @hidden */
  139382. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139383. }
  139384. }
  139385. declare module BABYLON {
  139386. /**
  139387. * Class used to store 2D array textures containing user data
  139388. */
  139389. export class RawTexture2DArray extends Texture {
  139390. /** Gets or sets the texture format to use */
  139391. format: number;
  139392. /**
  139393. * Create a new RawTexture2DArray
  139394. * @param data defines the data of the texture
  139395. * @param width defines the width of the texture
  139396. * @param height defines the height of the texture
  139397. * @param depth defines the number of layers of the texture
  139398. * @param format defines the texture format to use
  139399. * @param scene defines the hosting scene
  139400. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139401. * @param invertY defines if texture must be stored with Y axis inverted
  139402. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139403. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139404. */
  139405. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139406. /** Gets or sets the texture format to use */
  139407. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139408. /**
  139409. * Update the texture with new data
  139410. * @param data defines the data to store in the texture
  139411. */
  139412. update(data: ArrayBufferView): void;
  139413. }
  139414. }
  139415. declare module BABYLON {
  139416. /**
  139417. * Class used to store 3D textures containing user data
  139418. */
  139419. export class RawTexture3D extends Texture {
  139420. /** Gets or sets the texture format to use */
  139421. format: number;
  139422. /**
  139423. * Create a new RawTexture3D
  139424. * @param data defines the data of the texture
  139425. * @param width defines the width of the texture
  139426. * @param height defines the height of the texture
  139427. * @param depth defines the depth of the texture
  139428. * @param format defines the texture format to use
  139429. * @param scene defines the hosting scene
  139430. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139431. * @param invertY defines if texture must be stored with Y axis inverted
  139432. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139433. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139434. */
  139435. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139436. /** Gets or sets the texture format to use */
  139437. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139438. /**
  139439. * Update the texture with new data
  139440. * @param data defines the data to store in the texture
  139441. */
  139442. update(data: ArrayBufferView): void;
  139443. }
  139444. }
  139445. declare module BABYLON {
  139446. /**
  139447. * Creates a refraction texture used by refraction channel of the standard material.
  139448. * It is like a mirror but to see through a material.
  139449. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139450. */
  139451. export class RefractionTexture extends RenderTargetTexture {
  139452. /**
  139453. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139454. * 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.
  139455. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139456. */
  139457. refractionPlane: Plane;
  139458. /**
  139459. * Define how deep under the surface we should see.
  139460. */
  139461. depth: number;
  139462. /**
  139463. * Creates a refraction texture used by refraction channel of the standard material.
  139464. * It is like a mirror but to see through a material.
  139465. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139466. * @param name Define the texture name
  139467. * @param size Define the size of the underlying texture
  139468. * @param scene Define the scene the refraction belongs to
  139469. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139470. */
  139471. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139472. /**
  139473. * Clone the refraction texture.
  139474. * @returns the cloned texture
  139475. */
  139476. clone(): RefractionTexture;
  139477. /**
  139478. * Serialize the texture to a JSON representation you could use in Parse later on
  139479. * @returns the serialized JSON representation
  139480. */
  139481. serialize(): any;
  139482. }
  139483. }
  139484. declare module BABYLON {
  139485. /**
  139486. * Block used to add support for vertex skinning (bones)
  139487. */
  139488. export class BonesBlock extends NodeMaterialBlock {
  139489. /**
  139490. * Creates a new BonesBlock
  139491. * @param name defines the block name
  139492. */
  139493. constructor(name: string);
  139494. /**
  139495. * Initialize the block and prepare the context for build
  139496. * @param state defines the state that will be used for the build
  139497. */
  139498. initialize(state: NodeMaterialBuildState): void;
  139499. /**
  139500. * Gets the current class name
  139501. * @returns the class name
  139502. */
  139503. getClassName(): string;
  139504. /**
  139505. * Gets the matrix indices input component
  139506. */
  139507. get matricesIndices(): NodeMaterialConnectionPoint;
  139508. /**
  139509. * Gets the matrix weights input component
  139510. */
  139511. get matricesWeights(): NodeMaterialConnectionPoint;
  139512. /**
  139513. * Gets the extra matrix indices input component
  139514. */
  139515. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139516. /**
  139517. * Gets the extra matrix weights input component
  139518. */
  139519. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139520. /**
  139521. * Gets the world input component
  139522. */
  139523. get world(): NodeMaterialConnectionPoint;
  139524. /**
  139525. * Gets the output component
  139526. */
  139527. get output(): NodeMaterialConnectionPoint;
  139528. autoConfigure(material: NodeMaterial): void;
  139529. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139532. protected _buildBlock(state: NodeMaterialBuildState): this;
  139533. }
  139534. }
  139535. declare module BABYLON {
  139536. /**
  139537. * Block used to add support for instances
  139538. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139539. */
  139540. export class InstancesBlock extends NodeMaterialBlock {
  139541. /**
  139542. * Creates a new InstancesBlock
  139543. * @param name defines the block name
  139544. */
  139545. constructor(name: string);
  139546. /**
  139547. * Gets the current class name
  139548. * @returns the class name
  139549. */
  139550. getClassName(): string;
  139551. /**
  139552. * Gets the first world row input component
  139553. */
  139554. get world0(): NodeMaterialConnectionPoint;
  139555. /**
  139556. * Gets the second world row input component
  139557. */
  139558. get world1(): NodeMaterialConnectionPoint;
  139559. /**
  139560. * Gets the third world row input component
  139561. */
  139562. get world2(): NodeMaterialConnectionPoint;
  139563. /**
  139564. * Gets the forth world row input component
  139565. */
  139566. get world3(): NodeMaterialConnectionPoint;
  139567. /**
  139568. * Gets the world input component
  139569. */
  139570. get world(): NodeMaterialConnectionPoint;
  139571. /**
  139572. * Gets the output component
  139573. */
  139574. get output(): NodeMaterialConnectionPoint;
  139575. /**
  139576. * Gets the isntanceID component
  139577. */
  139578. get instanceID(): NodeMaterialConnectionPoint;
  139579. autoConfigure(material: NodeMaterial): void;
  139580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139581. protected _buildBlock(state: NodeMaterialBuildState): this;
  139582. }
  139583. }
  139584. declare module BABYLON {
  139585. /**
  139586. * Block used to add morph targets support to vertex shader
  139587. */
  139588. export class MorphTargetsBlock extends NodeMaterialBlock {
  139589. private _repeatableContentAnchor;
  139590. /**
  139591. * Create a new MorphTargetsBlock
  139592. * @param name defines the block name
  139593. */
  139594. constructor(name: string);
  139595. /**
  139596. * Gets the current class name
  139597. * @returns the class name
  139598. */
  139599. getClassName(): string;
  139600. /**
  139601. * Gets the position input component
  139602. */
  139603. get position(): NodeMaterialConnectionPoint;
  139604. /**
  139605. * Gets the normal input component
  139606. */
  139607. get normal(): NodeMaterialConnectionPoint;
  139608. /**
  139609. * Gets the tangent input component
  139610. */
  139611. get tangent(): NodeMaterialConnectionPoint;
  139612. /**
  139613. * Gets the tangent input component
  139614. */
  139615. get uv(): NodeMaterialConnectionPoint;
  139616. /**
  139617. * Gets the position output component
  139618. */
  139619. get positionOutput(): NodeMaterialConnectionPoint;
  139620. /**
  139621. * Gets the normal output component
  139622. */
  139623. get normalOutput(): NodeMaterialConnectionPoint;
  139624. /**
  139625. * Gets the tangent output component
  139626. */
  139627. get tangentOutput(): NodeMaterialConnectionPoint;
  139628. /**
  139629. * Gets the tangent output component
  139630. */
  139631. get uvOutput(): NodeMaterialConnectionPoint;
  139632. initialize(state: NodeMaterialBuildState): void;
  139633. autoConfigure(material: NodeMaterial): void;
  139634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139635. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139636. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139637. protected _buildBlock(state: NodeMaterialBuildState): this;
  139638. }
  139639. }
  139640. declare module BABYLON {
  139641. /**
  139642. * Block used to get data information from a light
  139643. */
  139644. export class LightInformationBlock extends NodeMaterialBlock {
  139645. private _lightDataUniformName;
  139646. private _lightColorUniformName;
  139647. private _lightTypeDefineName;
  139648. /**
  139649. * Gets or sets the light associated with this block
  139650. */
  139651. light: Nullable<Light>;
  139652. /**
  139653. * Creates a new LightInformationBlock
  139654. * @param name defines the block name
  139655. */
  139656. constructor(name: string);
  139657. /**
  139658. * Gets the current class name
  139659. * @returns the class name
  139660. */
  139661. getClassName(): string;
  139662. /**
  139663. * Gets the world position input component
  139664. */
  139665. get worldPosition(): NodeMaterialConnectionPoint;
  139666. /**
  139667. * Gets the direction output component
  139668. */
  139669. get direction(): NodeMaterialConnectionPoint;
  139670. /**
  139671. * Gets the direction output component
  139672. */
  139673. get color(): NodeMaterialConnectionPoint;
  139674. /**
  139675. * Gets the direction output component
  139676. */
  139677. get intensity(): NodeMaterialConnectionPoint;
  139678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139680. protected _buildBlock(state: NodeMaterialBuildState): this;
  139681. serialize(): any;
  139682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139683. }
  139684. }
  139685. declare module BABYLON {
  139686. /**
  139687. * Block used to add image processing support to fragment shader
  139688. */
  139689. export class ImageProcessingBlock extends NodeMaterialBlock {
  139690. /**
  139691. * Create a new ImageProcessingBlock
  139692. * @param name defines the block name
  139693. */
  139694. constructor(name: string);
  139695. /**
  139696. * Gets the current class name
  139697. * @returns the class name
  139698. */
  139699. getClassName(): string;
  139700. /**
  139701. * Gets the color input component
  139702. */
  139703. get color(): NodeMaterialConnectionPoint;
  139704. /**
  139705. * Gets the output component
  139706. */
  139707. get output(): NodeMaterialConnectionPoint;
  139708. /**
  139709. * Initialize the block and prepare the context for build
  139710. * @param state defines the state that will be used for the build
  139711. */
  139712. initialize(state: NodeMaterialBuildState): void;
  139713. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139715. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139716. protected _buildBlock(state: NodeMaterialBuildState): this;
  139717. }
  139718. }
  139719. declare module BABYLON {
  139720. /**
  139721. * Block used to pertub normals based on a normal map
  139722. */
  139723. export class PerturbNormalBlock extends NodeMaterialBlock {
  139724. private _tangentSpaceParameterName;
  139725. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139726. invertX: boolean;
  139727. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139728. invertY: boolean;
  139729. /**
  139730. * Create a new PerturbNormalBlock
  139731. * @param name defines the block name
  139732. */
  139733. constructor(name: string);
  139734. /**
  139735. * Gets the current class name
  139736. * @returns the class name
  139737. */
  139738. getClassName(): string;
  139739. /**
  139740. * Gets the world position input component
  139741. */
  139742. get worldPosition(): NodeMaterialConnectionPoint;
  139743. /**
  139744. * Gets the world normal input component
  139745. */
  139746. get worldNormal(): NodeMaterialConnectionPoint;
  139747. /**
  139748. * Gets the world tangent input component
  139749. */
  139750. get worldTangent(): NodeMaterialConnectionPoint;
  139751. /**
  139752. * Gets the uv input component
  139753. */
  139754. get uv(): NodeMaterialConnectionPoint;
  139755. /**
  139756. * Gets the normal map color input component
  139757. */
  139758. get normalMapColor(): NodeMaterialConnectionPoint;
  139759. /**
  139760. * Gets the strength input component
  139761. */
  139762. get strength(): NodeMaterialConnectionPoint;
  139763. /**
  139764. * Gets the output component
  139765. */
  139766. get output(): NodeMaterialConnectionPoint;
  139767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139769. autoConfigure(material: NodeMaterial): void;
  139770. protected _buildBlock(state: NodeMaterialBuildState): this;
  139771. protected _dumpPropertiesCode(): string;
  139772. serialize(): any;
  139773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139774. }
  139775. }
  139776. declare module BABYLON {
  139777. /**
  139778. * Block used to discard a pixel if a value is smaller than a cutoff
  139779. */
  139780. export class DiscardBlock extends NodeMaterialBlock {
  139781. /**
  139782. * Create a new DiscardBlock
  139783. * @param name defines the block name
  139784. */
  139785. constructor(name: string);
  139786. /**
  139787. * Gets the current class name
  139788. * @returns the class name
  139789. */
  139790. getClassName(): string;
  139791. /**
  139792. * Gets the color input component
  139793. */
  139794. get value(): NodeMaterialConnectionPoint;
  139795. /**
  139796. * Gets the cutoff input component
  139797. */
  139798. get cutoff(): NodeMaterialConnectionPoint;
  139799. protected _buildBlock(state: NodeMaterialBuildState): this;
  139800. }
  139801. }
  139802. declare module BABYLON {
  139803. /**
  139804. * Block used to test if the fragment shader is front facing
  139805. */
  139806. export class FrontFacingBlock extends NodeMaterialBlock {
  139807. /**
  139808. * Creates a new FrontFacingBlock
  139809. * @param name defines the block name
  139810. */
  139811. constructor(name: string);
  139812. /**
  139813. * Gets the current class name
  139814. * @returns the class name
  139815. */
  139816. getClassName(): string;
  139817. /**
  139818. * Gets the output component
  139819. */
  139820. get output(): NodeMaterialConnectionPoint;
  139821. protected _buildBlock(state: NodeMaterialBuildState): this;
  139822. }
  139823. }
  139824. declare module BABYLON {
  139825. /**
  139826. * Block used to get the derivative value on x and y of a given input
  139827. */
  139828. export class DerivativeBlock extends NodeMaterialBlock {
  139829. /**
  139830. * Create a new DerivativeBlock
  139831. * @param name defines the block name
  139832. */
  139833. constructor(name: string);
  139834. /**
  139835. * Gets the current class name
  139836. * @returns the class name
  139837. */
  139838. getClassName(): string;
  139839. /**
  139840. * Gets the input component
  139841. */
  139842. get input(): NodeMaterialConnectionPoint;
  139843. /**
  139844. * Gets the derivative output on x
  139845. */
  139846. get dx(): NodeMaterialConnectionPoint;
  139847. /**
  139848. * Gets the derivative output on y
  139849. */
  139850. get dy(): NodeMaterialConnectionPoint;
  139851. protected _buildBlock(state: NodeMaterialBuildState): this;
  139852. }
  139853. }
  139854. declare module BABYLON {
  139855. /**
  139856. * Block used to make gl_FragCoord available
  139857. */
  139858. export class FragCoordBlock extends NodeMaterialBlock {
  139859. /**
  139860. * Creates a new FragCoordBlock
  139861. * @param name defines the block name
  139862. */
  139863. constructor(name: string);
  139864. /**
  139865. * Gets the current class name
  139866. * @returns the class name
  139867. */
  139868. getClassName(): string;
  139869. /**
  139870. * Gets the xy component
  139871. */
  139872. get xy(): NodeMaterialConnectionPoint;
  139873. /**
  139874. * Gets the xyz component
  139875. */
  139876. get xyz(): NodeMaterialConnectionPoint;
  139877. /**
  139878. * Gets the xyzw component
  139879. */
  139880. get xyzw(): NodeMaterialConnectionPoint;
  139881. /**
  139882. * Gets the x component
  139883. */
  139884. get x(): NodeMaterialConnectionPoint;
  139885. /**
  139886. * Gets the y component
  139887. */
  139888. get y(): NodeMaterialConnectionPoint;
  139889. /**
  139890. * Gets the z component
  139891. */
  139892. get z(): NodeMaterialConnectionPoint;
  139893. /**
  139894. * Gets the w component
  139895. */
  139896. get output(): NodeMaterialConnectionPoint;
  139897. protected writeOutputs(state: NodeMaterialBuildState): string;
  139898. protected _buildBlock(state: NodeMaterialBuildState): this;
  139899. }
  139900. }
  139901. declare module BABYLON {
  139902. /**
  139903. * Block used to get the screen sizes
  139904. */
  139905. export class ScreenSizeBlock extends NodeMaterialBlock {
  139906. private _varName;
  139907. private _scene;
  139908. /**
  139909. * Creates a new ScreenSizeBlock
  139910. * @param name defines the block name
  139911. */
  139912. constructor(name: string);
  139913. /**
  139914. * Gets the current class name
  139915. * @returns the class name
  139916. */
  139917. getClassName(): string;
  139918. /**
  139919. * Gets the xy component
  139920. */
  139921. get xy(): NodeMaterialConnectionPoint;
  139922. /**
  139923. * Gets the x component
  139924. */
  139925. get x(): NodeMaterialConnectionPoint;
  139926. /**
  139927. * Gets the y component
  139928. */
  139929. get y(): NodeMaterialConnectionPoint;
  139930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139931. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139932. protected _buildBlock(state: NodeMaterialBuildState): this;
  139933. }
  139934. }
  139935. declare module BABYLON {
  139936. /**
  139937. * Block used to add support for scene fog
  139938. */
  139939. export class FogBlock extends NodeMaterialBlock {
  139940. private _fogDistanceName;
  139941. private _fogParameters;
  139942. /**
  139943. * Create a new FogBlock
  139944. * @param name defines the block name
  139945. */
  139946. constructor(name: string);
  139947. /**
  139948. * Gets the current class name
  139949. * @returns the class name
  139950. */
  139951. getClassName(): string;
  139952. /**
  139953. * Gets the world position input component
  139954. */
  139955. get worldPosition(): NodeMaterialConnectionPoint;
  139956. /**
  139957. * Gets the view input component
  139958. */
  139959. get view(): NodeMaterialConnectionPoint;
  139960. /**
  139961. * Gets the color input component
  139962. */
  139963. get input(): NodeMaterialConnectionPoint;
  139964. /**
  139965. * Gets the fog color input component
  139966. */
  139967. get fogColor(): NodeMaterialConnectionPoint;
  139968. /**
  139969. * Gets the output component
  139970. */
  139971. get output(): NodeMaterialConnectionPoint;
  139972. autoConfigure(material: NodeMaterial): void;
  139973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139975. protected _buildBlock(state: NodeMaterialBuildState): this;
  139976. }
  139977. }
  139978. declare module BABYLON {
  139979. /**
  139980. * Block used to add light in the fragment shader
  139981. */
  139982. export class LightBlock extends NodeMaterialBlock {
  139983. private _lightId;
  139984. /**
  139985. * Gets or sets the light associated with this block
  139986. */
  139987. light: Nullable<Light>;
  139988. /**
  139989. * Create a new LightBlock
  139990. * @param name defines the block name
  139991. */
  139992. constructor(name: string);
  139993. /**
  139994. * Gets the current class name
  139995. * @returns the class name
  139996. */
  139997. getClassName(): string;
  139998. /**
  139999. * Gets the world position input component
  140000. */
  140001. get worldPosition(): NodeMaterialConnectionPoint;
  140002. /**
  140003. * Gets the world normal input component
  140004. */
  140005. get worldNormal(): NodeMaterialConnectionPoint;
  140006. /**
  140007. * Gets the camera (or eye) position component
  140008. */
  140009. get cameraPosition(): NodeMaterialConnectionPoint;
  140010. /**
  140011. * Gets the glossiness component
  140012. */
  140013. get glossiness(): NodeMaterialConnectionPoint;
  140014. /**
  140015. * Gets the glossinness power component
  140016. */
  140017. get glossPower(): NodeMaterialConnectionPoint;
  140018. /**
  140019. * Gets the diffuse color component
  140020. */
  140021. get diffuseColor(): NodeMaterialConnectionPoint;
  140022. /**
  140023. * Gets the specular color component
  140024. */
  140025. get specularColor(): NodeMaterialConnectionPoint;
  140026. /**
  140027. * Gets the diffuse output component
  140028. */
  140029. get diffuseOutput(): NodeMaterialConnectionPoint;
  140030. /**
  140031. * Gets the specular output component
  140032. */
  140033. get specularOutput(): NodeMaterialConnectionPoint;
  140034. /**
  140035. * Gets the shadow output component
  140036. */
  140037. get shadow(): NodeMaterialConnectionPoint;
  140038. autoConfigure(material: NodeMaterial): void;
  140039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140040. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140042. private _injectVertexCode;
  140043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140044. serialize(): any;
  140045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140046. }
  140047. }
  140048. declare module BABYLON {
  140049. /**
  140050. * Block used to read a reflection texture from a sampler
  140051. */
  140052. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140053. /**
  140054. * Create a new ReflectionTextureBlock
  140055. * @param name defines the block name
  140056. */
  140057. constructor(name: string);
  140058. /**
  140059. * Gets the current class name
  140060. * @returns the class name
  140061. */
  140062. getClassName(): string;
  140063. /**
  140064. * Gets the world position input component
  140065. */
  140066. get position(): NodeMaterialConnectionPoint;
  140067. /**
  140068. * Gets the world position input component
  140069. */
  140070. get worldPosition(): NodeMaterialConnectionPoint;
  140071. /**
  140072. * Gets the world normal input component
  140073. */
  140074. get worldNormal(): NodeMaterialConnectionPoint;
  140075. /**
  140076. * Gets the world input component
  140077. */
  140078. get world(): NodeMaterialConnectionPoint;
  140079. /**
  140080. * Gets the camera (or eye) position component
  140081. */
  140082. get cameraPosition(): NodeMaterialConnectionPoint;
  140083. /**
  140084. * Gets the view input component
  140085. */
  140086. get view(): NodeMaterialConnectionPoint;
  140087. /**
  140088. * Gets the rgb output component
  140089. */
  140090. get rgb(): NodeMaterialConnectionPoint;
  140091. /**
  140092. * Gets the rgba output component
  140093. */
  140094. get rgba(): NodeMaterialConnectionPoint;
  140095. /**
  140096. * Gets the r output component
  140097. */
  140098. get r(): NodeMaterialConnectionPoint;
  140099. /**
  140100. * Gets the g output component
  140101. */
  140102. get g(): NodeMaterialConnectionPoint;
  140103. /**
  140104. * Gets the b output component
  140105. */
  140106. get b(): NodeMaterialConnectionPoint;
  140107. /**
  140108. * Gets the a output component
  140109. */
  140110. get a(): NodeMaterialConnectionPoint;
  140111. autoConfigure(material: NodeMaterial): void;
  140112. protected _buildBlock(state: NodeMaterialBuildState): this;
  140113. }
  140114. }
  140115. declare module BABYLON {
  140116. /**
  140117. * Block used to add 2 vectors
  140118. */
  140119. export class AddBlock extends NodeMaterialBlock {
  140120. /**
  140121. * Creates a new AddBlock
  140122. * @param name defines the block name
  140123. */
  140124. constructor(name: string);
  140125. /**
  140126. * Gets the current class name
  140127. * @returns the class name
  140128. */
  140129. getClassName(): string;
  140130. /**
  140131. * Gets the left operand input component
  140132. */
  140133. get left(): NodeMaterialConnectionPoint;
  140134. /**
  140135. * Gets the right operand input component
  140136. */
  140137. get right(): NodeMaterialConnectionPoint;
  140138. /**
  140139. * Gets the output component
  140140. */
  140141. get output(): NodeMaterialConnectionPoint;
  140142. protected _buildBlock(state: NodeMaterialBuildState): this;
  140143. }
  140144. }
  140145. declare module BABYLON {
  140146. /**
  140147. * Block used to scale a vector by a float
  140148. */
  140149. export class ScaleBlock extends NodeMaterialBlock {
  140150. /**
  140151. * Creates a new ScaleBlock
  140152. * @param name defines the block name
  140153. */
  140154. constructor(name: string);
  140155. /**
  140156. * Gets the current class name
  140157. * @returns the class name
  140158. */
  140159. getClassName(): string;
  140160. /**
  140161. * Gets the input component
  140162. */
  140163. get input(): NodeMaterialConnectionPoint;
  140164. /**
  140165. * Gets the factor input component
  140166. */
  140167. get factor(): NodeMaterialConnectionPoint;
  140168. /**
  140169. * Gets the output component
  140170. */
  140171. get output(): NodeMaterialConnectionPoint;
  140172. protected _buildBlock(state: NodeMaterialBuildState): this;
  140173. }
  140174. }
  140175. declare module BABYLON {
  140176. /**
  140177. * Block used to clamp a float
  140178. */
  140179. export class ClampBlock extends NodeMaterialBlock {
  140180. /** Gets or sets the minimum range */
  140181. minimum: number;
  140182. /** Gets or sets the maximum range */
  140183. maximum: number;
  140184. /**
  140185. * Creates a new ClampBlock
  140186. * @param name defines the block name
  140187. */
  140188. constructor(name: string);
  140189. /**
  140190. * Gets the current class name
  140191. * @returns the class name
  140192. */
  140193. getClassName(): string;
  140194. /**
  140195. * Gets the value input component
  140196. */
  140197. get value(): NodeMaterialConnectionPoint;
  140198. /**
  140199. * Gets the output component
  140200. */
  140201. get output(): NodeMaterialConnectionPoint;
  140202. protected _buildBlock(state: NodeMaterialBuildState): this;
  140203. protected _dumpPropertiesCode(): string;
  140204. serialize(): any;
  140205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140206. }
  140207. }
  140208. declare module BABYLON {
  140209. /**
  140210. * Block used to apply a cross product between 2 vectors
  140211. */
  140212. export class CrossBlock extends NodeMaterialBlock {
  140213. /**
  140214. * Creates a new CrossBlock
  140215. * @param name defines the block name
  140216. */
  140217. constructor(name: string);
  140218. /**
  140219. * Gets the current class name
  140220. * @returns the class name
  140221. */
  140222. getClassName(): string;
  140223. /**
  140224. * Gets the left operand input component
  140225. */
  140226. get left(): NodeMaterialConnectionPoint;
  140227. /**
  140228. * Gets the right operand input component
  140229. */
  140230. get right(): NodeMaterialConnectionPoint;
  140231. /**
  140232. * Gets the output component
  140233. */
  140234. get output(): NodeMaterialConnectionPoint;
  140235. protected _buildBlock(state: NodeMaterialBuildState): this;
  140236. }
  140237. }
  140238. declare module BABYLON {
  140239. /**
  140240. * Block used to apply a dot product between 2 vectors
  140241. */
  140242. export class DotBlock extends NodeMaterialBlock {
  140243. /**
  140244. * Creates a new DotBlock
  140245. * @param name defines the block name
  140246. */
  140247. constructor(name: string);
  140248. /**
  140249. * Gets the current class name
  140250. * @returns the class name
  140251. */
  140252. getClassName(): string;
  140253. /**
  140254. * Gets the left operand input component
  140255. */
  140256. get left(): NodeMaterialConnectionPoint;
  140257. /**
  140258. * Gets the right operand input component
  140259. */
  140260. get right(): NodeMaterialConnectionPoint;
  140261. /**
  140262. * Gets the output component
  140263. */
  140264. get output(): NodeMaterialConnectionPoint;
  140265. protected _buildBlock(state: NodeMaterialBuildState): this;
  140266. }
  140267. }
  140268. declare module BABYLON {
  140269. /**
  140270. * Block used to normalize a vector
  140271. */
  140272. export class NormalizeBlock extends NodeMaterialBlock {
  140273. /**
  140274. * Creates a new NormalizeBlock
  140275. * @param name defines the block name
  140276. */
  140277. constructor(name: string);
  140278. /**
  140279. * Gets the current class name
  140280. * @returns the class name
  140281. */
  140282. getClassName(): string;
  140283. /**
  140284. * Gets the input component
  140285. */
  140286. get input(): NodeMaterialConnectionPoint;
  140287. /**
  140288. * Gets the output component
  140289. */
  140290. get output(): NodeMaterialConnectionPoint;
  140291. protected _buildBlock(state: NodeMaterialBuildState): this;
  140292. }
  140293. }
  140294. declare module BABYLON {
  140295. /**
  140296. * Operations supported by the Trigonometry block
  140297. */
  140298. export enum TrigonometryBlockOperations {
  140299. /** Cos */
  140300. Cos = 0,
  140301. /** Sin */
  140302. Sin = 1,
  140303. /** Abs */
  140304. Abs = 2,
  140305. /** Exp */
  140306. Exp = 3,
  140307. /** Exp2 */
  140308. Exp2 = 4,
  140309. /** Round */
  140310. Round = 5,
  140311. /** Floor */
  140312. Floor = 6,
  140313. /** Ceiling */
  140314. Ceiling = 7,
  140315. /** Square root */
  140316. Sqrt = 8,
  140317. /** Log */
  140318. Log = 9,
  140319. /** Tangent */
  140320. Tan = 10,
  140321. /** Arc tangent */
  140322. ArcTan = 11,
  140323. /** Arc cosinus */
  140324. ArcCos = 12,
  140325. /** Arc sinus */
  140326. ArcSin = 13,
  140327. /** Fraction */
  140328. Fract = 14,
  140329. /** Sign */
  140330. Sign = 15,
  140331. /** To radians (from degrees) */
  140332. Radians = 16,
  140333. /** To degrees (from radians) */
  140334. Degrees = 17
  140335. }
  140336. /**
  140337. * Block used to apply trigonometry operation to floats
  140338. */
  140339. export class TrigonometryBlock extends NodeMaterialBlock {
  140340. /**
  140341. * Gets or sets the operation applied by the block
  140342. */
  140343. operation: TrigonometryBlockOperations;
  140344. /**
  140345. * Creates a new TrigonometryBlock
  140346. * @param name defines the block name
  140347. */
  140348. constructor(name: string);
  140349. /**
  140350. * Gets the current class name
  140351. * @returns the class name
  140352. */
  140353. getClassName(): string;
  140354. /**
  140355. * Gets the input component
  140356. */
  140357. get input(): NodeMaterialConnectionPoint;
  140358. /**
  140359. * Gets the output component
  140360. */
  140361. get output(): NodeMaterialConnectionPoint;
  140362. protected _buildBlock(state: NodeMaterialBuildState): this;
  140363. serialize(): any;
  140364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140365. protected _dumpPropertiesCode(): string;
  140366. }
  140367. }
  140368. declare module BABYLON {
  140369. /**
  140370. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140371. */
  140372. export class ColorMergerBlock extends NodeMaterialBlock {
  140373. /**
  140374. * Create a new ColorMergerBlock
  140375. * @param name defines the block name
  140376. */
  140377. constructor(name: string);
  140378. /**
  140379. * Gets the current class name
  140380. * @returns the class name
  140381. */
  140382. getClassName(): string;
  140383. /**
  140384. * Gets the rgb component (input)
  140385. */
  140386. get rgbIn(): NodeMaterialConnectionPoint;
  140387. /**
  140388. * Gets the r component (input)
  140389. */
  140390. get r(): NodeMaterialConnectionPoint;
  140391. /**
  140392. * Gets the g component (input)
  140393. */
  140394. get g(): NodeMaterialConnectionPoint;
  140395. /**
  140396. * Gets the b component (input)
  140397. */
  140398. get b(): NodeMaterialConnectionPoint;
  140399. /**
  140400. * Gets the a component (input)
  140401. */
  140402. get a(): NodeMaterialConnectionPoint;
  140403. /**
  140404. * Gets the rgba component (output)
  140405. */
  140406. get rgba(): NodeMaterialConnectionPoint;
  140407. /**
  140408. * Gets the rgb component (output)
  140409. */
  140410. get rgbOut(): NodeMaterialConnectionPoint;
  140411. /**
  140412. * Gets the rgb component (output)
  140413. * @deprecated Please use rgbOut instead.
  140414. */
  140415. get rgb(): NodeMaterialConnectionPoint;
  140416. protected _buildBlock(state: NodeMaterialBuildState): this;
  140417. }
  140418. }
  140419. declare module BABYLON {
  140420. /**
  140421. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140422. */
  140423. export class VectorSplitterBlock extends NodeMaterialBlock {
  140424. /**
  140425. * Create a new VectorSplitterBlock
  140426. * @param name defines the block name
  140427. */
  140428. constructor(name: string);
  140429. /**
  140430. * Gets the current class name
  140431. * @returns the class name
  140432. */
  140433. getClassName(): string;
  140434. /**
  140435. * Gets the xyzw component (input)
  140436. */
  140437. get xyzw(): NodeMaterialConnectionPoint;
  140438. /**
  140439. * Gets the xyz component (input)
  140440. */
  140441. get xyzIn(): NodeMaterialConnectionPoint;
  140442. /**
  140443. * Gets the xy component (input)
  140444. */
  140445. get xyIn(): NodeMaterialConnectionPoint;
  140446. /**
  140447. * Gets the xyz component (output)
  140448. */
  140449. get xyzOut(): NodeMaterialConnectionPoint;
  140450. /**
  140451. * Gets the xy component (output)
  140452. */
  140453. get xyOut(): NodeMaterialConnectionPoint;
  140454. /**
  140455. * Gets the x component (output)
  140456. */
  140457. get x(): NodeMaterialConnectionPoint;
  140458. /**
  140459. * Gets the y component (output)
  140460. */
  140461. get y(): NodeMaterialConnectionPoint;
  140462. /**
  140463. * Gets the z component (output)
  140464. */
  140465. get z(): NodeMaterialConnectionPoint;
  140466. /**
  140467. * Gets the w component (output)
  140468. */
  140469. get w(): NodeMaterialConnectionPoint;
  140470. protected _inputRename(name: string): string;
  140471. protected _outputRename(name: string): string;
  140472. protected _buildBlock(state: NodeMaterialBuildState): this;
  140473. }
  140474. }
  140475. declare module BABYLON {
  140476. /**
  140477. * Block used to lerp between 2 values
  140478. */
  140479. export class LerpBlock extends NodeMaterialBlock {
  140480. /**
  140481. * Creates a new LerpBlock
  140482. * @param name defines the block name
  140483. */
  140484. constructor(name: string);
  140485. /**
  140486. * Gets the current class name
  140487. * @returns the class name
  140488. */
  140489. getClassName(): string;
  140490. /**
  140491. * Gets the left operand input component
  140492. */
  140493. get left(): NodeMaterialConnectionPoint;
  140494. /**
  140495. * Gets the right operand input component
  140496. */
  140497. get right(): NodeMaterialConnectionPoint;
  140498. /**
  140499. * Gets the gradient operand input component
  140500. */
  140501. get gradient(): NodeMaterialConnectionPoint;
  140502. /**
  140503. * Gets the output component
  140504. */
  140505. get output(): NodeMaterialConnectionPoint;
  140506. protected _buildBlock(state: NodeMaterialBuildState): this;
  140507. }
  140508. }
  140509. declare module BABYLON {
  140510. /**
  140511. * Block used to divide 2 vectors
  140512. */
  140513. export class DivideBlock extends NodeMaterialBlock {
  140514. /**
  140515. * Creates a new DivideBlock
  140516. * @param name defines the block name
  140517. */
  140518. constructor(name: string);
  140519. /**
  140520. * Gets the current class name
  140521. * @returns the class name
  140522. */
  140523. getClassName(): string;
  140524. /**
  140525. * Gets the left operand input component
  140526. */
  140527. get left(): NodeMaterialConnectionPoint;
  140528. /**
  140529. * Gets the right operand input component
  140530. */
  140531. get right(): NodeMaterialConnectionPoint;
  140532. /**
  140533. * Gets the output component
  140534. */
  140535. get output(): NodeMaterialConnectionPoint;
  140536. protected _buildBlock(state: NodeMaterialBuildState): this;
  140537. }
  140538. }
  140539. declare module BABYLON {
  140540. /**
  140541. * Block used to subtract 2 vectors
  140542. */
  140543. export class SubtractBlock extends NodeMaterialBlock {
  140544. /**
  140545. * Creates a new SubtractBlock
  140546. * @param name defines the block name
  140547. */
  140548. constructor(name: string);
  140549. /**
  140550. * Gets the current class name
  140551. * @returns the class name
  140552. */
  140553. getClassName(): string;
  140554. /**
  140555. * Gets the left operand input component
  140556. */
  140557. get left(): NodeMaterialConnectionPoint;
  140558. /**
  140559. * Gets the right operand input component
  140560. */
  140561. get right(): NodeMaterialConnectionPoint;
  140562. /**
  140563. * Gets the output component
  140564. */
  140565. get output(): NodeMaterialConnectionPoint;
  140566. protected _buildBlock(state: NodeMaterialBuildState): this;
  140567. }
  140568. }
  140569. declare module BABYLON {
  140570. /**
  140571. * Block used to step a value
  140572. */
  140573. export class StepBlock extends NodeMaterialBlock {
  140574. /**
  140575. * Creates a new StepBlock
  140576. * @param name defines the block name
  140577. */
  140578. constructor(name: string);
  140579. /**
  140580. * Gets the current class name
  140581. * @returns the class name
  140582. */
  140583. getClassName(): string;
  140584. /**
  140585. * Gets the value operand input component
  140586. */
  140587. get value(): NodeMaterialConnectionPoint;
  140588. /**
  140589. * Gets the edge operand input component
  140590. */
  140591. get edge(): NodeMaterialConnectionPoint;
  140592. /**
  140593. * Gets the output component
  140594. */
  140595. get output(): NodeMaterialConnectionPoint;
  140596. protected _buildBlock(state: NodeMaterialBuildState): this;
  140597. }
  140598. }
  140599. declare module BABYLON {
  140600. /**
  140601. * Block used to get the opposite (1 - x) of a value
  140602. */
  140603. export class OneMinusBlock extends NodeMaterialBlock {
  140604. /**
  140605. * Creates a new OneMinusBlock
  140606. * @param name defines the block name
  140607. */
  140608. constructor(name: string);
  140609. /**
  140610. * Gets the current class name
  140611. * @returns the class name
  140612. */
  140613. getClassName(): string;
  140614. /**
  140615. * Gets the input component
  140616. */
  140617. get input(): NodeMaterialConnectionPoint;
  140618. /**
  140619. * Gets the output component
  140620. */
  140621. get output(): NodeMaterialConnectionPoint;
  140622. protected _buildBlock(state: NodeMaterialBuildState): this;
  140623. }
  140624. }
  140625. declare module BABYLON {
  140626. /**
  140627. * Block used to get the view direction
  140628. */
  140629. export class ViewDirectionBlock extends NodeMaterialBlock {
  140630. /**
  140631. * Creates a new ViewDirectionBlock
  140632. * @param name defines the block name
  140633. */
  140634. constructor(name: string);
  140635. /**
  140636. * Gets the current class name
  140637. * @returns the class name
  140638. */
  140639. getClassName(): string;
  140640. /**
  140641. * Gets the world position component
  140642. */
  140643. get worldPosition(): NodeMaterialConnectionPoint;
  140644. /**
  140645. * Gets the camera position component
  140646. */
  140647. get cameraPosition(): NodeMaterialConnectionPoint;
  140648. /**
  140649. * Gets the output component
  140650. */
  140651. get output(): NodeMaterialConnectionPoint;
  140652. autoConfigure(material: NodeMaterial): void;
  140653. protected _buildBlock(state: NodeMaterialBuildState): this;
  140654. }
  140655. }
  140656. declare module BABYLON {
  140657. /**
  140658. * Block used to compute fresnel value
  140659. */
  140660. export class FresnelBlock extends NodeMaterialBlock {
  140661. /**
  140662. * Create a new FresnelBlock
  140663. * @param name defines the block name
  140664. */
  140665. constructor(name: string);
  140666. /**
  140667. * Gets the current class name
  140668. * @returns the class name
  140669. */
  140670. getClassName(): string;
  140671. /**
  140672. * Gets the world normal input component
  140673. */
  140674. get worldNormal(): NodeMaterialConnectionPoint;
  140675. /**
  140676. * Gets the view direction input component
  140677. */
  140678. get viewDirection(): NodeMaterialConnectionPoint;
  140679. /**
  140680. * Gets the bias input component
  140681. */
  140682. get bias(): NodeMaterialConnectionPoint;
  140683. /**
  140684. * Gets the camera (or eye) position component
  140685. */
  140686. get power(): NodeMaterialConnectionPoint;
  140687. /**
  140688. * Gets the fresnel output component
  140689. */
  140690. get fresnel(): NodeMaterialConnectionPoint;
  140691. autoConfigure(material: NodeMaterial): void;
  140692. protected _buildBlock(state: NodeMaterialBuildState): this;
  140693. }
  140694. }
  140695. declare module BABYLON {
  140696. /**
  140697. * Block used to get the max of 2 values
  140698. */
  140699. export class MaxBlock extends NodeMaterialBlock {
  140700. /**
  140701. * Creates a new MaxBlock
  140702. * @param name defines the block name
  140703. */
  140704. constructor(name: string);
  140705. /**
  140706. * Gets the current class name
  140707. * @returns the class name
  140708. */
  140709. getClassName(): string;
  140710. /**
  140711. * Gets the left operand input component
  140712. */
  140713. get left(): NodeMaterialConnectionPoint;
  140714. /**
  140715. * Gets the right operand input component
  140716. */
  140717. get right(): NodeMaterialConnectionPoint;
  140718. /**
  140719. * Gets the output component
  140720. */
  140721. get output(): NodeMaterialConnectionPoint;
  140722. protected _buildBlock(state: NodeMaterialBuildState): this;
  140723. }
  140724. }
  140725. declare module BABYLON {
  140726. /**
  140727. * Block used to get the min of 2 values
  140728. */
  140729. export class MinBlock extends NodeMaterialBlock {
  140730. /**
  140731. * Creates a new MinBlock
  140732. * @param name defines the block name
  140733. */
  140734. constructor(name: string);
  140735. /**
  140736. * Gets the current class name
  140737. * @returns the class name
  140738. */
  140739. getClassName(): string;
  140740. /**
  140741. * Gets the left operand input component
  140742. */
  140743. get left(): NodeMaterialConnectionPoint;
  140744. /**
  140745. * Gets the right operand input component
  140746. */
  140747. get right(): NodeMaterialConnectionPoint;
  140748. /**
  140749. * Gets the output component
  140750. */
  140751. get output(): NodeMaterialConnectionPoint;
  140752. protected _buildBlock(state: NodeMaterialBuildState): this;
  140753. }
  140754. }
  140755. declare module BABYLON {
  140756. /**
  140757. * Block used to get the distance between 2 values
  140758. */
  140759. export class DistanceBlock extends NodeMaterialBlock {
  140760. /**
  140761. * Creates a new DistanceBlock
  140762. * @param name defines the block name
  140763. */
  140764. constructor(name: string);
  140765. /**
  140766. * Gets the current class name
  140767. * @returns the class name
  140768. */
  140769. getClassName(): string;
  140770. /**
  140771. * Gets the left operand input component
  140772. */
  140773. get left(): NodeMaterialConnectionPoint;
  140774. /**
  140775. * Gets the right operand input component
  140776. */
  140777. get right(): NodeMaterialConnectionPoint;
  140778. /**
  140779. * Gets the output component
  140780. */
  140781. get output(): NodeMaterialConnectionPoint;
  140782. protected _buildBlock(state: NodeMaterialBuildState): this;
  140783. }
  140784. }
  140785. declare module BABYLON {
  140786. /**
  140787. * Block used to get the length of a vector
  140788. */
  140789. export class LengthBlock extends NodeMaterialBlock {
  140790. /**
  140791. * Creates a new LengthBlock
  140792. * @param name defines the block name
  140793. */
  140794. constructor(name: string);
  140795. /**
  140796. * Gets the current class name
  140797. * @returns the class name
  140798. */
  140799. getClassName(): string;
  140800. /**
  140801. * Gets the value input component
  140802. */
  140803. get value(): NodeMaterialConnectionPoint;
  140804. /**
  140805. * Gets the output component
  140806. */
  140807. get output(): NodeMaterialConnectionPoint;
  140808. protected _buildBlock(state: NodeMaterialBuildState): this;
  140809. }
  140810. }
  140811. declare module BABYLON {
  140812. /**
  140813. * Block used to get negative version of a value (i.e. x * -1)
  140814. */
  140815. export class NegateBlock extends NodeMaterialBlock {
  140816. /**
  140817. * Creates a new NegateBlock
  140818. * @param name defines the block name
  140819. */
  140820. constructor(name: string);
  140821. /**
  140822. * Gets the current class name
  140823. * @returns the class name
  140824. */
  140825. getClassName(): string;
  140826. /**
  140827. * Gets the value input component
  140828. */
  140829. get value(): NodeMaterialConnectionPoint;
  140830. /**
  140831. * Gets the output component
  140832. */
  140833. get output(): NodeMaterialConnectionPoint;
  140834. protected _buildBlock(state: NodeMaterialBuildState): this;
  140835. }
  140836. }
  140837. declare module BABYLON {
  140838. /**
  140839. * Block used to get the value of the first parameter raised to the power of the second
  140840. */
  140841. export class PowBlock extends NodeMaterialBlock {
  140842. /**
  140843. * Creates a new PowBlock
  140844. * @param name defines the block name
  140845. */
  140846. constructor(name: string);
  140847. /**
  140848. * Gets the current class name
  140849. * @returns the class name
  140850. */
  140851. getClassName(): string;
  140852. /**
  140853. * Gets the value operand input component
  140854. */
  140855. get value(): NodeMaterialConnectionPoint;
  140856. /**
  140857. * Gets the power operand input component
  140858. */
  140859. get power(): NodeMaterialConnectionPoint;
  140860. /**
  140861. * Gets the output component
  140862. */
  140863. get output(): NodeMaterialConnectionPoint;
  140864. protected _buildBlock(state: NodeMaterialBuildState): this;
  140865. }
  140866. }
  140867. declare module BABYLON {
  140868. /**
  140869. * Block used to get a random number
  140870. */
  140871. export class RandomNumberBlock extends NodeMaterialBlock {
  140872. /**
  140873. * Creates a new RandomNumberBlock
  140874. * @param name defines the block name
  140875. */
  140876. constructor(name: string);
  140877. /**
  140878. * Gets the current class name
  140879. * @returns the class name
  140880. */
  140881. getClassName(): string;
  140882. /**
  140883. * Gets the seed input component
  140884. */
  140885. get seed(): NodeMaterialConnectionPoint;
  140886. /**
  140887. * Gets the output component
  140888. */
  140889. get output(): NodeMaterialConnectionPoint;
  140890. protected _buildBlock(state: NodeMaterialBuildState): this;
  140891. }
  140892. }
  140893. declare module BABYLON {
  140894. /**
  140895. * Block used to compute arc tangent of 2 values
  140896. */
  140897. export class ArcTan2Block extends NodeMaterialBlock {
  140898. /**
  140899. * Creates a new ArcTan2Block
  140900. * @param name defines the block name
  140901. */
  140902. constructor(name: string);
  140903. /**
  140904. * Gets the current class name
  140905. * @returns the class name
  140906. */
  140907. getClassName(): string;
  140908. /**
  140909. * Gets the x operand input component
  140910. */
  140911. get x(): NodeMaterialConnectionPoint;
  140912. /**
  140913. * Gets the y operand input component
  140914. */
  140915. get y(): NodeMaterialConnectionPoint;
  140916. /**
  140917. * Gets the output component
  140918. */
  140919. get output(): NodeMaterialConnectionPoint;
  140920. protected _buildBlock(state: NodeMaterialBuildState): this;
  140921. }
  140922. }
  140923. declare module BABYLON {
  140924. /**
  140925. * Block used to smooth step a value
  140926. */
  140927. export class SmoothStepBlock extends NodeMaterialBlock {
  140928. /**
  140929. * Creates a new SmoothStepBlock
  140930. * @param name defines the block name
  140931. */
  140932. constructor(name: string);
  140933. /**
  140934. * Gets the current class name
  140935. * @returns the class name
  140936. */
  140937. getClassName(): string;
  140938. /**
  140939. * Gets the value operand input component
  140940. */
  140941. get value(): NodeMaterialConnectionPoint;
  140942. /**
  140943. * Gets the first edge operand input component
  140944. */
  140945. get edge0(): NodeMaterialConnectionPoint;
  140946. /**
  140947. * Gets the second edge operand input component
  140948. */
  140949. get edge1(): NodeMaterialConnectionPoint;
  140950. /**
  140951. * Gets the output component
  140952. */
  140953. get output(): NodeMaterialConnectionPoint;
  140954. protected _buildBlock(state: NodeMaterialBuildState): this;
  140955. }
  140956. }
  140957. declare module BABYLON {
  140958. /**
  140959. * Block used to get the reciprocal (1 / x) of a value
  140960. */
  140961. export class ReciprocalBlock extends NodeMaterialBlock {
  140962. /**
  140963. * Creates a new ReciprocalBlock
  140964. * @param name defines the block name
  140965. */
  140966. constructor(name: string);
  140967. /**
  140968. * Gets the current class name
  140969. * @returns the class name
  140970. */
  140971. getClassName(): string;
  140972. /**
  140973. * Gets the input component
  140974. */
  140975. get input(): NodeMaterialConnectionPoint;
  140976. /**
  140977. * Gets the output component
  140978. */
  140979. get output(): NodeMaterialConnectionPoint;
  140980. protected _buildBlock(state: NodeMaterialBuildState): this;
  140981. }
  140982. }
  140983. declare module BABYLON {
  140984. /**
  140985. * Block used to replace a color by another one
  140986. */
  140987. export class ReplaceColorBlock extends NodeMaterialBlock {
  140988. /**
  140989. * Creates a new ReplaceColorBlock
  140990. * @param name defines the block name
  140991. */
  140992. constructor(name: string);
  140993. /**
  140994. * Gets the current class name
  140995. * @returns the class name
  140996. */
  140997. getClassName(): string;
  140998. /**
  140999. * Gets the value input component
  141000. */
  141001. get value(): NodeMaterialConnectionPoint;
  141002. /**
  141003. * Gets the reference input component
  141004. */
  141005. get reference(): NodeMaterialConnectionPoint;
  141006. /**
  141007. * Gets the distance input component
  141008. */
  141009. get distance(): NodeMaterialConnectionPoint;
  141010. /**
  141011. * Gets the replacement input component
  141012. */
  141013. get replacement(): NodeMaterialConnectionPoint;
  141014. /**
  141015. * Gets the output component
  141016. */
  141017. get output(): NodeMaterialConnectionPoint;
  141018. protected _buildBlock(state: NodeMaterialBuildState): this;
  141019. }
  141020. }
  141021. declare module BABYLON {
  141022. /**
  141023. * Block used to posterize a value
  141024. * @see https://en.wikipedia.org/wiki/Posterization
  141025. */
  141026. export class PosterizeBlock extends NodeMaterialBlock {
  141027. /**
  141028. * Creates a new PosterizeBlock
  141029. * @param name defines the block name
  141030. */
  141031. constructor(name: string);
  141032. /**
  141033. * Gets the current class name
  141034. * @returns the class name
  141035. */
  141036. getClassName(): string;
  141037. /**
  141038. * Gets the value input component
  141039. */
  141040. get value(): NodeMaterialConnectionPoint;
  141041. /**
  141042. * Gets the steps input component
  141043. */
  141044. get steps(): NodeMaterialConnectionPoint;
  141045. /**
  141046. * Gets the output component
  141047. */
  141048. get output(): NodeMaterialConnectionPoint;
  141049. protected _buildBlock(state: NodeMaterialBuildState): this;
  141050. }
  141051. }
  141052. declare module BABYLON {
  141053. /**
  141054. * Operations supported by the Wave block
  141055. */
  141056. export enum WaveBlockKind {
  141057. /** SawTooth */
  141058. SawTooth = 0,
  141059. /** Square */
  141060. Square = 1,
  141061. /** Triangle */
  141062. Triangle = 2
  141063. }
  141064. /**
  141065. * Block used to apply wave operation to floats
  141066. */
  141067. export class WaveBlock extends NodeMaterialBlock {
  141068. /**
  141069. * Gets or sets the kibnd of wave to be applied by the block
  141070. */
  141071. kind: WaveBlockKind;
  141072. /**
  141073. * Creates a new WaveBlock
  141074. * @param name defines the block name
  141075. */
  141076. constructor(name: string);
  141077. /**
  141078. * Gets the current class name
  141079. * @returns the class name
  141080. */
  141081. getClassName(): string;
  141082. /**
  141083. * Gets the input component
  141084. */
  141085. get input(): NodeMaterialConnectionPoint;
  141086. /**
  141087. * Gets the output component
  141088. */
  141089. get output(): NodeMaterialConnectionPoint;
  141090. protected _buildBlock(state: NodeMaterialBuildState): this;
  141091. serialize(): any;
  141092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141093. }
  141094. }
  141095. declare module BABYLON {
  141096. /**
  141097. * Class used to store a color step for the GradientBlock
  141098. */
  141099. export class GradientBlockColorStep {
  141100. /**
  141101. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141102. */
  141103. step: number;
  141104. /**
  141105. * Gets or sets the color associated with this step
  141106. */
  141107. color: Color3;
  141108. /**
  141109. * Creates a new GradientBlockColorStep
  141110. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141111. * @param color defines the color associated with this step
  141112. */
  141113. constructor(
  141114. /**
  141115. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141116. */
  141117. step: number,
  141118. /**
  141119. * Gets or sets the color associated with this step
  141120. */
  141121. color: Color3);
  141122. }
  141123. /**
  141124. * Block used to return a color from a gradient based on an input value between 0 and 1
  141125. */
  141126. export class GradientBlock extends NodeMaterialBlock {
  141127. /**
  141128. * Gets or sets the list of color steps
  141129. */
  141130. colorSteps: GradientBlockColorStep[];
  141131. /**
  141132. * Creates a new GradientBlock
  141133. * @param name defines the block name
  141134. */
  141135. constructor(name: string);
  141136. /**
  141137. * Gets the current class name
  141138. * @returns the class name
  141139. */
  141140. getClassName(): string;
  141141. /**
  141142. * Gets the gradient input component
  141143. */
  141144. get gradient(): NodeMaterialConnectionPoint;
  141145. /**
  141146. * Gets the output component
  141147. */
  141148. get output(): NodeMaterialConnectionPoint;
  141149. private _writeColorConstant;
  141150. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141151. serialize(): any;
  141152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141153. protected _dumpPropertiesCode(): string;
  141154. }
  141155. }
  141156. declare module BABYLON {
  141157. /**
  141158. * Block used to normalize lerp between 2 values
  141159. */
  141160. export class NLerpBlock extends NodeMaterialBlock {
  141161. /**
  141162. * Creates a new NLerpBlock
  141163. * @param name defines the block name
  141164. */
  141165. constructor(name: string);
  141166. /**
  141167. * Gets the current class name
  141168. * @returns the class name
  141169. */
  141170. getClassName(): string;
  141171. /**
  141172. * Gets the left operand input component
  141173. */
  141174. get left(): NodeMaterialConnectionPoint;
  141175. /**
  141176. * Gets the right operand input component
  141177. */
  141178. get right(): NodeMaterialConnectionPoint;
  141179. /**
  141180. * Gets the gradient operand input component
  141181. */
  141182. get gradient(): NodeMaterialConnectionPoint;
  141183. /**
  141184. * Gets the output component
  141185. */
  141186. get output(): NodeMaterialConnectionPoint;
  141187. protected _buildBlock(state: NodeMaterialBuildState): this;
  141188. }
  141189. }
  141190. declare module BABYLON {
  141191. /**
  141192. * block used to Generate a Worley Noise 3D Noise Pattern
  141193. */
  141194. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141195. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141196. manhattanDistance: boolean;
  141197. /**
  141198. * Creates a new WorleyNoise3DBlock
  141199. * @param name defines the block name
  141200. */
  141201. constructor(name: string);
  141202. /**
  141203. * Gets the current class name
  141204. * @returns the class name
  141205. */
  141206. getClassName(): string;
  141207. /**
  141208. * Gets the seed input component
  141209. */
  141210. get seed(): NodeMaterialConnectionPoint;
  141211. /**
  141212. * Gets the jitter input component
  141213. */
  141214. get jitter(): NodeMaterialConnectionPoint;
  141215. /**
  141216. * Gets the output component
  141217. */
  141218. get output(): NodeMaterialConnectionPoint;
  141219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141220. /**
  141221. * Exposes the properties to the UI?
  141222. */
  141223. protected _dumpPropertiesCode(): string;
  141224. /**
  141225. * Exposes the properties to the Seralize?
  141226. */
  141227. serialize(): any;
  141228. /**
  141229. * Exposes the properties to the deseralize?
  141230. */
  141231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141232. }
  141233. }
  141234. declare module BABYLON {
  141235. /**
  141236. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141237. */
  141238. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141239. /**
  141240. * Creates a new SimplexPerlin3DBlock
  141241. * @param name defines the block name
  141242. */
  141243. constructor(name: string);
  141244. /**
  141245. * Gets the current class name
  141246. * @returns the class name
  141247. */
  141248. getClassName(): string;
  141249. /**
  141250. * Gets the seed operand input component
  141251. */
  141252. get seed(): NodeMaterialConnectionPoint;
  141253. /**
  141254. * Gets the output component
  141255. */
  141256. get output(): NodeMaterialConnectionPoint;
  141257. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141258. }
  141259. }
  141260. declare module BABYLON {
  141261. /**
  141262. * Block used to blend normals
  141263. */
  141264. export class NormalBlendBlock extends NodeMaterialBlock {
  141265. /**
  141266. * Creates a new NormalBlendBlock
  141267. * @param name defines the block name
  141268. */
  141269. constructor(name: string);
  141270. /**
  141271. * Gets the current class name
  141272. * @returns the class name
  141273. */
  141274. getClassName(): string;
  141275. /**
  141276. * Gets the first input component
  141277. */
  141278. get normalMap0(): NodeMaterialConnectionPoint;
  141279. /**
  141280. * Gets the second input component
  141281. */
  141282. get normalMap1(): NodeMaterialConnectionPoint;
  141283. /**
  141284. * Gets the output component
  141285. */
  141286. get output(): NodeMaterialConnectionPoint;
  141287. protected _buildBlock(state: NodeMaterialBuildState): this;
  141288. }
  141289. }
  141290. declare module BABYLON {
  141291. /**
  141292. * Block used to rotate a 2d vector by a given angle
  141293. */
  141294. export class Rotate2dBlock extends NodeMaterialBlock {
  141295. /**
  141296. * Creates a new Rotate2dBlock
  141297. * @param name defines the block name
  141298. */
  141299. constructor(name: string);
  141300. /**
  141301. * Gets the current class name
  141302. * @returns the class name
  141303. */
  141304. getClassName(): string;
  141305. /**
  141306. * Gets the input vector
  141307. */
  141308. get input(): NodeMaterialConnectionPoint;
  141309. /**
  141310. * Gets the input angle
  141311. */
  141312. get angle(): NodeMaterialConnectionPoint;
  141313. /**
  141314. * Gets the output component
  141315. */
  141316. get output(): NodeMaterialConnectionPoint;
  141317. autoConfigure(material: NodeMaterial): void;
  141318. protected _buildBlock(state: NodeMaterialBuildState): this;
  141319. }
  141320. }
  141321. declare module BABYLON {
  141322. /**
  141323. * Block used to get the reflected vector from a direction and a normal
  141324. */
  141325. export class ReflectBlock extends NodeMaterialBlock {
  141326. /**
  141327. * Creates a new ReflectBlock
  141328. * @param name defines the block name
  141329. */
  141330. constructor(name: string);
  141331. /**
  141332. * Gets the current class name
  141333. * @returns the class name
  141334. */
  141335. getClassName(): string;
  141336. /**
  141337. * Gets the incident component
  141338. */
  141339. get incident(): NodeMaterialConnectionPoint;
  141340. /**
  141341. * Gets the normal component
  141342. */
  141343. get normal(): NodeMaterialConnectionPoint;
  141344. /**
  141345. * Gets the output component
  141346. */
  141347. get output(): NodeMaterialConnectionPoint;
  141348. protected _buildBlock(state: NodeMaterialBuildState): this;
  141349. }
  141350. }
  141351. declare module BABYLON {
  141352. /**
  141353. * Block used to get the refracted vector from a direction and a normal
  141354. */
  141355. export class RefractBlock extends NodeMaterialBlock {
  141356. /**
  141357. * Creates a new RefractBlock
  141358. * @param name defines the block name
  141359. */
  141360. constructor(name: string);
  141361. /**
  141362. * Gets the current class name
  141363. * @returns the class name
  141364. */
  141365. getClassName(): string;
  141366. /**
  141367. * Gets the incident component
  141368. */
  141369. get incident(): NodeMaterialConnectionPoint;
  141370. /**
  141371. * Gets the normal component
  141372. */
  141373. get normal(): NodeMaterialConnectionPoint;
  141374. /**
  141375. * Gets the index of refraction component
  141376. */
  141377. get ior(): NodeMaterialConnectionPoint;
  141378. /**
  141379. * Gets the output component
  141380. */
  141381. get output(): NodeMaterialConnectionPoint;
  141382. protected _buildBlock(state: NodeMaterialBuildState): this;
  141383. }
  141384. }
  141385. declare module BABYLON {
  141386. /**
  141387. * Block used to desaturate a color
  141388. */
  141389. export class DesaturateBlock extends NodeMaterialBlock {
  141390. /**
  141391. * Creates a new DesaturateBlock
  141392. * @param name defines the block name
  141393. */
  141394. constructor(name: string);
  141395. /**
  141396. * Gets the current class name
  141397. * @returns the class name
  141398. */
  141399. getClassName(): string;
  141400. /**
  141401. * Gets the color operand input component
  141402. */
  141403. get color(): NodeMaterialConnectionPoint;
  141404. /**
  141405. * Gets the level operand input component
  141406. */
  141407. get level(): NodeMaterialConnectionPoint;
  141408. /**
  141409. * Gets the output component
  141410. */
  141411. get output(): NodeMaterialConnectionPoint;
  141412. protected _buildBlock(state: NodeMaterialBuildState): this;
  141413. }
  141414. }
  141415. declare module BABYLON {
  141416. /**
  141417. * Block used to implement the ambient occlusion module of the PBR material
  141418. */
  141419. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141420. /**
  141421. * Create a new AmbientOcclusionBlock
  141422. * @param name defines the block name
  141423. */
  141424. constructor(name: string);
  141425. /**
  141426. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141427. */
  141428. useAmbientInGrayScale: boolean;
  141429. /**
  141430. * Initialize the block and prepare the context for build
  141431. * @param state defines the state that will be used for the build
  141432. */
  141433. initialize(state: NodeMaterialBuildState): void;
  141434. /**
  141435. * Gets the current class name
  141436. * @returns the class name
  141437. */
  141438. getClassName(): string;
  141439. /**
  141440. * Gets the texture input component
  141441. */
  141442. get texture(): NodeMaterialConnectionPoint;
  141443. /**
  141444. * Gets the texture intensity component
  141445. */
  141446. get intensity(): NodeMaterialConnectionPoint;
  141447. /**
  141448. * Gets the direct light intensity input component
  141449. */
  141450. get directLightIntensity(): NodeMaterialConnectionPoint;
  141451. /**
  141452. * Gets the ambient occlusion object output component
  141453. */
  141454. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141455. /**
  141456. * Gets the main code of the block (fragment side)
  141457. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141458. * @returns the shader code
  141459. */
  141460. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141462. protected _buildBlock(state: NodeMaterialBuildState): this;
  141463. protected _dumpPropertiesCode(): string;
  141464. serialize(): any;
  141465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141466. }
  141467. }
  141468. declare module BABYLON {
  141469. /**
  141470. * Block used to implement the reflection module of the PBR material
  141471. */
  141472. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141473. /** @hidden */
  141474. _defineLODReflectionAlpha: string;
  141475. /** @hidden */
  141476. _defineLinearSpecularReflection: string;
  141477. private _vEnvironmentIrradianceName;
  141478. /** @hidden */
  141479. _vReflectionMicrosurfaceInfosName: string;
  141480. /** @hidden */
  141481. _vReflectionInfosName: string;
  141482. /** @hidden */
  141483. _vReflectionFilteringInfoName: string;
  141484. private _scene;
  141485. /**
  141486. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141487. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141488. * It's less burden on the user side in the editor part.
  141489. */
  141490. /** @hidden */
  141491. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141492. /** @hidden */
  141493. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141494. /** @hidden */
  141495. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141496. /**
  141497. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141498. * diffuse part of the IBL.
  141499. */
  141500. useSphericalHarmonics: boolean;
  141501. /**
  141502. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141503. */
  141504. forceIrradianceInFragment: boolean;
  141505. /**
  141506. * Create a new ReflectionBlock
  141507. * @param name defines the block name
  141508. */
  141509. constructor(name: string);
  141510. /**
  141511. * Gets the current class name
  141512. * @returns the class name
  141513. */
  141514. getClassName(): string;
  141515. /**
  141516. * Gets the position input component
  141517. */
  141518. get position(): NodeMaterialConnectionPoint;
  141519. /**
  141520. * Gets the world position input component
  141521. */
  141522. get worldPosition(): NodeMaterialConnectionPoint;
  141523. /**
  141524. * Gets the world normal input component
  141525. */
  141526. get worldNormal(): NodeMaterialConnectionPoint;
  141527. /**
  141528. * Gets the world input component
  141529. */
  141530. get world(): NodeMaterialConnectionPoint;
  141531. /**
  141532. * Gets the camera (or eye) position component
  141533. */
  141534. get cameraPosition(): NodeMaterialConnectionPoint;
  141535. /**
  141536. * Gets the view input component
  141537. */
  141538. get view(): NodeMaterialConnectionPoint;
  141539. /**
  141540. * Gets the color input component
  141541. */
  141542. get color(): NodeMaterialConnectionPoint;
  141543. /**
  141544. * Gets the reflection object output component
  141545. */
  141546. get reflection(): NodeMaterialConnectionPoint;
  141547. /**
  141548. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141549. */
  141550. get hasTexture(): boolean;
  141551. /**
  141552. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141553. */
  141554. get reflectionColor(): string;
  141555. protected _getTexture(): Nullable<BaseTexture>;
  141556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141558. /**
  141559. * Gets the code to inject in the vertex shader
  141560. * @param state current state of the node material building
  141561. * @returns the shader code
  141562. */
  141563. handleVertexSide(state: NodeMaterialBuildState): string;
  141564. /**
  141565. * Gets the main code of the block (fragment side)
  141566. * @param state current state of the node material building
  141567. * @param normalVarName name of the existing variable corresponding to the normal
  141568. * @returns the shader code
  141569. */
  141570. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141571. protected _buildBlock(state: NodeMaterialBuildState): this;
  141572. protected _dumpPropertiesCode(): string;
  141573. serialize(): any;
  141574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141575. }
  141576. }
  141577. declare module BABYLON {
  141578. /**
  141579. * Block used to implement the sheen module of the PBR material
  141580. */
  141581. export class SheenBlock extends NodeMaterialBlock {
  141582. /**
  141583. * Create a new SheenBlock
  141584. * @param name defines the block name
  141585. */
  141586. constructor(name: string);
  141587. /**
  141588. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141589. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141590. * making it easier to setup and tweak the effect
  141591. */
  141592. albedoScaling: boolean;
  141593. /**
  141594. * Defines if the sheen is linked to the sheen color.
  141595. */
  141596. linkSheenWithAlbedo: boolean;
  141597. /**
  141598. * Initialize the block and prepare the context for build
  141599. * @param state defines the state that will be used for the build
  141600. */
  141601. initialize(state: NodeMaterialBuildState): void;
  141602. /**
  141603. * Gets the current class name
  141604. * @returns the class name
  141605. */
  141606. getClassName(): string;
  141607. /**
  141608. * Gets the intensity input component
  141609. */
  141610. get intensity(): NodeMaterialConnectionPoint;
  141611. /**
  141612. * Gets the color input component
  141613. */
  141614. get color(): NodeMaterialConnectionPoint;
  141615. /**
  141616. * Gets the roughness input component
  141617. */
  141618. get roughness(): NodeMaterialConnectionPoint;
  141619. /**
  141620. * Gets the sheen object output component
  141621. */
  141622. get sheen(): NodeMaterialConnectionPoint;
  141623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141624. /**
  141625. * Gets the main code of the block (fragment side)
  141626. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141627. * @returns the shader code
  141628. */
  141629. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141630. protected _buildBlock(state: NodeMaterialBuildState): this;
  141631. protected _dumpPropertiesCode(): string;
  141632. serialize(): any;
  141633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141634. }
  141635. }
  141636. declare module BABYLON {
  141637. /**
  141638. * Block used to implement the reflectivity module of the PBR material
  141639. */
  141640. export class ReflectivityBlock extends NodeMaterialBlock {
  141641. private _metallicReflectanceColor;
  141642. private _metallicF0Factor;
  141643. /** @hidden */
  141644. _vMetallicReflectanceFactorsName: string;
  141645. /**
  141646. * The property below is set by the main PBR block prior to calling methods of this class.
  141647. */
  141648. /** @hidden */
  141649. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141650. /**
  141651. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141652. */
  141653. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141654. /**
  141655. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141656. */
  141657. useMetallnessFromMetallicTextureBlue: boolean;
  141658. /**
  141659. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141660. */
  141661. useRoughnessFromMetallicTextureAlpha: boolean;
  141662. /**
  141663. * Specifies if the metallic texture contains the roughness information in its green channel.
  141664. */
  141665. useRoughnessFromMetallicTextureGreen: boolean;
  141666. /**
  141667. * Create a new ReflectivityBlock
  141668. * @param name defines the block name
  141669. */
  141670. constructor(name: string);
  141671. /**
  141672. * Initialize the block and prepare the context for build
  141673. * @param state defines the state that will be used for the build
  141674. */
  141675. initialize(state: NodeMaterialBuildState): void;
  141676. /**
  141677. * Gets the current class name
  141678. * @returns the class name
  141679. */
  141680. getClassName(): string;
  141681. /**
  141682. * Gets the metallic input component
  141683. */
  141684. get metallic(): NodeMaterialConnectionPoint;
  141685. /**
  141686. * Gets the roughness input component
  141687. */
  141688. get roughness(): NodeMaterialConnectionPoint;
  141689. /**
  141690. * Gets the texture input component
  141691. */
  141692. get texture(): NodeMaterialConnectionPoint;
  141693. /**
  141694. * Gets the reflectivity object output component
  141695. */
  141696. get reflectivity(): NodeMaterialConnectionPoint;
  141697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141698. /**
  141699. * Gets the main code of the block (fragment side)
  141700. * @param state current state of the node material building
  141701. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141702. * @returns the shader code
  141703. */
  141704. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141706. protected _buildBlock(state: NodeMaterialBuildState): this;
  141707. protected _dumpPropertiesCode(): string;
  141708. serialize(): any;
  141709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141710. }
  141711. }
  141712. declare module BABYLON {
  141713. /**
  141714. * Block used to implement the anisotropy module of the PBR material
  141715. */
  141716. export class AnisotropyBlock extends NodeMaterialBlock {
  141717. /**
  141718. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141719. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141720. * It's less burden on the user side in the editor part.
  141721. */
  141722. /** @hidden */
  141723. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141724. /** @hidden */
  141725. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141726. /**
  141727. * Create a new AnisotropyBlock
  141728. * @param name defines the block name
  141729. */
  141730. constructor(name: string);
  141731. /**
  141732. * Initialize the block and prepare the context for build
  141733. * @param state defines the state that will be used for the build
  141734. */
  141735. initialize(state: NodeMaterialBuildState): void;
  141736. /**
  141737. * Gets the current class name
  141738. * @returns the class name
  141739. */
  141740. getClassName(): string;
  141741. /**
  141742. * Gets the intensity input component
  141743. */
  141744. get intensity(): NodeMaterialConnectionPoint;
  141745. /**
  141746. * Gets the direction input component
  141747. */
  141748. get direction(): NodeMaterialConnectionPoint;
  141749. /**
  141750. * Gets the texture input component
  141751. */
  141752. get texture(): NodeMaterialConnectionPoint;
  141753. /**
  141754. * Gets the uv input component
  141755. */
  141756. get uv(): NodeMaterialConnectionPoint;
  141757. /**
  141758. * Gets the worldTangent input component
  141759. */
  141760. get worldTangent(): NodeMaterialConnectionPoint;
  141761. /**
  141762. * Gets the anisotropy object output component
  141763. */
  141764. get anisotropy(): NodeMaterialConnectionPoint;
  141765. private _generateTBNSpace;
  141766. /**
  141767. * Gets the main code of the block (fragment side)
  141768. * @param state current state of the node material building
  141769. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141770. * @returns the shader code
  141771. */
  141772. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141774. protected _buildBlock(state: NodeMaterialBuildState): this;
  141775. }
  141776. }
  141777. declare module BABYLON {
  141778. /**
  141779. * Block used to implement the clear coat module of the PBR material
  141780. */
  141781. export class ClearCoatBlock extends NodeMaterialBlock {
  141782. private _scene;
  141783. /**
  141784. * Create a new ClearCoatBlock
  141785. * @param name defines the block name
  141786. */
  141787. constructor(name: string);
  141788. /**
  141789. * Initialize the block and prepare the context for build
  141790. * @param state defines the state that will be used for the build
  141791. */
  141792. initialize(state: NodeMaterialBuildState): void;
  141793. /**
  141794. * Gets the current class name
  141795. * @returns the class name
  141796. */
  141797. getClassName(): string;
  141798. /**
  141799. * Gets the intensity input component
  141800. */
  141801. get intensity(): NodeMaterialConnectionPoint;
  141802. /**
  141803. * Gets the roughness input component
  141804. */
  141805. get roughness(): NodeMaterialConnectionPoint;
  141806. /**
  141807. * Gets the ior input component
  141808. */
  141809. get ior(): NodeMaterialConnectionPoint;
  141810. /**
  141811. * Gets the texture input component
  141812. */
  141813. get texture(): NodeMaterialConnectionPoint;
  141814. /**
  141815. * Gets the bump texture input component
  141816. */
  141817. get bumpTexture(): NodeMaterialConnectionPoint;
  141818. /**
  141819. * Gets the uv input component
  141820. */
  141821. get uv(): NodeMaterialConnectionPoint;
  141822. /**
  141823. * Gets the tint color input component
  141824. */
  141825. get tintColor(): NodeMaterialConnectionPoint;
  141826. /**
  141827. * Gets the tint "at distance" input component
  141828. */
  141829. get tintAtDistance(): NodeMaterialConnectionPoint;
  141830. /**
  141831. * Gets the tint thickness input component
  141832. */
  141833. get tintThickness(): NodeMaterialConnectionPoint;
  141834. /**
  141835. * Gets the world tangent input component
  141836. */
  141837. get worldTangent(): NodeMaterialConnectionPoint;
  141838. /**
  141839. * Gets the clear coat object output component
  141840. */
  141841. get clearcoat(): NodeMaterialConnectionPoint;
  141842. autoConfigure(material: NodeMaterial): void;
  141843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141845. private _generateTBNSpace;
  141846. /**
  141847. * Gets the main code of the block (fragment side)
  141848. * @param state current state of the node material building
  141849. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141850. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141851. * @param worldPosVarName name of the variable holding the world position
  141852. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141853. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141854. * @param worldNormalVarName name of the variable holding the world normal
  141855. * @returns the shader code
  141856. */
  141857. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141858. protected _buildBlock(state: NodeMaterialBuildState): this;
  141859. }
  141860. }
  141861. declare module BABYLON {
  141862. /**
  141863. * Block used to implement the sub surface module of the PBR material
  141864. */
  141865. export class SubSurfaceBlock extends NodeMaterialBlock {
  141866. /**
  141867. * Create a new SubSurfaceBlock
  141868. * @param name defines the block name
  141869. */
  141870. constructor(name: string);
  141871. /**
  141872. * Stores the intensity of the different subsurface effects in the thickness texture.
  141873. * * the green channel is the translucency intensity.
  141874. * * the blue channel is the scattering intensity.
  141875. * * the alpha channel is the refraction intensity.
  141876. */
  141877. useMaskFromThicknessTexture: boolean;
  141878. /**
  141879. * Initialize the block and prepare the context for build
  141880. * @param state defines the state that will be used for the build
  141881. */
  141882. initialize(state: NodeMaterialBuildState): void;
  141883. /**
  141884. * Gets the current class name
  141885. * @returns the class name
  141886. */
  141887. getClassName(): string;
  141888. /**
  141889. * Gets the min thickness input component
  141890. */
  141891. get minThickness(): NodeMaterialConnectionPoint;
  141892. /**
  141893. * Gets the max thickness input component
  141894. */
  141895. get maxThickness(): NodeMaterialConnectionPoint;
  141896. /**
  141897. * Gets the thickness texture component
  141898. */
  141899. get thicknessTexture(): NodeMaterialConnectionPoint;
  141900. /**
  141901. * Gets the tint color input component
  141902. */
  141903. get tintColor(): NodeMaterialConnectionPoint;
  141904. /**
  141905. * Gets the translucency intensity input component
  141906. */
  141907. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141908. /**
  141909. * Gets the translucency diffusion distance input component
  141910. */
  141911. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141912. /**
  141913. * Gets the refraction object parameters
  141914. */
  141915. get refraction(): NodeMaterialConnectionPoint;
  141916. /**
  141917. * Gets the sub surface object output component
  141918. */
  141919. get subsurface(): NodeMaterialConnectionPoint;
  141920. autoConfigure(material: NodeMaterial): void;
  141921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141922. /**
  141923. * Gets the main code of the block (fragment side)
  141924. * @param state current state of the node material building
  141925. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141926. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141927. * @param worldPosVarName name of the variable holding the world position
  141928. * @returns the shader code
  141929. */
  141930. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141931. protected _buildBlock(state: NodeMaterialBuildState): this;
  141932. }
  141933. }
  141934. declare module BABYLON {
  141935. /**
  141936. * Block used to implement the PBR metallic/roughness model
  141937. */
  141938. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141939. /**
  141940. * Gets or sets the light associated with this block
  141941. */
  141942. light: Nullable<Light>;
  141943. private _lightId;
  141944. private _scene;
  141945. private _environmentBRDFTexture;
  141946. private _environmentBrdfSamplerName;
  141947. private _vNormalWName;
  141948. private _invertNormalName;
  141949. /**
  141950. * Create a new ReflectionBlock
  141951. * @param name defines the block name
  141952. */
  141953. constructor(name: string);
  141954. /**
  141955. * Intensity of the direct lights e.g. the four lights available in your scene.
  141956. * This impacts both the direct diffuse and specular highlights.
  141957. */
  141958. directIntensity: number;
  141959. /**
  141960. * Intensity of the environment e.g. how much the environment will light the object
  141961. * either through harmonics for rough material or through the refelction for shiny ones.
  141962. */
  141963. environmentIntensity: number;
  141964. /**
  141965. * This is a special control allowing the reduction of the specular highlights coming from the
  141966. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141967. */
  141968. specularIntensity: number;
  141969. /**
  141970. * Defines the falloff type used in this material.
  141971. * It by default is Physical.
  141972. */
  141973. lightFalloff: number;
  141974. /**
  141975. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141976. */
  141977. useAlphaFromAlbedoTexture: boolean;
  141978. /**
  141979. * Specifies that alpha test should be used
  141980. */
  141981. useAlphaTest: boolean;
  141982. /**
  141983. * Defines the alpha limits in alpha test mode.
  141984. */
  141985. alphaTestCutoff: number;
  141986. /**
  141987. * Specifies that alpha blending should be used
  141988. */
  141989. useAlphaBlending: boolean;
  141990. /**
  141991. * Defines if the alpha value should be determined via the rgb values.
  141992. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141993. */
  141994. opacityRGB: boolean;
  141995. /**
  141996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141998. */
  141999. useRadianceOverAlpha: boolean;
  142000. /**
  142001. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142003. */
  142004. useSpecularOverAlpha: boolean;
  142005. /**
  142006. * Enables specular anti aliasing in the PBR shader.
  142007. * It will both interacts on the Geometry for analytical and IBL lighting.
  142008. * It also prefilter the roughness map based on the bump values.
  142009. */
  142010. enableSpecularAntiAliasing: boolean;
  142011. /**
  142012. * Enables realtime filtering on the texture.
  142013. */
  142014. realTimeFiltering: boolean;
  142015. /**
  142016. * Quality switch for realtime filtering
  142017. */
  142018. realTimeFilteringQuality: number;
  142019. /**
  142020. * Defines if the material uses energy conservation.
  142021. */
  142022. useEnergyConservation: boolean;
  142023. /**
  142024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142025. * too much the area relying on ambient texture to define their ambient occlusion.
  142026. */
  142027. useRadianceOcclusion: boolean;
  142028. /**
  142029. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142030. * makes the reflect vector face the model (under horizon).
  142031. */
  142032. useHorizonOcclusion: boolean;
  142033. /**
  142034. * If set to true, no lighting calculations will be applied.
  142035. */
  142036. unlit: boolean;
  142037. /**
  142038. * Force normal to face away from face.
  142039. */
  142040. forceNormalForward: boolean;
  142041. /**
  142042. * Defines the material debug mode.
  142043. * It helps seeing only some components of the material while troubleshooting.
  142044. */
  142045. debugMode: number;
  142046. /**
  142047. * Specify from where on screen the debug mode should start.
  142048. * The value goes from -1 (full screen) to 1 (not visible)
  142049. * It helps with side by side comparison against the final render
  142050. * This defaults to 0
  142051. */
  142052. debugLimit: number;
  142053. /**
  142054. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142055. * You can use the factor to better multiply the final value.
  142056. */
  142057. debugFactor: number;
  142058. /**
  142059. * Initialize the block and prepare the context for build
  142060. * @param state defines the state that will be used for the build
  142061. */
  142062. initialize(state: NodeMaterialBuildState): void;
  142063. /**
  142064. * Gets the current class name
  142065. * @returns the class name
  142066. */
  142067. getClassName(): string;
  142068. /**
  142069. * Gets the world position input component
  142070. */
  142071. get worldPosition(): NodeMaterialConnectionPoint;
  142072. /**
  142073. * Gets the world normal input component
  142074. */
  142075. get worldNormal(): NodeMaterialConnectionPoint;
  142076. /**
  142077. * Gets the perturbed normal input component
  142078. */
  142079. get perturbedNormal(): NodeMaterialConnectionPoint;
  142080. /**
  142081. * Gets the camera position input component
  142082. */
  142083. get cameraPosition(): NodeMaterialConnectionPoint;
  142084. /**
  142085. * Gets the base color input component
  142086. */
  142087. get baseColor(): NodeMaterialConnectionPoint;
  142088. /**
  142089. * Gets the opacity texture input component
  142090. */
  142091. get opacityTexture(): NodeMaterialConnectionPoint;
  142092. /**
  142093. * Gets the ambient color input component
  142094. */
  142095. get ambientColor(): NodeMaterialConnectionPoint;
  142096. /**
  142097. * Gets the reflectivity object parameters
  142098. */
  142099. get reflectivity(): NodeMaterialConnectionPoint;
  142100. /**
  142101. * Gets the ambient occlusion object parameters
  142102. */
  142103. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142104. /**
  142105. * Gets the reflection object parameters
  142106. */
  142107. get reflection(): NodeMaterialConnectionPoint;
  142108. /**
  142109. * Gets the sheen object parameters
  142110. */
  142111. get sheen(): NodeMaterialConnectionPoint;
  142112. /**
  142113. * Gets the clear coat object parameters
  142114. */
  142115. get clearcoat(): NodeMaterialConnectionPoint;
  142116. /**
  142117. * Gets the sub surface object parameters
  142118. */
  142119. get subsurface(): NodeMaterialConnectionPoint;
  142120. /**
  142121. * Gets the anisotropy object parameters
  142122. */
  142123. get anisotropy(): NodeMaterialConnectionPoint;
  142124. /**
  142125. * Gets the ambient output component
  142126. */
  142127. get ambient(): NodeMaterialConnectionPoint;
  142128. /**
  142129. * Gets the diffuse output component
  142130. */
  142131. get diffuse(): NodeMaterialConnectionPoint;
  142132. /**
  142133. * Gets the specular output component
  142134. */
  142135. get specular(): NodeMaterialConnectionPoint;
  142136. /**
  142137. * Gets the sheen output component
  142138. */
  142139. get sheenDir(): NodeMaterialConnectionPoint;
  142140. /**
  142141. * Gets the clear coat output component
  142142. */
  142143. get clearcoatDir(): NodeMaterialConnectionPoint;
  142144. /**
  142145. * Gets the indirect diffuse output component
  142146. */
  142147. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142148. /**
  142149. * Gets the indirect specular output component
  142150. */
  142151. get specularIndirect(): NodeMaterialConnectionPoint;
  142152. /**
  142153. * Gets the indirect sheen output component
  142154. */
  142155. get sheenIndirect(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the indirect clear coat output component
  142158. */
  142159. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the refraction output component
  142162. */
  142163. get refraction(): NodeMaterialConnectionPoint;
  142164. /**
  142165. * Gets the global lighting output component
  142166. */
  142167. get lighting(): NodeMaterialConnectionPoint;
  142168. /**
  142169. * Gets the shadow output component
  142170. */
  142171. get shadow(): NodeMaterialConnectionPoint;
  142172. /**
  142173. * Gets the alpha output component
  142174. */
  142175. get alpha(): NodeMaterialConnectionPoint;
  142176. autoConfigure(material: NodeMaterial): void;
  142177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142178. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142180. private _injectVertexCode;
  142181. /**
  142182. * Gets the code corresponding to the albedo/opacity module
  142183. * @returns the shader code
  142184. */
  142185. getAlbedoOpacityCode(): string;
  142186. protected _buildBlock(state: NodeMaterialBuildState): this;
  142187. protected _dumpPropertiesCode(): string;
  142188. serialize(): any;
  142189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142190. }
  142191. }
  142192. declare module BABYLON {
  142193. /**
  142194. * Block used to compute value of one parameter modulo another
  142195. */
  142196. export class ModBlock extends NodeMaterialBlock {
  142197. /**
  142198. * Creates a new ModBlock
  142199. * @param name defines the block name
  142200. */
  142201. constructor(name: string);
  142202. /**
  142203. * Gets the current class name
  142204. * @returns the class name
  142205. */
  142206. getClassName(): string;
  142207. /**
  142208. * Gets the left operand input component
  142209. */
  142210. get left(): NodeMaterialConnectionPoint;
  142211. /**
  142212. * Gets the right operand input component
  142213. */
  142214. get right(): NodeMaterialConnectionPoint;
  142215. /**
  142216. * Gets the output component
  142217. */
  142218. get output(): NodeMaterialConnectionPoint;
  142219. protected _buildBlock(state: NodeMaterialBuildState): this;
  142220. }
  142221. }
  142222. declare module BABYLON {
  142223. /**
  142224. * Helper class to push actions to a pool of workers.
  142225. */
  142226. export class WorkerPool implements IDisposable {
  142227. private _workerInfos;
  142228. private _pendingActions;
  142229. /**
  142230. * Constructor
  142231. * @param workers Array of workers to use for actions
  142232. */
  142233. constructor(workers: Array<Worker>);
  142234. /**
  142235. * Terminates all workers and clears any pending actions.
  142236. */
  142237. dispose(): void;
  142238. /**
  142239. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142240. * pended until a worker has completed its action.
  142241. * @param action The action to perform. Call onComplete when the action is complete.
  142242. */
  142243. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142244. private _execute;
  142245. }
  142246. }
  142247. declare module BABYLON {
  142248. /**
  142249. * Configuration for Draco compression
  142250. */
  142251. export interface IDracoCompressionConfiguration {
  142252. /**
  142253. * Configuration for the decoder.
  142254. */
  142255. decoder: {
  142256. /**
  142257. * The url to the WebAssembly module.
  142258. */
  142259. wasmUrl?: string;
  142260. /**
  142261. * The url to the WebAssembly binary.
  142262. */
  142263. wasmBinaryUrl?: string;
  142264. /**
  142265. * The url to the fallback JavaScript module.
  142266. */
  142267. fallbackUrl?: string;
  142268. };
  142269. }
  142270. /**
  142271. * Draco compression (https://google.github.io/draco/)
  142272. *
  142273. * This class wraps the Draco module.
  142274. *
  142275. * **Encoder**
  142276. *
  142277. * The encoder is not currently implemented.
  142278. *
  142279. * **Decoder**
  142280. *
  142281. * 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.
  142282. *
  142283. * To update the configuration, use the following code:
  142284. * ```javascript
  142285. * DracoCompression.Configuration = {
  142286. * decoder: {
  142287. * wasmUrl: "<url to the WebAssembly library>",
  142288. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142289. * fallbackUrl: "<url to the fallback JavaScript library>",
  142290. * }
  142291. * };
  142292. * ```
  142293. *
  142294. * 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.
  142295. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142296. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142297. *
  142298. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142299. * ```javascript
  142300. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142301. * ```
  142302. *
  142303. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142304. */
  142305. export class DracoCompression implements IDisposable {
  142306. private _workerPoolPromise?;
  142307. private _decoderModulePromise?;
  142308. /**
  142309. * The configuration. Defaults to the following urls:
  142310. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142311. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142312. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142313. */
  142314. static Configuration: IDracoCompressionConfiguration;
  142315. /**
  142316. * Returns true if the decoder configuration is available.
  142317. */
  142318. static get DecoderAvailable(): boolean;
  142319. /**
  142320. * Default number of workers to create when creating the draco compression object.
  142321. */
  142322. static DefaultNumWorkers: number;
  142323. private static GetDefaultNumWorkers;
  142324. private static _Default;
  142325. /**
  142326. * Default instance for the draco compression object.
  142327. */
  142328. static get Default(): DracoCompression;
  142329. /**
  142330. * Constructor
  142331. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142332. */
  142333. constructor(numWorkers?: number);
  142334. /**
  142335. * Stop all async operations and release resources.
  142336. */
  142337. dispose(): void;
  142338. /**
  142339. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142340. * @returns a promise that resolves when ready
  142341. */
  142342. whenReadyAsync(): Promise<void>;
  142343. /**
  142344. * Decode Draco compressed mesh data to vertex data.
  142345. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142346. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142347. * @returns A promise that resolves with the decoded vertex data
  142348. */
  142349. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142350. [kind: string]: number;
  142351. }): Promise<VertexData>;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /**
  142356. * Class for building Constructive Solid Geometry
  142357. */
  142358. export class CSG {
  142359. private polygons;
  142360. /**
  142361. * The world matrix
  142362. */
  142363. matrix: Matrix;
  142364. /**
  142365. * Stores the position
  142366. */
  142367. position: Vector3;
  142368. /**
  142369. * Stores the rotation
  142370. */
  142371. rotation: Vector3;
  142372. /**
  142373. * Stores the rotation quaternion
  142374. */
  142375. rotationQuaternion: Nullable<Quaternion>;
  142376. /**
  142377. * Stores the scaling vector
  142378. */
  142379. scaling: Vector3;
  142380. /**
  142381. * Convert the Mesh to CSG
  142382. * @param mesh The Mesh to convert to CSG
  142383. * @returns A new CSG from the Mesh
  142384. */
  142385. static FromMesh(mesh: Mesh): CSG;
  142386. /**
  142387. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142388. * @param polygons Polygons used to construct a CSG solid
  142389. */
  142390. private static FromPolygons;
  142391. /**
  142392. * Clones, or makes a deep copy, of the CSG
  142393. * @returns A new CSG
  142394. */
  142395. clone(): CSG;
  142396. /**
  142397. * Unions this CSG with another CSG
  142398. * @param csg The CSG to union against this CSG
  142399. * @returns The unioned CSG
  142400. */
  142401. union(csg: CSG): CSG;
  142402. /**
  142403. * Unions this CSG with another CSG in place
  142404. * @param csg The CSG to union against this CSG
  142405. */
  142406. unionInPlace(csg: CSG): void;
  142407. /**
  142408. * Subtracts this CSG with another CSG
  142409. * @param csg The CSG to subtract against this CSG
  142410. * @returns A new CSG
  142411. */
  142412. subtract(csg: CSG): CSG;
  142413. /**
  142414. * Subtracts this CSG with another CSG in place
  142415. * @param csg The CSG to subtact against this CSG
  142416. */
  142417. subtractInPlace(csg: CSG): void;
  142418. /**
  142419. * Intersect this CSG with another CSG
  142420. * @param csg The CSG to intersect against this CSG
  142421. * @returns A new CSG
  142422. */
  142423. intersect(csg: CSG): CSG;
  142424. /**
  142425. * Intersects this CSG with another CSG in place
  142426. * @param csg The CSG to intersect against this CSG
  142427. */
  142428. intersectInPlace(csg: CSG): void;
  142429. /**
  142430. * Return a new CSG solid with solid and empty space switched. This solid is
  142431. * not modified.
  142432. * @returns A new CSG solid with solid and empty space switched
  142433. */
  142434. inverse(): CSG;
  142435. /**
  142436. * Inverses the CSG in place
  142437. */
  142438. inverseInPlace(): void;
  142439. /**
  142440. * This is used to keep meshes transformations so they can be restored
  142441. * when we build back a Babylon Mesh
  142442. * NB : All CSG operations are performed in world coordinates
  142443. * @param csg The CSG to copy the transform attributes from
  142444. * @returns This CSG
  142445. */
  142446. copyTransformAttributes(csg: CSG): CSG;
  142447. /**
  142448. * Build Raw mesh from CSG
  142449. * Coordinates here are in world space
  142450. * @param name The name of the mesh geometry
  142451. * @param scene The Scene
  142452. * @param keepSubMeshes Specifies if the submeshes should be kept
  142453. * @returns A new Mesh
  142454. */
  142455. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142456. /**
  142457. * Build Mesh from CSG taking material and transforms into account
  142458. * @param name The name of the Mesh
  142459. * @param material The material of the Mesh
  142460. * @param scene The Scene
  142461. * @param keepSubMeshes Specifies if submeshes should be kept
  142462. * @returns The new Mesh
  142463. */
  142464. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142465. }
  142466. }
  142467. declare module BABYLON {
  142468. /**
  142469. * Class used to create a trail following a mesh
  142470. */
  142471. export class TrailMesh extends Mesh {
  142472. private _generator;
  142473. private _autoStart;
  142474. private _running;
  142475. private _diameter;
  142476. private _length;
  142477. private _sectionPolygonPointsCount;
  142478. private _sectionVectors;
  142479. private _sectionNormalVectors;
  142480. private _beforeRenderObserver;
  142481. /**
  142482. * @constructor
  142483. * @param name The value used by scene.getMeshByName() to do a lookup.
  142484. * @param generator The mesh or transform node to generate a trail.
  142485. * @param scene The scene to add this mesh to.
  142486. * @param diameter Diameter of trailing mesh. Default is 1.
  142487. * @param length Length of trailing mesh. Default is 60.
  142488. * @param autoStart Automatically start trailing mesh. Default true.
  142489. */
  142490. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142491. /**
  142492. * "TrailMesh"
  142493. * @returns "TrailMesh"
  142494. */
  142495. getClassName(): string;
  142496. private _createMesh;
  142497. /**
  142498. * Start trailing mesh.
  142499. */
  142500. start(): void;
  142501. /**
  142502. * Stop trailing mesh.
  142503. */
  142504. stop(): void;
  142505. /**
  142506. * Update trailing mesh geometry.
  142507. */
  142508. update(): void;
  142509. /**
  142510. * Returns a new TrailMesh object.
  142511. * @param name is a string, the name given to the new mesh
  142512. * @param newGenerator use new generator object for cloned trail mesh
  142513. * @returns a new mesh
  142514. */
  142515. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142516. /**
  142517. * Serializes this trail mesh
  142518. * @param serializationObject object to write serialization to
  142519. */
  142520. serialize(serializationObject: any): void;
  142521. /**
  142522. * Parses a serialized trail mesh
  142523. * @param parsedMesh the serialized mesh
  142524. * @param scene the scene to create the trail mesh in
  142525. * @returns the created trail mesh
  142526. */
  142527. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142528. }
  142529. }
  142530. declare module BABYLON {
  142531. /**
  142532. * Class containing static functions to help procedurally build meshes
  142533. */
  142534. export class TiledBoxBuilder {
  142535. /**
  142536. * Creates a box mesh
  142537. * 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)
  142538. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142542. * @param name defines the name of the mesh
  142543. * @param options defines the options used to create the mesh
  142544. * @param scene defines the hosting scene
  142545. * @returns the box mesh
  142546. */
  142547. static CreateTiledBox(name: string, options: {
  142548. pattern?: number;
  142549. width?: number;
  142550. height?: number;
  142551. depth?: number;
  142552. tileSize?: number;
  142553. tileWidth?: number;
  142554. tileHeight?: number;
  142555. alignHorizontal?: number;
  142556. alignVertical?: number;
  142557. faceUV?: Vector4[];
  142558. faceColors?: Color4[];
  142559. sideOrientation?: number;
  142560. updatable?: boolean;
  142561. }, scene?: Nullable<Scene>): Mesh;
  142562. }
  142563. }
  142564. declare module BABYLON {
  142565. /**
  142566. * Class containing static functions to help procedurally build meshes
  142567. */
  142568. export class TorusKnotBuilder {
  142569. /**
  142570. * Creates a torus knot mesh
  142571. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142572. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142573. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142574. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142578. * @param name defines the name of the mesh
  142579. * @param options defines the options used to create the mesh
  142580. * @param scene defines the hosting scene
  142581. * @returns the torus knot mesh
  142582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142583. */
  142584. static CreateTorusKnot(name: string, options: {
  142585. radius?: number;
  142586. tube?: number;
  142587. radialSegments?: number;
  142588. tubularSegments?: number;
  142589. p?: number;
  142590. q?: number;
  142591. updatable?: boolean;
  142592. sideOrientation?: number;
  142593. frontUVs?: Vector4;
  142594. backUVs?: Vector4;
  142595. }, scene: any): Mesh;
  142596. }
  142597. }
  142598. declare module BABYLON {
  142599. /**
  142600. * Polygon
  142601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142602. */
  142603. export class Polygon {
  142604. /**
  142605. * Creates a rectangle
  142606. * @param xmin bottom X coord
  142607. * @param ymin bottom Y coord
  142608. * @param xmax top X coord
  142609. * @param ymax top Y coord
  142610. * @returns points that make the resulting rectation
  142611. */
  142612. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142613. /**
  142614. * Creates a circle
  142615. * @param radius radius of circle
  142616. * @param cx scale in x
  142617. * @param cy scale in y
  142618. * @param numberOfSides number of sides that make up the circle
  142619. * @returns points that make the resulting circle
  142620. */
  142621. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142622. /**
  142623. * Creates a polygon from input string
  142624. * @param input Input polygon data
  142625. * @returns the parsed points
  142626. */
  142627. static Parse(input: string): Vector2[];
  142628. /**
  142629. * Starts building a polygon from x and y coordinates
  142630. * @param x x coordinate
  142631. * @param y y coordinate
  142632. * @returns the started path2
  142633. */
  142634. static StartingAt(x: number, y: number): Path2;
  142635. }
  142636. /**
  142637. * Builds a polygon
  142638. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142639. */
  142640. export class PolygonMeshBuilder {
  142641. private _points;
  142642. private _outlinepoints;
  142643. private _holes;
  142644. private _name;
  142645. private _scene;
  142646. private _epoints;
  142647. private _eholes;
  142648. private _addToepoint;
  142649. /**
  142650. * Babylon reference to the earcut plugin.
  142651. */
  142652. bjsEarcut: any;
  142653. /**
  142654. * Creates a PolygonMeshBuilder
  142655. * @param name name of the builder
  142656. * @param contours Path of the polygon
  142657. * @param scene scene to add to when creating the mesh
  142658. * @param earcutInjection can be used to inject your own earcut reference
  142659. */
  142660. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142661. /**
  142662. * Adds a whole within the polygon
  142663. * @param hole Array of points defining the hole
  142664. * @returns this
  142665. */
  142666. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142667. /**
  142668. * Creates the polygon
  142669. * @param updatable If the mesh should be updatable
  142670. * @param depth The depth of the mesh created
  142671. * @returns the created mesh
  142672. */
  142673. build(updatable?: boolean, depth?: number): Mesh;
  142674. /**
  142675. * Creates the polygon
  142676. * @param depth The depth of the mesh created
  142677. * @returns the created VertexData
  142678. */
  142679. buildVertexData(depth?: number): VertexData;
  142680. /**
  142681. * Adds a side to the polygon
  142682. * @param positions points that make the polygon
  142683. * @param normals normals of the polygon
  142684. * @param uvs uvs of the polygon
  142685. * @param indices indices of the polygon
  142686. * @param bounds bounds of the polygon
  142687. * @param points points of the polygon
  142688. * @param depth depth of the polygon
  142689. * @param flip flip of the polygon
  142690. */
  142691. private addSide;
  142692. }
  142693. }
  142694. declare module BABYLON {
  142695. /**
  142696. * Class containing static functions to help procedurally build meshes
  142697. */
  142698. export class PolygonBuilder {
  142699. /**
  142700. * Creates a polygon mesh
  142701. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142702. * * 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
  142703. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142706. * * Remember you can only change the shape positions, not their number when updating a polygon
  142707. * @param name defines the name of the mesh
  142708. * @param options defines the options used to create the mesh
  142709. * @param scene defines the hosting scene
  142710. * @param earcutInjection can be used to inject your own earcut reference
  142711. * @returns the polygon mesh
  142712. */
  142713. static CreatePolygon(name: string, options: {
  142714. shape: Vector3[];
  142715. holes?: Vector3[][];
  142716. depth?: number;
  142717. faceUV?: Vector4[];
  142718. faceColors?: Color4[];
  142719. updatable?: boolean;
  142720. sideOrientation?: number;
  142721. frontUVs?: Vector4;
  142722. backUVs?: Vector4;
  142723. wrap?: boolean;
  142724. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142725. /**
  142726. * Creates an extruded polygon mesh, with depth in the Y direction.
  142727. * * 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)
  142728. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142729. * @param name defines the name of the mesh
  142730. * @param options defines the options used to create the mesh
  142731. * @param scene defines the hosting scene
  142732. * @param earcutInjection can be used to inject your own earcut reference
  142733. * @returns the polygon mesh
  142734. */
  142735. static ExtrudePolygon(name: string, options: {
  142736. shape: Vector3[];
  142737. holes?: Vector3[][];
  142738. depth?: number;
  142739. faceUV?: Vector4[];
  142740. faceColors?: Color4[];
  142741. updatable?: boolean;
  142742. sideOrientation?: number;
  142743. frontUVs?: Vector4;
  142744. backUVs?: Vector4;
  142745. wrap?: boolean;
  142746. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142747. }
  142748. }
  142749. declare module BABYLON {
  142750. /**
  142751. * Class containing static functions to help procedurally build meshes
  142752. */
  142753. export class LatheBuilder {
  142754. /**
  142755. * Creates lathe mesh.
  142756. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142757. * * 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
  142758. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142759. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142760. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142761. * * 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
  142762. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142763. * * 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
  142764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142768. * @param name defines the name of the mesh
  142769. * @param options defines the options used to create the mesh
  142770. * @param scene defines the hosting scene
  142771. * @returns the lathe mesh
  142772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142773. */
  142774. static CreateLathe(name: string, options: {
  142775. shape: Vector3[];
  142776. radius?: number;
  142777. tessellation?: number;
  142778. clip?: number;
  142779. arc?: number;
  142780. closed?: boolean;
  142781. updatable?: boolean;
  142782. sideOrientation?: number;
  142783. frontUVs?: Vector4;
  142784. backUVs?: Vector4;
  142785. cap?: number;
  142786. invertUV?: boolean;
  142787. }, scene?: Nullable<Scene>): Mesh;
  142788. }
  142789. }
  142790. declare module BABYLON {
  142791. /**
  142792. * Class containing static functions to help procedurally build meshes
  142793. */
  142794. export class TiledPlaneBuilder {
  142795. /**
  142796. * Creates a tiled plane mesh
  142797. * * The parameter `pattern` will, depending on value, do nothing or
  142798. * * * flip (reflect about central vertical) alternate tiles across and up
  142799. * * * flip every tile on alternate rows
  142800. * * * rotate (180 degs) alternate tiles across and up
  142801. * * * rotate every tile on alternate rows
  142802. * * * flip and rotate alternate tiles across and up
  142803. * * * flip and rotate every tile on alternate rows
  142804. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142805. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142808. * * 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)
  142809. * * 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)
  142810. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142811. * @param name defines the name of the mesh
  142812. * @param options defines the options used to create the mesh
  142813. * @param scene defines the hosting scene
  142814. * @returns the box mesh
  142815. */
  142816. static CreateTiledPlane(name: string, options: {
  142817. pattern?: number;
  142818. tileSize?: number;
  142819. tileWidth?: number;
  142820. tileHeight?: number;
  142821. size?: number;
  142822. width?: number;
  142823. height?: number;
  142824. alignHorizontal?: number;
  142825. alignVertical?: number;
  142826. sideOrientation?: number;
  142827. frontUVs?: Vector4;
  142828. backUVs?: Vector4;
  142829. updatable?: boolean;
  142830. }, scene?: Nullable<Scene>): Mesh;
  142831. }
  142832. }
  142833. declare module BABYLON {
  142834. /**
  142835. * Class containing static functions to help procedurally build meshes
  142836. */
  142837. export class TubeBuilder {
  142838. /**
  142839. * Creates a tube mesh.
  142840. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142841. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142842. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142843. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142844. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142845. * * 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)
  142846. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142847. * * 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
  142848. * * 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
  142849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142853. * @param name defines the name of the mesh
  142854. * @param options defines the options used to create the mesh
  142855. * @param scene defines the hosting scene
  142856. * @returns the tube mesh
  142857. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142858. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142859. */
  142860. static CreateTube(name: string, options: {
  142861. path: Vector3[];
  142862. radius?: number;
  142863. tessellation?: number;
  142864. radiusFunction?: {
  142865. (i: number, distance: number): number;
  142866. };
  142867. cap?: number;
  142868. arc?: number;
  142869. updatable?: boolean;
  142870. sideOrientation?: number;
  142871. frontUVs?: Vector4;
  142872. backUVs?: Vector4;
  142873. instance?: Mesh;
  142874. invertUV?: boolean;
  142875. }, scene?: Nullable<Scene>): Mesh;
  142876. }
  142877. }
  142878. declare module BABYLON {
  142879. /**
  142880. * Class containing static functions to help procedurally build meshes
  142881. */
  142882. export class IcoSphereBuilder {
  142883. /**
  142884. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142885. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142886. * * 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`)
  142887. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142888. * * 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
  142889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142892. * @param name defines the name of the mesh
  142893. * @param options defines the options used to create the mesh
  142894. * @param scene defines the hosting scene
  142895. * @returns the icosahedron mesh
  142896. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142897. */
  142898. static CreateIcoSphere(name: string, options: {
  142899. radius?: number;
  142900. radiusX?: number;
  142901. radiusY?: number;
  142902. radiusZ?: number;
  142903. flat?: boolean;
  142904. subdivisions?: number;
  142905. sideOrientation?: number;
  142906. frontUVs?: Vector4;
  142907. backUVs?: Vector4;
  142908. updatable?: boolean;
  142909. }, scene?: Nullable<Scene>): Mesh;
  142910. }
  142911. }
  142912. declare module BABYLON {
  142913. /**
  142914. * Class containing static functions to help procedurally build meshes
  142915. */
  142916. export class DecalBuilder {
  142917. /**
  142918. * Creates a decal mesh.
  142919. * 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
  142920. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142921. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142922. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142923. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142924. * @param name defines the name of the mesh
  142925. * @param sourceMesh defines the mesh where the decal must be applied
  142926. * @param options defines the options used to create the mesh
  142927. * @param scene defines the hosting scene
  142928. * @returns the decal mesh
  142929. * @see https://doc.babylonjs.com/how_to/decals
  142930. */
  142931. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142932. position?: Vector3;
  142933. normal?: Vector3;
  142934. size?: Vector3;
  142935. angle?: number;
  142936. }): Mesh;
  142937. }
  142938. }
  142939. declare module BABYLON {
  142940. /**
  142941. * Class containing static functions to help procedurally build meshes
  142942. */
  142943. export class MeshBuilder {
  142944. /**
  142945. * Creates a box mesh
  142946. * * The parameter `size` sets the size (float) of each box side (default 1)
  142947. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142948. * * 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)
  142949. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142953. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142954. * @param name defines the name of the mesh
  142955. * @param options defines the options used to create the mesh
  142956. * @param scene defines the hosting scene
  142957. * @returns the box mesh
  142958. */
  142959. static CreateBox(name: string, options: {
  142960. size?: number;
  142961. width?: number;
  142962. height?: number;
  142963. depth?: number;
  142964. faceUV?: Vector4[];
  142965. faceColors?: Color4[];
  142966. sideOrientation?: number;
  142967. frontUVs?: Vector4;
  142968. backUVs?: Vector4;
  142969. wrap?: boolean;
  142970. topBaseAt?: number;
  142971. bottomBaseAt?: number;
  142972. updatable?: boolean;
  142973. }, scene?: Nullable<Scene>): Mesh;
  142974. /**
  142975. * Creates a tiled box mesh
  142976. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142978. * @param name defines the name of the mesh
  142979. * @param options defines the options used to create the mesh
  142980. * @param scene defines the hosting scene
  142981. * @returns the tiled box mesh
  142982. */
  142983. static CreateTiledBox(name: string, options: {
  142984. pattern?: number;
  142985. size?: number;
  142986. width?: number;
  142987. height?: number;
  142988. depth: number;
  142989. tileSize?: number;
  142990. tileWidth?: number;
  142991. tileHeight?: number;
  142992. faceUV?: Vector4[];
  142993. faceColors?: Color4[];
  142994. alignHorizontal?: number;
  142995. alignVertical?: number;
  142996. sideOrientation?: number;
  142997. updatable?: boolean;
  142998. }, scene?: Nullable<Scene>): Mesh;
  142999. /**
  143000. * Creates a sphere mesh
  143001. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143002. * * 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`)
  143003. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143004. * * 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
  143005. * * 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)
  143006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143009. * @param name defines the name of the mesh
  143010. * @param options defines the options used to create the mesh
  143011. * @param scene defines the hosting scene
  143012. * @returns the sphere mesh
  143013. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143014. */
  143015. static CreateSphere(name: string, options: {
  143016. segments?: number;
  143017. diameter?: number;
  143018. diameterX?: number;
  143019. diameterY?: number;
  143020. diameterZ?: number;
  143021. arc?: number;
  143022. slice?: number;
  143023. sideOrientation?: number;
  143024. frontUVs?: Vector4;
  143025. backUVs?: Vector4;
  143026. updatable?: boolean;
  143027. }, scene?: Nullable<Scene>): Mesh;
  143028. /**
  143029. * Creates a plane polygonal mesh. By default, this is a disc
  143030. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143031. * * 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
  143032. * * 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
  143033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143036. * @param name defines the name of the mesh
  143037. * @param options defines the options used to create the mesh
  143038. * @param scene defines the hosting scene
  143039. * @returns the plane polygonal mesh
  143040. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143041. */
  143042. static CreateDisc(name: string, options: {
  143043. radius?: number;
  143044. tessellation?: number;
  143045. arc?: number;
  143046. updatable?: boolean;
  143047. sideOrientation?: number;
  143048. frontUVs?: Vector4;
  143049. backUVs?: Vector4;
  143050. }, scene?: Nullable<Scene>): Mesh;
  143051. /**
  143052. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143053. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143054. * * 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`)
  143055. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143056. * * 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
  143057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143060. * @param name defines the name of the mesh
  143061. * @param options defines the options used to create the mesh
  143062. * @param scene defines the hosting scene
  143063. * @returns the icosahedron mesh
  143064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143065. */
  143066. static CreateIcoSphere(name: string, options: {
  143067. radius?: number;
  143068. radiusX?: number;
  143069. radiusY?: number;
  143070. radiusZ?: number;
  143071. flat?: boolean;
  143072. subdivisions?: number;
  143073. sideOrientation?: number;
  143074. frontUVs?: Vector4;
  143075. backUVs?: Vector4;
  143076. updatable?: boolean;
  143077. }, scene?: Nullable<Scene>): Mesh;
  143078. /**
  143079. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143080. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143081. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143082. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143083. * * 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
  143084. * * 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
  143085. * * 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
  143086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143089. * * 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
  143090. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143091. * * 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
  143092. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143094. * @param name defines the name of the mesh
  143095. * @param options defines the options used to create the mesh
  143096. * @param scene defines the hosting scene
  143097. * @returns the ribbon mesh
  143098. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143100. */
  143101. static CreateRibbon(name: string, options: {
  143102. pathArray: Vector3[][];
  143103. closeArray?: boolean;
  143104. closePath?: boolean;
  143105. offset?: number;
  143106. updatable?: boolean;
  143107. sideOrientation?: number;
  143108. frontUVs?: Vector4;
  143109. backUVs?: Vector4;
  143110. instance?: Mesh;
  143111. invertUV?: boolean;
  143112. uvs?: Vector2[];
  143113. colors?: Color4[];
  143114. }, scene?: Nullable<Scene>): Mesh;
  143115. /**
  143116. * Creates a cylinder or a cone mesh
  143117. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143118. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143119. * * 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.
  143120. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143121. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143122. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143123. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143124. * * 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).
  143125. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143126. * * 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).
  143127. * * 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
  143128. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143129. * * 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
  143130. * * 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.
  143131. * * If `enclose` is false, a ring surface is one element.
  143132. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143133. * * 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
  143134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143137. * @param name defines the name of the mesh
  143138. * @param options defines the options used to create the mesh
  143139. * @param scene defines the hosting scene
  143140. * @returns the cylinder mesh
  143141. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143142. */
  143143. static CreateCylinder(name: string, options: {
  143144. height?: number;
  143145. diameterTop?: number;
  143146. diameterBottom?: number;
  143147. diameter?: number;
  143148. tessellation?: number;
  143149. subdivisions?: number;
  143150. arc?: number;
  143151. faceColors?: Color4[];
  143152. faceUV?: Vector4[];
  143153. updatable?: boolean;
  143154. hasRings?: boolean;
  143155. enclose?: boolean;
  143156. cap?: number;
  143157. sideOrientation?: number;
  143158. frontUVs?: Vector4;
  143159. backUVs?: Vector4;
  143160. }, scene?: Nullable<Scene>): Mesh;
  143161. /**
  143162. * Creates a torus mesh
  143163. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143164. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143165. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143169. * @param name defines the name of the mesh
  143170. * @param options defines the options used to create the mesh
  143171. * @param scene defines the hosting scene
  143172. * @returns the torus mesh
  143173. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143174. */
  143175. static CreateTorus(name: string, options: {
  143176. diameter?: number;
  143177. thickness?: number;
  143178. tessellation?: number;
  143179. updatable?: boolean;
  143180. sideOrientation?: number;
  143181. frontUVs?: Vector4;
  143182. backUVs?: Vector4;
  143183. }, scene?: Nullable<Scene>): Mesh;
  143184. /**
  143185. * Creates a torus knot mesh
  143186. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143187. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143188. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143189. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143193. * @param name defines the name of the mesh
  143194. * @param options defines the options used to create the mesh
  143195. * @param scene defines the hosting scene
  143196. * @returns the torus knot mesh
  143197. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143198. */
  143199. static CreateTorusKnot(name: string, options: {
  143200. radius?: number;
  143201. tube?: number;
  143202. radialSegments?: number;
  143203. tubularSegments?: number;
  143204. p?: number;
  143205. q?: number;
  143206. updatable?: boolean;
  143207. sideOrientation?: number;
  143208. frontUVs?: Vector4;
  143209. backUVs?: Vector4;
  143210. }, scene?: Nullable<Scene>): Mesh;
  143211. /**
  143212. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143213. * * 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
  143214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143215. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143216. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143217. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143219. * * 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
  143220. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143223. * @param name defines the name of the new line system
  143224. * @param options defines the options used to create the line system
  143225. * @param scene defines the hosting scene
  143226. * @returns a new line system mesh
  143227. */
  143228. static CreateLineSystem(name: string, options: {
  143229. lines: Vector3[][];
  143230. updatable?: boolean;
  143231. instance?: Nullable<LinesMesh>;
  143232. colors?: Nullable<Color4[][]>;
  143233. useVertexAlpha?: boolean;
  143234. }, scene: Nullable<Scene>): LinesMesh;
  143235. /**
  143236. * Creates a line mesh
  143237. * 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
  143238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143239. * * The parameter `points` is an array successive Vector3
  143240. * * 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
  143241. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143243. * * When updating an instance, remember that only point positions can change, not the number of points
  143244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143246. * @param name defines the name of the new line system
  143247. * @param options defines the options used to create the line system
  143248. * @param scene defines the hosting scene
  143249. * @returns a new line mesh
  143250. */
  143251. static CreateLines(name: string, options: {
  143252. points: Vector3[];
  143253. updatable?: boolean;
  143254. instance?: Nullable<LinesMesh>;
  143255. colors?: Color4[];
  143256. useVertexAlpha?: boolean;
  143257. }, scene?: Nullable<Scene>): LinesMesh;
  143258. /**
  143259. * Creates a dashed line mesh
  143260. * * 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
  143261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143262. * * The parameter `points` is an array successive Vector3
  143263. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143264. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143265. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143266. * * 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
  143267. * * When updating an instance, remember that only point positions can change, not the number of points
  143268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143269. * @param name defines the name of the mesh
  143270. * @param options defines the options used to create the mesh
  143271. * @param scene defines the hosting scene
  143272. * @returns the dashed line mesh
  143273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143274. */
  143275. static CreateDashedLines(name: string, options: {
  143276. points: Vector3[];
  143277. dashSize?: number;
  143278. gapSize?: number;
  143279. dashNb?: number;
  143280. updatable?: boolean;
  143281. instance?: LinesMesh;
  143282. }, scene?: Nullable<Scene>): LinesMesh;
  143283. /**
  143284. * 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.
  143285. * * 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.
  143286. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143287. * * 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.
  143288. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143289. * * 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
  143290. * * 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
  143291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143296. * @param name defines the name of the mesh
  143297. * @param options defines the options used to create the mesh
  143298. * @param scene defines the hosting scene
  143299. * @returns the extruded shape mesh
  143300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143302. */
  143303. static ExtrudeShape(name: string, options: {
  143304. shape: Vector3[];
  143305. path: Vector3[];
  143306. scale?: number;
  143307. rotation?: number;
  143308. cap?: number;
  143309. updatable?: boolean;
  143310. sideOrientation?: number;
  143311. frontUVs?: Vector4;
  143312. backUVs?: Vector4;
  143313. instance?: Mesh;
  143314. invertUV?: boolean;
  143315. }, scene?: Nullable<Scene>): Mesh;
  143316. /**
  143317. * Creates an custom extruded shape mesh.
  143318. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143319. * * 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.
  143320. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143321. * * 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
  143322. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143323. * * 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
  143324. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143325. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143326. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143327. * * 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
  143328. * * 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
  143329. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143334. * @param name defines the name of the mesh
  143335. * @param options defines the options used to create the mesh
  143336. * @param scene defines the hosting scene
  143337. * @returns the custom extruded shape mesh
  143338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143341. */
  143342. static ExtrudeShapeCustom(name: string, options: {
  143343. shape: Vector3[];
  143344. path: Vector3[];
  143345. scaleFunction?: any;
  143346. rotationFunction?: any;
  143347. ribbonCloseArray?: boolean;
  143348. ribbonClosePath?: boolean;
  143349. cap?: number;
  143350. updatable?: boolean;
  143351. sideOrientation?: number;
  143352. frontUVs?: Vector4;
  143353. backUVs?: Vector4;
  143354. instance?: Mesh;
  143355. invertUV?: boolean;
  143356. }, scene?: Nullable<Scene>): Mesh;
  143357. /**
  143358. * Creates lathe mesh.
  143359. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143360. * * 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
  143361. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143362. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143363. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143364. * * 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
  143365. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143366. * * 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
  143367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143371. * @param name defines the name of the mesh
  143372. * @param options defines the options used to create the mesh
  143373. * @param scene defines the hosting scene
  143374. * @returns the lathe mesh
  143375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143376. */
  143377. static CreateLathe(name: string, options: {
  143378. shape: Vector3[];
  143379. radius?: number;
  143380. tessellation?: number;
  143381. clip?: number;
  143382. arc?: number;
  143383. closed?: boolean;
  143384. updatable?: boolean;
  143385. sideOrientation?: number;
  143386. frontUVs?: Vector4;
  143387. backUVs?: Vector4;
  143388. cap?: number;
  143389. invertUV?: boolean;
  143390. }, scene?: Nullable<Scene>): Mesh;
  143391. /**
  143392. * Creates a tiled plane mesh
  143393. * * You can set a limited pattern arrangement with the tiles
  143394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143397. * @param name defines the name of the mesh
  143398. * @param options defines the options used to create the mesh
  143399. * @param scene defines the hosting scene
  143400. * @returns the plane mesh
  143401. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143402. */
  143403. static CreateTiledPlane(name: string, options: {
  143404. pattern?: number;
  143405. tileSize?: number;
  143406. tileWidth?: number;
  143407. tileHeight?: number;
  143408. size?: number;
  143409. width?: number;
  143410. height?: number;
  143411. alignHorizontal?: number;
  143412. alignVertical?: number;
  143413. sideOrientation?: number;
  143414. frontUVs?: Vector4;
  143415. backUVs?: Vector4;
  143416. updatable?: boolean;
  143417. }, scene?: Nullable<Scene>): Mesh;
  143418. /**
  143419. * Creates a plane mesh
  143420. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143421. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143422. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143426. * @param name defines the name of the mesh
  143427. * @param options defines the options used to create the mesh
  143428. * @param scene defines the hosting scene
  143429. * @returns the plane mesh
  143430. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143431. */
  143432. static CreatePlane(name: string, options: {
  143433. size?: number;
  143434. width?: number;
  143435. height?: number;
  143436. sideOrientation?: number;
  143437. frontUVs?: Vector4;
  143438. backUVs?: Vector4;
  143439. updatable?: boolean;
  143440. sourcePlane?: Plane;
  143441. }, scene?: Nullable<Scene>): Mesh;
  143442. /**
  143443. * Creates a ground mesh
  143444. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143445. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143447. * @param name defines the name of the mesh
  143448. * @param options defines the options used to create the mesh
  143449. * @param scene defines the hosting scene
  143450. * @returns the ground mesh
  143451. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143452. */
  143453. static CreateGround(name: string, options: {
  143454. width?: number;
  143455. height?: number;
  143456. subdivisions?: number;
  143457. subdivisionsX?: number;
  143458. subdivisionsY?: number;
  143459. updatable?: boolean;
  143460. }, scene?: Nullable<Scene>): Mesh;
  143461. /**
  143462. * Creates a tiled ground mesh
  143463. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143464. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143465. * * 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
  143466. * * 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
  143467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143468. * @param name defines the name of the mesh
  143469. * @param options defines the options used to create the mesh
  143470. * @param scene defines the hosting scene
  143471. * @returns the tiled ground mesh
  143472. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143473. */
  143474. static CreateTiledGround(name: string, options: {
  143475. xmin: number;
  143476. zmin: number;
  143477. xmax: number;
  143478. zmax: number;
  143479. subdivisions?: {
  143480. w: number;
  143481. h: number;
  143482. };
  143483. precision?: {
  143484. w: number;
  143485. h: number;
  143486. };
  143487. updatable?: boolean;
  143488. }, scene?: Nullable<Scene>): Mesh;
  143489. /**
  143490. * Creates a ground mesh from a height map
  143491. * * The parameter `url` sets the URL of the height map image resource.
  143492. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143493. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143494. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143495. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143496. * * 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.
  143497. * * 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).
  143498. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143500. * @param name defines the name of the mesh
  143501. * @param url defines the url to the height map
  143502. * @param options defines the options used to create the mesh
  143503. * @param scene defines the hosting scene
  143504. * @returns the ground mesh
  143505. * @see https://doc.babylonjs.com/babylon101/height_map
  143506. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143507. */
  143508. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143509. width?: number;
  143510. height?: number;
  143511. subdivisions?: number;
  143512. minHeight?: number;
  143513. maxHeight?: number;
  143514. colorFilter?: Color3;
  143515. alphaFilter?: number;
  143516. updatable?: boolean;
  143517. onReady?: (mesh: GroundMesh) => void;
  143518. }, scene?: Nullable<Scene>): GroundMesh;
  143519. /**
  143520. * Creates a polygon mesh
  143521. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143522. * * 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
  143523. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143526. * * Remember you can only change the shape positions, not their number when updating a polygon
  143527. * @param name defines the name of the mesh
  143528. * @param options defines the options used to create the mesh
  143529. * @param scene defines the hosting scene
  143530. * @param earcutInjection can be used to inject your own earcut reference
  143531. * @returns the polygon mesh
  143532. */
  143533. static CreatePolygon(name: string, options: {
  143534. shape: Vector3[];
  143535. holes?: Vector3[][];
  143536. depth?: number;
  143537. faceUV?: Vector4[];
  143538. faceColors?: Color4[];
  143539. updatable?: boolean;
  143540. sideOrientation?: number;
  143541. frontUVs?: Vector4;
  143542. backUVs?: Vector4;
  143543. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143544. /**
  143545. * Creates an extruded polygon mesh, with depth in the Y direction.
  143546. * * 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)
  143547. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143548. * @param name defines the name of the mesh
  143549. * @param options defines the options used to create the mesh
  143550. * @param scene defines the hosting scene
  143551. * @param earcutInjection can be used to inject your own earcut reference
  143552. * @returns the polygon mesh
  143553. */
  143554. static ExtrudePolygon(name: string, options: {
  143555. shape: Vector3[];
  143556. holes?: Vector3[][];
  143557. depth?: number;
  143558. faceUV?: Vector4[];
  143559. faceColors?: Color4[];
  143560. updatable?: boolean;
  143561. sideOrientation?: number;
  143562. frontUVs?: Vector4;
  143563. backUVs?: Vector4;
  143564. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143565. /**
  143566. * Creates a tube mesh.
  143567. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143568. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143569. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143570. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143571. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143572. * * 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)
  143573. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143574. * * 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
  143575. * * 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
  143576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143580. * @param name defines the name of the mesh
  143581. * @param options defines the options used to create the mesh
  143582. * @param scene defines the hosting scene
  143583. * @returns the tube mesh
  143584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143585. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143586. */
  143587. static CreateTube(name: string, options: {
  143588. path: Vector3[];
  143589. radius?: number;
  143590. tessellation?: number;
  143591. radiusFunction?: {
  143592. (i: number, distance: number): number;
  143593. };
  143594. cap?: number;
  143595. arc?: number;
  143596. updatable?: boolean;
  143597. sideOrientation?: number;
  143598. frontUVs?: Vector4;
  143599. backUVs?: Vector4;
  143600. instance?: Mesh;
  143601. invertUV?: boolean;
  143602. }, scene?: Nullable<Scene>): Mesh;
  143603. /**
  143604. * Creates a polyhedron mesh
  143605. * * 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
  143606. * * The parameter `size` (positive float, default 1) sets the polygon size
  143607. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143608. * * 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`
  143609. * * 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
  143610. * * 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)`)
  143611. * * 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
  143612. * * 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
  143613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143616. * @param name defines the name of the mesh
  143617. * @param options defines the options used to create the mesh
  143618. * @param scene defines the hosting scene
  143619. * @returns the polyhedron mesh
  143620. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143621. */
  143622. static CreatePolyhedron(name: string, options: {
  143623. type?: number;
  143624. size?: number;
  143625. sizeX?: number;
  143626. sizeY?: number;
  143627. sizeZ?: number;
  143628. custom?: any;
  143629. faceUV?: Vector4[];
  143630. faceColors?: Color4[];
  143631. flat?: boolean;
  143632. updatable?: boolean;
  143633. sideOrientation?: number;
  143634. frontUVs?: Vector4;
  143635. backUVs?: Vector4;
  143636. }, scene?: Nullable<Scene>): Mesh;
  143637. /**
  143638. * Creates a decal mesh.
  143639. * 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
  143640. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143641. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143642. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143643. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143644. * @param name defines the name of the mesh
  143645. * @param sourceMesh defines the mesh where the decal must be applied
  143646. * @param options defines the options used to create the mesh
  143647. * @param scene defines the hosting scene
  143648. * @returns the decal mesh
  143649. * @see https://doc.babylonjs.com/how_to/decals
  143650. */
  143651. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143652. position?: Vector3;
  143653. normal?: Vector3;
  143654. size?: Vector3;
  143655. angle?: number;
  143656. }): Mesh;
  143657. }
  143658. }
  143659. declare module BABYLON {
  143660. /**
  143661. * A simplifier interface for future simplification implementations
  143662. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143663. */
  143664. export interface ISimplifier {
  143665. /**
  143666. * Simplification of a given mesh according to the given settings.
  143667. * Since this requires computation, it is assumed that the function runs async.
  143668. * @param settings The settings of the simplification, including quality and distance
  143669. * @param successCallback A callback that will be called after the mesh was simplified.
  143670. * @param errorCallback in case of an error, this callback will be called. optional.
  143671. */
  143672. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143673. }
  143674. /**
  143675. * Expected simplification settings.
  143676. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143677. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143678. */
  143679. export interface ISimplificationSettings {
  143680. /**
  143681. * Gets or sets the expected quality
  143682. */
  143683. quality: number;
  143684. /**
  143685. * Gets or sets the distance when this optimized version should be used
  143686. */
  143687. distance: number;
  143688. /**
  143689. * Gets an already optimized mesh
  143690. */
  143691. optimizeMesh?: boolean;
  143692. }
  143693. /**
  143694. * Class used to specify simplification options
  143695. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143696. */
  143697. export class SimplificationSettings implements ISimplificationSettings {
  143698. /** expected quality */
  143699. quality: number;
  143700. /** distance when this optimized version should be used */
  143701. distance: number;
  143702. /** already optimized mesh */
  143703. optimizeMesh?: boolean | undefined;
  143704. /**
  143705. * Creates a SimplificationSettings
  143706. * @param quality expected quality
  143707. * @param distance distance when this optimized version should be used
  143708. * @param optimizeMesh already optimized mesh
  143709. */
  143710. constructor(
  143711. /** expected quality */
  143712. quality: number,
  143713. /** distance when this optimized version should be used */
  143714. distance: number,
  143715. /** already optimized mesh */
  143716. optimizeMesh?: boolean | undefined);
  143717. }
  143718. /**
  143719. * Interface used to define a simplification task
  143720. */
  143721. export interface ISimplificationTask {
  143722. /**
  143723. * Array of settings
  143724. */
  143725. settings: Array<ISimplificationSettings>;
  143726. /**
  143727. * Simplification type
  143728. */
  143729. simplificationType: SimplificationType;
  143730. /**
  143731. * Mesh to simplify
  143732. */
  143733. mesh: Mesh;
  143734. /**
  143735. * Callback called on success
  143736. */
  143737. successCallback?: () => void;
  143738. /**
  143739. * Defines if parallel processing can be used
  143740. */
  143741. parallelProcessing: boolean;
  143742. }
  143743. /**
  143744. * Queue used to order the simplification tasks
  143745. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143746. */
  143747. export class SimplificationQueue {
  143748. private _simplificationArray;
  143749. /**
  143750. * Gets a boolean indicating that the process is still running
  143751. */
  143752. running: boolean;
  143753. /**
  143754. * Creates a new queue
  143755. */
  143756. constructor();
  143757. /**
  143758. * Adds a new simplification task
  143759. * @param task defines a task to add
  143760. */
  143761. addTask(task: ISimplificationTask): void;
  143762. /**
  143763. * Execute next task
  143764. */
  143765. executeNext(): void;
  143766. /**
  143767. * Execute a simplification task
  143768. * @param task defines the task to run
  143769. */
  143770. runSimplification(task: ISimplificationTask): void;
  143771. private getSimplifier;
  143772. }
  143773. /**
  143774. * The implemented types of simplification
  143775. * At the moment only Quadratic Error Decimation is implemented
  143776. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143777. */
  143778. export enum SimplificationType {
  143779. /** Quadratic error decimation */
  143780. QUADRATIC = 0
  143781. }
  143782. /**
  143783. * An implementation of the Quadratic Error simplification algorithm.
  143784. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143785. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143786. * @author RaananW
  143787. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143788. */
  143789. export class QuadraticErrorSimplification implements ISimplifier {
  143790. private _mesh;
  143791. private triangles;
  143792. private vertices;
  143793. private references;
  143794. private _reconstructedMesh;
  143795. /** Gets or sets the number pf sync interations */
  143796. syncIterations: number;
  143797. /** Gets or sets the aggressiveness of the simplifier */
  143798. aggressiveness: number;
  143799. /** Gets or sets the number of allowed iterations for decimation */
  143800. decimationIterations: number;
  143801. /** Gets or sets the espilon to use for bounding box computation */
  143802. boundingBoxEpsilon: number;
  143803. /**
  143804. * Creates a new QuadraticErrorSimplification
  143805. * @param _mesh defines the target mesh
  143806. */
  143807. constructor(_mesh: Mesh);
  143808. /**
  143809. * Simplification of a given mesh according to the given settings.
  143810. * Since this requires computation, it is assumed that the function runs async.
  143811. * @param settings The settings of the simplification, including quality and distance
  143812. * @param successCallback A callback that will be called after the mesh was simplified.
  143813. */
  143814. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143815. private runDecimation;
  143816. private initWithMesh;
  143817. private init;
  143818. private reconstructMesh;
  143819. private initDecimatedMesh;
  143820. private isFlipped;
  143821. private updateTriangles;
  143822. private identifyBorder;
  143823. private updateMesh;
  143824. private vertexError;
  143825. private calculateError;
  143826. }
  143827. }
  143828. declare module BABYLON {
  143829. interface Scene {
  143830. /** @hidden (Backing field) */
  143831. _simplificationQueue: SimplificationQueue;
  143832. /**
  143833. * Gets or sets the simplification queue attached to the scene
  143834. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143835. */
  143836. simplificationQueue: SimplificationQueue;
  143837. }
  143838. interface Mesh {
  143839. /**
  143840. * Simplify the mesh according to the given array of settings.
  143841. * Function will return immediately and will simplify async
  143842. * @param settings a collection of simplification settings
  143843. * @param parallelProcessing should all levels calculate parallel or one after the other
  143844. * @param simplificationType the type of simplification to run
  143845. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143846. * @returns the current mesh
  143847. */
  143848. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143849. }
  143850. /**
  143851. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143852. * created in a scene
  143853. */
  143854. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143855. /**
  143856. * The component name helpfull to identify the component in the list of scene components.
  143857. */
  143858. readonly name: string;
  143859. /**
  143860. * The scene the component belongs to.
  143861. */
  143862. scene: Scene;
  143863. /**
  143864. * Creates a new instance of the component for the given scene
  143865. * @param scene Defines the scene to register the component in
  143866. */
  143867. constructor(scene: Scene);
  143868. /**
  143869. * Registers the component in a given scene
  143870. */
  143871. register(): void;
  143872. /**
  143873. * Rebuilds the elements related to this component in case of
  143874. * context lost for instance.
  143875. */
  143876. rebuild(): void;
  143877. /**
  143878. * Disposes the component and the associated ressources
  143879. */
  143880. dispose(): void;
  143881. private _beforeCameraUpdate;
  143882. }
  143883. }
  143884. declare module BABYLON {
  143885. interface Mesh {
  143886. /**
  143887. * Creates a new thin instance
  143888. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143889. * @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
  143890. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143891. */
  143892. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143893. /**
  143894. * Adds the transformation (matrix) of the current mesh as a thin instance
  143895. * @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
  143896. * @returns the thin instance index number
  143897. */
  143898. thinInstanceAddSelf(refresh: boolean): number;
  143899. /**
  143900. * Registers a custom attribute to be used with thin instances
  143901. * @param kind name of the attribute
  143902. * @param stride size in floats of the attribute
  143903. */
  143904. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143905. /**
  143906. * Sets the matrix of a thin instance
  143907. * @param index index of the thin instance
  143908. * @param matrix matrix to set
  143909. * @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
  143910. */
  143911. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143912. /**
  143913. * Sets the value of a custom attribute for a thin instance
  143914. * @param kind name of the attribute
  143915. * @param index index of the thin instance
  143916. * @param value value to set
  143917. * @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
  143918. */
  143919. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143920. /**
  143921. * 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.
  143922. */
  143923. thinInstanceCount: number;
  143924. /**
  143925. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143926. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143927. * @param buffer buffer to set
  143928. * @param stride size in floats of each value of the buffer
  143929. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143930. */
  143931. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143932. /**
  143933. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143934. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143935. */
  143936. thinInstanceBufferUpdated(kind: string): void;
  143937. /**
  143938. * Refreshes the bounding info, taking into account all the thin instances defined
  143939. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143940. */
  143941. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143942. /** @hidden */
  143943. _thinInstanceInitializeUserStorage(): void;
  143944. /** @hidden */
  143945. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143946. /** @hidden */
  143947. _userThinInstanceBuffersStorage: {
  143948. data: {
  143949. [key: string]: Float32Array;
  143950. };
  143951. sizes: {
  143952. [key: string]: number;
  143953. };
  143954. vertexBuffers: {
  143955. [key: string]: Nullable<VertexBuffer>;
  143956. };
  143957. strides: {
  143958. [key: string]: number;
  143959. };
  143960. };
  143961. }
  143962. }
  143963. declare module BABYLON {
  143964. /**
  143965. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143966. */
  143967. export interface INavigationEnginePlugin {
  143968. /**
  143969. * plugin name
  143970. */
  143971. name: string;
  143972. /**
  143973. * Creates a navigation mesh
  143974. * @param meshes array of all the geometry used to compute the navigatio mesh
  143975. * @param parameters bunch of parameters used to filter geometry
  143976. */
  143977. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143978. /**
  143979. * Create a navigation mesh debug mesh
  143980. * @param scene is where the mesh will be added
  143981. * @returns debug display mesh
  143982. */
  143983. createDebugNavMesh(scene: Scene): Mesh;
  143984. /**
  143985. * Get a navigation mesh constrained position, closest to the parameter position
  143986. * @param position world position
  143987. * @returns the closest point to position constrained by the navigation mesh
  143988. */
  143989. getClosestPoint(position: Vector3): Vector3;
  143990. /**
  143991. * Get a navigation mesh constrained position, closest to the parameter position
  143992. * @param position world position
  143993. * @param result output the closest point to position constrained by the navigation mesh
  143994. */
  143995. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143996. /**
  143997. * Get a navigation mesh constrained position, within a particular radius
  143998. * @param position world position
  143999. * @param maxRadius the maximum distance to the constrained world position
  144000. * @returns the closest point to position constrained by the navigation mesh
  144001. */
  144002. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144003. /**
  144004. * Get a navigation mesh constrained position, within a particular radius
  144005. * @param position world position
  144006. * @param maxRadius the maximum distance to the constrained world position
  144007. * @param result output the closest point to position constrained by the navigation mesh
  144008. */
  144009. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144010. /**
  144011. * Compute the final position from a segment made of destination-position
  144012. * @param position world position
  144013. * @param destination world position
  144014. * @returns the resulting point along the navmesh
  144015. */
  144016. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144017. /**
  144018. * Compute the final position from a segment made of destination-position
  144019. * @param position world position
  144020. * @param destination world position
  144021. * @param result output the resulting point along the navmesh
  144022. */
  144023. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144024. /**
  144025. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144026. * @param start world position
  144027. * @param end world position
  144028. * @returns array containing world position composing the path
  144029. */
  144030. computePath(start: Vector3, end: Vector3): Vector3[];
  144031. /**
  144032. * If this plugin is supported
  144033. * @returns true if plugin is supported
  144034. */
  144035. isSupported(): boolean;
  144036. /**
  144037. * Create a new Crowd so you can add agents
  144038. * @param maxAgents the maximum agent count in the crowd
  144039. * @param maxAgentRadius the maximum radius an agent can have
  144040. * @param scene to attach the crowd to
  144041. * @returns the crowd you can add agents to
  144042. */
  144043. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144044. /**
  144045. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144046. * The queries will try to find a solution within those bounds
  144047. * default is (1,1,1)
  144048. * @param extent x,y,z value that define the extent around the queries point of reference
  144049. */
  144050. setDefaultQueryExtent(extent: Vector3): void;
  144051. /**
  144052. * Get the Bounding box extent specified by setDefaultQueryExtent
  144053. * @returns the box extent values
  144054. */
  144055. getDefaultQueryExtent(): Vector3;
  144056. /**
  144057. * build the navmesh from a previously saved state using getNavmeshData
  144058. * @param data the Uint8Array returned by getNavmeshData
  144059. */
  144060. buildFromNavmeshData(data: Uint8Array): void;
  144061. /**
  144062. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144063. * @returns data the Uint8Array that can be saved and reused
  144064. */
  144065. getNavmeshData(): Uint8Array;
  144066. /**
  144067. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144068. * @param result output the box extent values
  144069. */
  144070. getDefaultQueryExtentToRef(result: Vector3): void;
  144071. /**
  144072. * Release all resources
  144073. */
  144074. dispose(): void;
  144075. }
  144076. /**
  144077. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144078. */
  144079. export interface ICrowd {
  144080. /**
  144081. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144082. * You can attach anything to that node. The node position is updated in the scene update tick.
  144083. * @param pos world position that will be constrained by the navigation mesh
  144084. * @param parameters agent parameters
  144085. * @param transform hooked to the agent that will be update by the scene
  144086. * @returns agent index
  144087. */
  144088. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144089. /**
  144090. * Returns the agent position in world space
  144091. * @param index agent index returned by addAgent
  144092. * @returns world space position
  144093. */
  144094. getAgentPosition(index: number): Vector3;
  144095. /**
  144096. * Gets the agent position result in world space
  144097. * @param index agent index returned by addAgent
  144098. * @param result output world space position
  144099. */
  144100. getAgentPositionToRef(index: number, result: Vector3): void;
  144101. /**
  144102. * Gets the agent velocity in world space
  144103. * @param index agent index returned by addAgent
  144104. * @returns world space velocity
  144105. */
  144106. getAgentVelocity(index: number): Vector3;
  144107. /**
  144108. * Gets the agent velocity result in world space
  144109. * @param index agent index returned by addAgent
  144110. * @param result output world space velocity
  144111. */
  144112. getAgentVelocityToRef(index: number, result: Vector3): void;
  144113. /**
  144114. * remove a particular agent previously created
  144115. * @param index agent index returned by addAgent
  144116. */
  144117. removeAgent(index: number): void;
  144118. /**
  144119. * get the list of all agents attached to this crowd
  144120. * @returns list of agent indices
  144121. */
  144122. getAgents(): number[];
  144123. /**
  144124. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144125. * @param deltaTime in seconds
  144126. */
  144127. update(deltaTime: number): void;
  144128. /**
  144129. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144130. * @param index agent index returned by addAgent
  144131. * @param destination targeted world position
  144132. */
  144133. agentGoto(index: number, destination: Vector3): void;
  144134. /**
  144135. * Teleport the agent to a new position
  144136. * @param index agent index returned by addAgent
  144137. * @param destination targeted world position
  144138. */
  144139. agentTeleport(index: number, destination: Vector3): void;
  144140. /**
  144141. * Update agent parameters
  144142. * @param index agent index returned by addAgent
  144143. * @param parameters agent parameters
  144144. */
  144145. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144146. /**
  144147. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144148. * The queries will try to find a solution within those bounds
  144149. * default is (1,1,1)
  144150. * @param extent x,y,z value that define the extent around the queries point of reference
  144151. */
  144152. setDefaultQueryExtent(extent: Vector3): void;
  144153. /**
  144154. * Get the Bounding box extent specified by setDefaultQueryExtent
  144155. * @returns the box extent values
  144156. */
  144157. getDefaultQueryExtent(): Vector3;
  144158. /**
  144159. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144160. * @param result output the box extent values
  144161. */
  144162. getDefaultQueryExtentToRef(result: Vector3): void;
  144163. /**
  144164. * Release all resources
  144165. */
  144166. dispose(): void;
  144167. }
  144168. /**
  144169. * Configures an agent
  144170. */
  144171. export interface IAgentParameters {
  144172. /**
  144173. * Agent radius. [Limit: >= 0]
  144174. */
  144175. radius: number;
  144176. /**
  144177. * Agent height. [Limit: > 0]
  144178. */
  144179. height: number;
  144180. /**
  144181. * Maximum allowed acceleration. [Limit: >= 0]
  144182. */
  144183. maxAcceleration: number;
  144184. /**
  144185. * Maximum allowed speed. [Limit: >= 0]
  144186. */
  144187. maxSpeed: number;
  144188. /**
  144189. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144190. */
  144191. collisionQueryRange: number;
  144192. /**
  144193. * The path visibility optimization range. [Limit: > 0]
  144194. */
  144195. pathOptimizationRange: number;
  144196. /**
  144197. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144198. */
  144199. separationWeight: number;
  144200. }
  144201. /**
  144202. * Configures the navigation mesh creation
  144203. */
  144204. export interface INavMeshParameters {
  144205. /**
  144206. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144207. */
  144208. cs: number;
  144209. /**
  144210. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144211. */
  144212. ch: number;
  144213. /**
  144214. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144215. */
  144216. walkableSlopeAngle: number;
  144217. /**
  144218. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144219. * be considered walkable. [Limit: >= 3] [Units: vx]
  144220. */
  144221. walkableHeight: number;
  144222. /**
  144223. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144224. */
  144225. walkableClimb: number;
  144226. /**
  144227. * The distance to erode/shrink the walkable area of the heightfield away from
  144228. * obstructions. [Limit: >=0] [Units: vx]
  144229. */
  144230. walkableRadius: number;
  144231. /**
  144232. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144233. */
  144234. maxEdgeLen: number;
  144235. /**
  144236. * The maximum distance a simplfied contour's border edges should deviate
  144237. * the original raw contour. [Limit: >=0] [Units: vx]
  144238. */
  144239. maxSimplificationError: number;
  144240. /**
  144241. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144242. */
  144243. minRegionArea: number;
  144244. /**
  144245. * Any regions with a span count smaller than this value will, if possible,
  144246. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144247. */
  144248. mergeRegionArea: number;
  144249. /**
  144250. * The maximum number of vertices allowed for polygons generated during the
  144251. * contour to polygon conversion process. [Limit: >= 3]
  144252. */
  144253. maxVertsPerPoly: number;
  144254. /**
  144255. * Sets the sampling distance to use when generating the detail mesh.
  144256. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144257. */
  144258. detailSampleDist: number;
  144259. /**
  144260. * The maximum distance the detail mesh surface should deviate from heightfield
  144261. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144262. */
  144263. detailSampleMaxError: number;
  144264. }
  144265. }
  144266. declare module BABYLON {
  144267. /**
  144268. * RecastJS navigation plugin
  144269. */
  144270. export class RecastJSPlugin implements INavigationEnginePlugin {
  144271. /**
  144272. * Reference to the Recast library
  144273. */
  144274. bjsRECAST: any;
  144275. /**
  144276. * plugin name
  144277. */
  144278. name: string;
  144279. /**
  144280. * the first navmesh created. We might extend this to support multiple navmeshes
  144281. */
  144282. navMesh: any;
  144283. /**
  144284. * Initializes the recastJS plugin
  144285. * @param recastInjection can be used to inject your own recast reference
  144286. */
  144287. constructor(recastInjection?: any);
  144288. /**
  144289. * Creates a navigation mesh
  144290. * @param meshes array of all the geometry used to compute the navigatio mesh
  144291. * @param parameters bunch of parameters used to filter geometry
  144292. */
  144293. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144294. /**
  144295. * Create a navigation mesh debug mesh
  144296. * @param scene is where the mesh will be added
  144297. * @returns debug display mesh
  144298. */
  144299. createDebugNavMesh(scene: Scene): Mesh;
  144300. /**
  144301. * Get a navigation mesh constrained position, closest to the parameter position
  144302. * @param position world position
  144303. * @returns the closest point to position constrained by the navigation mesh
  144304. */
  144305. getClosestPoint(position: Vector3): Vector3;
  144306. /**
  144307. * Get a navigation mesh constrained position, closest to the parameter position
  144308. * @param position world position
  144309. * @param result output the closest point to position constrained by the navigation mesh
  144310. */
  144311. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144312. /**
  144313. * Get a navigation mesh constrained position, within a particular radius
  144314. * @param position world position
  144315. * @param maxRadius the maximum distance to the constrained world position
  144316. * @returns the closest point to position constrained by the navigation mesh
  144317. */
  144318. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144319. /**
  144320. * Get a navigation mesh constrained position, within a particular radius
  144321. * @param position world position
  144322. * @param maxRadius the maximum distance to the constrained world position
  144323. * @param result output the closest point to position constrained by the navigation mesh
  144324. */
  144325. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144326. /**
  144327. * Compute the final position from a segment made of destination-position
  144328. * @param position world position
  144329. * @param destination world position
  144330. * @returns the resulting point along the navmesh
  144331. */
  144332. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144333. /**
  144334. * Compute the final position from a segment made of destination-position
  144335. * @param position world position
  144336. * @param destination world position
  144337. * @param result output the resulting point along the navmesh
  144338. */
  144339. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144340. /**
  144341. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144342. * @param start world position
  144343. * @param end world position
  144344. * @returns array containing world position composing the path
  144345. */
  144346. computePath(start: Vector3, end: Vector3): Vector3[];
  144347. /**
  144348. * Create a new Crowd so you can add agents
  144349. * @param maxAgents the maximum agent count in the crowd
  144350. * @param maxAgentRadius the maximum radius an agent can have
  144351. * @param scene to attach the crowd to
  144352. * @returns the crowd you can add agents to
  144353. */
  144354. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144355. /**
  144356. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144357. * The queries will try to find a solution within those bounds
  144358. * default is (1,1,1)
  144359. * @param extent x,y,z value that define the extent around the queries point of reference
  144360. */
  144361. setDefaultQueryExtent(extent: Vector3): void;
  144362. /**
  144363. * Get the Bounding box extent specified by setDefaultQueryExtent
  144364. * @returns the box extent values
  144365. */
  144366. getDefaultQueryExtent(): Vector3;
  144367. /**
  144368. * build the navmesh from a previously saved state using getNavmeshData
  144369. * @param data the Uint8Array returned by getNavmeshData
  144370. */
  144371. buildFromNavmeshData(data: Uint8Array): void;
  144372. /**
  144373. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144374. * @returns data the Uint8Array that can be saved and reused
  144375. */
  144376. getNavmeshData(): Uint8Array;
  144377. /**
  144378. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144379. * @param result output the box extent values
  144380. */
  144381. getDefaultQueryExtentToRef(result: Vector3): void;
  144382. /**
  144383. * Disposes
  144384. */
  144385. dispose(): void;
  144386. /**
  144387. * If this plugin is supported
  144388. * @returns true if plugin is supported
  144389. */
  144390. isSupported(): boolean;
  144391. }
  144392. /**
  144393. * Recast detour crowd implementation
  144394. */
  144395. export class RecastJSCrowd implements ICrowd {
  144396. /**
  144397. * Recast/detour plugin
  144398. */
  144399. bjsRECASTPlugin: RecastJSPlugin;
  144400. /**
  144401. * Link to the detour crowd
  144402. */
  144403. recastCrowd: any;
  144404. /**
  144405. * One transform per agent
  144406. */
  144407. transforms: TransformNode[];
  144408. /**
  144409. * All agents created
  144410. */
  144411. agents: number[];
  144412. /**
  144413. * Link to the scene is kept to unregister the crowd from the scene
  144414. */
  144415. private _scene;
  144416. /**
  144417. * Observer for crowd updates
  144418. */
  144419. private _onBeforeAnimationsObserver;
  144420. /**
  144421. * Constructor
  144422. * @param plugin recastJS plugin
  144423. * @param maxAgents the maximum agent count in the crowd
  144424. * @param maxAgentRadius the maximum radius an agent can have
  144425. * @param scene to attach the crowd to
  144426. * @returns the crowd you can add agents to
  144427. */
  144428. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144429. /**
  144430. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144431. * You can attach anything to that node. The node position is updated in the scene update tick.
  144432. * @param pos world position that will be constrained by the navigation mesh
  144433. * @param parameters agent parameters
  144434. * @param transform hooked to the agent that will be update by the scene
  144435. * @returns agent index
  144436. */
  144437. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144438. /**
  144439. * Returns the agent position in world space
  144440. * @param index agent index returned by addAgent
  144441. * @returns world space position
  144442. */
  144443. getAgentPosition(index: number): Vector3;
  144444. /**
  144445. * Returns the agent position result in world space
  144446. * @param index agent index returned by addAgent
  144447. * @param result output world space position
  144448. */
  144449. getAgentPositionToRef(index: number, result: Vector3): void;
  144450. /**
  144451. * Returns the agent velocity in world space
  144452. * @param index agent index returned by addAgent
  144453. * @returns world space velocity
  144454. */
  144455. getAgentVelocity(index: number): Vector3;
  144456. /**
  144457. * Returns the agent velocity result in world space
  144458. * @param index agent index returned by addAgent
  144459. * @param result output world space velocity
  144460. */
  144461. getAgentVelocityToRef(index: number, result: Vector3): void;
  144462. /**
  144463. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144464. * @param index agent index returned by addAgent
  144465. * @param destination targeted world position
  144466. */
  144467. agentGoto(index: number, destination: Vector3): void;
  144468. /**
  144469. * Teleport the agent to a new position
  144470. * @param index agent index returned by addAgent
  144471. * @param destination targeted world position
  144472. */
  144473. agentTeleport(index: number, destination: Vector3): void;
  144474. /**
  144475. * Update agent parameters
  144476. * @param index agent index returned by addAgent
  144477. * @param parameters agent parameters
  144478. */
  144479. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144480. /**
  144481. * remove a particular agent previously created
  144482. * @param index agent index returned by addAgent
  144483. */
  144484. removeAgent(index: number): void;
  144485. /**
  144486. * get the list of all agents attached to this crowd
  144487. * @returns list of agent indices
  144488. */
  144489. getAgents(): number[];
  144490. /**
  144491. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144492. * @param deltaTime in seconds
  144493. */
  144494. update(deltaTime: number): void;
  144495. /**
  144496. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144497. * The queries will try to find a solution within those bounds
  144498. * default is (1,1,1)
  144499. * @param extent x,y,z value that define the extent around the queries point of reference
  144500. */
  144501. setDefaultQueryExtent(extent: Vector3): void;
  144502. /**
  144503. * Get the Bounding box extent specified by setDefaultQueryExtent
  144504. * @returns the box extent values
  144505. */
  144506. getDefaultQueryExtent(): Vector3;
  144507. /**
  144508. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144509. * @param result output the box extent values
  144510. */
  144511. getDefaultQueryExtentToRef(result: Vector3): void;
  144512. /**
  144513. * Release all resources
  144514. */
  144515. dispose(): void;
  144516. }
  144517. }
  144518. declare module BABYLON {
  144519. /**
  144520. * Class used to enable access to IndexedDB
  144521. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144522. */
  144523. export class Database implements IOfflineProvider {
  144524. private _callbackManifestChecked;
  144525. private _currentSceneUrl;
  144526. private _db;
  144527. private _enableSceneOffline;
  144528. private _enableTexturesOffline;
  144529. private _manifestVersionFound;
  144530. private _mustUpdateRessources;
  144531. private _hasReachedQuota;
  144532. private _isSupported;
  144533. private _idbFactory;
  144534. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144535. private static IsUASupportingBlobStorage;
  144536. /**
  144537. * Gets a boolean indicating if Database storate is enabled (off by default)
  144538. */
  144539. static IDBStorageEnabled: boolean;
  144540. /**
  144541. * Gets a boolean indicating if scene must be saved in the database
  144542. */
  144543. get enableSceneOffline(): boolean;
  144544. /**
  144545. * Gets a boolean indicating if textures must be saved in the database
  144546. */
  144547. get enableTexturesOffline(): boolean;
  144548. /**
  144549. * Creates a new Database
  144550. * @param urlToScene defines the url to load the scene
  144551. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144552. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144553. */
  144554. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144555. private static _ParseURL;
  144556. private static _ReturnFullUrlLocation;
  144557. private _checkManifestFile;
  144558. /**
  144559. * Open the database and make it available
  144560. * @param successCallback defines the callback to call on success
  144561. * @param errorCallback defines the callback to call on error
  144562. */
  144563. open(successCallback: () => void, errorCallback: () => void): void;
  144564. /**
  144565. * Loads an image from the database
  144566. * @param url defines the url to load from
  144567. * @param image defines the target DOM image
  144568. */
  144569. loadImage(url: string, image: HTMLImageElement): void;
  144570. private _loadImageFromDBAsync;
  144571. private _saveImageIntoDBAsync;
  144572. private _checkVersionFromDB;
  144573. private _loadVersionFromDBAsync;
  144574. private _saveVersionIntoDBAsync;
  144575. /**
  144576. * Loads a file from database
  144577. * @param url defines the URL to load from
  144578. * @param sceneLoaded defines a callback to call on success
  144579. * @param progressCallBack defines a callback to call when progress changed
  144580. * @param errorCallback defines a callback to call on error
  144581. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144582. */
  144583. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144584. private _loadFileAsync;
  144585. private _saveFileAsync;
  144586. /**
  144587. * Validates if xhr data is correct
  144588. * @param xhr defines the request to validate
  144589. * @param dataType defines the expected data type
  144590. * @returns true if data is correct
  144591. */
  144592. private static _ValidateXHRData;
  144593. }
  144594. }
  144595. declare module BABYLON {
  144596. /** @hidden */
  144597. export var gpuUpdateParticlesPixelShader: {
  144598. name: string;
  144599. shader: string;
  144600. };
  144601. }
  144602. declare module BABYLON {
  144603. /** @hidden */
  144604. export var gpuUpdateParticlesVertexShader: {
  144605. name: string;
  144606. shader: string;
  144607. };
  144608. }
  144609. declare module BABYLON {
  144610. /** @hidden */
  144611. export var clipPlaneFragmentDeclaration2: {
  144612. name: string;
  144613. shader: string;
  144614. };
  144615. }
  144616. declare module BABYLON {
  144617. /** @hidden */
  144618. export var gpuRenderParticlesPixelShader: {
  144619. name: string;
  144620. shader: string;
  144621. };
  144622. }
  144623. declare module BABYLON {
  144624. /** @hidden */
  144625. export var clipPlaneVertexDeclaration2: {
  144626. name: string;
  144627. shader: string;
  144628. };
  144629. }
  144630. declare module BABYLON {
  144631. /** @hidden */
  144632. export var gpuRenderParticlesVertexShader: {
  144633. name: string;
  144634. shader: string;
  144635. };
  144636. }
  144637. declare module BABYLON {
  144638. /**
  144639. * This represents a GPU particle system in Babylon
  144640. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144641. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144642. */
  144643. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144644. /**
  144645. * The layer mask we are rendering the particles through.
  144646. */
  144647. layerMask: number;
  144648. private _capacity;
  144649. private _activeCount;
  144650. private _currentActiveCount;
  144651. private _accumulatedCount;
  144652. private _renderEffect;
  144653. private _updateEffect;
  144654. private _buffer0;
  144655. private _buffer1;
  144656. private _spriteBuffer;
  144657. private _updateVAO;
  144658. private _renderVAO;
  144659. private _targetIndex;
  144660. private _sourceBuffer;
  144661. private _targetBuffer;
  144662. private _engine;
  144663. private _currentRenderId;
  144664. private _started;
  144665. private _stopped;
  144666. private _timeDelta;
  144667. private _randomTexture;
  144668. private _randomTexture2;
  144669. private _attributesStrideSize;
  144670. private _updateEffectOptions;
  144671. private _randomTextureSize;
  144672. private _actualFrame;
  144673. private _customEffect;
  144674. private readonly _rawTextureWidth;
  144675. /**
  144676. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144677. */
  144678. static get IsSupported(): boolean;
  144679. /**
  144680. * An event triggered when the system is disposed.
  144681. */
  144682. onDisposeObservable: Observable<IParticleSystem>;
  144683. /**
  144684. * Gets the maximum number of particles active at the same time.
  144685. * @returns The max number of active particles.
  144686. */
  144687. getCapacity(): number;
  144688. /**
  144689. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144690. * to override the particles.
  144691. */
  144692. forceDepthWrite: boolean;
  144693. /**
  144694. * Gets or set the number of active particles
  144695. */
  144696. get activeParticleCount(): number;
  144697. set activeParticleCount(value: number);
  144698. private _preWarmDone;
  144699. /**
  144700. * Specifies if the particles are updated in emitter local space or world space.
  144701. */
  144702. isLocal: boolean;
  144703. /**
  144704. * Is this system ready to be used/rendered
  144705. * @return true if the system is ready
  144706. */
  144707. isReady(): boolean;
  144708. /**
  144709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144710. * @returns True if it has been started, otherwise false.
  144711. */
  144712. isStarted(): boolean;
  144713. /**
  144714. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144715. * @returns True if it has been stopped, otherwise false.
  144716. */
  144717. isStopped(): boolean;
  144718. /**
  144719. * Gets a boolean indicating that the system is stopping
  144720. * @returns true if the system is currently stopping
  144721. */
  144722. isStopping(): boolean;
  144723. /**
  144724. * Gets the number of particles active at the same time.
  144725. * @returns The number of active particles.
  144726. */
  144727. getActiveCount(): number;
  144728. /**
  144729. * Starts the particle system and begins to emit
  144730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144731. */
  144732. start(delay?: number): void;
  144733. /**
  144734. * Stops the particle system.
  144735. */
  144736. stop(): void;
  144737. /**
  144738. * Remove all active particles
  144739. */
  144740. reset(): void;
  144741. /**
  144742. * Returns the string "GPUParticleSystem"
  144743. * @returns a string containing the class name
  144744. */
  144745. getClassName(): string;
  144746. /**
  144747. * Gets the custom effect used to render the particles
  144748. * @param blendMode Blend mode for which the effect should be retrieved
  144749. * @returns The effect
  144750. */
  144751. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144752. /**
  144753. * Sets the custom effect used to render the particles
  144754. * @param effect The effect to set
  144755. * @param blendMode Blend mode for which the effect should be set
  144756. */
  144757. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144758. /** @hidden */
  144759. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144760. /**
  144761. * Observable that will be called just before the particles are drawn
  144762. */
  144763. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144764. /**
  144765. * Gets the name of the particle vertex shader
  144766. */
  144767. get vertexShaderName(): string;
  144768. private _colorGradientsTexture;
  144769. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144770. /**
  144771. * Adds a new color gradient
  144772. * @param gradient defines the gradient to use (between 0 and 1)
  144773. * @param color1 defines the color to affect to the specified gradient
  144774. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144775. * @returns the current particle system
  144776. */
  144777. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144778. private _refreshColorGradient;
  144779. /** Force the system to rebuild all gradients that need to be resync */
  144780. forceRefreshGradients(): void;
  144781. /**
  144782. * Remove a specific color gradient
  144783. * @param gradient defines the gradient to remove
  144784. * @returns the current particle system
  144785. */
  144786. removeColorGradient(gradient: number): GPUParticleSystem;
  144787. private _angularSpeedGradientsTexture;
  144788. private _sizeGradientsTexture;
  144789. private _velocityGradientsTexture;
  144790. private _limitVelocityGradientsTexture;
  144791. private _dragGradientsTexture;
  144792. private _addFactorGradient;
  144793. /**
  144794. * Adds a new size gradient
  144795. * @param gradient defines the gradient to use (between 0 and 1)
  144796. * @param factor defines the size factor to affect to the specified gradient
  144797. * @returns the current particle system
  144798. */
  144799. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144800. /**
  144801. * Remove a specific size gradient
  144802. * @param gradient defines the gradient to remove
  144803. * @returns the current particle system
  144804. */
  144805. removeSizeGradient(gradient: number): GPUParticleSystem;
  144806. private _refreshFactorGradient;
  144807. /**
  144808. * Adds a new angular speed gradient
  144809. * @param gradient defines the gradient to use (between 0 and 1)
  144810. * @param factor defines the angular speed to affect to the specified gradient
  144811. * @returns the current particle system
  144812. */
  144813. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144814. /**
  144815. * Remove a specific angular speed gradient
  144816. * @param gradient defines the gradient to remove
  144817. * @returns the current particle system
  144818. */
  144819. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144820. /**
  144821. * Adds a new velocity gradient
  144822. * @param gradient defines the gradient to use (between 0 and 1)
  144823. * @param factor defines the velocity to affect to the specified gradient
  144824. * @returns the current particle system
  144825. */
  144826. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144827. /**
  144828. * Remove a specific velocity gradient
  144829. * @param gradient defines the gradient to remove
  144830. * @returns the current particle system
  144831. */
  144832. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144833. /**
  144834. * Adds a new limit velocity gradient
  144835. * @param gradient defines the gradient to use (between 0 and 1)
  144836. * @param factor defines the limit velocity value to affect to the specified gradient
  144837. * @returns the current particle system
  144838. */
  144839. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144840. /**
  144841. * Remove a specific limit velocity gradient
  144842. * @param gradient defines the gradient to remove
  144843. * @returns the current particle system
  144844. */
  144845. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144846. /**
  144847. * Adds a new drag gradient
  144848. * @param gradient defines the gradient to use (between 0 and 1)
  144849. * @param factor defines the drag value to affect to the specified gradient
  144850. * @returns the current particle system
  144851. */
  144852. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144853. /**
  144854. * Remove a specific drag gradient
  144855. * @param gradient defines the gradient to remove
  144856. * @returns the current particle system
  144857. */
  144858. removeDragGradient(gradient: number): GPUParticleSystem;
  144859. /**
  144860. * Not supported by GPUParticleSystem
  144861. * @param gradient defines the gradient to use (between 0 and 1)
  144862. * @param factor defines the emit rate value to affect to the specified gradient
  144863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144864. * @returns the current particle system
  144865. */
  144866. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144867. /**
  144868. * Not supported by GPUParticleSystem
  144869. * @param gradient defines the gradient to remove
  144870. * @returns the current particle system
  144871. */
  144872. removeEmitRateGradient(gradient: number): IParticleSystem;
  144873. /**
  144874. * Not supported by GPUParticleSystem
  144875. * @param gradient defines the gradient to use (between 0 and 1)
  144876. * @param factor defines the start size value to affect to the specified gradient
  144877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144878. * @returns the current particle system
  144879. */
  144880. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144881. /**
  144882. * Not supported by GPUParticleSystem
  144883. * @param gradient defines the gradient to remove
  144884. * @returns the current particle system
  144885. */
  144886. removeStartSizeGradient(gradient: number): IParticleSystem;
  144887. /**
  144888. * Not supported by GPUParticleSystem
  144889. * @param gradient defines the gradient to use (between 0 and 1)
  144890. * @param min defines the color remap minimal range
  144891. * @param max defines the color remap maximal range
  144892. * @returns the current particle system
  144893. */
  144894. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144895. /**
  144896. * Not supported by GPUParticleSystem
  144897. * @param gradient defines the gradient to remove
  144898. * @returns the current particle system
  144899. */
  144900. removeColorRemapGradient(): IParticleSystem;
  144901. /**
  144902. * Not supported by GPUParticleSystem
  144903. * @param gradient defines the gradient to use (between 0 and 1)
  144904. * @param min defines the alpha remap minimal range
  144905. * @param max defines the alpha remap maximal range
  144906. * @returns the current particle system
  144907. */
  144908. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144909. /**
  144910. * Not supported by GPUParticleSystem
  144911. * @param gradient defines the gradient to remove
  144912. * @returns the current particle system
  144913. */
  144914. removeAlphaRemapGradient(): IParticleSystem;
  144915. /**
  144916. * Not supported by GPUParticleSystem
  144917. * @param gradient defines the gradient to use (between 0 and 1)
  144918. * @param color defines the color to affect to the specified gradient
  144919. * @returns the current particle system
  144920. */
  144921. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144922. /**
  144923. * Not supported by GPUParticleSystem
  144924. * @param gradient defines the gradient to remove
  144925. * @returns the current particle system
  144926. */
  144927. removeRampGradient(): IParticleSystem;
  144928. /**
  144929. * Not supported by GPUParticleSystem
  144930. * @returns the list of ramp gradients
  144931. */
  144932. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144933. /**
  144934. * Not supported by GPUParticleSystem
  144935. * Gets or sets a boolean indicating that ramp gradients must be used
  144936. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144937. */
  144938. get useRampGradients(): boolean;
  144939. set useRampGradients(value: boolean);
  144940. /**
  144941. * Not supported by GPUParticleSystem
  144942. * @param gradient defines the gradient to use (between 0 and 1)
  144943. * @param factor defines the life time factor to affect to the specified gradient
  144944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144945. * @returns the current particle system
  144946. */
  144947. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144948. /**
  144949. * Not supported by GPUParticleSystem
  144950. * @param gradient defines the gradient to remove
  144951. * @returns the current particle system
  144952. */
  144953. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144954. /**
  144955. * Instantiates a GPU particle system.
  144956. * 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.
  144957. * @param name The name of the particle system
  144958. * @param options The options used to create the system
  144959. * @param scene The scene the particle system belongs to
  144960. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144961. * @param customEffect a custom effect used to change the way particles are rendered by default
  144962. */
  144963. constructor(name: string, options: Partial<{
  144964. capacity: number;
  144965. randomTextureSize: number;
  144966. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144967. protected _reset(): void;
  144968. private _createUpdateVAO;
  144969. private _createRenderVAO;
  144970. private _initialize;
  144971. /** @hidden */
  144972. _recreateUpdateEffect(): void;
  144973. private _getEffect;
  144974. /**
  144975. * Fill the defines array according to the current settings of the particle system
  144976. * @param defines Array to be updated
  144977. * @param blendMode blend mode to take into account when updating the array
  144978. */
  144979. fillDefines(defines: Array<string>, blendMode?: number): void;
  144980. /**
  144981. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144982. * @param uniforms Uniforms array to fill
  144983. * @param attributes Attributes array to fill
  144984. * @param samplers Samplers array to fill
  144985. */
  144986. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144987. /** @hidden */
  144988. _recreateRenderEffect(): Effect;
  144989. /**
  144990. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144991. * @param preWarm defines if we are in the pre-warmimg phase
  144992. */
  144993. animate(preWarm?: boolean): void;
  144994. private _createFactorGradientTexture;
  144995. private _createSizeGradientTexture;
  144996. private _createAngularSpeedGradientTexture;
  144997. private _createVelocityGradientTexture;
  144998. private _createLimitVelocityGradientTexture;
  144999. private _createDragGradientTexture;
  145000. private _createColorGradientTexture;
  145001. /**
  145002. * Renders the particle system in its current state
  145003. * @param preWarm defines if the system should only update the particles but not render them
  145004. * @returns the current number of particles
  145005. */
  145006. render(preWarm?: boolean): number;
  145007. /**
  145008. * Rebuilds the particle system
  145009. */
  145010. rebuild(): void;
  145011. private _releaseBuffers;
  145012. private _releaseVAOs;
  145013. /**
  145014. * Disposes the particle system and free the associated resources
  145015. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145016. */
  145017. dispose(disposeTexture?: boolean): void;
  145018. /**
  145019. * Clones the particle system.
  145020. * @param name The name of the cloned object
  145021. * @param newEmitter The new emitter to use
  145022. * @returns the cloned particle system
  145023. */
  145024. clone(name: string, newEmitter: any): GPUParticleSystem;
  145025. /**
  145026. * Serializes the particle system to a JSON object
  145027. * @param serializeTexture defines if the texture must be serialized as well
  145028. * @returns the JSON object
  145029. */
  145030. serialize(serializeTexture?: boolean): any;
  145031. /**
  145032. * Parses a JSON object to create a GPU particle system.
  145033. * @param parsedParticleSystem The JSON object to parse
  145034. * @param scene The scene to create the particle system in
  145035. * @param rootUrl The root url to use to load external dependencies like texture
  145036. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145037. * @returns the parsed GPU particle system
  145038. */
  145039. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145040. }
  145041. }
  145042. declare module BABYLON {
  145043. /**
  145044. * Represents a set of particle systems working together to create a specific effect
  145045. */
  145046. export class ParticleSystemSet implements IDisposable {
  145047. /**
  145048. * Gets or sets base Assets URL
  145049. */
  145050. static BaseAssetsUrl: string;
  145051. private _emitterCreationOptions;
  145052. private _emitterNode;
  145053. /**
  145054. * Gets the particle system list
  145055. */
  145056. systems: IParticleSystem[];
  145057. /**
  145058. * Gets the emitter node used with this set
  145059. */
  145060. get emitterNode(): Nullable<TransformNode>;
  145061. /**
  145062. * Creates a new emitter mesh as a sphere
  145063. * @param options defines the options used to create the sphere
  145064. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145065. * @param scene defines the hosting scene
  145066. */
  145067. setEmitterAsSphere(options: {
  145068. diameter: number;
  145069. segments: number;
  145070. color: Color3;
  145071. }, renderingGroupId: number, scene: Scene): void;
  145072. /**
  145073. * Starts all particle systems of the set
  145074. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145075. */
  145076. start(emitter?: AbstractMesh): void;
  145077. /**
  145078. * Release all associated resources
  145079. */
  145080. dispose(): void;
  145081. /**
  145082. * Serialize the set into a JSON compatible object
  145083. * @param serializeTexture defines if the texture must be serialized as well
  145084. * @returns a JSON compatible representation of the set
  145085. */
  145086. serialize(serializeTexture?: boolean): any;
  145087. /**
  145088. * Parse a new ParticleSystemSet from a serialized source
  145089. * @param data defines a JSON compatible representation of the set
  145090. * @param scene defines the hosting scene
  145091. * @param gpu defines if we want GPU particles or CPU particles
  145092. * @returns a new ParticleSystemSet
  145093. */
  145094. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145095. }
  145096. }
  145097. declare module BABYLON {
  145098. /**
  145099. * This class is made for on one-liner static method to help creating particle system set.
  145100. */
  145101. export class ParticleHelper {
  145102. /**
  145103. * Gets or sets base Assets URL
  145104. */
  145105. static BaseAssetsUrl: string;
  145106. /** Define the Url to load snippets */
  145107. static SnippetUrl: string;
  145108. /**
  145109. * Create a default particle system that you can tweak
  145110. * @param emitter defines the emitter to use
  145111. * @param capacity defines the system capacity (default is 500 particles)
  145112. * @param scene defines the hosting scene
  145113. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145114. * @returns the new Particle system
  145115. */
  145116. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145117. /**
  145118. * This is the main static method (one-liner) of this helper to create different particle systems
  145119. * @param type This string represents the type to the particle system to create
  145120. * @param scene The scene where the particle system should live
  145121. * @param gpu If the system will use gpu
  145122. * @returns the ParticleSystemSet created
  145123. */
  145124. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145125. /**
  145126. * Static function used to export a particle system to a ParticleSystemSet variable.
  145127. * Please note that the emitter shape is not exported
  145128. * @param systems defines the particle systems to export
  145129. * @returns the created particle system set
  145130. */
  145131. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145132. /**
  145133. * Creates a particle system from a snippet saved in a remote file
  145134. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145135. * @param url defines the url to load from
  145136. * @param scene defines the hosting scene
  145137. * @param gpu If the system will use gpu
  145138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145139. * @returns a promise that will resolve to the new particle system
  145140. */
  145141. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145142. /**
  145143. * Creates a particle system from a snippet saved by the particle system editor
  145144. * @param snippetId defines the snippet to load
  145145. * @param scene defines the hosting scene
  145146. * @param gpu If the system will use gpu
  145147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145148. * @returns a promise that will resolve to the new particle system
  145149. */
  145150. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145151. }
  145152. }
  145153. declare module BABYLON {
  145154. interface Engine {
  145155. /**
  145156. * Create an effect to use with particle systems.
  145157. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145158. * the particle system for which you want to create a custom effect in the last parameter
  145159. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145160. * @param uniformsNames defines a list of attribute names
  145161. * @param samplers defines an array of string used to represent textures
  145162. * @param defines defines the string containing the defines to use to compile the shaders
  145163. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145164. * @param onCompiled defines a function to call when the effect creation is successful
  145165. * @param onError defines a function to call when the effect creation has failed
  145166. * @param particleSystem the particle system you want to create the effect for
  145167. * @returns the new Effect
  145168. */
  145169. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145170. }
  145171. interface Mesh {
  145172. /**
  145173. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145174. * @returns an array of IParticleSystem
  145175. */
  145176. getEmittedParticleSystems(): IParticleSystem[];
  145177. /**
  145178. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145179. * @returns an array of IParticleSystem
  145180. */
  145181. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145182. }
  145183. }
  145184. declare module BABYLON {
  145185. /** Defines the 4 color options */
  145186. export enum PointColor {
  145187. /** color value */
  145188. Color = 2,
  145189. /** uv value */
  145190. UV = 1,
  145191. /** random value */
  145192. Random = 0,
  145193. /** stated value */
  145194. Stated = 3
  145195. }
  145196. /**
  145197. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145198. * 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.
  145199. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145200. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145201. *
  145202. * Full documentation here : TO BE ENTERED
  145203. */
  145204. export class PointsCloudSystem implements IDisposable {
  145205. /**
  145206. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145207. * Example : var p = SPS.particles[i];
  145208. */
  145209. particles: CloudPoint[];
  145210. /**
  145211. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145212. */
  145213. nbParticles: number;
  145214. /**
  145215. * This a counter for your own usage. It's not set by any SPS functions.
  145216. */
  145217. counter: number;
  145218. /**
  145219. * The PCS name. This name is also given to the underlying mesh.
  145220. */
  145221. name: string;
  145222. /**
  145223. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145224. */
  145225. mesh: Mesh;
  145226. /**
  145227. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145228. * Please read :
  145229. */
  145230. vars: any;
  145231. /**
  145232. * @hidden
  145233. */
  145234. _size: number;
  145235. private _scene;
  145236. private _promises;
  145237. private _positions;
  145238. private _indices;
  145239. private _normals;
  145240. private _colors;
  145241. private _uvs;
  145242. private _indices32;
  145243. private _positions32;
  145244. private _colors32;
  145245. private _uvs32;
  145246. private _updatable;
  145247. private _isVisibilityBoxLocked;
  145248. private _alwaysVisible;
  145249. private _groups;
  145250. private _groupCounter;
  145251. private _computeParticleColor;
  145252. private _computeParticleTexture;
  145253. private _computeParticleRotation;
  145254. private _computeBoundingBox;
  145255. private _isReady;
  145256. /**
  145257. * Creates a PCS (Points Cloud System) object
  145258. * @param name (String) is the PCS name, this will be the underlying mesh name
  145259. * @param pointSize (number) is the size for each point
  145260. * @param scene (Scene) is the scene in which the PCS is added
  145261. * @param options defines the options of the PCS e.g.
  145262. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145263. */
  145264. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145265. updatable?: boolean;
  145266. });
  145267. /**
  145268. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145269. * If no points were added to the PCS, the returned mesh is just a single point.
  145270. * @returns a promise for the created mesh
  145271. */
  145272. buildMeshAsync(): Promise<Mesh>;
  145273. /**
  145274. * @hidden
  145275. */
  145276. private _buildMesh;
  145277. private _addParticle;
  145278. private _randomUnitVector;
  145279. private _getColorIndicesForCoord;
  145280. private _setPointsColorOrUV;
  145281. private _colorFromTexture;
  145282. private _calculateDensity;
  145283. /**
  145284. * Adds points to the PCS in random positions within a unit sphere
  145285. * @param nb (positive integer) the number of particles to be created from this model
  145286. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145287. * @returns the number of groups in the system
  145288. */
  145289. addPoints(nb: number, pointFunction?: any): number;
  145290. /**
  145291. * Adds points to the PCS from the surface of the model shape
  145292. * @param mesh is any Mesh object that will be used as a surface model for the points
  145293. * @param nb (positive integer) the number of particles to be created from this model
  145294. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145295. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145296. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145297. * @returns the number of groups in the system
  145298. */
  145299. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145300. /**
  145301. * Adds points to the PCS inside the model shape
  145302. * @param mesh is any Mesh object that will be used as a surface model for the points
  145303. * @param nb (positive integer) the number of particles to be created from this model
  145304. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145305. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145306. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145307. * @returns the number of groups in the system
  145308. */
  145309. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145310. /**
  145311. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145312. * This method calls `updateParticle()` for each particle of the SPS.
  145313. * For an animated SPS, it is usually called within the render loop.
  145314. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145315. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145316. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145317. * @returns the PCS.
  145318. */
  145319. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145320. /**
  145321. * Disposes the PCS.
  145322. */
  145323. dispose(): void;
  145324. /**
  145325. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145326. * doc :
  145327. * @returns the PCS.
  145328. */
  145329. refreshVisibleSize(): PointsCloudSystem;
  145330. /**
  145331. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145332. * @param size the size (float) of the visibility box
  145333. * note : this doesn't lock the PCS mesh bounding box.
  145334. * doc :
  145335. */
  145336. setVisibilityBox(size: number): void;
  145337. /**
  145338. * Gets whether the PCS is always visible or not
  145339. * doc :
  145340. */
  145341. get isAlwaysVisible(): boolean;
  145342. /**
  145343. * Sets the PCS as always visible or not
  145344. * doc :
  145345. */
  145346. set isAlwaysVisible(val: boolean);
  145347. /**
  145348. * Tells to `setParticles()` to compute the particle rotations or not
  145349. * Default value : false. The PCS is faster when it's set to false
  145350. * Note : particle rotations are only applied to parent particles
  145351. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145352. */
  145353. set computeParticleRotation(val: boolean);
  145354. /**
  145355. * Tells to `setParticles()` to compute the particle colors or not.
  145356. * Default value : true. The PCS is faster when it's set to false.
  145357. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145358. */
  145359. set computeParticleColor(val: boolean);
  145360. set computeParticleTexture(val: boolean);
  145361. /**
  145362. * Gets if `setParticles()` computes the particle colors or not.
  145363. * Default value : false. The PCS is faster when it's set to false.
  145364. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145365. */
  145366. get computeParticleColor(): boolean;
  145367. /**
  145368. * Gets if `setParticles()` computes the particle textures or not.
  145369. * Default value : false. The PCS is faster when it's set to false.
  145370. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145371. */
  145372. get computeParticleTexture(): boolean;
  145373. /**
  145374. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145375. */
  145376. set computeBoundingBox(val: boolean);
  145377. /**
  145378. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145379. */
  145380. get computeBoundingBox(): boolean;
  145381. /**
  145382. * This function does nothing. It may be overwritten to set all the particle first values.
  145383. * The PCS doesn't call this function, you may have to call it by your own.
  145384. * doc :
  145385. */
  145386. initParticles(): void;
  145387. /**
  145388. * This function does nothing. It may be overwritten to recycle a particle
  145389. * The PCS doesn't call this function, you can to call it
  145390. * doc :
  145391. * @param particle The particle to recycle
  145392. * @returns the recycled particle
  145393. */
  145394. recycleParticle(particle: CloudPoint): CloudPoint;
  145395. /**
  145396. * Updates a particle : this function should be overwritten by the user.
  145397. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145398. * doc :
  145399. * @example : just set a particle position or velocity and recycle conditions
  145400. * @param particle The particle to update
  145401. * @returns the updated particle
  145402. */
  145403. updateParticle(particle: CloudPoint): CloudPoint;
  145404. /**
  145405. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145406. * This does nothing and may be overwritten by the user.
  145407. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145408. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145409. * @param update the boolean update value actually passed to setParticles()
  145410. */
  145411. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145412. /**
  145413. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145414. * This will be passed three parameters.
  145415. * This does nothing and may be overwritten by the user.
  145416. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145417. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145418. * @param update the boolean update value actually passed to setParticles()
  145419. */
  145420. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145421. }
  145422. }
  145423. declare module BABYLON {
  145424. /**
  145425. * Represents one particle of a points cloud system.
  145426. */
  145427. export class CloudPoint {
  145428. /**
  145429. * particle global index
  145430. */
  145431. idx: number;
  145432. /**
  145433. * The color of the particle
  145434. */
  145435. color: Nullable<Color4>;
  145436. /**
  145437. * The world space position of the particle.
  145438. */
  145439. position: Vector3;
  145440. /**
  145441. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145442. */
  145443. rotation: Vector3;
  145444. /**
  145445. * The world space rotation quaternion of the particle.
  145446. */
  145447. rotationQuaternion: Nullable<Quaternion>;
  145448. /**
  145449. * The uv of the particle.
  145450. */
  145451. uv: Nullable<Vector2>;
  145452. /**
  145453. * The current speed of the particle.
  145454. */
  145455. velocity: Vector3;
  145456. /**
  145457. * The pivot point in the particle local space.
  145458. */
  145459. pivot: Vector3;
  145460. /**
  145461. * Must the particle be translated from its pivot point in its local space ?
  145462. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145463. * Default : false
  145464. */
  145465. translateFromPivot: boolean;
  145466. /**
  145467. * Index of this particle in the global "positions" array (Internal use)
  145468. * @hidden
  145469. */
  145470. _pos: number;
  145471. /**
  145472. * @hidden Index of this particle in the global "indices" array (Internal use)
  145473. */
  145474. _ind: number;
  145475. /**
  145476. * Group this particle belongs to
  145477. */
  145478. _group: PointsGroup;
  145479. /**
  145480. * Group id of this particle
  145481. */
  145482. groupId: number;
  145483. /**
  145484. * Index of the particle in its group id (Internal use)
  145485. */
  145486. idxInGroup: number;
  145487. /**
  145488. * @hidden Particle BoundingInfo object (Internal use)
  145489. */
  145490. _boundingInfo: BoundingInfo;
  145491. /**
  145492. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145493. */
  145494. _pcs: PointsCloudSystem;
  145495. /**
  145496. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145497. */
  145498. _stillInvisible: boolean;
  145499. /**
  145500. * @hidden Last computed particle rotation matrix
  145501. */
  145502. _rotationMatrix: number[];
  145503. /**
  145504. * Parent particle Id, if any.
  145505. * Default null.
  145506. */
  145507. parentId: Nullable<number>;
  145508. /**
  145509. * @hidden Internal global position in the PCS.
  145510. */
  145511. _globalPosition: Vector3;
  145512. /**
  145513. * Creates a Point Cloud object.
  145514. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145515. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145516. * @param group (PointsGroup) is the group the particle belongs to
  145517. * @param groupId (integer) is the group identifier in the PCS.
  145518. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145519. * @param pcs defines the PCS it is associated to
  145520. */
  145521. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145522. /**
  145523. * get point size
  145524. */
  145525. get size(): Vector3;
  145526. /**
  145527. * Set point size
  145528. */
  145529. set size(scale: Vector3);
  145530. /**
  145531. * Legacy support, changed quaternion to rotationQuaternion
  145532. */
  145533. get quaternion(): Nullable<Quaternion>;
  145534. /**
  145535. * Legacy support, changed quaternion to rotationQuaternion
  145536. */
  145537. set quaternion(q: Nullable<Quaternion>);
  145538. /**
  145539. * Returns a boolean. True if the particle intersects a mesh, else false
  145540. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145541. * @param target is the object (point or mesh) what the intersection is computed against
  145542. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145543. * @returns true if it intersects
  145544. */
  145545. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145546. /**
  145547. * get the rotation matrix of the particle
  145548. * @hidden
  145549. */
  145550. getRotationMatrix(m: Matrix): void;
  145551. }
  145552. /**
  145553. * Represents a group of points in a points cloud system
  145554. * * PCS internal tool, don't use it manually.
  145555. */
  145556. export class PointsGroup {
  145557. /**
  145558. * The group id
  145559. * @hidden
  145560. */
  145561. groupID: number;
  145562. /**
  145563. * image data for group (internal use)
  145564. * @hidden
  145565. */
  145566. _groupImageData: Nullable<ArrayBufferView>;
  145567. /**
  145568. * Image Width (internal use)
  145569. * @hidden
  145570. */
  145571. _groupImgWidth: number;
  145572. /**
  145573. * Image Height (internal use)
  145574. * @hidden
  145575. */
  145576. _groupImgHeight: number;
  145577. /**
  145578. * Custom position function (internal use)
  145579. * @hidden
  145580. */
  145581. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145582. /**
  145583. * density per facet for surface points
  145584. * @hidden
  145585. */
  145586. _groupDensity: number[];
  145587. /**
  145588. * Only when points are colored by texture carries pointer to texture list array
  145589. * @hidden
  145590. */
  145591. _textureNb: number;
  145592. /**
  145593. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145594. * PCS internal tool, don't use it manually.
  145595. * @hidden
  145596. */
  145597. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145598. }
  145599. }
  145600. declare module BABYLON {
  145601. interface Scene {
  145602. /** @hidden (Backing field) */
  145603. _physicsEngine: Nullable<IPhysicsEngine>;
  145604. /** @hidden */
  145605. _physicsTimeAccumulator: number;
  145606. /**
  145607. * Gets the current physics engine
  145608. * @returns a IPhysicsEngine or null if none attached
  145609. */
  145610. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145611. /**
  145612. * Enables physics to the current scene
  145613. * @param gravity defines the scene's gravity for the physics engine
  145614. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145615. * @return a boolean indicating if the physics engine was initialized
  145616. */
  145617. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145618. /**
  145619. * Disables and disposes the physics engine associated with the scene
  145620. */
  145621. disablePhysicsEngine(): void;
  145622. /**
  145623. * Gets a boolean indicating if there is an active physics engine
  145624. * @returns a boolean indicating if there is an active physics engine
  145625. */
  145626. isPhysicsEnabled(): boolean;
  145627. /**
  145628. * Deletes a physics compound impostor
  145629. * @param compound defines the compound to delete
  145630. */
  145631. deleteCompoundImpostor(compound: any): void;
  145632. /**
  145633. * An event triggered when physic simulation is about to be run
  145634. */
  145635. onBeforePhysicsObservable: Observable<Scene>;
  145636. /**
  145637. * An event triggered when physic simulation has been done
  145638. */
  145639. onAfterPhysicsObservable: Observable<Scene>;
  145640. }
  145641. interface AbstractMesh {
  145642. /** @hidden */
  145643. _physicsImpostor: Nullable<PhysicsImpostor>;
  145644. /**
  145645. * Gets or sets impostor used for physic simulation
  145646. * @see https://doc.babylonjs.com/features/physics_engine
  145647. */
  145648. physicsImpostor: Nullable<PhysicsImpostor>;
  145649. /**
  145650. * Gets the current physics impostor
  145651. * @see https://doc.babylonjs.com/features/physics_engine
  145652. * @returns a physics impostor or null
  145653. */
  145654. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145655. /** Apply a physic impulse to the mesh
  145656. * @param force defines the force to apply
  145657. * @param contactPoint defines where to apply the force
  145658. * @returns the current mesh
  145659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145660. */
  145661. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145662. /**
  145663. * Creates a physic joint between two meshes
  145664. * @param otherMesh defines the other mesh to use
  145665. * @param pivot1 defines the pivot to use on this mesh
  145666. * @param pivot2 defines the pivot to use on the other mesh
  145667. * @param options defines additional options (can be plugin dependent)
  145668. * @returns the current mesh
  145669. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145670. */
  145671. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145672. /** @hidden */
  145673. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145674. }
  145675. /**
  145676. * Defines the physics engine scene component responsible to manage a physics engine
  145677. */
  145678. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145679. /**
  145680. * The component name helpful to identify the component in the list of scene components.
  145681. */
  145682. readonly name: string;
  145683. /**
  145684. * The scene the component belongs to.
  145685. */
  145686. scene: Scene;
  145687. /**
  145688. * Creates a new instance of the component for the given scene
  145689. * @param scene Defines the scene to register the component in
  145690. */
  145691. constructor(scene: Scene);
  145692. /**
  145693. * Registers the component in a given scene
  145694. */
  145695. register(): void;
  145696. /**
  145697. * Rebuilds the elements related to this component in case of
  145698. * context lost for instance.
  145699. */
  145700. rebuild(): void;
  145701. /**
  145702. * Disposes the component and the associated ressources
  145703. */
  145704. dispose(): void;
  145705. }
  145706. }
  145707. declare module BABYLON {
  145708. /**
  145709. * A helper for physics simulations
  145710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145711. */
  145712. export class PhysicsHelper {
  145713. private _scene;
  145714. private _physicsEngine;
  145715. /**
  145716. * Initializes the Physics helper
  145717. * @param scene Babylon.js scene
  145718. */
  145719. constructor(scene: Scene);
  145720. /**
  145721. * Applies a radial explosion impulse
  145722. * @param origin the origin of the explosion
  145723. * @param radiusOrEventOptions the radius or the options of radial explosion
  145724. * @param strength the explosion strength
  145725. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145726. * @returns A physics radial explosion event, or null
  145727. */
  145728. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145729. /**
  145730. * Applies a radial explosion force
  145731. * @param origin the origin of the explosion
  145732. * @param radiusOrEventOptions the radius or the options of radial explosion
  145733. * @param strength the explosion strength
  145734. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145735. * @returns A physics radial explosion event, or null
  145736. */
  145737. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145738. /**
  145739. * Creates a gravitational field
  145740. * @param origin the origin of the explosion
  145741. * @param radiusOrEventOptions the radius or the options of radial explosion
  145742. * @param strength the explosion strength
  145743. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145744. * @returns A physics gravitational field event, or null
  145745. */
  145746. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145747. /**
  145748. * Creates a physics updraft event
  145749. * @param origin the origin of the updraft
  145750. * @param radiusOrEventOptions the radius or the options of the updraft
  145751. * @param strength the strength of the updraft
  145752. * @param height the height of the updraft
  145753. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145754. * @returns A physics updraft event, or null
  145755. */
  145756. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145757. /**
  145758. * Creates a physics vortex event
  145759. * @param origin the of the vortex
  145760. * @param radiusOrEventOptions the radius or the options of the vortex
  145761. * @param strength the strength of the vortex
  145762. * @param height the height of the vortex
  145763. * @returns a Physics vortex event, or null
  145764. * A physics vortex event or null
  145765. */
  145766. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145767. }
  145768. /**
  145769. * Represents a physics radial explosion event
  145770. */
  145771. class PhysicsRadialExplosionEvent {
  145772. private _scene;
  145773. private _options;
  145774. private _sphere;
  145775. private _dataFetched;
  145776. /**
  145777. * Initializes a radial explosioin event
  145778. * @param _scene BabylonJS scene
  145779. * @param _options The options for the vortex event
  145780. */
  145781. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145782. /**
  145783. * Returns the data related to the radial explosion event (sphere).
  145784. * @returns The radial explosion event data
  145785. */
  145786. getData(): PhysicsRadialExplosionEventData;
  145787. /**
  145788. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145789. * @param impostor A physics imposter
  145790. * @param origin the origin of the explosion
  145791. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145792. */
  145793. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145794. /**
  145795. * Triggers affecterd impostors callbacks
  145796. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145797. */
  145798. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145799. /**
  145800. * Disposes the sphere.
  145801. * @param force Specifies if the sphere should be disposed by force
  145802. */
  145803. dispose(force?: boolean): void;
  145804. /*** Helpers ***/
  145805. private _prepareSphere;
  145806. private _intersectsWithSphere;
  145807. }
  145808. /**
  145809. * Represents a gravitational field event
  145810. */
  145811. class PhysicsGravitationalFieldEvent {
  145812. private _physicsHelper;
  145813. private _scene;
  145814. private _origin;
  145815. private _options;
  145816. private _tickCallback;
  145817. private _sphere;
  145818. private _dataFetched;
  145819. /**
  145820. * Initializes the physics gravitational field event
  145821. * @param _physicsHelper A physics helper
  145822. * @param _scene BabylonJS scene
  145823. * @param _origin The origin position of the gravitational field event
  145824. * @param _options The options for the vortex event
  145825. */
  145826. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145827. /**
  145828. * Returns the data related to the gravitational field event (sphere).
  145829. * @returns A gravitational field event
  145830. */
  145831. getData(): PhysicsGravitationalFieldEventData;
  145832. /**
  145833. * Enables the gravitational field.
  145834. */
  145835. enable(): void;
  145836. /**
  145837. * Disables the gravitational field.
  145838. */
  145839. disable(): void;
  145840. /**
  145841. * Disposes the sphere.
  145842. * @param force The force to dispose from the gravitational field event
  145843. */
  145844. dispose(force?: boolean): void;
  145845. private _tick;
  145846. }
  145847. /**
  145848. * Represents a physics updraft event
  145849. */
  145850. class PhysicsUpdraftEvent {
  145851. private _scene;
  145852. private _origin;
  145853. private _options;
  145854. private _physicsEngine;
  145855. private _originTop;
  145856. private _originDirection;
  145857. private _tickCallback;
  145858. private _cylinder;
  145859. private _cylinderPosition;
  145860. private _dataFetched;
  145861. /**
  145862. * Initializes the physics updraft event
  145863. * @param _scene BabylonJS scene
  145864. * @param _origin The origin position of the updraft
  145865. * @param _options The options for the updraft event
  145866. */
  145867. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145868. /**
  145869. * Returns the data related to the updraft event (cylinder).
  145870. * @returns A physics updraft event
  145871. */
  145872. getData(): PhysicsUpdraftEventData;
  145873. /**
  145874. * Enables the updraft.
  145875. */
  145876. enable(): void;
  145877. /**
  145878. * Disables the updraft.
  145879. */
  145880. disable(): void;
  145881. /**
  145882. * Disposes the cylinder.
  145883. * @param force Specifies if the updraft should be disposed by force
  145884. */
  145885. dispose(force?: boolean): void;
  145886. private getImpostorHitData;
  145887. private _tick;
  145888. /*** Helpers ***/
  145889. private _prepareCylinder;
  145890. private _intersectsWithCylinder;
  145891. }
  145892. /**
  145893. * Represents a physics vortex event
  145894. */
  145895. class PhysicsVortexEvent {
  145896. private _scene;
  145897. private _origin;
  145898. private _options;
  145899. private _physicsEngine;
  145900. private _originTop;
  145901. private _tickCallback;
  145902. private _cylinder;
  145903. private _cylinderPosition;
  145904. private _dataFetched;
  145905. /**
  145906. * Initializes the physics vortex event
  145907. * @param _scene The BabylonJS scene
  145908. * @param _origin The origin position of the vortex
  145909. * @param _options The options for the vortex event
  145910. */
  145911. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145912. /**
  145913. * Returns the data related to the vortex event (cylinder).
  145914. * @returns The physics vortex event data
  145915. */
  145916. getData(): PhysicsVortexEventData;
  145917. /**
  145918. * Enables the vortex.
  145919. */
  145920. enable(): void;
  145921. /**
  145922. * Disables the cortex.
  145923. */
  145924. disable(): void;
  145925. /**
  145926. * Disposes the sphere.
  145927. * @param force
  145928. */
  145929. dispose(force?: boolean): void;
  145930. private getImpostorHitData;
  145931. private _tick;
  145932. /*** Helpers ***/
  145933. private _prepareCylinder;
  145934. private _intersectsWithCylinder;
  145935. }
  145936. /**
  145937. * Options fot the radial explosion event
  145938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145939. */
  145940. export class PhysicsRadialExplosionEventOptions {
  145941. /**
  145942. * The radius of the sphere for the radial explosion.
  145943. */
  145944. radius: number;
  145945. /**
  145946. * The strenth of the explosion.
  145947. */
  145948. strength: number;
  145949. /**
  145950. * The strenght of the force in correspondence to the distance of the affected object
  145951. */
  145952. falloff: PhysicsRadialImpulseFalloff;
  145953. /**
  145954. * Sphere options for the radial explosion.
  145955. */
  145956. sphere: {
  145957. segments: number;
  145958. diameter: number;
  145959. };
  145960. /**
  145961. * Sphere options for the radial explosion.
  145962. */
  145963. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145964. }
  145965. /**
  145966. * Options fot the updraft event
  145967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145968. */
  145969. export class PhysicsUpdraftEventOptions {
  145970. /**
  145971. * The radius of the cylinder for the vortex
  145972. */
  145973. radius: number;
  145974. /**
  145975. * The strenth of the updraft.
  145976. */
  145977. strength: number;
  145978. /**
  145979. * The height of the cylinder for the updraft.
  145980. */
  145981. height: number;
  145982. /**
  145983. * The mode for the the updraft.
  145984. */
  145985. updraftMode: PhysicsUpdraftMode;
  145986. }
  145987. /**
  145988. * Options fot the vortex event
  145989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145990. */
  145991. export class PhysicsVortexEventOptions {
  145992. /**
  145993. * The radius of the cylinder for the vortex
  145994. */
  145995. radius: number;
  145996. /**
  145997. * The strenth of the vortex.
  145998. */
  145999. strength: number;
  146000. /**
  146001. * The height of the cylinder for the vortex.
  146002. */
  146003. height: number;
  146004. /**
  146005. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146006. */
  146007. centripetalForceThreshold: number;
  146008. /**
  146009. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146010. */
  146011. centripetalForceMultiplier: number;
  146012. /**
  146013. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146014. */
  146015. centrifugalForceMultiplier: number;
  146016. /**
  146017. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146018. */
  146019. updraftForceMultiplier: number;
  146020. }
  146021. /**
  146022. * The strenght of the force in correspondence to the distance of the affected object
  146023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146024. */
  146025. export enum PhysicsRadialImpulseFalloff {
  146026. /** Defines that impulse is constant in strength across it's whole radius */
  146027. Constant = 0,
  146028. /** Defines that impulse gets weaker if it's further from the origin */
  146029. Linear = 1
  146030. }
  146031. /**
  146032. * The strength of the force in correspondence to the distance of the affected object
  146033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146034. */
  146035. export enum PhysicsUpdraftMode {
  146036. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146037. Center = 0,
  146038. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146039. Perpendicular = 1
  146040. }
  146041. /**
  146042. * Interface for a physics hit data
  146043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146044. */
  146045. export interface PhysicsHitData {
  146046. /**
  146047. * The force applied at the contact point
  146048. */
  146049. force: Vector3;
  146050. /**
  146051. * The contact point
  146052. */
  146053. contactPoint: Vector3;
  146054. /**
  146055. * The distance from the origin to the contact point
  146056. */
  146057. distanceFromOrigin: number;
  146058. }
  146059. /**
  146060. * Interface for radial explosion event data
  146061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146062. */
  146063. export interface PhysicsRadialExplosionEventData {
  146064. /**
  146065. * A sphere used for the radial explosion event
  146066. */
  146067. sphere: Mesh;
  146068. }
  146069. /**
  146070. * Interface for gravitational field event data
  146071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146072. */
  146073. export interface PhysicsGravitationalFieldEventData {
  146074. /**
  146075. * A sphere mesh used for the gravitational field event
  146076. */
  146077. sphere: Mesh;
  146078. }
  146079. /**
  146080. * Interface for updraft event data
  146081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146082. */
  146083. export interface PhysicsUpdraftEventData {
  146084. /**
  146085. * A cylinder used for the updraft event
  146086. */
  146087. cylinder: Mesh;
  146088. }
  146089. /**
  146090. * Interface for vortex event data
  146091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146092. */
  146093. export interface PhysicsVortexEventData {
  146094. /**
  146095. * A cylinder used for the vortex event
  146096. */
  146097. cylinder: Mesh;
  146098. }
  146099. /**
  146100. * Interface for an affected physics impostor
  146101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146102. */
  146103. export interface PhysicsAffectedImpostorWithData {
  146104. /**
  146105. * The impostor affected by the effect
  146106. */
  146107. impostor: PhysicsImpostor;
  146108. /**
  146109. * The data about the hit/horce from the explosion
  146110. */
  146111. hitData: PhysicsHitData;
  146112. }
  146113. }
  146114. declare module BABYLON {
  146115. /** @hidden */
  146116. export var blackAndWhitePixelShader: {
  146117. name: string;
  146118. shader: string;
  146119. };
  146120. }
  146121. declare module BABYLON {
  146122. /**
  146123. * Post process used to render in black and white
  146124. */
  146125. export class BlackAndWhitePostProcess extends PostProcess {
  146126. /**
  146127. * Linear about to convert he result to black and white (default: 1)
  146128. */
  146129. degree: number;
  146130. /**
  146131. * Creates a black and white post process
  146132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146133. * @param name The name of the effect.
  146134. * @param options The required width/height ratio to downsize to before computing the render pass.
  146135. * @param camera The camera to apply the render pass to.
  146136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146137. * @param engine The engine which the post process will be applied. (default: current engine)
  146138. * @param reusable If the post process can be reused on the same frame. (default: false)
  146139. */
  146140. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146141. }
  146142. }
  146143. declare module BABYLON {
  146144. /**
  146145. * This represents a set of one or more post processes in Babylon.
  146146. * A post process can be used to apply a shader to a texture after it is rendered.
  146147. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146148. */
  146149. export class PostProcessRenderEffect {
  146150. private _postProcesses;
  146151. private _getPostProcesses;
  146152. private _singleInstance;
  146153. private _cameras;
  146154. private _indicesForCamera;
  146155. /**
  146156. * Name of the effect
  146157. * @hidden
  146158. */
  146159. _name: string;
  146160. /**
  146161. * Instantiates a post process render effect.
  146162. * A post process can be used to apply a shader to a texture after it is rendered.
  146163. * @param engine The engine the effect is tied to
  146164. * @param name The name of the effect
  146165. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146166. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146167. */
  146168. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146169. /**
  146170. * Checks if all the post processes in the effect are supported.
  146171. */
  146172. get isSupported(): boolean;
  146173. /**
  146174. * Updates the current state of the effect
  146175. * @hidden
  146176. */
  146177. _update(): void;
  146178. /**
  146179. * Attaches the effect on cameras
  146180. * @param cameras The camera to attach to.
  146181. * @hidden
  146182. */
  146183. _attachCameras(cameras: Camera): void;
  146184. /**
  146185. * Attaches the effect on cameras
  146186. * @param cameras The camera to attach to.
  146187. * @hidden
  146188. */
  146189. _attachCameras(cameras: Camera[]): void;
  146190. /**
  146191. * Detaches the effect on cameras
  146192. * @param cameras The camera to detatch from.
  146193. * @hidden
  146194. */
  146195. _detachCameras(cameras: Camera): void;
  146196. /**
  146197. * Detatches the effect on cameras
  146198. * @param cameras The camera to detatch from.
  146199. * @hidden
  146200. */
  146201. _detachCameras(cameras: Camera[]): void;
  146202. /**
  146203. * Enables the effect on given cameras
  146204. * @param cameras The camera to enable.
  146205. * @hidden
  146206. */
  146207. _enable(cameras: Camera): void;
  146208. /**
  146209. * Enables the effect on given cameras
  146210. * @param cameras The camera to enable.
  146211. * @hidden
  146212. */
  146213. _enable(cameras: Nullable<Camera[]>): void;
  146214. /**
  146215. * Disables the effect on the given cameras
  146216. * @param cameras The camera to disable.
  146217. * @hidden
  146218. */
  146219. _disable(cameras: Camera): void;
  146220. /**
  146221. * Disables the effect on the given cameras
  146222. * @param cameras The camera to disable.
  146223. * @hidden
  146224. */
  146225. _disable(cameras: Nullable<Camera[]>): void;
  146226. /**
  146227. * Gets a list of the post processes contained in the effect.
  146228. * @param camera The camera to get the post processes on.
  146229. * @returns The list of the post processes in the effect.
  146230. */
  146231. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146232. }
  146233. }
  146234. declare module BABYLON {
  146235. /** @hidden */
  146236. export var extractHighlightsPixelShader: {
  146237. name: string;
  146238. shader: string;
  146239. };
  146240. }
  146241. declare module BABYLON {
  146242. /**
  146243. * 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.
  146244. */
  146245. export class ExtractHighlightsPostProcess extends PostProcess {
  146246. /**
  146247. * The luminance threshold, pixels below this value will be set to black.
  146248. */
  146249. threshold: number;
  146250. /** @hidden */
  146251. _exposure: number;
  146252. /**
  146253. * Post process which has the input texture to be used when performing highlight extraction
  146254. * @hidden
  146255. */
  146256. _inputPostProcess: Nullable<PostProcess>;
  146257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146258. }
  146259. }
  146260. declare module BABYLON {
  146261. /** @hidden */
  146262. export var bloomMergePixelShader: {
  146263. name: string;
  146264. shader: string;
  146265. };
  146266. }
  146267. declare module BABYLON {
  146268. /**
  146269. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146270. */
  146271. export class BloomMergePostProcess extends PostProcess {
  146272. /** Weight of the bloom to be added to the original input. */
  146273. weight: number;
  146274. /**
  146275. * Creates a new instance of @see BloomMergePostProcess
  146276. * @param name The name of the effect.
  146277. * @param originalFromInput Post process which's input will be used for the merge.
  146278. * @param blurred Blurred highlights post process which's output will be used.
  146279. * @param weight Weight of the bloom to be added to the original input.
  146280. * @param options The required width/height ratio to downsize to before computing the render pass.
  146281. * @param camera The camera to apply the render pass to.
  146282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146283. * @param engine The engine which the post process will be applied. (default: current engine)
  146284. * @param reusable If the post process can be reused on the same frame. (default: false)
  146285. * @param textureType Type of textures used when performing the post process. (default: 0)
  146286. * @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)
  146287. */
  146288. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146289. /** Weight of the bloom to be added to the original input. */
  146290. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146291. }
  146292. }
  146293. declare module BABYLON {
  146294. /**
  146295. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146296. */
  146297. export class BloomEffect extends PostProcessRenderEffect {
  146298. private bloomScale;
  146299. /**
  146300. * @hidden Internal
  146301. */
  146302. _effects: Array<PostProcess>;
  146303. /**
  146304. * @hidden Internal
  146305. */
  146306. _downscale: ExtractHighlightsPostProcess;
  146307. private _blurX;
  146308. private _blurY;
  146309. private _merge;
  146310. /**
  146311. * The luminance threshold to find bright areas of the image to bloom.
  146312. */
  146313. get threshold(): number;
  146314. set threshold(value: number);
  146315. /**
  146316. * The strength of the bloom.
  146317. */
  146318. get weight(): number;
  146319. set weight(value: number);
  146320. /**
  146321. * Specifies the size of the bloom blur kernel, relative to the final output size
  146322. */
  146323. get kernel(): number;
  146324. set kernel(value: number);
  146325. /**
  146326. * Creates a new instance of @see BloomEffect
  146327. * @param scene The scene the effect belongs to.
  146328. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146329. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146330. * @param bloomWeight The the strength of bloom.
  146331. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146332. * @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)
  146333. */
  146334. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146335. /**
  146336. * Disposes each of the internal effects for a given camera.
  146337. * @param camera The camera to dispose the effect on.
  146338. */
  146339. disposeEffects(camera: Camera): void;
  146340. /**
  146341. * @hidden Internal
  146342. */
  146343. _updateEffects(): void;
  146344. /**
  146345. * Internal
  146346. * @returns if all the contained post processes are ready.
  146347. * @hidden
  146348. */
  146349. _isReady(): boolean;
  146350. }
  146351. }
  146352. declare module BABYLON {
  146353. /** @hidden */
  146354. export var chromaticAberrationPixelShader: {
  146355. name: string;
  146356. shader: string;
  146357. };
  146358. }
  146359. declare module BABYLON {
  146360. /**
  146361. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146362. */
  146363. export class ChromaticAberrationPostProcess extends PostProcess {
  146364. /**
  146365. * The amount of seperation of rgb channels (default: 30)
  146366. */
  146367. aberrationAmount: number;
  146368. /**
  146369. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146370. */
  146371. radialIntensity: number;
  146372. /**
  146373. * 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))
  146374. */
  146375. direction: Vector2;
  146376. /**
  146377. * 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))
  146378. */
  146379. centerPosition: Vector2;
  146380. /**
  146381. * Creates a new instance ChromaticAberrationPostProcess
  146382. * @param name The name of the effect.
  146383. * @param screenWidth The width of the screen to apply the effect on.
  146384. * @param screenHeight The height of the screen to apply the effect on.
  146385. * @param options The required width/height ratio to downsize to before computing the render pass.
  146386. * @param camera The camera to apply the render pass to.
  146387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146388. * @param engine The engine which the post process will be applied. (default: current engine)
  146389. * @param reusable If the post process can be reused on the same frame. (default: false)
  146390. * @param textureType Type of textures used when performing the post process. (default: 0)
  146391. * @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)
  146392. */
  146393. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146394. }
  146395. }
  146396. declare module BABYLON {
  146397. /** @hidden */
  146398. export var circleOfConfusionPixelShader: {
  146399. name: string;
  146400. shader: string;
  146401. };
  146402. }
  146403. declare module BABYLON {
  146404. /**
  146405. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146406. */
  146407. export class CircleOfConfusionPostProcess extends PostProcess {
  146408. /**
  146409. * 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.
  146410. */
  146411. lensSize: number;
  146412. /**
  146413. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146414. */
  146415. fStop: number;
  146416. /**
  146417. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146418. */
  146419. focusDistance: number;
  146420. /**
  146421. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146422. */
  146423. focalLength: number;
  146424. private _depthTexture;
  146425. /**
  146426. * Creates a new instance CircleOfConfusionPostProcess
  146427. * @param name The name of the effect.
  146428. * @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.
  146429. * @param options The required width/height ratio to downsize to before computing the render pass.
  146430. * @param camera The camera to apply the render pass to.
  146431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146432. * @param engine The engine which the post process will be applied. (default: current engine)
  146433. * @param reusable If the post process can be reused on the same frame. (default: false)
  146434. * @param textureType Type of textures used when performing the post process. (default: 0)
  146435. * @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)
  146436. */
  146437. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146438. /**
  146439. * 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.
  146440. */
  146441. set depthTexture(value: RenderTargetTexture);
  146442. }
  146443. }
  146444. declare module BABYLON {
  146445. /** @hidden */
  146446. export var colorCorrectionPixelShader: {
  146447. name: string;
  146448. shader: string;
  146449. };
  146450. }
  146451. declare module BABYLON {
  146452. /**
  146453. *
  146454. * This post-process allows the modification of rendered colors by using
  146455. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146456. *
  146457. * The object needs to be provided an url to a texture containing the color
  146458. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146459. * Use an image editing software to tweak the LUT to match your needs.
  146460. *
  146461. * For an example of a color LUT, see here:
  146462. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146463. * For explanations on color grading, see here:
  146464. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146465. *
  146466. */
  146467. export class ColorCorrectionPostProcess extends PostProcess {
  146468. private _colorTableTexture;
  146469. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146470. }
  146471. }
  146472. declare module BABYLON {
  146473. /** @hidden */
  146474. export var convolutionPixelShader: {
  146475. name: string;
  146476. shader: string;
  146477. };
  146478. }
  146479. declare module BABYLON {
  146480. /**
  146481. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146482. * input texture to perform effects such as edge detection or sharpening
  146483. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146484. */
  146485. export class ConvolutionPostProcess extends PostProcess {
  146486. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146487. kernel: number[];
  146488. /**
  146489. * Creates a new instance ConvolutionPostProcess
  146490. * @param name The name of the effect.
  146491. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146492. * @param options The required width/height ratio to downsize to before computing the render pass.
  146493. * @param camera The camera to apply the render pass to.
  146494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146495. * @param engine The engine which the post process will be applied. (default: current engine)
  146496. * @param reusable If the post process can be reused on the same frame. (default: false)
  146497. * @param textureType Type of textures used when performing the post process. (default: 0)
  146498. */
  146499. constructor(name: string,
  146500. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146501. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146502. /**
  146503. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146504. */
  146505. static EdgeDetect0Kernel: number[];
  146506. /**
  146507. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146508. */
  146509. static EdgeDetect1Kernel: number[];
  146510. /**
  146511. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146512. */
  146513. static EdgeDetect2Kernel: number[];
  146514. /**
  146515. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146516. */
  146517. static SharpenKernel: number[];
  146518. /**
  146519. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146520. */
  146521. static EmbossKernel: number[];
  146522. /**
  146523. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146524. */
  146525. static GaussianKernel: number[];
  146526. }
  146527. }
  146528. declare module BABYLON {
  146529. /**
  146530. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146531. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146532. * based on samples that have a large difference in distance than the center pixel.
  146533. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146534. */
  146535. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146536. direction: Vector2;
  146537. /**
  146538. * Creates a new instance CircleOfConfusionPostProcess
  146539. * @param name The name of the effect.
  146540. * @param scene The scene the effect belongs to.
  146541. * @param direction The direction the blur should be applied.
  146542. * @param kernel The size of the kernel used to blur.
  146543. * @param options The required width/height ratio to downsize to before computing the render pass.
  146544. * @param camera The camera to apply the render pass to.
  146545. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146546. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146548. * @param engine The engine which the post process will be applied. (default: current engine)
  146549. * @param reusable If the post process can be reused on the same frame. (default: false)
  146550. * @param textureType Type of textures used when performing the post process. (default: 0)
  146551. * @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)
  146552. */
  146553. 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);
  146554. }
  146555. }
  146556. declare module BABYLON {
  146557. /** @hidden */
  146558. export var depthOfFieldMergePixelShader: {
  146559. name: string;
  146560. shader: string;
  146561. };
  146562. }
  146563. declare module BABYLON {
  146564. /**
  146565. * Options to be set when merging outputs from the default pipeline.
  146566. */
  146567. export class DepthOfFieldMergePostProcessOptions {
  146568. /**
  146569. * The original image to merge on top of
  146570. */
  146571. originalFromInput: PostProcess;
  146572. /**
  146573. * Parameters to perform the merge of the depth of field effect
  146574. */
  146575. depthOfField?: {
  146576. circleOfConfusion: PostProcess;
  146577. blurSteps: Array<PostProcess>;
  146578. };
  146579. /**
  146580. * Parameters to perform the merge of bloom effect
  146581. */
  146582. bloom?: {
  146583. blurred: PostProcess;
  146584. weight: number;
  146585. };
  146586. }
  146587. /**
  146588. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146589. */
  146590. export class DepthOfFieldMergePostProcess extends PostProcess {
  146591. private blurSteps;
  146592. /**
  146593. * Creates a new instance of DepthOfFieldMergePostProcess
  146594. * @param name The name of the effect.
  146595. * @param originalFromInput Post process which's input will be used for the merge.
  146596. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146597. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146598. * @param options The required width/height ratio to downsize to before computing the render pass.
  146599. * @param camera The camera to apply the render pass to.
  146600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146601. * @param engine The engine which the post process will be applied. (default: current engine)
  146602. * @param reusable If the post process can be reused on the same frame. (default: false)
  146603. * @param textureType Type of textures used when performing the post process. (default: 0)
  146604. * @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)
  146605. */
  146606. 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);
  146607. /**
  146608. * Updates the effect with the current post process compile time values and recompiles the shader.
  146609. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146610. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146611. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146612. * @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
  146613. * @param onCompiled Called when the shader has been compiled.
  146614. * @param onError Called if there is an error when compiling a shader.
  146615. */
  146616. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146617. }
  146618. }
  146619. declare module BABYLON {
  146620. /**
  146621. * Specifies the level of max blur that should be applied when using the depth of field effect
  146622. */
  146623. export enum DepthOfFieldEffectBlurLevel {
  146624. /**
  146625. * Subtle blur
  146626. */
  146627. Low = 0,
  146628. /**
  146629. * Medium blur
  146630. */
  146631. Medium = 1,
  146632. /**
  146633. * Large blur
  146634. */
  146635. High = 2
  146636. }
  146637. /**
  146638. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146639. */
  146640. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146641. private _circleOfConfusion;
  146642. /**
  146643. * @hidden Internal, blurs from high to low
  146644. */
  146645. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146646. private _depthOfFieldBlurY;
  146647. private _dofMerge;
  146648. /**
  146649. * @hidden Internal post processes in depth of field effect
  146650. */
  146651. _effects: Array<PostProcess>;
  146652. /**
  146653. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146654. */
  146655. set focalLength(value: number);
  146656. get focalLength(): number;
  146657. /**
  146658. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146659. */
  146660. set fStop(value: number);
  146661. get fStop(): number;
  146662. /**
  146663. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146664. */
  146665. set focusDistance(value: number);
  146666. get focusDistance(): number;
  146667. /**
  146668. * 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.
  146669. */
  146670. set lensSize(value: number);
  146671. get lensSize(): number;
  146672. /**
  146673. * Creates a new instance DepthOfFieldEffect
  146674. * @param scene The scene the effect belongs to.
  146675. * @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.
  146676. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146677. * @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)
  146678. */
  146679. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146680. /**
  146681. * Get the current class name of the current effet
  146682. * @returns "DepthOfFieldEffect"
  146683. */
  146684. getClassName(): string;
  146685. /**
  146686. * 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.
  146687. */
  146688. set depthTexture(value: RenderTargetTexture);
  146689. /**
  146690. * Disposes each of the internal effects for a given camera.
  146691. * @param camera The camera to dispose the effect on.
  146692. */
  146693. disposeEffects(camera: Camera): void;
  146694. /**
  146695. * @hidden Internal
  146696. */
  146697. _updateEffects(): void;
  146698. /**
  146699. * Internal
  146700. * @returns if all the contained post processes are ready.
  146701. * @hidden
  146702. */
  146703. _isReady(): boolean;
  146704. }
  146705. }
  146706. declare module BABYLON {
  146707. /** @hidden */
  146708. export var displayPassPixelShader: {
  146709. name: string;
  146710. shader: string;
  146711. };
  146712. }
  146713. declare module BABYLON {
  146714. /**
  146715. * DisplayPassPostProcess which produces an output the same as it's input
  146716. */
  146717. export class DisplayPassPostProcess extends PostProcess {
  146718. /**
  146719. * Creates the DisplayPassPostProcess
  146720. * @param name The name of the effect.
  146721. * @param options The required width/height ratio to downsize to before computing the render pass.
  146722. * @param camera The camera to apply the render pass to.
  146723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146724. * @param engine The engine which the post process will be applied. (default: current engine)
  146725. * @param reusable If the post process can be reused on the same frame. (default: false)
  146726. */
  146727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146728. }
  146729. }
  146730. declare module BABYLON {
  146731. /** @hidden */
  146732. export var filterPixelShader: {
  146733. name: string;
  146734. shader: string;
  146735. };
  146736. }
  146737. declare module BABYLON {
  146738. /**
  146739. * Applies a kernel filter to the image
  146740. */
  146741. export class FilterPostProcess extends PostProcess {
  146742. /** The matrix to be applied to the image */
  146743. kernelMatrix: Matrix;
  146744. /**
  146745. *
  146746. * @param name The name of the effect.
  146747. * @param kernelMatrix The matrix to be applied to the image
  146748. * @param options The required width/height ratio to downsize to before computing the render pass.
  146749. * @param camera The camera to apply the render pass to.
  146750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146751. * @param engine The engine which the post process will be applied. (default: current engine)
  146752. * @param reusable If the post process can be reused on the same frame. (default: false)
  146753. */
  146754. constructor(name: string,
  146755. /** The matrix to be applied to the image */
  146756. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146757. }
  146758. }
  146759. declare module BABYLON {
  146760. /** @hidden */
  146761. export var fxaaPixelShader: {
  146762. name: string;
  146763. shader: string;
  146764. };
  146765. }
  146766. declare module BABYLON {
  146767. /** @hidden */
  146768. export var fxaaVertexShader: {
  146769. name: string;
  146770. shader: string;
  146771. };
  146772. }
  146773. declare module BABYLON {
  146774. /**
  146775. * Fxaa post process
  146776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146777. */
  146778. export class FxaaPostProcess extends PostProcess {
  146779. /** @hidden */
  146780. texelWidth: number;
  146781. /** @hidden */
  146782. texelHeight: number;
  146783. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146784. private _getDefines;
  146785. }
  146786. }
  146787. declare module BABYLON {
  146788. /** @hidden */
  146789. export var grainPixelShader: {
  146790. name: string;
  146791. shader: string;
  146792. };
  146793. }
  146794. declare module BABYLON {
  146795. /**
  146796. * The GrainPostProcess adds noise to the image at mid luminance levels
  146797. */
  146798. export class GrainPostProcess extends PostProcess {
  146799. /**
  146800. * The intensity of the grain added (default: 30)
  146801. */
  146802. intensity: number;
  146803. /**
  146804. * If the grain should be randomized on every frame
  146805. */
  146806. animated: boolean;
  146807. /**
  146808. * Creates a new instance of @see GrainPostProcess
  146809. * @param name The name of the effect.
  146810. * @param options The required width/height ratio to downsize to before computing the render pass.
  146811. * @param camera The camera to apply the render pass to.
  146812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146813. * @param engine The engine which the post process will be applied. (default: current engine)
  146814. * @param reusable If the post process can be reused on the same frame. (default: false)
  146815. * @param textureType Type of textures used when performing the post process. (default: 0)
  146816. * @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)
  146817. */
  146818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146819. }
  146820. }
  146821. declare module BABYLON {
  146822. /** @hidden */
  146823. export var highlightsPixelShader: {
  146824. name: string;
  146825. shader: string;
  146826. };
  146827. }
  146828. declare module BABYLON {
  146829. /**
  146830. * Extracts highlights from the image
  146831. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146832. */
  146833. export class HighlightsPostProcess extends PostProcess {
  146834. /**
  146835. * Extracts highlights from the image
  146836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146837. * @param name The name of the effect.
  146838. * @param options The required width/height ratio to downsize to before computing the render pass.
  146839. * @param camera The camera to apply the render pass to.
  146840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146841. * @param engine The engine which the post process will be applied. (default: current engine)
  146842. * @param reusable If the post process can be reused on the same frame. (default: false)
  146843. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146844. */
  146845. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146846. }
  146847. }
  146848. declare module BABYLON {
  146849. /** @hidden */
  146850. export var mrtFragmentDeclaration: {
  146851. name: string;
  146852. shader: string;
  146853. };
  146854. }
  146855. declare module BABYLON {
  146856. /** @hidden */
  146857. export var geometryPixelShader: {
  146858. name: string;
  146859. shader: string;
  146860. };
  146861. }
  146862. declare module BABYLON {
  146863. /** @hidden */
  146864. export var geometryVertexShader: {
  146865. name: string;
  146866. shader: string;
  146867. };
  146868. }
  146869. declare module BABYLON {
  146870. /** @hidden */
  146871. interface ISavedTransformationMatrix {
  146872. world: Matrix;
  146873. viewProjection: Matrix;
  146874. }
  146875. /**
  146876. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146877. */
  146878. export class GeometryBufferRenderer {
  146879. /**
  146880. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146881. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146882. */
  146883. static readonly POSITION_TEXTURE_TYPE: number;
  146884. /**
  146885. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146886. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146887. */
  146888. static readonly VELOCITY_TEXTURE_TYPE: number;
  146889. /**
  146890. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146891. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146892. */
  146893. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146894. /**
  146895. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146896. * in order to compute objects velocities when enableVelocity is set to "true"
  146897. * @hidden
  146898. */
  146899. _previousTransformationMatrices: {
  146900. [index: number]: ISavedTransformationMatrix;
  146901. };
  146902. /**
  146903. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146904. * in order to compute objects velocities when enableVelocity is set to "true"
  146905. * @hidden
  146906. */
  146907. _previousBonesTransformationMatrices: {
  146908. [index: number]: Float32Array;
  146909. };
  146910. /**
  146911. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146912. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146913. */
  146914. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146915. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146916. renderTransparentMeshes: boolean;
  146917. private _scene;
  146918. private _multiRenderTarget;
  146919. private _ratio;
  146920. private _enablePosition;
  146921. private _enableVelocity;
  146922. private _enableReflectivity;
  146923. private _positionIndex;
  146924. private _velocityIndex;
  146925. private _reflectivityIndex;
  146926. protected _effect: Effect;
  146927. protected _cachedDefines: string;
  146928. /**
  146929. * Set the render list (meshes to be rendered) used in the G buffer.
  146930. */
  146931. set renderList(meshes: Mesh[]);
  146932. /**
  146933. * Gets wether or not G buffer are supported by the running hardware.
  146934. * This requires draw buffer supports
  146935. */
  146936. get isSupported(): boolean;
  146937. /**
  146938. * Returns the index of the given texture type in the G-Buffer textures array
  146939. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146940. * @returns the index of the given texture type in the G-Buffer textures array
  146941. */
  146942. getTextureIndex(textureType: number): number;
  146943. /**
  146944. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146945. */
  146946. get enablePosition(): boolean;
  146947. /**
  146948. * Sets whether or not objects positions are enabled for the G buffer.
  146949. */
  146950. set enablePosition(enable: boolean);
  146951. /**
  146952. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146953. */
  146954. get enableVelocity(): boolean;
  146955. /**
  146956. * Sets wether or not objects velocities are enabled for the G buffer.
  146957. */
  146958. set enableVelocity(enable: boolean);
  146959. /**
  146960. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146961. */
  146962. get enableReflectivity(): boolean;
  146963. /**
  146964. * Sets wether or not objects roughness are enabled for the G buffer.
  146965. */
  146966. set enableReflectivity(enable: boolean);
  146967. /**
  146968. * Gets the scene associated with the buffer.
  146969. */
  146970. get scene(): Scene;
  146971. /**
  146972. * Gets the ratio used by the buffer during its creation.
  146973. * How big is the buffer related to the main canvas.
  146974. */
  146975. get ratio(): number;
  146976. /** @hidden */
  146977. static _SceneComponentInitialization: (scene: Scene) => void;
  146978. /**
  146979. * Creates a new G Buffer for the scene
  146980. * @param scene The scene the buffer belongs to
  146981. * @param ratio How big is the buffer related to the main canvas.
  146982. */
  146983. constructor(scene: Scene, ratio?: number);
  146984. /**
  146985. * Checks wether everything is ready to render a submesh to the G buffer.
  146986. * @param subMesh the submesh to check readiness for
  146987. * @param useInstances is the mesh drawn using instance or not
  146988. * @returns true if ready otherwise false
  146989. */
  146990. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146991. /**
  146992. * Gets the current underlying G Buffer.
  146993. * @returns the buffer
  146994. */
  146995. getGBuffer(): MultiRenderTarget;
  146996. /**
  146997. * Gets the number of samples used to render the buffer (anti aliasing).
  146998. */
  146999. get samples(): number;
  147000. /**
  147001. * Sets the number of samples used to render the buffer (anti aliasing).
  147002. */
  147003. set samples(value: number);
  147004. /**
  147005. * Disposes the renderer and frees up associated resources.
  147006. */
  147007. dispose(): void;
  147008. protected _createRenderTargets(): void;
  147009. private _copyBonesTransformationMatrices;
  147010. }
  147011. }
  147012. declare module BABYLON {
  147013. interface Scene {
  147014. /** @hidden (Backing field) */
  147015. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147016. /**
  147017. * Gets or Sets the current geometry buffer associated to the scene.
  147018. */
  147019. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147020. /**
  147021. * Enables a GeometryBufferRender and associates it with the scene
  147022. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147023. * @returns the GeometryBufferRenderer
  147024. */
  147025. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147026. /**
  147027. * Disables the GeometryBufferRender associated with the scene
  147028. */
  147029. disableGeometryBufferRenderer(): void;
  147030. }
  147031. /**
  147032. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147033. * in several rendering techniques.
  147034. */
  147035. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147036. /**
  147037. * The component name helpful to identify the component in the list of scene components.
  147038. */
  147039. readonly name: string;
  147040. /**
  147041. * The scene the component belongs to.
  147042. */
  147043. scene: Scene;
  147044. /**
  147045. * Creates a new instance of the component for the given scene
  147046. * @param scene Defines the scene to register the component in
  147047. */
  147048. constructor(scene: Scene);
  147049. /**
  147050. * Registers the component in a given scene
  147051. */
  147052. register(): void;
  147053. /**
  147054. * Rebuilds the elements related to this component in case of
  147055. * context lost for instance.
  147056. */
  147057. rebuild(): void;
  147058. /**
  147059. * Disposes the component and the associated ressources
  147060. */
  147061. dispose(): void;
  147062. private _gatherRenderTargets;
  147063. }
  147064. }
  147065. declare module BABYLON {
  147066. /** @hidden */
  147067. export var motionBlurPixelShader: {
  147068. name: string;
  147069. shader: string;
  147070. };
  147071. }
  147072. declare module BABYLON {
  147073. /**
  147074. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147075. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147076. * As an example, all you have to do is to create the post-process:
  147077. * var mb = new BABYLON.MotionBlurPostProcess(
  147078. * 'mb', // The name of the effect.
  147079. * scene, // The scene containing the objects to blur according to their velocity.
  147080. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147081. * camera // The camera to apply the render pass to.
  147082. * );
  147083. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147084. */
  147085. export class MotionBlurPostProcess extends PostProcess {
  147086. /**
  147087. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147088. */
  147089. motionStrength: number;
  147090. /**
  147091. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147092. */
  147093. get motionBlurSamples(): number;
  147094. /**
  147095. * Sets the number of iterations to be used for motion blur quality
  147096. */
  147097. set motionBlurSamples(samples: number);
  147098. private _motionBlurSamples;
  147099. private _geometryBufferRenderer;
  147100. /**
  147101. * Creates a new instance MotionBlurPostProcess
  147102. * @param name The name of the effect.
  147103. * @param scene The scene containing the objects to blur according to their velocity.
  147104. * @param options The required width/height ratio to downsize to before computing the render pass.
  147105. * @param camera The camera to apply the render pass to.
  147106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147107. * @param engine The engine which the post process will be applied. (default: current engine)
  147108. * @param reusable If the post process can be reused on the same frame. (default: false)
  147109. * @param textureType Type of textures used when performing the post process. (default: 0)
  147110. * @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)
  147111. */
  147112. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147113. /**
  147114. * Excludes the given skinned mesh from computing bones velocities.
  147115. * 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.
  147116. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147117. */
  147118. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147119. /**
  147120. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147121. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147122. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147123. */
  147124. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147125. /**
  147126. * Disposes the post process.
  147127. * @param camera The camera to dispose the post process on.
  147128. */
  147129. dispose(camera?: Camera): void;
  147130. }
  147131. }
  147132. declare module BABYLON {
  147133. /** @hidden */
  147134. export var refractionPixelShader: {
  147135. name: string;
  147136. shader: string;
  147137. };
  147138. }
  147139. declare module BABYLON {
  147140. /**
  147141. * Post process which applies a refractin texture
  147142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147143. */
  147144. export class RefractionPostProcess extends PostProcess {
  147145. /** the base color of the refraction (used to taint the rendering) */
  147146. color: Color3;
  147147. /** simulated refraction depth */
  147148. depth: number;
  147149. /** the coefficient of the base color (0 to remove base color tainting) */
  147150. colorLevel: number;
  147151. private _refTexture;
  147152. private _ownRefractionTexture;
  147153. /**
  147154. * Gets or sets the refraction texture
  147155. * Please note that you are responsible for disposing the texture if you set it manually
  147156. */
  147157. get refractionTexture(): Texture;
  147158. set refractionTexture(value: Texture);
  147159. /**
  147160. * Initializes the RefractionPostProcess
  147161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147162. * @param name The name of the effect.
  147163. * @param refractionTextureUrl Url of the refraction texture to use
  147164. * @param color the base color of the refraction (used to taint the rendering)
  147165. * @param depth simulated refraction depth
  147166. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147167. * @param camera The camera to apply the render pass to.
  147168. * @param options The required width/height ratio to downsize to before computing the render pass.
  147169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147170. * @param engine The engine which the post process will be applied. (default: current engine)
  147171. * @param reusable If the post process can be reused on the same frame. (default: false)
  147172. */
  147173. constructor(name: string, refractionTextureUrl: string,
  147174. /** the base color of the refraction (used to taint the rendering) */
  147175. color: Color3,
  147176. /** simulated refraction depth */
  147177. depth: number,
  147178. /** the coefficient of the base color (0 to remove base color tainting) */
  147179. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147180. /**
  147181. * Disposes of the post process
  147182. * @param camera Camera to dispose post process on
  147183. */
  147184. dispose(camera: Camera): void;
  147185. }
  147186. }
  147187. declare module BABYLON {
  147188. /** @hidden */
  147189. export var sharpenPixelShader: {
  147190. name: string;
  147191. shader: string;
  147192. };
  147193. }
  147194. declare module BABYLON {
  147195. /**
  147196. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147197. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147198. */
  147199. export class SharpenPostProcess extends PostProcess {
  147200. /**
  147201. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147202. */
  147203. colorAmount: number;
  147204. /**
  147205. * How much sharpness should be applied (default: 0.3)
  147206. */
  147207. edgeAmount: number;
  147208. /**
  147209. * Creates a new instance ConvolutionPostProcess
  147210. * @param name The name of the effect.
  147211. * @param options The required width/height ratio to downsize to before computing the render pass.
  147212. * @param camera The camera to apply the render pass to.
  147213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147214. * @param engine The engine which the post process will be applied. (default: current engine)
  147215. * @param reusable If the post process can be reused on the same frame. (default: false)
  147216. * @param textureType Type of textures used when performing the post process. (default: 0)
  147217. * @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)
  147218. */
  147219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147220. }
  147221. }
  147222. declare module BABYLON {
  147223. /**
  147224. * PostProcessRenderPipeline
  147225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147226. */
  147227. export class PostProcessRenderPipeline {
  147228. private engine;
  147229. private _renderEffects;
  147230. private _renderEffectsForIsolatedPass;
  147231. /**
  147232. * List of inspectable custom properties (used by the Inspector)
  147233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147234. */
  147235. inspectableCustomProperties: IInspectable[];
  147236. /**
  147237. * @hidden
  147238. */
  147239. protected _cameras: Camera[];
  147240. /** @hidden */
  147241. _name: string;
  147242. /**
  147243. * Gets pipeline name
  147244. */
  147245. get name(): string;
  147246. /** Gets the list of attached cameras */
  147247. get cameras(): Camera[];
  147248. /**
  147249. * Initializes a PostProcessRenderPipeline
  147250. * @param engine engine to add the pipeline to
  147251. * @param name name of the pipeline
  147252. */
  147253. constructor(engine: Engine, name: string);
  147254. /**
  147255. * Gets the class name
  147256. * @returns "PostProcessRenderPipeline"
  147257. */
  147258. getClassName(): string;
  147259. /**
  147260. * If all the render effects in the pipeline are supported
  147261. */
  147262. get isSupported(): boolean;
  147263. /**
  147264. * Adds an effect to the pipeline
  147265. * @param renderEffect the effect to add
  147266. */
  147267. addEffect(renderEffect: PostProcessRenderEffect): void;
  147268. /** @hidden */
  147269. _rebuild(): void;
  147270. /** @hidden */
  147271. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147272. /** @hidden */
  147273. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147274. /** @hidden */
  147275. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147276. /** @hidden */
  147277. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147278. /** @hidden */
  147279. _attachCameras(cameras: Camera, unique: boolean): void;
  147280. /** @hidden */
  147281. _attachCameras(cameras: Camera[], unique: boolean): void;
  147282. /** @hidden */
  147283. _detachCameras(cameras: Camera): void;
  147284. /** @hidden */
  147285. _detachCameras(cameras: Nullable<Camera[]>): void;
  147286. /** @hidden */
  147287. _update(): void;
  147288. /** @hidden */
  147289. _reset(): void;
  147290. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147291. /**
  147292. * Disposes of the pipeline
  147293. */
  147294. dispose(): void;
  147295. }
  147296. }
  147297. declare module BABYLON {
  147298. /**
  147299. * PostProcessRenderPipelineManager class
  147300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147301. */
  147302. export class PostProcessRenderPipelineManager {
  147303. private _renderPipelines;
  147304. /**
  147305. * Initializes a PostProcessRenderPipelineManager
  147306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147307. */
  147308. constructor();
  147309. /**
  147310. * Gets the list of supported render pipelines
  147311. */
  147312. get supportedPipelines(): PostProcessRenderPipeline[];
  147313. /**
  147314. * Adds a pipeline to the manager
  147315. * @param renderPipeline The pipeline to add
  147316. */
  147317. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147318. /**
  147319. * Attaches a camera to the pipeline
  147320. * @param renderPipelineName The name of the pipeline to attach to
  147321. * @param cameras the camera to attach
  147322. * @param unique if the camera can be attached multiple times to the pipeline
  147323. */
  147324. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147325. /**
  147326. * Detaches a camera from the pipeline
  147327. * @param renderPipelineName The name of the pipeline to detach from
  147328. * @param cameras the camera to detach
  147329. */
  147330. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147331. /**
  147332. * Enables an effect by name on a pipeline
  147333. * @param renderPipelineName the name of the pipeline to enable the effect in
  147334. * @param renderEffectName the name of the effect to enable
  147335. * @param cameras the cameras that the effect should be enabled on
  147336. */
  147337. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147338. /**
  147339. * Disables an effect by name on a pipeline
  147340. * @param renderPipelineName the name of the pipeline to disable the effect in
  147341. * @param renderEffectName the name of the effect to disable
  147342. * @param cameras the cameras that the effect should be disabled on
  147343. */
  147344. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147345. /**
  147346. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147347. */
  147348. update(): void;
  147349. /** @hidden */
  147350. _rebuild(): void;
  147351. /**
  147352. * Disposes of the manager and pipelines
  147353. */
  147354. dispose(): void;
  147355. }
  147356. }
  147357. declare module BABYLON {
  147358. interface Scene {
  147359. /** @hidden (Backing field) */
  147360. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147361. /**
  147362. * Gets the postprocess render pipeline manager
  147363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147364. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147365. */
  147366. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147367. }
  147368. /**
  147369. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147370. */
  147371. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147372. /**
  147373. * The component name helpfull to identify the component in the list of scene components.
  147374. */
  147375. readonly name: string;
  147376. /**
  147377. * The scene the component belongs to.
  147378. */
  147379. scene: Scene;
  147380. /**
  147381. * Creates a new instance of the component for the given scene
  147382. * @param scene Defines the scene to register the component in
  147383. */
  147384. constructor(scene: Scene);
  147385. /**
  147386. * Registers the component in a given scene
  147387. */
  147388. register(): void;
  147389. /**
  147390. * Rebuilds the elements related to this component in case of
  147391. * context lost for instance.
  147392. */
  147393. rebuild(): void;
  147394. /**
  147395. * Disposes the component and the associated ressources
  147396. */
  147397. dispose(): void;
  147398. private _gatherRenderTargets;
  147399. }
  147400. }
  147401. declare module BABYLON {
  147402. /**
  147403. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147404. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147405. */
  147406. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147407. private _scene;
  147408. private _camerasToBeAttached;
  147409. /**
  147410. * ID of the sharpen post process,
  147411. */
  147412. private readonly SharpenPostProcessId;
  147413. /**
  147414. * @ignore
  147415. * ID of the image processing post process;
  147416. */
  147417. readonly ImageProcessingPostProcessId: string;
  147418. /**
  147419. * @ignore
  147420. * ID of the Fast Approximate Anti-Aliasing post process;
  147421. */
  147422. readonly FxaaPostProcessId: string;
  147423. /**
  147424. * ID of the chromatic aberration post process,
  147425. */
  147426. private readonly ChromaticAberrationPostProcessId;
  147427. /**
  147428. * ID of the grain post process
  147429. */
  147430. private readonly GrainPostProcessId;
  147431. /**
  147432. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147433. */
  147434. sharpen: SharpenPostProcess;
  147435. private _sharpenEffect;
  147436. private bloom;
  147437. /**
  147438. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147439. */
  147440. depthOfField: DepthOfFieldEffect;
  147441. /**
  147442. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147443. */
  147444. fxaa: FxaaPostProcess;
  147445. /**
  147446. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147447. */
  147448. imageProcessing: ImageProcessingPostProcess;
  147449. /**
  147450. * Chromatic aberration post process which will shift rgb colors in the image
  147451. */
  147452. chromaticAberration: ChromaticAberrationPostProcess;
  147453. private _chromaticAberrationEffect;
  147454. /**
  147455. * Grain post process which add noise to the image
  147456. */
  147457. grain: GrainPostProcess;
  147458. private _grainEffect;
  147459. /**
  147460. * Glow post process which adds a glow to emissive areas of the image
  147461. */
  147462. private _glowLayer;
  147463. /**
  147464. * Animations which can be used to tweak settings over a period of time
  147465. */
  147466. animations: Animation[];
  147467. private _imageProcessingConfigurationObserver;
  147468. private _sharpenEnabled;
  147469. private _bloomEnabled;
  147470. private _depthOfFieldEnabled;
  147471. private _depthOfFieldBlurLevel;
  147472. private _fxaaEnabled;
  147473. private _imageProcessingEnabled;
  147474. private _defaultPipelineTextureType;
  147475. private _bloomScale;
  147476. private _chromaticAberrationEnabled;
  147477. private _grainEnabled;
  147478. private _buildAllowed;
  147479. /**
  147480. * Gets active scene
  147481. */
  147482. get scene(): Scene;
  147483. /**
  147484. * Enable or disable the sharpen process from the pipeline
  147485. */
  147486. set sharpenEnabled(enabled: boolean);
  147487. get sharpenEnabled(): boolean;
  147488. private _resizeObserver;
  147489. private _hardwareScaleLevel;
  147490. private _bloomKernel;
  147491. /**
  147492. * Specifies the size of the bloom blur kernel, relative to the final output size
  147493. */
  147494. get bloomKernel(): number;
  147495. set bloomKernel(value: number);
  147496. /**
  147497. * Specifies the weight of the bloom in the final rendering
  147498. */
  147499. private _bloomWeight;
  147500. /**
  147501. * Specifies the luma threshold for the area that will be blurred by the bloom
  147502. */
  147503. private _bloomThreshold;
  147504. private _hdr;
  147505. /**
  147506. * The strength of the bloom.
  147507. */
  147508. set bloomWeight(value: number);
  147509. get bloomWeight(): number;
  147510. /**
  147511. * The strength of the bloom.
  147512. */
  147513. set bloomThreshold(value: number);
  147514. get bloomThreshold(): number;
  147515. /**
  147516. * The scale of the bloom, lower value will provide better performance.
  147517. */
  147518. set bloomScale(value: number);
  147519. get bloomScale(): number;
  147520. /**
  147521. * Enable or disable the bloom from the pipeline
  147522. */
  147523. set bloomEnabled(enabled: boolean);
  147524. get bloomEnabled(): boolean;
  147525. private _rebuildBloom;
  147526. /**
  147527. * If the depth of field is enabled.
  147528. */
  147529. get depthOfFieldEnabled(): boolean;
  147530. set depthOfFieldEnabled(enabled: boolean);
  147531. /**
  147532. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147533. */
  147534. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147535. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147536. /**
  147537. * If the anti aliasing is enabled.
  147538. */
  147539. set fxaaEnabled(enabled: boolean);
  147540. get fxaaEnabled(): boolean;
  147541. private _samples;
  147542. /**
  147543. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147544. */
  147545. set samples(sampleCount: number);
  147546. get samples(): number;
  147547. /**
  147548. * If image processing is enabled.
  147549. */
  147550. set imageProcessingEnabled(enabled: boolean);
  147551. get imageProcessingEnabled(): boolean;
  147552. /**
  147553. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147554. */
  147555. set glowLayerEnabled(enabled: boolean);
  147556. get glowLayerEnabled(): boolean;
  147557. /**
  147558. * Gets the glow layer (or null if not defined)
  147559. */
  147560. get glowLayer(): Nullable<GlowLayer>;
  147561. /**
  147562. * Enable or disable the chromaticAberration process from the pipeline
  147563. */
  147564. set chromaticAberrationEnabled(enabled: boolean);
  147565. get chromaticAberrationEnabled(): boolean;
  147566. /**
  147567. * Enable or disable the grain process from the pipeline
  147568. */
  147569. set grainEnabled(enabled: boolean);
  147570. get grainEnabled(): boolean;
  147571. /**
  147572. * @constructor
  147573. * @param name - The rendering pipeline name (default: "")
  147574. * @param hdr - If high dynamic range textures should be used (default: true)
  147575. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147576. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147577. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147578. */
  147579. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147580. /**
  147581. * Get the class name
  147582. * @returns "DefaultRenderingPipeline"
  147583. */
  147584. getClassName(): string;
  147585. /**
  147586. * Force the compilation of the entire pipeline.
  147587. */
  147588. prepare(): void;
  147589. private _hasCleared;
  147590. private _prevPostProcess;
  147591. private _prevPrevPostProcess;
  147592. private _setAutoClearAndTextureSharing;
  147593. private _depthOfFieldSceneObserver;
  147594. private _buildPipeline;
  147595. private _disposePostProcesses;
  147596. /**
  147597. * Adds a camera to the pipeline
  147598. * @param camera the camera to be added
  147599. */
  147600. addCamera(camera: Camera): void;
  147601. /**
  147602. * Removes a camera from the pipeline
  147603. * @param camera the camera to remove
  147604. */
  147605. removeCamera(camera: Camera): void;
  147606. /**
  147607. * Dispose of the pipeline and stop all post processes
  147608. */
  147609. dispose(): void;
  147610. /**
  147611. * Serialize the rendering pipeline (Used when exporting)
  147612. * @returns the serialized object
  147613. */
  147614. serialize(): any;
  147615. /**
  147616. * Parse the serialized pipeline
  147617. * @param source Source pipeline.
  147618. * @param scene The scene to load the pipeline to.
  147619. * @param rootUrl The URL of the serialized pipeline.
  147620. * @returns An instantiated pipeline from the serialized object.
  147621. */
  147622. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147623. }
  147624. }
  147625. declare module BABYLON {
  147626. /** @hidden */
  147627. export var lensHighlightsPixelShader: {
  147628. name: string;
  147629. shader: string;
  147630. };
  147631. }
  147632. declare module BABYLON {
  147633. /** @hidden */
  147634. export var depthOfFieldPixelShader: {
  147635. name: string;
  147636. shader: string;
  147637. };
  147638. }
  147639. declare module BABYLON {
  147640. /**
  147641. * BABYLON.JS Chromatic Aberration GLSL Shader
  147642. * Author: Olivier Guyot
  147643. * Separates very slightly R, G and B colors on the edges of the screen
  147644. * Inspired by Francois Tarlier & Martins Upitis
  147645. */
  147646. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147647. /**
  147648. * @ignore
  147649. * The chromatic aberration PostProcess id in the pipeline
  147650. */
  147651. LensChromaticAberrationEffect: string;
  147652. /**
  147653. * @ignore
  147654. * The highlights enhancing PostProcess id in the pipeline
  147655. */
  147656. HighlightsEnhancingEffect: string;
  147657. /**
  147658. * @ignore
  147659. * The depth-of-field PostProcess id in the pipeline
  147660. */
  147661. LensDepthOfFieldEffect: string;
  147662. private _scene;
  147663. private _depthTexture;
  147664. private _grainTexture;
  147665. private _chromaticAberrationPostProcess;
  147666. private _highlightsPostProcess;
  147667. private _depthOfFieldPostProcess;
  147668. private _edgeBlur;
  147669. private _grainAmount;
  147670. private _chromaticAberration;
  147671. private _distortion;
  147672. private _highlightsGain;
  147673. private _highlightsThreshold;
  147674. private _dofDistance;
  147675. private _dofAperture;
  147676. private _dofDarken;
  147677. private _dofPentagon;
  147678. private _blurNoise;
  147679. /**
  147680. * @constructor
  147681. *
  147682. * Effect parameters are as follow:
  147683. * {
  147684. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147685. * edge_blur: number; // from 0 to x (1 for realism)
  147686. * distortion: number; // from 0 to x (1 for realism)
  147687. * grain_amount: number; // from 0 to 1
  147688. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147689. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147690. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147691. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147692. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147693. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147694. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147695. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147696. * }
  147697. * Note: if an effect parameter is unset, effect is disabled
  147698. *
  147699. * @param name The rendering pipeline name
  147700. * @param parameters - An object containing all parameters (see above)
  147701. * @param scene The scene linked to this pipeline
  147702. * @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)
  147703. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147704. */
  147705. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147706. /**
  147707. * Get the class name
  147708. * @returns "LensRenderingPipeline"
  147709. */
  147710. getClassName(): string;
  147711. /**
  147712. * Gets associated scene
  147713. */
  147714. get scene(): Scene;
  147715. /**
  147716. * Gets or sets the edge blur
  147717. */
  147718. get edgeBlur(): number;
  147719. set edgeBlur(value: number);
  147720. /**
  147721. * Gets or sets the grain amount
  147722. */
  147723. get grainAmount(): number;
  147724. set grainAmount(value: number);
  147725. /**
  147726. * Gets or sets the chromatic aberration amount
  147727. */
  147728. get chromaticAberration(): number;
  147729. set chromaticAberration(value: number);
  147730. /**
  147731. * Gets or sets the depth of field aperture
  147732. */
  147733. get dofAperture(): number;
  147734. set dofAperture(value: number);
  147735. /**
  147736. * Gets or sets the edge distortion
  147737. */
  147738. get edgeDistortion(): number;
  147739. set edgeDistortion(value: number);
  147740. /**
  147741. * Gets or sets the depth of field distortion
  147742. */
  147743. get dofDistortion(): number;
  147744. set dofDistortion(value: number);
  147745. /**
  147746. * Gets or sets the darken out of focus amount
  147747. */
  147748. get darkenOutOfFocus(): number;
  147749. set darkenOutOfFocus(value: number);
  147750. /**
  147751. * Gets or sets a boolean indicating if blur noise is enabled
  147752. */
  147753. get blurNoise(): boolean;
  147754. set blurNoise(value: boolean);
  147755. /**
  147756. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147757. */
  147758. get pentagonBokeh(): boolean;
  147759. set pentagonBokeh(value: boolean);
  147760. /**
  147761. * Gets or sets the highlight grain amount
  147762. */
  147763. get highlightsGain(): number;
  147764. set highlightsGain(value: number);
  147765. /**
  147766. * Gets or sets the highlight threshold
  147767. */
  147768. get highlightsThreshold(): number;
  147769. set highlightsThreshold(value: number);
  147770. /**
  147771. * Sets the amount of blur at the edges
  147772. * @param amount blur amount
  147773. */
  147774. setEdgeBlur(amount: number): void;
  147775. /**
  147776. * Sets edge blur to 0
  147777. */
  147778. disableEdgeBlur(): void;
  147779. /**
  147780. * Sets the amout of grain
  147781. * @param amount Amount of grain
  147782. */
  147783. setGrainAmount(amount: number): void;
  147784. /**
  147785. * Set grain amount to 0
  147786. */
  147787. disableGrain(): void;
  147788. /**
  147789. * Sets the chromatic aberration amount
  147790. * @param amount amount of chromatic aberration
  147791. */
  147792. setChromaticAberration(amount: number): void;
  147793. /**
  147794. * Sets chromatic aberration amount to 0
  147795. */
  147796. disableChromaticAberration(): void;
  147797. /**
  147798. * Sets the EdgeDistortion amount
  147799. * @param amount amount of EdgeDistortion
  147800. */
  147801. setEdgeDistortion(amount: number): void;
  147802. /**
  147803. * Sets edge distortion to 0
  147804. */
  147805. disableEdgeDistortion(): void;
  147806. /**
  147807. * Sets the FocusDistance amount
  147808. * @param amount amount of FocusDistance
  147809. */
  147810. setFocusDistance(amount: number): void;
  147811. /**
  147812. * Disables depth of field
  147813. */
  147814. disableDepthOfField(): void;
  147815. /**
  147816. * Sets the Aperture amount
  147817. * @param amount amount of Aperture
  147818. */
  147819. setAperture(amount: number): void;
  147820. /**
  147821. * Sets the DarkenOutOfFocus amount
  147822. * @param amount amount of DarkenOutOfFocus
  147823. */
  147824. setDarkenOutOfFocus(amount: number): void;
  147825. private _pentagonBokehIsEnabled;
  147826. /**
  147827. * Creates a pentagon bokeh effect
  147828. */
  147829. enablePentagonBokeh(): void;
  147830. /**
  147831. * Disables the pentagon bokeh effect
  147832. */
  147833. disablePentagonBokeh(): void;
  147834. /**
  147835. * Enables noise blur
  147836. */
  147837. enableNoiseBlur(): void;
  147838. /**
  147839. * Disables noise blur
  147840. */
  147841. disableNoiseBlur(): void;
  147842. /**
  147843. * Sets the HighlightsGain amount
  147844. * @param amount amount of HighlightsGain
  147845. */
  147846. setHighlightsGain(amount: number): void;
  147847. /**
  147848. * Sets the HighlightsThreshold amount
  147849. * @param amount amount of HighlightsThreshold
  147850. */
  147851. setHighlightsThreshold(amount: number): void;
  147852. /**
  147853. * Disables highlights
  147854. */
  147855. disableHighlights(): void;
  147856. /**
  147857. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147858. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147859. */
  147860. dispose(disableDepthRender?: boolean): void;
  147861. private _createChromaticAberrationPostProcess;
  147862. private _createHighlightsPostProcess;
  147863. private _createDepthOfFieldPostProcess;
  147864. private _createGrainTexture;
  147865. }
  147866. }
  147867. declare module BABYLON {
  147868. /** @hidden */
  147869. export var ssao2PixelShader: {
  147870. name: string;
  147871. shader: string;
  147872. };
  147873. }
  147874. declare module BABYLON {
  147875. /** @hidden */
  147876. export var ssaoCombinePixelShader: {
  147877. name: string;
  147878. shader: string;
  147879. };
  147880. }
  147881. declare module BABYLON {
  147882. /**
  147883. * Render pipeline to produce ssao effect
  147884. */
  147885. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147886. /**
  147887. * @ignore
  147888. * The PassPostProcess id in the pipeline that contains the original scene color
  147889. */
  147890. SSAOOriginalSceneColorEffect: string;
  147891. /**
  147892. * @ignore
  147893. * The SSAO PostProcess id in the pipeline
  147894. */
  147895. SSAORenderEffect: string;
  147896. /**
  147897. * @ignore
  147898. * The horizontal blur PostProcess id in the pipeline
  147899. */
  147900. SSAOBlurHRenderEffect: string;
  147901. /**
  147902. * @ignore
  147903. * The vertical blur PostProcess id in the pipeline
  147904. */
  147905. SSAOBlurVRenderEffect: string;
  147906. /**
  147907. * @ignore
  147908. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147909. */
  147910. SSAOCombineRenderEffect: string;
  147911. /**
  147912. * The output strength of the SSAO post-process. Default value is 1.0.
  147913. */
  147914. totalStrength: number;
  147915. /**
  147916. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147917. */
  147918. maxZ: number;
  147919. /**
  147920. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147921. */
  147922. minZAspect: number;
  147923. private _samples;
  147924. /**
  147925. * Number of samples used for the SSAO calculations. Default value is 8
  147926. */
  147927. set samples(n: number);
  147928. get samples(): number;
  147929. private _textureSamples;
  147930. /**
  147931. * Number of samples to use for antialiasing
  147932. */
  147933. set textureSamples(n: number);
  147934. get textureSamples(): number;
  147935. /**
  147936. * Ratio object used for SSAO ratio and blur ratio
  147937. */
  147938. private _ratio;
  147939. /**
  147940. * Dynamically generated sphere sampler.
  147941. */
  147942. private _sampleSphere;
  147943. /**
  147944. * Blur filter offsets
  147945. */
  147946. private _samplerOffsets;
  147947. private _expensiveBlur;
  147948. /**
  147949. * If bilateral blur should be used
  147950. */
  147951. set expensiveBlur(b: boolean);
  147952. get expensiveBlur(): boolean;
  147953. /**
  147954. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147955. */
  147956. radius: number;
  147957. /**
  147958. * The base color of the SSAO post-process
  147959. * The final result is "base + ssao" between [0, 1]
  147960. */
  147961. base: number;
  147962. /**
  147963. * Support test.
  147964. */
  147965. static get IsSupported(): boolean;
  147966. private _scene;
  147967. private _depthTexture;
  147968. private _normalTexture;
  147969. private _randomTexture;
  147970. private _originalColorPostProcess;
  147971. private _ssaoPostProcess;
  147972. private _blurHPostProcess;
  147973. private _blurVPostProcess;
  147974. private _ssaoCombinePostProcess;
  147975. /**
  147976. * Gets active scene
  147977. */
  147978. get scene(): Scene;
  147979. /**
  147980. * @constructor
  147981. * @param name The rendering pipeline name
  147982. * @param scene The scene linked to this pipeline
  147983. * @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 }
  147984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147985. */
  147986. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147987. /**
  147988. * Get the class name
  147989. * @returns "SSAO2RenderingPipeline"
  147990. */
  147991. getClassName(): string;
  147992. /**
  147993. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147994. */
  147995. dispose(disableGeometryBufferRenderer?: boolean): void;
  147996. private _createBlurPostProcess;
  147997. /** @hidden */
  147998. _rebuild(): void;
  147999. private _bits;
  148000. private _radicalInverse_VdC;
  148001. private _hammersley;
  148002. private _hemisphereSample_uniform;
  148003. private _generateHemisphere;
  148004. private _createSSAOPostProcess;
  148005. private _createSSAOCombinePostProcess;
  148006. private _createRandomTexture;
  148007. /**
  148008. * Serialize the rendering pipeline (Used when exporting)
  148009. * @returns the serialized object
  148010. */
  148011. serialize(): any;
  148012. /**
  148013. * Parse the serialized pipeline
  148014. * @param source Source pipeline.
  148015. * @param scene The scene to load the pipeline to.
  148016. * @param rootUrl The URL of the serialized pipeline.
  148017. * @returns An instantiated pipeline from the serialized object.
  148018. */
  148019. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148020. }
  148021. }
  148022. declare module BABYLON {
  148023. /** @hidden */
  148024. export var ssaoPixelShader: {
  148025. name: string;
  148026. shader: string;
  148027. };
  148028. }
  148029. declare module BABYLON {
  148030. /**
  148031. * Render pipeline to produce ssao effect
  148032. */
  148033. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148034. /**
  148035. * @ignore
  148036. * The PassPostProcess id in the pipeline that contains the original scene color
  148037. */
  148038. SSAOOriginalSceneColorEffect: string;
  148039. /**
  148040. * @ignore
  148041. * The SSAO PostProcess id in the pipeline
  148042. */
  148043. SSAORenderEffect: string;
  148044. /**
  148045. * @ignore
  148046. * The horizontal blur PostProcess id in the pipeline
  148047. */
  148048. SSAOBlurHRenderEffect: string;
  148049. /**
  148050. * @ignore
  148051. * The vertical blur PostProcess id in the pipeline
  148052. */
  148053. SSAOBlurVRenderEffect: string;
  148054. /**
  148055. * @ignore
  148056. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148057. */
  148058. SSAOCombineRenderEffect: string;
  148059. /**
  148060. * The output strength of the SSAO post-process. Default value is 1.0.
  148061. */
  148062. totalStrength: number;
  148063. /**
  148064. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148065. */
  148066. radius: number;
  148067. /**
  148068. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148069. * Must not be equal to fallOff and superior to fallOff.
  148070. * Default value is 0.0075
  148071. */
  148072. area: number;
  148073. /**
  148074. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148075. * Must not be equal to area and inferior to area.
  148076. * Default value is 0.000001
  148077. */
  148078. fallOff: number;
  148079. /**
  148080. * The base color of the SSAO post-process
  148081. * The final result is "base + ssao" between [0, 1]
  148082. */
  148083. base: number;
  148084. private _scene;
  148085. private _depthTexture;
  148086. private _randomTexture;
  148087. private _originalColorPostProcess;
  148088. private _ssaoPostProcess;
  148089. private _blurHPostProcess;
  148090. private _blurVPostProcess;
  148091. private _ssaoCombinePostProcess;
  148092. private _firstUpdate;
  148093. /**
  148094. * Gets active scene
  148095. */
  148096. get scene(): Scene;
  148097. /**
  148098. * @constructor
  148099. * @param name - The rendering pipeline name
  148100. * @param scene - The scene linked to this pipeline
  148101. * @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 }
  148102. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148103. */
  148104. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148105. /**
  148106. * Get the class name
  148107. * @returns "SSAORenderingPipeline"
  148108. */
  148109. getClassName(): string;
  148110. /**
  148111. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148112. */
  148113. dispose(disableDepthRender?: boolean): void;
  148114. private _createBlurPostProcess;
  148115. /** @hidden */
  148116. _rebuild(): void;
  148117. private _createSSAOPostProcess;
  148118. private _createSSAOCombinePostProcess;
  148119. private _createRandomTexture;
  148120. }
  148121. }
  148122. declare module BABYLON {
  148123. /** @hidden */
  148124. export var screenSpaceReflectionPixelShader: {
  148125. name: string;
  148126. shader: string;
  148127. };
  148128. }
  148129. declare module BABYLON {
  148130. /**
  148131. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148132. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148133. */
  148134. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148135. /**
  148136. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148137. */
  148138. threshold: number;
  148139. /**
  148140. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148141. */
  148142. strength: number;
  148143. /**
  148144. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148145. */
  148146. reflectionSpecularFalloffExponent: number;
  148147. /**
  148148. * 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]
  148149. */
  148150. step: number;
  148151. /**
  148152. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148153. */
  148154. roughnessFactor: number;
  148155. private _geometryBufferRenderer;
  148156. private _enableSmoothReflections;
  148157. private _reflectionSamples;
  148158. private _smoothSteps;
  148159. /**
  148160. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148161. * @param name The name of the effect.
  148162. * @param scene The scene containing the objects to calculate reflections.
  148163. * @param options The required width/height ratio to downsize to before computing the render pass.
  148164. * @param camera The camera to apply the render pass to.
  148165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148166. * @param engine The engine which the post process will be applied. (default: current engine)
  148167. * @param reusable If the post process can be reused on the same frame. (default: false)
  148168. * @param textureType Type of textures used when performing the post process. (default: 0)
  148169. * @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)
  148170. */
  148171. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148172. /**
  148173. * Gets wether or not smoothing reflections is enabled.
  148174. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148175. */
  148176. get enableSmoothReflections(): boolean;
  148177. /**
  148178. * Sets wether or not smoothing reflections is enabled.
  148179. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148180. */
  148181. set enableSmoothReflections(enabled: boolean);
  148182. /**
  148183. * Gets the number of samples taken while computing reflections. More samples count is high,
  148184. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148185. */
  148186. get reflectionSamples(): number;
  148187. /**
  148188. * Sets the number of samples taken while computing reflections. More samples count is high,
  148189. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148190. */
  148191. set reflectionSamples(samples: number);
  148192. /**
  148193. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148194. * more the post-process will require GPU power and can generate a drop in FPS.
  148195. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148196. */
  148197. get smoothSteps(): number;
  148198. set smoothSteps(steps: number);
  148199. private _updateEffectDefines;
  148200. }
  148201. }
  148202. declare module BABYLON {
  148203. /** @hidden */
  148204. export var standardPixelShader: {
  148205. name: string;
  148206. shader: string;
  148207. };
  148208. }
  148209. declare module BABYLON {
  148210. /**
  148211. * Standard rendering pipeline
  148212. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148213. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148214. */
  148215. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148216. /**
  148217. * Public members
  148218. */
  148219. /**
  148220. * Post-process which contains the original scene color before the pipeline applies all the effects
  148221. */
  148222. originalPostProcess: Nullable<PostProcess>;
  148223. /**
  148224. * Post-process used to down scale an image x4
  148225. */
  148226. downSampleX4PostProcess: Nullable<PostProcess>;
  148227. /**
  148228. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148229. */
  148230. brightPassPostProcess: Nullable<PostProcess>;
  148231. /**
  148232. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148233. */
  148234. blurHPostProcesses: PostProcess[];
  148235. /**
  148236. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148237. */
  148238. blurVPostProcesses: PostProcess[];
  148239. /**
  148240. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148241. */
  148242. textureAdderPostProcess: Nullable<PostProcess>;
  148243. /**
  148244. * Post-process used to create volumetric lighting effect
  148245. */
  148246. volumetricLightPostProcess: Nullable<PostProcess>;
  148247. /**
  148248. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148249. */
  148250. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148251. /**
  148252. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148253. */
  148254. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148255. /**
  148256. * Post-process used to merge the volumetric light effect and the real scene color
  148257. */
  148258. volumetricLightMergePostProces: Nullable<PostProcess>;
  148259. /**
  148260. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148261. */
  148262. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148263. /**
  148264. * Base post-process used to calculate the average luminance of the final image for HDR
  148265. */
  148266. luminancePostProcess: Nullable<PostProcess>;
  148267. /**
  148268. * Post-processes used to create down sample post-processes in order to get
  148269. * the average luminance of the final image for HDR
  148270. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148271. */
  148272. luminanceDownSamplePostProcesses: PostProcess[];
  148273. /**
  148274. * Post-process used to create a HDR effect (light adaptation)
  148275. */
  148276. hdrPostProcess: Nullable<PostProcess>;
  148277. /**
  148278. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148279. */
  148280. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148281. /**
  148282. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148283. */
  148284. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148285. /**
  148286. * Post-process used to merge the final HDR post-process and the real scene color
  148287. */
  148288. hdrFinalPostProcess: Nullable<PostProcess>;
  148289. /**
  148290. * Post-process used to create a lens flare effect
  148291. */
  148292. lensFlarePostProcess: Nullable<PostProcess>;
  148293. /**
  148294. * Post-process that merges the result of the lens flare post-process and the real scene color
  148295. */
  148296. lensFlareComposePostProcess: Nullable<PostProcess>;
  148297. /**
  148298. * Post-process used to create a motion blur effect
  148299. */
  148300. motionBlurPostProcess: Nullable<PostProcess>;
  148301. /**
  148302. * Post-process used to create a depth of field effect
  148303. */
  148304. depthOfFieldPostProcess: Nullable<PostProcess>;
  148305. /**
  148306. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148307. */
  148308. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148309. /**
  148310. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148311. */
  148312. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148313. /**
  148314. * Represents the brightness threshold in order to configure the illuminated surfaces
  148315. */
  148316. brightThreshold: number;
  148317. /**
  148318. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148319. */
  148320. blurWidth: number;
  148321. /**
  148322. * Sets if the blur for highlighted surfaces must be only horizontal
  148323. */
  148324. horizontalBlur: boolean;
  148325. /**
  148326. * Gets the overall exposure used by the pipeline
  148327. */
  148328. get exposure(): number;
  148329. /**
  148330. * Sets the overall exposure used by the pipeline
  148331. */
  148332. set exposure(value: number);
  148333. /**
  148334. * Texture used typically to simulate "dirty" on camera lens
  148335. */
  148336. lensTexture: Nullable<Texture>;
  148337. /**
  148338. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148339. */
  148340. volumetricLightCoefficient: number;
  148341. /**
  148342. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148343. */
  148344. volumetricLightPower: number;
  148345. /**
  148346. * Used the set the blur intensity to smooth the volumetric lights
  148347. */
  148348. volumetricLightBlurScale: number;
  148349. /**
  148350. * Light (spot or directional) used to generate the volumetric lights rays
  148351. * The source light must have a shadow generate so the pipeline can get its
  148352. * depth map
  148353. */
  148354. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148355. /**
  148356. * For eye adaptation, represents the minimum luminance the eye can see
  148357. */
  148358. hdrMinimumLuminance: number;
  148359. /**
  148360. * For eye adaptation, represents the decrease luminance speed
  148361. */
  148362. hdrDecreaseRate: number;
  148363. /**
  148364. * For eye adaptation, represents the increase luminance speed
  148365. */
  148366. hdrIncreaseRate: number;
  148367. /**
  148368. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148369. */
  148370. get hdrAutoExposure(): boolean;
  148371. /**
  148372. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148373. */
  148374. set hdrAutoExposure(value: boolean);
  148375. /**
  148376. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148377. */
  148378. lensColorTexture: Nullable<Texture>;
  148379. /**
  148380. * The overall strengh for the lens flare effect
  148381. */
  148382. lensFlareStrength: number;
  148383. /**
  148384. * Dispersion coefficient for lens flare ghosts
  148385. */
  148386. lensFlareGhostDispersal: number;
  148387. /**
  148388. * Main lens flare halo width
  148389. */
  148390. lensFlareHaloWidth: number;
  148391. /**
  148392. * Based on the lens distortion effect, defines how much the lens flare result
  148393. * is distorted
  148394. */
  148395. lensFlareDistortionStrength: number;
  148396. /**
  148397. * Configures the blur intensity used for for lens flare (halo)
  148398. */
  148399. lensFlareBlurWidth: number;
  148400. /**
  148401. * Lens star texture must be used to simulate rays on the flares and is available
  148402. * in the documentation
  148403. */
  148404. lensStarTexture: Nullable<Texture>;
  148405. /**
  148406. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148407. * flare effect by taking account of the dirt texture
  148408. */
  148409. lensFlareDirtTexture: Nullable<Texture>;
  148410. /**
  148411. * Represents the focal length for the depth of field effect
  148412. */
  148413. depthOfFieldDistance: number;
  148414. /**
  148415. * Represents the blur intensity for the blurred part of the depth of field effect
  148416. */
  148417. depthOfFieldBlurWidth: number;
  148418. /**
  148419. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148420. */
  148421. get motionStrength(): number;
  148422. /**
  148423. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148424. */
  148425. set motionStrength(strength: number);
  148426. /**
  148427. * Gets wether or not the motion blur post-process is object based or screen based.
  148428. */
  148429. get objectBasedMotionBlur(): boolean;
  148430. /**
  148431. * Sets wether or not the motion blur post-process should be object based or screen based
  148432. */
  148433. set objectBasedMotionBlur(value: boolean);
  148434. /**
  148435. * List of animations for the pipeline (IAnimatable implementation)
  148436. */
  148437. animations: Animation[];
  148438. /**
  148439. * Private members
  148440. */
  148441. private _scene;
  148442. private _currentDepthOfFieldSource;
  148443. private _basePostProcess;
  148444. private _fixedExposure;
  148445. private _currentExposure;
  148446. private _hdrAutoExposure;
  148447. private _hdrCurrentLuminance;
  148448. private _motionStrength;
  148449. private _isObjectBasedMotionBlur;
  148450. private _floatTextureType;
  148451. private _camerasToBeAttached;
  148452. private _ratio;
  148453. private _bloomEnabled;
  148454. private _depthOfFieldEnabled;
  148455. private _vlsEnabled;
  148456. private _lensFlareEnabled;
  148457. private _hdrEnabled;
  148458. private _motionBlurEnabled;
  148459. private _fxaaEnabled;
  148460. private _screenSpaceReflectionsEnabled;
  148461. private _motionBlurSamples;
  148462. private _volumetricLightStepsCount;
  148463. private _samples;
  148464. /**
  148465. * @ignore
  148466. * Specifies if the bloom pipeline is enabled
  148467. */
  148468. get BloomEnabled(): boolean;
  148469. set BloomEnabled(enabled: boolean);
  148470. /**
  148471. * @ignore
  148472. * Specifies if the depth of field pipeline is enabed
  148473. */
  148474. get DepthOfFieldEnabled(): boolean;
  148475. set DepthOfFieldEnabled(enabled: boolean);
  148476. /**
  148477. * @ignore
  148478. * Specifies if the lens flare pipeline is enabed
  148479. */
  148480. get LensFlareEnabled(): boolean;
  148481. set LensFlareEnabled(enabled: boolean);
  148482. /**
  148483. * @ignore
  148484. * Specifies if the HDR pipeline is enabled
  148485. */
  148486. get HDREnabled(): boolean;
  148487. set HDREnabled(enabled: boolean);
  148488. /**
  148489. * @ignore
  148490. * Specifies if the volumetric lights scattering effect is enabled
  148491. */
  148492. get VLSEnabled(): boolean;
  148493. set VLSEnabled(enabled: boolean);
  148494. /**
  148495. * @ignore
  148496. * Specifies if the motion blur effect is enabled
  148497. */
  148498. get MotionBlurEnabled(): boolean;
  148499. set MotionBlurEnabled(enabled: boolean);
  148500. /**
  148501. * Specifies if anti-aliasing is enabled
  148502. */
  148503. get fxaaEnabled(): boolean;
  148504. set fxaaEnabled(enabled: boolean);
  148505. /**
  148506. * Specifies if screen space reflections are enabled.
  148507. */
  148508. get screenSpaceReflectionsEnabled(): boolean;
  148509. set screenSpaceReflectionsEnabled(enabled: boolean);
  148510. /**
  148511. * Specifies the number of steps used to calculate the volumetric lights
  148512. * Typically in interval [50, 200]
  148513. */
  148514. get volumetricLightStepsCount(): number;
  148515. set volumetricLightStepsCount(count: number);
  148516. /**
  148517. * Specifies the number of samples used for the motion blur effect
  148518. * Typically in interval [16, 64]
  148519. */
  148520. get motionBlurSamples(): number;
  148521. set motionBlurSamples(samples: number);
  148522. /**
  148523. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148524. */
  148525. get samples(): number;
  148526. set samples(sampleCount: number);
  148527. /**
  148528. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148529. * @constructor
  148530. * @param name The rendering pipeline name
  148531. * @param scene The scene linked to this pipeline
  148532. * @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)
  148533. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148534. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148535. */
  148536. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148537. private _buildPipeline;
  148538. private _createDownSampleX4PostProcess;
  148539. private _createBrightPassPostProcess;
  148540. private _createBlurPostProcesses;
  148541. private _createTextureAdderPostProcess;
  148542. private _createVolumetricLightPostProcess;
  148543. private _createLuminancePostProcesses;
  148544. private _createHdrPostProcess;
  148545. private _createLensFlarePostProcess;
  148546. private _createDepthOfFieldPostProcess;
  148547. private _createMotionBlurPostProcess;
  148548. private _getDepthTexture;
  148549. private _disposePostProcesses;
  148550. /**
  148551. * Dispose of the pipeline and stop all post processes
  148552. */
  148553. dispose(): void;
  148554. /**
  148555. * Serialize the rendering pipeline (Used when exporting)
  148556. * @returns the serialized object
  148557. */
  148558. serialize(): any;
  148559. /**
  148560. * Parse the serialized pipeline
  148561. * @param source Source pipeline.
  148562. * @param scene The scene to load the pipeline to.
  148563. * @param rootUrl The URL of the serialized pipeline.
  148564. * @returns An instantiated pipeline from the serialized object.
  148565. */
  148566. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148567. /**
  148568. * Luminance steps
  148569. */
  148570. static LuminanceSteps: number;
  148571. }
  148572. }
  148573. declare module BABYLON {
  148574. /** @hidden */
  148575. export var stereoscopicInterlacePixelShader: {
  148576. name: string;
  148577. shader: string;
  148578. };
  148579. }
  148580. declare module BABYLON {
  148581. /**
  148582. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148583. */
  148584. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148585. private _stepSize;
  148586. private _passedProcess;
  148587. /**
  148588. * Initializes a StereoscopicInterlacePostProcessI
  148589. * @param name The name of the effect.
  148590. * @param rigCameras The rig cameras to be appled to the post process
  148591. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148592. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148594. * @param engine The engine which the post process will be applied. (default: current engine)
  148595. * @param reusable If the post process can be reused on the same frame. (default: false)
  148596. */
  148597. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148598. }
  148599. /**
  148600. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148601. */
  148602. export class StereoscopicInterlacePostProcess extends PostProcess {
  148603. private _stepSize;
  148604. private _passedProcess;
  148605. /**
  148606. * Initializes a StereoscopicInterlacePostProcess
  148607. * @param name The name of the effect.
  148608. * @param rigCameras The rig cameras to be appled to the post process
  148609. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148611. * @param engine The engine which the post process will be applied. (default: current engine)
  148612. * @param reusable If the post process can be reused on the same frame. (default: false)
  148613. */
  148614. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148615. }
  148616. }
  148617. declare module BABYLON {
  148618. /** @hidden */
  148619. export var tonemapPixelShader: {
  148620. name: string;
  148621. shader: string;
  148622. };
  148623. }
  148624. declare module BABYLON {
  148625. /** Defines operator used for tonemapping */
  148626. export enum TonemappingOperator {
  148627. /** Hable */
  148628. Hable = 0,
  148629. /** Reinhard */
  148630. Reinhard = 1,
  148631. /** HejiDawson */
  148632. HejiDawson = 2,
  148633. /** Photographic */
  148634. Photographic = 3
  148635. }
  148636. /**
  148637. * Defines a post process to apply tone mapping
  148638. */
  148639. export class TonemapPostProcess extends PostProcess {
  148640. private _operator;
  148641. /** Defines the required exposure adjustement */
  148642. exposureAdjustment: number;
  148643. /**
  148644. * Creates a new TonemapPostProcess
  148645. * @param name defines the name of the postprocess
  148646. * @param _operator defines the operator to use
  148647. * @param exposureAdjustment defines the required exposure adjustement
  148648. * @param camera defines the camera to use (can be null)
  148649. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148650. * @param engine defines the hosting engine (can be ignore if camera is set)
  148651. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148652. */
  148653. constructor(name: string, _operator: TonemappingOperator,
  148654. /** Defines the required exposure adjustement */
  148655. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148656. }
  148657. }
  148658. declare module BABYLON {
  148659. /** @hidden */
  148660. export var volumetricLightScatteringPixelShader: {
  148661. name: string;
  148662. shader: string;
  148663. };
  148664. }
  148665. declare module BABYLON {
  148666. /** @hidden */
  148667. export var volumetricLightScatteringPassVertexShader: {
  148668. name: string;
  148669. shader: string;
  148670. };
  148671. }
  148672. declare module BABYLON {
  148673. /** @hidden */
  148674. export var volumetricLightScatteringPassPixelShader: {
  148675. name: string;
  148676. shader: string;
  148677. };
  148678. }
  148679. declare module BABYLON {
  148680. /**
  148681. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148682. */
  148683. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148684. private _volumetricLightScatteringPass;
  148685. private _volumetricLightScatteringRTT;
  148686. private _viewPort;
  148687. private _screenCoordinates;
  148688. private _cachedDefines;
  148689. /**
  148690. * If not undefined, the mesh position is computed from the attached node position
  148691. */
  148692. attachedNode: {
  148693. position: Vector3;
  148694. };
  148695. /**
  148696. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148697. */
  148698. customMeshPosition: Vector3;
  148699. /**
  148700. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148701. */
  148702. useCustomMeshPosition: boolean;
  148703. /**
  148704. * If the post-process should inverse the light scattering direction
  148705. */
  148706. invert: boolean;
  148707. /**
  148708. * The internal mesh used by the post-process
  148709. */
  148710. mesh: Mesh;
  148711. /**
  148712. * @hidden
  148713. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148714. */
  148715. get useDiffuseColor(): boolean;
  148716. set useDiffuseColor(useDiffuseColor: boolean);
  148717. /**
  148718. * Array containing the excluded meshes not rendered in the internal pass
  148719. */
  148720. excludedMeshes: AbstractMesh[];
  148721. /**
  148722. * Controls the overall intensity of the post-process
  148723. */
  148724. exposure: number;
  148725. /**
  148726. * Dissipates each sample's contribution in range [0, 1]
  148727. */
  148728. decay: number;
  148729. /**
  148730. * Controls the overall intensity of each sample
  148731. */
  148732. weight: number;
  148733. /**
  148734. * Controls the density of each sample
  148735. */
  148736. density: number;
  148737. /**
  148738. * @constructor
  148739. * @param name The post-process name
  148740. * @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)
  148741. * @param camera The camera that the post-process will be attached to
  148742. * @param mesh The mesh used to create the light scattering
  148743. * @param samples The post-process quality, default 100
  148744. * @param samplingModeThe post-process filtering mode
  148745. * @param engine The babylon engine
  148746. * @param reusable If the post-process is reusable
  148747. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148748. */
  148749. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148750. /**
  148751. * Returns the string "VolumetricLightScatteringPostProcess"
  148752. * @returns "VolumetricLightScatteringPostProcess"
  148753. */
  148754. getClassName(): string;
  148755. private _isReady;
  148756. /**
  148757. * Sets the new light position for light scattering effect
  148758. * @param position The new custom light position
  148759. */
  148760. setCustomMeshPosition(position: Vector3): void;
  148761. /**
  148762. * Returns the light position for light scattering effect
  148763. * @return Vector3 The custom light position
  148764. */
  148765. getCustomMeshPosition(): Vector3;
  148766. /**
  148767. * Disposes the internal assets and detaches the post-process from the camera
  148768. */
  148769. dispose(camera: Camera): void;
  148770. /**
  148771. * Returns the render target texture used by the post-process
  148772. * @return the render target texture used by the post-process
  148773. */
  148774. getPass(): RenderTargetTexture;
  148775. private _meshExcluded;
  148776. private _createPass;
  148777. private _updateMeshScreenCoordinates;
  148778. /**
  148779. * Creates a default mesh for the Volumeric Light Scattering post-process
  148780. * @param name The mesh name
  148781. * @param scene The scene where to create the mesh
  148782. * @return the default mesh
  148783. */
  148784. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148785. }
  148786. }
  148787. declare module BABYLON {
  148788. interface Scene {
  148789. /** @hidden (Backing field) */
  148790. _boundingBoxRenderer: BoundingBoxRenderer;
  148791. /** @hidden (Backing field) */
  148792. _forceShowBoundingBoxes: boolean;
  148793. /**
  148794. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148795. */
  148796. forceShowBoundingBoxes: boolean;
  148797. /**
  148798. * Gets the bounding box renderer associated with the scene
  148799. * @returns a BoundingBoxRenderer
  148800. */
  148801. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148802. }
  148803. interface AbstractMesh {
  148804. /** @hidden (Backing field) */
  148805. _showBoundingBox: boolean;
  148806. /**
  148807. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148808. */
  148809. showBoundingBox: boolean;
  148810. }
  148811. /**
  148812. * Component responsible of rendering the bounding box of the meshes in a scene.
  148813. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148814. */
  148815. export class BoundingBoxRenderer implements ISceneComponent {
  148816. /**
  148817. * The component name helpfull to identify the component in the list of scene components.
  148818. */
  148819. readonly name: string;
  148820. /**
  148821. * The scene the component belongs to.
  148822. */
  148823. scene: Scene;
  148824. /**
  148825. * Color of the bounding box lines placed in front of an object
  148826. */
  148827. frontColor: Color3;
  148828. /**
  148829. * Color of the bounding box lines placed behind an object
  148830. */
  148831. backColor: Color3;
  148832. /**
  148833. * Defines if the renderer should show the back lines or not
  148834. */
  148835. showBackLines: boolean;
  148836. /**
  148837. * Observable raised before rendering a bounding box
  148838. */
  148839. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148840. /**
  148841. * Observable raised after rendering a bounding box
  148842. */
  148843. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148844. /**
  148845. * @hidden
  148846. */
  148847. renderList: SmartArray<BoundingBox>;
  148848. private _colorShader;
  148849. private _vertexBuffers;
  148850. private _indexBuffer;
  148851. private _fillIndexBuffer;
  148852. private _fillIndexData;
  148853. /**
  148854. * Instantiates a new bounding box renderer in a scene.
  148855. * @param scene the scene the renderer renders in
  148856. */
  148857. constructor(scene: Scene);
  148858. /**
  148859. * Registers the component in a given scene
  148860. */
  148861. register(): void;
  148862. private _evaluateSubMesh;
  148863. private _activeMesh;
  148864. private _prepareRessources;
  148865. private _createIndexBuffer;
  148866. /**
  148867. * Rebuilds the elements related to this component in case of
  148868. * context lost for instance.
  148869. */
  148870. rebuild(): void;
  148871. /**
  148872. * @hidden
  148873. */
  148874. reset(): void;
  148875. /**
  148876. * Render the bounding boxes of a specific rendering group
  148877. * @param renderingGroupId defines the rendering group to render
  148878. */
  148879. render(renderingGroupId: number): void;
  148880. /**
  148881. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148882. * @param mesh Define the mesh to render the occlusion bounding box for
  148883. */
  148884. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148885. /**
  148886. * Dispose and release the resources attached to this renderer.
  148887. */
  148888. dispose(): void;
  148889. }
  148890. }
  148891. declare module BABYLON {
  148892. interface Scene {
  148893. /** @hidden (Backing field) */
  148894. _depthRenderer: {
  148895. [id: string]: DepthRenderer;
  148896. };
  148897. /**
  148898. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148899. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148900. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148901. * @returns the created depth renderer
  148902. */
  148903. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148904. /**
  148905. * Disables a depth renderer for a given camera
  148906. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148907. */
  148908. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148909. }
  148910. /**
  148911. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148912. * in several rendering techniques.
  148913. */
  148914. export class DepthRendererSceneComponent implements ISceneComponent {
  148915. /**
  148916. * The component name helpfull to identify the component in the list of scene components.
  148917. */
  148918. readonly name: string;
  148919. /**
  148920. * The scene the component belongs to.
  148921. */
  148922. scene: Scene;
  148923. /**
  148924. * Creates a new instance of the component for the given scene
  148925. * @param scene Defines the scene to register the component in
  148926. */
  148927. constructor(scene: Scene);
  148928. /**
  148929. * Registers the component in a given scene
  148930. */
  148931. register(): void;
  148932. /**
  148933. * Rebuilds the elements related to this component in case of
  148934. * context lost for instance.
  148935. */
  148936. rebuild(): void;
  148937. /**
  148938. * Disposes the component and the associated ressources
  148939. */
  148940. dispose(): void;
  148941. private _gatherRenderTargets;
  148942. private _gatherActiveCameraRenderTargets;
  148943. }
  148944. }
  148945. declare module BABYLON {
  148946. /** @hidden */
  148947. export var fibonacci: {
  148948. name: string;
  148949. shader: string;
  148950. };
  148951. }
  148952. declare module BABYLON {
  148953. /** @hidden */
  148954. export var diffusionProfile: {
  148955. name: string;
  148956. shader: string;
  148957. };
  148958. }
  148959. declare module BABYLON {
  148960. /** @hidden */
  148961. export var subSurfaceScatteringPixelShader: {
  148962. name: string;
  148963. shader: string;
  148964. };
  148965. }
  148966. declare module BABYLON {
  148967. /**
  148968. * Sub surface scattering post process
  148969. */
  148970. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148971. /** @hidden */
  148972. texelWidth: number;
  148973. /** @hidden */
  148974. texelHeight: number;
  148975. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148976. }
  148977. }
  148978. declare module BABYLON {
  148979. /**
  148980. * Contains all parameters needed for the prepass to perform
  148981. * screen space subsurface scattering
  148982. */
  148983. export class SubSurfaceConfiguration {
  148984. private _ssDiffusionS;
  148985. private _ssFilterRadii;
  148986. private _ssDiffusionD;
  148987. /**
  148988. * Diffusion profile color for subsurface scattering
  148989. */
  148990. get ssDiffusionS(): number[];
  148991. /**
  148992. * Diffusion profile max color channel value for subsurface scattering
  148993. */
  148994. get ssDiffusionD(): number[];
  148995. /**
  148996. * Diffusion profile filter radius for subsurface scattering
  148997. */
  148998. get ssFilterRadii(): number[];
  148999. /**
  149000. * Diffusion profile colors for subsurface scattering
  149001. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  149002. * See ...
  149003. * Note that you can only store up to 5 of them
  149004. */
  149005. ssDiffusionProfileColors: Color3[];
  149006. /**
  149007. * Defines the ratio real world => scene units.
  149008. * Used for subsurface scattering
  149009. */
  149010. metersPerUnit: number;
  149011. /**
  149012. * Builds a subsurface configuration object
  149013. * @param scene The scene
  149014. */
  149015. constructor();
  149016. /**
  149017. * Adds a new diffusion profile.
  149018. * Useful for more realistic subsurface scattering on diverse materials.
  149019. * @param color The color of the diffusion profile. Should be the average color of the material.
  149020. * @return The index of the diffusion profile for the material subsurface configuration
  149021. */
  149022. addDiffusionProfile(color: Color3): number;
  149023. /**
  149024. * Deletes all diffusion profiles.
  149025. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  149026. */
  149027. clearAllDiffusionProfiles(): void;
  149028. /**
  149029. * Disposes this object
  149030. */
  149031. dispose(): void;
  149032. /**
  149033. * @hidden
  149034. * https://zero-radiance.github.io/post/sampling-diffusion/
  149035. *
  149036. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  149037. * ------------------------------------------------------------------------------------
  149038. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  149039. * PDF[r, phi, s] = r * R[r, phi, s]
  149040. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  149041. * ------------------------------------------------------------------------------------
  149042. * We importance sample the color channel with the widest scattering distance.
  149043. */
  149044. getDiffusionProfileParameters(color: Color3): number;
  149045. /**
  149046. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  149047. * 'u' is the random number (the value of the CDF): [0, 1).
  149048. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  149049. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  149050. */
  149051. private _sampleBurleyDiffusionProfile;
  149052. }
  149053. }
  149054. declare module BABYLON {
  149055. /**
  149056. * Renders a pre pass of the scene
  149057. * This means every mesh in the scene will be rendered to a render target texture
  149058. * And then this texture will be composited to the rendering canvas with post processes
  149059. * It is necessary for effects like subsurface scattering or deferred shading
  149060. */
  149061. export class PrePassRenderer {
  149062. /** @hidden */
  149063. static _SceneComponentInitialization: (scene: Scene) => void;
  149064. private _scene;
  149065. private _engine;
  149066. private _isDirty;
  149067. /**
  149068. * Number of textures in the multi render target texture where the scene is directly rendered
  149069. */
  149070. readonly mrtCount: number;
  149071. /**
  149072. * The render target where the scene is directly rendered
  149073. */
  149074. prePassRT: MultiRenderTarget;
  149075. private _mrtTypes;
  149076. private _multiRenderAttachments;
  149077. private _defaultAttachments;
  149078. private _clearAttachments;
  149079. private readonly _clearColor;
  149080. /**
  149081. * Image processing post process for composition
  149082. */
  149083. imageProcessingPostProcess: ImageProcessingPostProcess;
  149084. /**
  149085. * Post process for subsurface scattering
  149086. */
  149087. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  149088. /**
  149089. * Configuration for sub surface scattering post process
  149090. */
  149091. subSurfaceConfiguration: SubSurfaceConfiguration;
  149092. private _enabled;
  149093. /**
  149094. * Indicates if the prepass is enabled
  149095. */
  149096. get enabled(): boolean;
  149097. /**
  149098. * How many samples are used for MSAA of the scene render target
  149099. */
  149100. get samples(): number;
  149101. set samples(n: number);
  149102. /**
  149103. * Instanciates a prepass renderer
  149104. * @param scene The scene
  149105. */
  149106. constructor(scene: Scene);
  149107. private _initializeAttachments;
  149108. private _createEffects;
  149109. /**
  149110. * Indicates if rendering a prepass is supported
  149111. */
  149112. get isSupported(): boolean;
  149113. /**
  149114. * Sets the proper output textures to draw in the engine.
  149115. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  149116. */
  149117. bindAttachmentsForEffect(effect: Effect): void;
  149118. /**
  149119. * @hidden
  149120. */
  149121. _beforeCameraDraw(): void;
  149122. /**
  149123. * @hidden
  149124. */
  149125. _afterCameraDraw(): void;
  149126. private _checkRTSize;
  149127. private _bindFrameBuffer;
  149128. /**
  149129. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  149130. */
  149131. clear(): void;
  149132. private _setState;
  149133. private _enable;
  149134. private _disable;
  149135. /**
  149136. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  149137. */
  149138. markAsDirty(): void;
  149139. private _update;
  149140. /**
  149141. * Disposes the prepass renderer.
  149142. */
  149143. dispose(): void;
  149144. }
  149145. }
  149146. declare module BABYLON {
  149147. interface AbstractScene {
  149148. /** @hidden (Backing field) */
  149149. _prePassRenderer: Nullable<PrePassRenderer>;
  149150. /**
  149151. * Gets or Sets the current prepass renderer associated to the scene.
  149152. */
  149153. prePassRenderer: Nullable<PrePassRenderer>;
  149154. /**
  149155. * Enables the prepass and associates it with the scene
  149156. * @returns the PrePassRenderer
  149157. */
  149158. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149159. /**
  149160. * Disables the prepass associated with the scene
  149161. */
  149162. disablePrePassRenderer(): void;
  149163. }
  149164. /**
  149165. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149166. * in several rendering techniques.
  149167. */
  149168. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149169. /**
  149170. * The component name helpful to identify the component in the list of scene components.
  149171. */
  149172. readonly name: string;
  149173. /**
  149174. * The scene the component belongs to.
  149175. */
  149176. scene: Scene;
  149177. /**
  149178. * Creates a new instance of the component for the given scene
  149179. * @param scene Defines the scene to register the component in
  149180. */
  149181. constructor(scene: Scene);
  149182. /**
  149183. * Registers the component in a given scene
  149184. */
  149185. register(): void;
  149186. private _beforeCameraDraw;
  149187. private _afterCameraDraw;
  149188. private _beforeClearStage;
  149189. /**
  149190. * Serializes the component data to the specified json object
  149191. * @param serializationObject The object to serialize to
  149192. */
  149193. serialize(serializationObject: any): void;
  149194. /**
  149195. * Adds all the elements from the container to the scene
  149196. * @param container the container holding the elements
  149197. */
  149198. addFromContainer(container: AbstractScene): void;
  149199. /**
  149200. * Removes all the elements in the container from the scene
  149201. * @param container contains the elements to remove
  149202. * @param dispose if the removed element should be disposed (default: false)
  149203. */
  149204. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149205. /**
  149206. * Rebuilds the elements related to this component in case of
  149207. * context lost for instance.
  149208. */
  149209. rebuild(): void;
  149210. /**
  149211. * Disposes the component and the associated ressources
  149212. */
  149213. dispose(): void;
  149214. }
  149215. }
  149216. declare module BABYLON {
  149217. /** @hidden */
  149218. export var outlinePixelShader: {
  149219. name: string;
  149220. shader: string;
  149221. };
  149222. }
  149223. declare module BABYLON {
  149224. /** @hidden */
  149225. export var outlineVertexShader: {
  149226. name: string;
  149227. shader: string;
  149228. };
  149229. }
  149230. declare module BABYLON {
  149231. interface Scene {
  149232. /** @hidden */
  149233. _outlineRenderer: OutlineRenderer;
  149234. /**
  149235. * Gets the outline renderer associated with the scene
  149236. * @returns a OutlineRenderer
  149237. */
  149238. getOutlineRenderer(): OutlineRenderer;
  149239. }
  149240. interface AbstractMesh {
  149241. /** @hidden (Backing field) */
  149242. _renderOutline: boolean;
  149243. /**
  149244. * Gets or sets a boolean indicating if the outline must be rendered as well
  149245. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149246. */
  149247. renderOutline: boolean;
  149248. /** @hidden (Backing field) */
  149249. _renderOverlay: boolean;
  149250. /**
  149251. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149252. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149253. */
  149254. renderOverlay: boolean;
  149255. }
  149256. /**
  149257. * This class is responsible to draw bothe outline/overlay of meshes.
  149258. * It should not be used directly but through the available method on mesh.
  149259. */
  149260. export class OutlineRenderer implements ISceneComponent {
  149261. /**
  149262. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149263. */
  149264. private static _StencilReference;
  149265. /**
  149266. * The name of the component. Each component must have a unique name.
  149267. */
  149268. name: string;
  149269. /**
  149270. * The scene the component belongs to.
  149271. */
  149272. scene: Scene;
  149273. /**
  149274. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149275. */
  149276. zOffset: number;
  149277. private _engine;
  149278. private _effect;
  149279. private _cachedDefines;
  149280. private _savedDepthWrite;
  149281. /**
  149282. * Instantiates a new outline renderer. (There could be only one per scene).
  149283. * @param scene Defines the scene it belongs to
  149284. */
  149285. constructor(scene: Scene);
  149286. /**
  149287. * Register the component to one instance of a scene.
  149288. */
  149289. register(): void;
  149290. /**
  149291. * Rebuilds the elements related to this component in case of
  149292. * context lost for instance.
  149293. */
  149294. rebuild(): void;
  149295. /**
  149296. * Disposes the component and the associated ressources.
  149297. */
  149298. dispose(): void;
  149299. /**
  149300. * Renders the outline in the canvas.
  149301. * @param subMesh Defines the sumesh to render
  149302. * @param batch Defines the batch of meshes in case of instances
  149303. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149304. */
  149305. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149306. /**
  149307. * Returns whether or not the outline renderer is ready for a given submesh.
  149308. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149309. * @param subMesh Defines the submesh to check readyness for
  149310. * @param useInstances Defines wheter wee are trying to render instances or not
  149311. * @returns true if ready otherwise false
  149312. */
  149313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149314. private _beforeRenderingMesh;
  149315. private _afterRenderingMesh;
  149316. }
  149317. }
  149318. declare module BABYLON {
  149319. /**
  149320. * Defines the basic options interface of a Sprite Frame Source Size.
  149321. */
  149322. export interface ISpriteJSONSpriteSourceSize {
  149323. /**
  149324. * number of the original width of the Frame
  149325. */
  149326. w: number;
  149327. /**
  149328. * number of the original height of the Frame
  149329. */
  149330. h: number;
  149331. }
  149332. /**
  149333. * Defines the basic options interface of a Sprite Frame Data.
  149334. */
  149335. export interface ISpriteJSONSpriteFrameData {
  149336. /**
  149337. * number of the x offset of the Frame
  149338. */
  149339. x: number;
  149340. /**
  149341. * number of the y offset of the Frame
  149342. */
  149343. y: number;
  149344. /**
  149345. * number of the width of the Frame
  149346. */
  149347. w: number;
  149348. /**
  149349. * number of the height of the Frame
  149350. */
  149351. h: number;
  149352. }
  149353. /**
  149354. * Defines the basic options interface of a JSON Sprite.
  149355. */
  149356. export interface ISpriteJSONSprite {
  149357. /**
  149358. * string name of the Frame
  149359. */
  149360. filename: string;
  149361. /**
  149362. * ISpriteJSONSpriteFrame basic object of the frame data
  149363. */
  149364. frame: ISpriteJSONSpriteFrameData;
  149365. /**
  149366. * boolean to flag is the frame was rotated.
  149367. */
  149368. rotated: boolean;
  149369. /**
  149370. * boolean to flag is the frame was trimmed.
  149371. */
  149372. trimmed: boolean;
  149373. /**
  149374. * ISpriteJSONSpriteFrame basic object of the source data
  149375. */
  149376. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149377. /**
  149378. * ISpriteJSONSpriteFrame basic object of the source data
  149379. */
  149380. sourceSize: ISpriteJSONSpriteSourceSize;
  149381. }
  149382. /**
  149383. * Defines the basic options interface of a JSON atlas.
  149384. */
  149385. export interface ISpriteJSONAtlas {
  149386. /**
  149387. * Array of objects that contain the frame data.
  149388. */
  149389. frames: Array<ISpriteJSONSprite>;
  149390. /**
  149391. * object basic object containing the sprite meta data.
  149392. */
  149393. meta?: object;
  149394. }
  149395. }
  149396. declare module BABYLON {
  149397. /** @hidden */
  149398. export var spriteMapPixelShader: {
  149399. name: string;
  149400. shader: string;
  149401. };
  149402. }
  149403. declare module BABYLON {
  149404. /** @hidden */
  149405. export var spriteMapVertexShader: {
  149406. name: string;
  149407. shader: string;
  149408. };
  149409. }
  149410. declare module BABYLON {
  149411. /**
  149412. * Defines the basic options interface of a SpriteMap
  149413. */
  149414. export interface ISpriteMapOptions {
  149415. /**
  149416. * Vector2 of the number of cells in the grid.
  149417. */
  149418. stageSize?: Vector2;
  149419. /**
  149420. * Vector2 of the size of the output plane in World Units.
  149421. */
  149422. outputSize?: Vector2;
  149423. /**
  149424. * Vector3 of the position of the output plane in World Units.
  149425. */
  149426. outputPosition?: Vector3;
  149427. /**
  149428. * Vector3 of the rotation of the output plane.
  149429. */
  149430. outputRotation?: Vector3;
  149431. /**
  149432. * number of layers that the system will reserve in resources.
  149433. */
  149434. layerCount?: number;
  149435. /**
  149436. * number of max animation frames a single cell will reserve in resources.
  149437. */
  149438. maxAnimationFrames?: number;
  149439. /**
  149440. * number cell index of the base tile when the system compiles.
  149441. */
  149442. baseTile?: number;
  149443. /**
  149444. * boolean flip the sprite after its been repositioned by the framing data.
  149445. */
  149446. flipU?: boolean;
  149447. /**
  149448. * Vector3 scalar of the global RGB values of the SpriteMap.
  149449. */
  149450. colorMultiply?: Vector3;
  149451. }
  149452. /**
  149453. * Defines the IDisposable interface in order to be cleanable from resources.
  149454. */
  149455. export interface ISpriteMap extends IDisposable {
  149456. /**
  149457. * String name of the SpriteMap.
  149458. */
  149459. name: string;
  149460. /**
  149461. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149462. */
  149463. atlasJSON: ISpriteJSONAtlas;
  149464. /**
  149465. * Texture of the SpriteMap.
  149466. */
  149467. spriteSheet: Texture;
  149468. /**
  149469. * The parameters to initialize the SpriteMap with.
  149470. */
  149471. options: ISpriteMapOptions;
  149472. }
  149473. /**
  149474. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149475. */
  149476. export class SpriteMap implements ISpriteMap {
  149477. /** The Name of the spriteMap */
  149478. name: string;
  149479. /** The JSON file with the frame and meta data */
  149480. atlasJSON: ISpriteJSONAtlas;
  149481. /** The systems Sprite Sheet Texture */
  149482. spriteSheet: Texture;
  149483. /** Arguments passed with the Constructor */
  149484. options: ISpriteMapOptions;
  149485. /** Public Sprite Storage array, parsed from atlasJSON */
  149486. sprites: Array<ISpriteJSONSprite>;
  149487. /** Returns the Number of Sprites in the System */
  149488. get spriteCount(): number;
  149489. /** Returns the Position of Output Plane*/
  149490. get position(): Vector3;
  149491. /** Returns the Position of Output Plane*/
  149492. set position(v: Vector3);
  149493. /** Returns the Rotation of Output Plane*/
  149494. get rotation(): Vector3;
  149495. /** Returns the Rotation of Output Plane*/
  149496. set rotation(v: Vector3);
  149497. /** Sets the AnimationMap*/
  149498. get animationMap(): RawTexture;
  149499. /** Sets the AnimationMap*/
  149500. set animationMap(v: RawTexture);
  149501. /** Scene that the SpriteMap was created in */
  149502. private _scene;
  149503. /** Texture Buffer of Float32 that holds tile frame data*/
  149504. private _frameMap;
  149505. /** Texture Buffers of Float32 that holds tileMap data*/
  149506. private _tileMaps;
  149507. /** Texture Buffer of Float32 that holds Animation Data*/
  149508. private _animationMap;
  149509. /** Custom ShaderMaterial Central to the System*/
  149510. private _material;
  149511. /** Custom ShaderMaterial Central to the System*/
  149512. private _output;
  149513. /** Systems Time Ticker*/
  149514. private _time;
  149515. /**
  149516. * Creates a new SpriteMap
  149517. * @param name defines the SpriteMaps Name
  149518. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149519. * @param spriteSheet is the Texture that the Sprites are on.
  149520. * @param options a basic deployment configuration
  149521. * @param scene The Scene that the map is deployed on
  149522. */
  149523. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149524. /**
  149525. * Returns tileID location
  149526. * @returns Vector2 the cell position ID
  149527. */
  149528. getTileID(): Vector2;
  149529. /**
  149530. * Gets the UV location of the mouse over the SpriteMap.
  149531. * @returns Vector2 the UV position of the mouse interaction
  149532. */
  149533. getMousePosition(): Vector2;
  149534. /**
  149535. * Creates the "frame" texture Buffer
  149536. * -------------------------------------
  149537. * Structure of frames
  149538. * "filename": "Falling-Water-2.png",
  149539. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149540. * "rotated": true,
  149541. * "trimmed": true,
  149542. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149543. * "sourceSize": {"w":32,"h":32}
  149544. * @returns RawTexture of the frameMap
  149545. */
  149546. private _createFrameBuffer;
  149547. /**
  149548. * Creates the tileMap texture Buffer
  149549. * @param buffer normally and array of numbers, or a false to generate from scratch
  149550. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149551. * @returns RawTexture of the tileMap
  149552. */
  149553. private _createTileBuffer;
  149554. /**
  149555. * Modifies the data of the tileMaps
  149556. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149557. * @param pos is the iVector2 Coordinates of the Tile
  149558. * @param tile The SpriteIndex of the new Tile
  149559. */
  149560. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149561. /**
  149562. * Creates the animationMap texture Buffer
  149563. * @param buffer normally and array of numbers, or a false to generate from scratch
  149564. * @returns RawTexture of the animationMap
  149565. */
  149566. private _createTileAnimationBuffer;
  149567. /**
  149568. * Modifies the data of the animationMap
  149569. * @param cellID is the Index of the Sprite
  149570. * @param _frame is the target Animation frame
  149571. * @param toCell is the Target Index of the next frame of the animation
  149572. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149573. * @param speed is a global scalar of the time variable on the map.
  149574. */
  149575. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149576. /**
  149577. * Exports the .tilemaps file
  149578. */
  149579. saveTileMaps(): void;
  149580. /**
  149581. * Imports the .tilemaps file
  149582. * @param url of the .tilemaps file
  149583. */
  149584. loadTileMaps(url: string): void;
  149585. /**
  149586. * Release associated resources
  149587. */
  149588. dispose(): void;
  149589. }
  149590. }
  149591. declare module BABYLON {
  149592. /**
  149593. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149594. * @see https://doc.babylonjs.com/babylon101/sprites
  149595. */
  149596. export class SpritePackedManager extends SpriteManager {
  149597. /** defines the packed manager's name */
  149598. name: string;
  149599. /**
  149600. * Creates a new sprite manager from a packed sprite sheet
  149601. * @param name defines the manager's name
  149602. * @param imgUrl defines the sprite sheet url
  149603. * @param capacity defines the maximum allowed number of sprites
  149604. * @param scene defines the hosting scene
  149605. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149606. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149607. * @param samplingMode defines the smapling mode to use with spritesheet
  149608. * @param fromPacked set to true; do not alter
  149609. */
  149610. constructor(
  149611. /** defines the packed manager's name */
  149612. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149613. }
  149614. }
  149615. declare module BABYLON {
  149616. /**
  149617. * Defines the list of states available for a task inside a AssetsManager
  149618. */
  149619. export enum AssetTaskState {
  149620. /**
  149621. * Initialization
  149622. */
  149623. INIT = 0,
  149624. /**
  149625. * Running
  149626. */
  149627. RUNNING = 1,
  149628. /**
  149629. * Done
  149630. */
  149631. DONE = 2,
  149632. /**
  149633. * Error
  149634. */
  149635. ERROR = 3
  149636. }
  149637. /**
  149638. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149639. */
  149640. export abstract class AbstractAssetTask {
  149641. /**
  149642. * Task name
  149643. */ name: string;
  149644. /**
  149645. * Callback called when the task is successful
  149646. */
  149647. onSuccess: (task: any) => void;
  149648. /**
  149649. * Callback called when the task is not successful
  149650. */
  149651. onError: (task: any, message?: string, exception?: any) => void;
  149652. /**
  149653. * Creates a new AssetsManager
  149654. * @param name defines the name of the task
  149655. */
  149656. constructor(
  149657. /**
  149658. * Task name
  149659. */ name: string);
  149660. private _isCompleted;
  149661. private _taskState;
  149662. private _errorObject;
  149663. /**
  149664. * Get if the task is completed
  149665. */
  149666. get isCompleted(): boolean;
  149667. /**
  149668. * Gets the current state of the task
  149669. */
  149670. get taskState(): AssetTaskState;
  149671. /**
  149672. * Gets the current error object (if task is in error)
  149673. */
  149674. get errorObject(): {
  149675. message?: string;
  149676. exception?: any;
  149677. };
  149678. /**
  149679. * Internal only
  149680. * @hidden
  149681. */
  149682. _setErrorObject(message?: string, exception?: any): void;
  149683. /**
  149684. * Execute the current task
  149685. * @param scene defines the scene where you want your assets to be loaded
  149686. * @param onSuccess is a callback called when the task is successfully executed
  149687. * @param onError is a callback called if an error occurs
  149688. */
  149689. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149690. /**
  149691. * Execute the current task
  149692. * @param scene defines the scene where you want your assets to be loaded
  149693. * @param onSuccess is a callback called when the task is successfully executed
  149694. * @param onError is a callback called if an error occurs
  149695. */
  149696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149697. /**
  149698. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149699. * This can be used with failed tasks that have the reason for failure fixed.
  149700. */
  149701. reset(): void;
  149702. private onErrorCallback;
  149703. private onDoneCallback;
  149704. }
  149705. /**
  149706. * Define the interface used by progress events raised during assets loading
  149707. */
  149708. export interface IAssetsProgressEvent {
  149709. /**
  149710. * Defines the number of remaining tasks to process
  149711. */
  149712. remainingCount: number;
  149713. /**
  149714. * Defines the total number of tasks
  149715. */
  149716. totalCount: number;
  149717. /**
  149718. * Defines the task that was just processed
  149719. */
  149720. task: AbstractAssetTask;
  149721. }
  149722. /**
  149723. * Class used to share progress information about assets loading
  149724. */
  149725. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149726. /**
  149727. * Defines the number of remaining tasks to process
  149728. */
  149729. remainingCount: number;
  149730. /**
  149731. * Defines the total number of tasks
  149732. */
  149733. totalCount: number;
  149734. /**
  149735. * Defines the task that was just processed
  149736. */
  149737. task: AbstractAssetTask;
  149738. /**
  149739. * Creates a AssetsProgressEvent
  149740. * @param remainingCount defines the number of remaining tasks to process
  149741. * @param totalCount defines the total number of tasks
  149742. * @param task defines the task that was just processed
  149743. */
  149744. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149745. }
  149746. /**
  149747. * Define a task used by AssetsManager to load meshes
  149748. */
  149749. export class MeshAssetTask extends AbstractAssetTask {
  149750. /**
  149751. * Defines the name of the task
  149752. */
  149753. name: string;
  149754. /**
  149755. * Defines the list of mesh's names you want to load
  149756. */
  149757. meshesNames: any;
  149758. /**
  149759. * Defines the root url to use as a base to load your meshes and associated resources
  149760. */
  149761. rootUrl: string;
  149762. /**
  149763. * Defines the filename or File of the scene to load from
  149764. */
  149765. sceneFilename: string | File;
  149766. /**
  149767. * Gets the list of loaded meshes
  149768. */
  149769. loadedMeshes: Array<AbstractMesh>;
  149770. /**
  149771. * Gets the list of loaded particle systems
  149772. */
  149773. loadedParticleSystems: Array<IParticleSystem>;
  149774. /**
  149775. * Gets the list of loaded skeletons
  149776. */
  149777. loadedSkeletons: Array<Skeleton>;
  149778. /**
  149779. * Gets the list of loaded animation groups
  149780. */
  149781. loadedAnimationGroups: Array<AnimationGroup>;
  149782. /**
  149783. * Callback called when the task is successful
  149784. */
  149785. onSuccess: (task: MeshAssetTask) => void;
  149786. /**
  149787. * Callback called when the task is successful
  149788. */
  149789. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149790. /**
  149791. * Creates a new MeshAssetTask
  149792. * @param name defines the name of the task
  149793. * @param meshesNames defines the list of mesh's names you want to load
  149794. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149795. * @param sceneFilename defines the filename or File of the scene to load from
  149796. */
  149797. constructor(
  149798. /**
  149799. * Defines the name of the task
  149800. */
  149801. name: string,
  149802. /**
  149803. * Defines the list of mesh's names you want to load
  149804. */
  149805. meshesNames: any,
  149806. /**
  149807. * Defines the root url to use as a base to load your meshes and associated resources
  149808. */
  149809. rootUrl: string,
  149810. /**
  149811. * Defines the filename or File of the scene to load from
  149812. */
  149813. sceneFilename: string | File);
  149814. /**
  149815. * Execute the current task
  149816. * @param scene defines the scene where you want your assets to be loaded
  149817. * @param onSuccess is a callback called when the task is successfully executed
  149818. * @param onError is a callback called if an error occurs
  149819. */
  149820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149821. }
  149822. /**
  149823. * Define a task used by AssetsManager to load text content
  149824. */
  149825. export class TextFileAssetTask extends AbstractAssetTask {
  149826. /**
  149827. * Defines the name of the task
  149828. */
  149829. name: string;
  149830. /**
  149831. * Defines the location of the file to load
  149832. */
  149833. url: string;
  149834. /**
  149835. * Gets the loaded text string
  149836. */
  149837. text: string;
  149838. /**
  149839. * Callback called when the task is successful
  149840. */
  149841. onSuccess: (task: TextFileAssetTask) => void;
  149842. /**
  149843. * Callback called when the task is successful
  149844. */
  149845. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149846. /**
  149847. * Creates a new TextFileAssetTask object
  149848. * @param name defines the name of the task
  149849. * @param url defines the location of the file to load
  149850. */
  149851. constructor(
  149852. /**
  149853. * Defines the name of the task
  149854. */
  149855. name: string,
  149856. /**
  149857. * Defines the location of the file to load
  149858. */
  149859. url: string);
  149860. /**
  149861. * Execute the current task
  149862. * @param scene defines the scene where you want your assets to be loaded
  149863. * @param onSuccess is a callback called when the task is successfully executed
  149864. * @param onError is a callback called if an error occurs
  149865. */
  149866. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149867. }
  149868. /**
  149869. * Define a task used by AssetsManager to load binary data
  149870. */
  149871. export class BinaryFileAssetTask extends AbstractAssetTask {
  149872. /**
  149873. * Defines the name of the task
  149874. */
  149875. name: string;
  149876. /**
  149877. * Defines the location of the file to load
  149878. */
  149879. url: string;
  149880. /**
  149881. * Gets the lodaded data (as an array buffer)
  149882. */
  149883. data: ArrayBuffer;
  149884. /**
  149885. * Callback called when the task is successful
  149886. */
  149887. onSuccess: (task: BinaryFileAssetTask) => void;
  149888. /**
  149889. * Callback called when the task is successful
  149890. */
  149891. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149892. /**
  149893. * Creates a new BinaryFileAssetTask object
  149894. * @param name defines the name of the new task
  149895. * @param url defines the location of the file to load
  149896. */
  149897. constructor(
  149898. /**
  149899. * Defines the name of the task
  149900. */
  149901. name: string,
  149902. /**
  149903. * Defines the location of the file to load
  149904. */
  149905. url: string);
  149906. /**
  149907. * Execute the current task
  149908. * @param scene defines the scene where you want your assets to be loaded
  149909. * @param onSuccess is a callback called when the task is successfully executed
  149910. * @param onError is a callback called if an error occurs
  149911. */
  149912. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149913. }
  149914. /**
  149915. * Define a task used by AssetsManager to load images
  149916. */
  149917. export class ImageAssetTask extends AbstractAssetTask {
  149918. /**
  149919. * Defines the name of the task
  149920. */
  149921. name: string;
  149922. /**
  149923. * Defines the location of the image to load
  149924. */
  149925. url: string;
  149926. /**
  149927. * Gets the loaded images
  149928. */
  149929. image: HTMLImageElement;
  149930. /**
  149931. * Callback called when the task is successful
  149932. */
  149933. onSuccess: (task: ImageAssetTask) => void;
  149934. /**
  149935. * Callback called when the task is successful
  149936. */
  149937. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149938. /**
  149939. * Creates a new ImageAssetTask
  149940. * @param name defines the name of the task
  149941. * @param url defines the location of the image to load
  149942. */
  149943. constructor(
  149944. /**
  149945. * Defines the name of the task
  149946. */
  149947. name: string,
  149948. /**
  149949. * Defines the location of the image to load
  149950. */
  149951. url: string);
  149952. /**
  149953. * Execute the current task
  149954. * @param scene defines the scene where you want your assets to be loaded
  149955. * @param onSuccess is a callback called when the task is successfully executed
  149956. * @param onError is a callback called if an error occurs
  149957. */
  149958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149959. }
  149960. /**
  149961. * Defines the interface used by texture loading tasks
  149962. */
  149963. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149964. /**
  149965. * Gets the loaded texture
  149966. */
  149967. texture: TEX;
  149968. }
  149969. /**
  149970. * Define a task used by AssetsManager to load 2D textures
  149971. */
  149972. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149973. /**
  149974. * Defines the name of the task
  149975. */
  149976. name: string;
  149977. /**
  149978. * Defines the location of the file to load
  149979. */
  149980. url: string;
  149981. /**
  149982. * Defines if mipmap should not be generated (default is false)
  149983. */
  149984. noMipmap?: boolean | undefined;
  149985. /**
  149986. * Defines if texture must be inverted on Y axis (default is true)
  149987. */
  149988. invertY: boolean;
  149989. /**
  149990. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149991. */
  149992. samplingMode: number;
  149993. /**
  149994. * Gets the loaded texture
  149995. */
  149996. texture: Texture;
  149997. /**
  149998. * Callback called when the task is successful
  149999. */
  150000. onSuccess: (task: TextureAssetTask) => void;
  150001. /**
  150002. * Callback called when the task is successful
  150003. */
  150004. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150005. /**
  150006. * Creates a new TextureAssetTask object
  150007. * @param name defines the name of the task
  150008. * @param url defines the location of the file to load
  150009. * @param noMipmap defines if mipmap should not be generated (default is false)
  150010. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150011. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150012. */
  150013. constructor(
  150014. /**
  150015. * Defines the name of the task
  150016. */
  150017. name: string,
  150018. /**
  150019. * Defines the location of the file to load
  150020. */
  150021. url: string,
  150022. /**
  150023. * Defines if mipmap should not be generated (default is false)
  150024. */
  150025. noMipmap?: boolean | undefined,
  150026. /**
  150027. * Defines if texture must be inverted on Y axis (default is true)
  150028. */
  150029. invertY?: boolean,
  150030. /**
  150031. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150032. */
  150033. samplingMode?: number);
  150034. /**
  150035. * Execute the current task
  150036. * @param scene defines the scene where you want your assets to be loaded
  150037. * @param onSuccess is a callback called when the task is successfully executed
  150038. * @param onError is a callback called if an error occurs
  150039. */
  150040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150041. }
  150042. /**
  150043. * Define a task used by AssetsManager to load cube textures
  150044. */
  150045. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150046. /**
  150047. * Defines the name of the task
  150048. */
  150049. name: string;
  150050. /**
  150051. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150052. */
  150053. url: string;
  150054. /**
  150055. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150056. */
  150057. extensions?: string[] | undefined;
  150058. /**
  150059. * Defines if mipmaps should not be generated (default is false)
  150060. */
  150061. noMipmap?: boolean | undefined;
  150062. /**
  150063. * Defines the explicit list of files (undefined by default)
  150064. */
  150065. files?: string[] | undefined;
  150066. /**
  150067. * Gets the loaded texture
  150068. */
  150069. texture: CubeTexture;
  150070. /**
  150071. * Callback called when the task is successful
  150072. */
  150073. onSuccess: (task: CubeTextureAssetTask) => void;
  150074. /**
  150075. * Callback called when the task is successful
  150076. */
  150077. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150078. /**
  150079. * Creates a new CubeTextureAssetTask
  150080. * @param name defines the name of the task
  150081. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150082. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150083. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150084. * @param files defines the explicit list of files (undefined by default)
  150085. */
  150086. constructor(
  150087. /**
  150088. * Defines the name of the task
  150089. */
  150090. name: string,
  150091. /**
  150092. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150093. */
  150094. url: string,
  150095. /**
  150096. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150097. */
  150098. extensions?: string[] | undefined,
  150099. /**
  150100. * Defines if mipmaps should not be generated (default is false)
  150101. */
  150102. noMipmap?: boolean | undefined,
  150103. /**
  150104. * Defines the explicit list of files (undefined by default)
  150105. */
  150106. files?: string[] | undefined);
  150107. /**
  150108. * Execute the current task
  150109. * @param scene defines the scene where you want your assets to be loaded
  150110. * @param onSuccess is a callback called when the task is successfully executed
  150111. * @param onError is a callback called if an error occurs
  150112. */
  150113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150114. }
  150115. /**
  150116. * Define a task used by AssetsManager to load HDR cube textures
  150117. */
  150118. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150119. /**
  150120. * Defines the name of the task
  150121. */
  150122. name: string;
  150123. /**
  150124. * Defines the location of the file to load
  150125. */
  150126. url: string;
  150127. /**
  150128. * Defines the desired size (the more it increases the longer the generation will be)
  150129. */
  150130. size: number;
  150131. /**
  150132. * Defines if mipmaps should not be generated (default is false)
  150133. */
  150134. noMipmap: boolean;
  150135. /**
  150136. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150137. */
  150138. generateHarmonics: boolean;
  150139. /**
  150140. * 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)
  150141. */
  150142. gammaSpace: boolean;
  150143. /**
  150144. * Internal Use Only
  150145. */
  150146. reserved: boolean;
  150147. /**
  150148. * Gets the loaded texture
  150149. */
  150150. texture: HDRCubeTexture;
  150151. /**
  150152. * Callback called when the task is successful
  150153. */
  150154. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150155. /**
  150156. * Callback called when the task is successful
  150157. */
  150158. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150159. /**
  150160. * Creates a new HDRCubeTextureAssetTask object
  150161. * @param name defines the name of the task
  150162. * @param url defines the location of the file to load
  150163. * @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.
  150164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150165. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150166. * @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)
  150167. * @param reserved Internal use only
  150168. */
  150169. constructor(
  150170. /**
  150171. * Defines the name of the task
  150172. */
  150173. name: string,
  150174. /**
  150175. * Defines the location of the file to load
  150176. */
  150177. url: string,
  150178. /**
  150179. * Defines the desired size (the more it increases the longer the generation will be)
  150180. */
  150181. size: number,
  150182. /**
  150183. * Defines if mipmaps should not be generated (default is false)
  150184. */
  150185. noMipmap?: boolean,
  150186. /**
  150187. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150188. */
  150189. generateHarmonics?: boolean,
  150190. /**
  150191. * 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)
  150192. */
  150193. gammaSpace?: boolean,
  150194. /**
  150195. * Internal Use Only
  150196. */
  150197. reserved?: boolean);
  150198. /**
  150199. * Execute the current task
  150200. * @param scene defines the scene where you want your assets to be loaded
  150201. * @param onSuccess is a callback called when the task is successfully executed
  150202. * @param onError is a callback called if an error occurs
  150203. */
  150204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150205. }
  150206. /**
  150207. * Define a task used by AssetsManager to load Equirectangular cube textures
  150208. */
  150209. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150210. /**
  150211. * Defines the name of the task
  150212. */
  150213. name: string;
  150214. /**
  150215. * Defines the location of the file to load
  150216. */
  150217. url: string;
  150218. /**
  150219. * Defines the desired size (the more it increases the longer the generation will be)
  150220. */
  150221. size: number;
  150222. /**
  150223. * Defines if mipmaps should not be generated (default is false)
  150224. */
  150225. noMipmap: boolean;
  150226. /**
  150227. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150228. * but the standard material would require them in Gamma space) (default is true)
  150229. */
  150230. gammaSpace: boolean;
  150231. /**
  150232. * Gets the loaded texture
  150233. */
  150234. texture: EquiRectangularCubeTexture;
  150235. /**
  150236. * Callback called when the task is successful
  150237. */
  150238. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150239. /**
  150240. * Callback called when the task is successful
  150241. */
  150242. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150243. /**
  150244. * Creates a new EquiRectangularCubeTextureAssetTask object
  150245. * @param name defines the name of the task
  150246. * @param url defines the location of the file to load
  150247. * @param size defines the desired size (the more it increases the longer the generation will be)
  150248. * If the size is omitted this implies you are using a preprocessed cubemap.
  150249. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150250. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150251. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150252. * (default is true)
  150253. */
  150254. constructor(
  150255. /**
  150256. * Defines the name of the task
  150257. */
  150258. name: string,
  150259. /**
  150260. * Defines the location of the file to load
  150261. */
  150262. url: string,
  150263. /**
  150264. * Defines the desired size (the more it increases the longer the generation will be)
  150265. */
  150266. size: number,
  150267. /**
  150268. * Defines if mipmaps should not be generated (default is false)
  150269. */
  150270. noMipmap?: boolean,
  150271. /**
  150272. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150273. * but the standard material would require them in Gamma space) (default is true)
  150274. */
  150275. gammaSpace?: boolean);
  150276. /**
  150277. * Execute the current task
  150278. * @param scene defines the scene where you want your assets to be loaded
  150279. * @param onSuccess is a callback called when the task is successfully executed
  150280. * @param onError is a callback called if an error occurs
  150281. */
  150282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150283. }
  150284. /**
  150285. * This class can be used to easily import assets into a scene
  150286. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150287. */
  150288. export class AssetsManager {
  150289. private _scene;
  150290. private _isLoading;
  150291. protected _tasks: AbstractAssetTask[];
  150292. protected _waitingTasksCount: number;
  150293. protected _totalTasksCount: number;
  150294. /**
  150295. * Callback called when all tasks are processed
  150296. */
  150297. onFinish: (tasks: AbstractAssetTask[]) => void;
  150298. /**
  150299. * Callback called when a task is successful
  150300. */
  150301. onTaskSuccess: (task: AbstractAssetTask) => void;
  150302. /**
  150303. * Callback called when a task had an error
  150304. */
  150305. onTaskError: (task: AbstractAssetTask) => void;
  150306. /**
  150307. * Callback called when a task is done (whatever the result is)
  150308. */
  150309. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150310. /**
  150311. * Observable called when all tasks are processed
  150312. */
  150313. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150314. /**
  150315. * Observable called when a task had an error
  150316. */
  150317. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150318. /**
  150319. * Observable called when all tasks were executed
  150320. */
  150321. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150322. /**
  150323. * Observable called when a task is done (whatever the result is)
  150324. */
  150325. onProgressObservable: Observable<IAssetsProgressEvent>;
  150326. /**
  150327. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150328. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150329. */
  150330. useDefaultLoadingScreen: boolean;
  150331. /**
  150332. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150333. * when all assets have been downloaded.
  150334. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150335. */
  150336. autoHideLoadingUI: boolean;
  150337. /**
  150338. * Creates a new AssetsManager
  150339. * @param scene defines the scene to work on
  150340. */
  150341. constructor(scene: Scene);
  150342. /**
  150343. * Add a MeshAssetTask to the list of active tasks
  150344. * @param taskName defines the name of the new task
  150345. * @param meshesNames defines the name of meshes to load
  150346. * @param rootUrl defines the root url to use to locate files
  150347. * @param sceneFilename defines the filename of the scene file
  150348. * @returns a new MeshAssetTask object
  150349. */
  150350. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150351. /**
  150352. * Add a TextFileAssetTask to the list of active tasks
  150353. * @param taskName defines the name of the new task
  150354. * @param url defines the url of the file to load
  150355. * @returns a new TextFileAssetTask object
  150356. */
  150357. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150358. /**
  150359. * Add a BinaryFileAssetTask to the list of active tasks
  150360. * @param taskName defines the name of the new task
  150361. * @param url defines the url of the file to load
  150362. * @returns a new BinaryFileAssetTask object
  150363. */
  150364. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150365. /**
  150366. * Add a ImageAssetTask to the list of active tasks
  150367. * @param taskName defines the name of the new task
  150368. * @param url defines the url of the file to load
  150369. * @returns a new ImageAssetTask object
  150370. */
  150371. addImageTask(taskName: string, url: string): ImageAssetTask;
  150372. /**
  150373. * Add a TextureAssetTask to the list of active tasks
  150374. * @param taskName defines the name of the new task
  150375. * @param url defines the url of the file to load
  150376. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150377. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150378. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150379. * @returns a new TextureAssetTask object
  150380. */
  150381. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150382. /**
  150383. * Add a CubeTextureAssetTask to the list of active tasks
  150384. * @param taskName defines the name of the new task
  150385. * @param url defines the url of the file to load
  150386. * @param extensions defines the extension to use to load the cube map (can be null)
  150387. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150388. * @param files defines the list of files to load (can be null)
  150389. * @returns a new CubeTextureAssetTask object
  150390. */
  150391. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150392. /**
  150393. *
  150394. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150395. * @param taskName defines the name of the new task
  150396. * @param url defines the url of the file to load
  150397. * @param size defines the size you want for the cubemap (can be null)
  150398. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150399. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150400. * @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)
  150401. * @param reserved Internal use only
  150402. * @returns a new HDRCubeTextureAssetTask object
  150403. */
  150404. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150405. /**
  150406. *
  150407. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150408. * @param taskName defines the name of the new task
  150409. * @param url defines the url of the file to load
  150410. * @param size defines the size you want for the cubemap (can be null)
  150411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150412. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150413. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150414. * @returns a new EquiRectangularCubeTextureAssetTask object
  150415. */
  150416. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150417. /**
  150418. * Remove a task from the assets manager.
  150419. * @param task the task to remove
  150420. */
  150421. removeTask(task: AbstractAssetTask): void;
  150422. private _decreaseWaitingTasksCount;
  150423. private _runTask;
  150424. /**
  150425. * Reset the AssetsManager and remove all tasks
  150426. * @return the current instance of the AssetsManager
  150427. */
  150428. reset(): AssetsManager;
  150429. /**
  150430. * Start the loading process
  150431. * @return the current instance of the AssetsManager
  150432. */
  150433. load(): AssetsManager;
  150434. /**
  150435. * Start the loading process as an async operation
  150436. * @return a promise returning the list of failed tasks
  150437. */
  150438. loadAsync(): Promise<void>;
  150439. }
  150440. }
  150441. declare module BABYLON {
  150442. /**
  150443. * Wrapper class for promise with external resolve and reject.
  150444. */
  150445. export class Deferred<T> {
  150446. /**
  150447. * The promise associated with this deferred object.
  150448. */
  150449. readonly promise: Promise<T>;
  150450. private _resolve;
  150451. private _reject;
  150452. /**
  150453. * The resolve method of the promise associated with this deferred object.
  150454. */
  150455. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150456. /**
  150457. * The reject method of the promise associated with this deferred object.
  150458. */
  150459. get reject(): (reason?: any) => void;
  150460. /**
  150461. * Constructor for this deferred object.
  150462. */
  150463. constructor();
  150464. }
  150465. }
  150466. declare module BABYLON {
  150467. /**
  150468. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150469. */
  150470. export class MeshExploder {
  150471. private _centerMesh;
  150472. private _meshes;
  150473. private _meshesOrigins;
  150474. private _toCenterVectors;
  150475. private _scaledDirection;
  150476. private _newPosition;
  150477. private _centerPosition;
  150478. /**
  150479. * Explodes meshes from a center mesh.
  150480. * @param meshes The meshes to explode.
  150481. * @param centerMesh The mesh to be center of explosion.
  150482. */
  150483. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150484. private _setCenterMesh;
  150485. /**
  150486. * Get class name
  150487. * @returns "MeshExploder"
  150488. */
  150489. getClassName(): string;
  150490. /**
  150491. * "Exploded meshes"
  150492. * @returns Array of meshes with the centerMesh at index 0.
  150493. */
  150494. getMeshes(): Array<Mesh>;
  150495. /**
  150496. * Explodes meshes giving a specific direction
  150497. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150498. */
  150499. explode(direction?: number): void;
  150500. }
  150501. }
  150502. declare module BABYLON {
  150503. /**
  150504. * Class used to help managing file picking and drag'n'drop
  150505. */
  150506. export class FilesInput {
  150507. /**
  150508. * List of files ready to be loaded
  150509. */
  150510. static get FilesToLoad(): {
  150511. [key: string]: File;
  150512. };
  150513. /**
  150514. * Callback called when a file is processed
  150515. */
  150516. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150517. private _engine;
  150518. private _currentScene;
  150519. private _sceneLoadedCallback;
  150520. private _progressCallback;
  150521. private _additionalRenderLoopLogicCallback;
  150522. private _textureLoadingCallback;
  150523. private _startingProcessingFilesCallback;
  150524. private _onReloadCallback;
  150525. private _errorCallback;
  150526. private _elementToMonitor;
  150527. private _sceneFileToLoad;
  150528. private _filesToLoad;
  150529. /**
  150530. * Creates a new FilesInput
  150531. * @param engine defines the rendering engine
  150532. * @param scene defines the hosting scene
  150533. * @param sceneLoadedCallback callback called when scene is loaded
  150534. * @param progressCallback callback called to track progress
  150535. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150536. * @param textureLoadingCallback callback called when a texture is loading
  150537. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150538. * @param onReloadCallback callback called when a reload is requested
  150539. * @param errorCallback callback call if an error occurs
  150540. */
  150541. 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>);
  150542. private _dragEnterHandler;
  150543. private _dragOverHandler;
  150544. private _dropHandler;
  150545. /**
  150546. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150547. * @param elementToMonitor defines the DOM element to track
  150548. */
  150549. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150550. /** Gets the current list of files to load */
  150551. get filesToLoad(): File[];
  150552. /**
  150553. * Release all associated resources
  150554. */
  150555. dispose(): void;
  150556. private renderFunction;
  150557. private drag;
  150558. private drop;
  150559. private _traverseFolder;
  150560. private _processFiles;
  150561. /**
  150562. * Load files from a drop event
  150563. * @param event defines the drop event to use as source
  150564. */
  150565. loadFiles(event: any): void;
  150566. private _processReload;
  150567. /**
  150568. * Reload the current scene from the loaded files
  150569. */
  150570. reload(): void;
  150571. }
  150572. }
  150573. declare module BABYLON {
  150574. /**
  150575. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150576. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150577. */
  150578. export class SceneOptimization {
  150579. /**
  150580. * Defines the priority of this optimization (0 by default which means first in the list)
  150581. */
  150582. priority: number;
  150583. /**
  150584. * Gets a string describing the action executed by the current optimization
  150585. * @returns description string
  150586. */
  150587. getDescription(): string;
  150588. /**
  150589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150590. * @param scene defines the current scene where to apply this optimization
  150591. * @param optimizer defines the current optimizer
  150592. * @returns true if everything that can be done was applied
  150593. */
  150594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150595. /**
  150596. * Creates the SceneOptimization object
  150597. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150598. * @param desc defines the description associated with the optimization
  150599. */
  150600. constructor(
  150601. /**
  150602. * Defines the priority of this optimization (0 by default which means first in the list)
  150603. */
  150604. priority?: number);
  150605. }
  150606. /**
  150607. * Defines an optimization used to reduce the size of render target textures
  150608. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150609. */
  150610. export class TextureOptimization extends SceneOptimization {
  150611. /**
  150612. * Defines the priority of this optimization (0 by default which means first in the list)
  150613. */
  150614. priority: number;
  150615. /**
  150616. * 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
  150617. */
  150618. maximumSize: number;
  150619. /**
  150620. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150621. */
  150622. step: number;
  150623. /**
  150624. * Gets a string describing the action executed by the current optimization
  150625. * @returns description string
  150626. */
  150627. getDescription(): string;
  150628. /**
  150629. * Creates the TextureOptimization object
  150630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150631. * @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
  150632. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150633. */
  150634. constructor(
  150635. /**
  150636. * Defines the priority of this optimization (0 by default which means first in the list)
  150637. */
  150638. priority?: number,
  150639. /**
  150640. * 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
  150641. */
  150642. maximumSize?: number,
  150643. /**
  150644. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150645. */
  150646. step?: number);
  150647. /**
  150648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150649. * @param scene defines the current scene where to apply this optimization
  150650. * @param optimizer defines the current optimizer
  150651. * @returns true if everything that can be done was applied
  150652. */
  150653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150654. }
  150655. /**
  150656. * Defines an optimization used to increase or decrease the rendering resolution
  150657. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150658. */
  150659. export class HardwareScalingOptimization extends SceneOptimization {
  150660. /**
  150661. * Defines the priority of this optimization (0 by default which means first in the list)
  150662. */
  150663. priority: number;
  150664. /**
  150665. * Defines the maximum scale to use (2 by default)
  150666. */
  150667. maximumScale: number;
  150668. /**
  150669. * Defines the step to use between two passes (0.5 by default)
  150670. */
  150671. step: number;
  150672. private _currentScale;
  150673. private _directionOffset;
  150674. /**
  150675. * Gets a string describing the action executed by the current optimization
  150676. * @return description string
  150677. */
  150678. getDescription(): string;
  150679. /**
  150680. * Creates the HardwareScalingOptimization object
  150681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150682. * @param maximumScale defines the maximum scale to use (2 by default)
  150683. * @param step defines the step to use between two passes (0.5 by default)
  150684. */
  150685. constructor(
  150686. /**
  150687. * Defines the priority of this optimization (0 by default which means first in the list)
  150688. */
  150689. priority?: number,
  150690. /**
  150691. * Defines the maximum scale to use (2 by default)
  150692. */
  150693. maximumScale?: number,
  150694. /**
  150695. * Defines the step to use between two passes (0.5 by default)
  150696. */
  150697. step?: number);
  150698. /**
  150699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150700. * @param scene defines the current scene where to apply this optimization
  150701. * @param optimizer defines the current optimizer
  150702. * @returns true if everything that can be done was applied
  150703. */
  150704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150705. }
  150706. /**
  150707. * Defines an optimization used to remove shadows
  150708. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150709. */
  150710. export class ShadowsOptimization extends SceneOptimization {
  150711. /**
  150712. * Gets a string describing the action executed by the current optimization
  150713. * @return description string
  150714. */
  150715. getDescription(): string;
  150716. /**
  150717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150718. * @param scene defines the current scene where to apply this optimization
  150719. * @param optimizer defines the current optimizer
  150720. * @returns true if everything that can be done was applied
  150721. */
  150722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150723. }
  150724. /**
  150725. * Defines an optimization used to turn post-processes off
  150726. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150727. */
  150728. export class PostProcessesOptimization extends SceneOptimization {
  150729. /**
  150730. * Gets a string describing the action executed by the current optimization
  150731. * @return description string
  150732. */
  150733. getDescription(): string;
  150734. /**
  150735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150736. * @param scene defines the current scene where to apply this optimization
  150737. * @param optimizer defines the current optimizer
  150738. * @returns true if everything that can be done was applied
  150739. */
  150740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150741. }
  150742. /**
  150743. * Defines an optimization used to turn lens flares off
  150744. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150745. */
  150746. export class LensFlaresOptimization extends SceneOptimization {
  150747. /**
  150748. * Gets a string describing the action executed by the current optimization
  150749. * @return description string
  150750. */
  150751. getDescription(): string;
  150752. /**
  150753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150754. * @param scene defines the current scene where to apply this optimization
  150755. * @param optimizer defines the current optimizer
  150756. * @returns true if everything that can be done was applied
  150757. */
  150758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150759. }
  150760. /**
  150761. * Defines an optimization based on user defined callback.
  150762. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150763. */
  150764. export class CustomOptimization extends SceneOptimization {
  150765. /**
  150766. * Callback called to apply the custom optimization.
  150767. */
  150768. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150769. /**
  150770. * Callback called to get custom description
  150771. */
  150772. onGetDescription: () => string;
  150773. /**
  150774. * Gets a string describing the action executed by the current optimization
  150775. * @returns description string
  150776. */
  150777. getDescription(): string;
  150778. /**
  150779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150780. * @param scene defines the current scene where to apply this optimization
  150781. * @param optimizer defines the current optimizer
  150782. * @returns true if everything that can be done was applied
  150783. */
  150784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150785. }
  150786. /**
  150787. * Defines an optimization used to turn particles off
  150788. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150789. */
  150790. export class ParticlesOptimization extends SceneOptimization {
  150791. /**
  150792. * Gets a string describing the action executed by the current optimization
  150793. * @return description string
  150794. */
  150795. getDescription(): string;
  150796. /**
  150797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150798. * @param scene defines the current scene where to apply this optimization
  150799. * @param optimizer defines the current optimizer
  150800. * @returns true if everything that can be done was applied
  150801. */
  150802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150803. }
  150804. /**
  150805. * Defines an optimization used to turn render targets off
  150806. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150807. */
  150808. export class RenderTargetsOptimization extends SceneOptimization {
  150809. /**
  150810. * Gets a string describing the action executed by the current optimization
  150811. * @return description string
  150812. */
  150813. getDescription(): string;
  150814. /**
  150815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150816. * @param scene defines the current scene where to apply this optimization
  150817. * @param optimizer defines the current optimizer
  150818. * @returns true if everything that can be done was applied
  150819. */
  150820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150821. }
  150822. /**
  150823. * Defines an optimization used to merge meshes with compatible materials
  150824. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150825. */
  150826. export class MergeMeshesOptimization extends SceneOptimization {
  150827. private static _UpdateSelectionTree;
  150828. /**
  150829. * Gets or sets a boolean which defines if optimization octree has to be updated
  150830. */
  150831. static get UpdateSelectionTree(): boolean;
  150832. /**
  150833. * Gets or sets a boolean which defines if optimization octree has to be updated
  150834. */
  150835. static set UpdateSelectionTree(value: boolean);
  150836. /**
  150837. * Gets a string describing the action executed by the current optimization
  150838. * @return description string
  150839. */
  150840. getDescription(): string;
  150841. private _canBeMerged;
  150842. /**
  150843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150844. * @param scene defines the current scene where to apply this optimization
  150845. * @param optimizer defines the current optimizer
  150846. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150847. * @returns true if everything that can be done was applied
  150848. */
  150849. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150850. }
  150851. /**
  150852. * Defines a list of options used by SceneOptimizer
  150853. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150854. */
  150855. export class SceneOptimizerOptions {
  150856. /**
  150857. * Defines the target frame rate to reach (60 by default)
  150858. */
  150859. targetFrameRate: number;
  150860. /**
  150861. * Defines the interval between two checkes (2000ms by default)
  150862. */
  150863. trackerDuration: number;
  150864. /**
  150865. * Gets the list of optimizations to apply
  150866. */
  150867. optimizations: SceneOptimization[];
  150868. /**
  150869. * Creates a new list of options used by SceneOptimizer
  150870. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150871. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150872. */
  150873. constructor(
  150874. /**
  150875. * Defines the target frame rate to reach (60 by default)
  150876. */
  150877. targetFrameRate?: number,
  150878. /**
  150879. * Defines the interval between two checkes (2000ms by default)
  150880. */
  150881. trackerDuration?: number);
  150882. /**
  150883. * Add a new optimization
  150884. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150885. * @returns the current SceneOptimizerOptions
  150886. */
  150887. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150888. /**
  150889. * Add a new custom optimization
  150890. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150891. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150893. * @returns the current SceneOptimizerOptions
  150894. */
  150895. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150896. /**
  150897. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150898. * @param targetFrameRate defines the target frame rate (60 by default)
  150899. * @returns a SceneOptimizerOptions object
  150900. */
  150901. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150902. /**
  150903. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150904. * @param targetFrameRate defines the target frame rate (60 by default)
  150905. * @returns a SceneOptimizerOptions object
  150906. */
  150907. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150908. /**
  150909. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150910. * @param targetFrameRate defines the target frame rate (60 by default)
  150911. * @returns a SceneOptimizerOptions object
  150912. */
  150913. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150914. }
  150915. /**
  150916. * Class used to run optimizations in order to reach a target frame rate
  150917. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150918. */
  150919. export class SceneOptimizer implements IDisposable {
  150920. private _isRunning;
  150921. private _options;
  150922. private _scene;
  150923. private _currentPriorityLevel;
  150924. private _targetFrameRate;
  150925. private _trackerDuration;
  150926. private _currentFrameRate;
  150927. private _sceneDisposeObserver;
  150928. private _improvementMode;
  150929. /**
  150930. * Defines an observable called when the optimizer reaches the target frame rate
  150931. */
  150932. onSuccessObservable: Observable<SceneOptimizer>;
  150933. /**
  150934. * Defines an observable called when the optimizer enables an optimization
  150935. */
  150936. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150937. /**
  150938. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150939. */
  150940. onFailureObservable: Observable<SceneOptimizer>;
  150941. /**
  150942. * Gets a boolean indicating if the optimizer is in improvement mode
  150943. */
  150944. get isInImprovementMode(): boolean;
  150945. /**
  150946. * Gets the current priority level (0 at start)
  150947. */
  150948. get currentPriorityLevel(): number;
  150949. /**
  150950. * Gets the current frame rate checked by the SceneOptimizer
  150951. */
  150952. get currentFrameRate(): number;
  150953. /**
  150954. * Gets or sets the current target frame rate (60 by default)
  150955. */
  150956. get targetFrameRate(): number;
  150957. /**
  150958. * Gets or sets the current target frame rate (60 by default)
  150959. */
  150960. set targetFrameRate(value: number);
  150961. /**
  150962. * Gets or sets the current interval between two checks (every 2000ms by default)
  150963. */
  150964. get trackerDuration(): number;
  150965. /**
  150966. * Gets or sets the current interval between two checks (every 2000ms by default)
  150967. */
  150968. set trackerDuration(value: number);
  150969. /**
  150970. * Gets the list of active optimizations
  150971. */
  150972. get optimizations(): SceneOptimization[];
  150973. /**
  150974. * Creates a new SceneOptimizer
  150975. * @param scene defines the scene to work on
  150976. * @param options defines the options to use with the SceneOptimizer
  150977. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150978. * @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)
  150979. */
  150980. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150981. /**
  150982. * Stops the current optimizer
  150983. */
  150984. stop(): void;
  150985. /**
  150986. * Reset the optimizer to initial step (current priority level = 0)
  150987. */
  150988. reset(): void;
  150989. /**
  150990. * Start the optimizer. By default it will try to reach a specific framerate
  150991. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150992. */
  150993. start(): void;
  150994. private _checkCurrentState;
  150995. /**
  150996. * Release all resources
  150997. */
  150998. dispose(): void;
  150999. /**
  151000. * Helper function to create a SceneOptimizer with one single line of code
  151001. * @param scene defines the scene to work on
  151002. * @param options defines the options to use with the SceneOptimizer
  151003. * @param onSuccess defines a callback to call on success
  151004. * @param onFailure defines a callback to call on failure
  151005. * @returns the new SceneOptimizer object
  151006. */
  151007. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151008. }
  151009. }
  151010. declare module BABYLON {
  151011. /**
  151012. * Class used to serialize a scene into a string
  151013. */
  151014. export class SceneSerializer {
  151015. /**
  151016. * Clear cache used by a previous serialization
  151017. */
  151018. static ClearCache(): void;
  151019. /**
  151020. * Serialize a scene into a JSON compatible object
  151021. * @param scene defines the scene to serialize
  151022. * @returns a JSON compatible object
  151023. */
  151024. static Serialize(scene: Scene): any;
  151025. /**
  151026. * Serialize a mesh into a JSON compatible object
  151027. * @param toSerialize defines the mesh to serialize
  151028. * @param withParents defines if parents must be serialized as well
  151029. * @param withChildren defines if children must be serialized as well
  151030. * @returns a JSON compatible object
  151031. */
  151032. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151033. }
  151034. }
  151035. declare module BABYLON {
  151036. /**
  151037. * Class used to host texture specific utilities
  151038. */
  151039. export class TextureTools {
  151040. /**
  151041. * Uses the GPU to create a copy texture rescaled at a given size
  151042. * @param texture Texture to copy from
  151043. * @param width defines the desired width
  151044. * @param height defines the desired height
  151045. * @param useBilinearMode defines if bilinear mode has to be used
  151046. * @return the generated texture
  151047. */
  151048. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151049. }
  151050. }
  151051. declare module BABYLON {
  151052. /**
  151053. * This represents the different options available for the video capture.
  151054. */
  151055. export interface VideoRecorderOptions {
  151056. /** Defines the mime type of the video. */
  151057. mimeType: string;
  151058. /** Defines the FPS the video should be recorded at. */
  151059. fps: number;
  151060. /** Defines the chunk size for the recording data. */
  151061. recordChunckSize: number;
  151062. /** The audio tracks to attach to the recording. */
  151063. audioTracks?: MediaStreamTrack[];
  151064. }
  151065. /**
  151066. * This can help with recording videos from BabylonJS.
  151067. * This is based on the available WebRTC functionalities of the browser.
  151068. *
  151069. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151070. */
  151071. export class VideoRecorder {
  151072. private static readonly _defaultOptions;
  151073. /**
  151074. * Returns whether or not the VideoRecorder is available in your browser.
  151075. * @param engine Defines the Babylon Engine.
  151076. * @returns true if supported otherwise false.
  151077. */
  151078. static IsSupported(engine: Engine): boolean;
  151079. private readonly _options;
  151080. private _canvas;
  151081. private _mediaRecorder;
  151082. private _recordedChunks;
  151083. private _fileName;
  151084. private _resolve;
  151085. private _reject;
  151086. /**
  151087. * True when a recording is already in progress.
  151088. */
  151089. get isRecording(): boolean;
  151090. /**
  151091. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151092. * @param engine Defines the BabylonJS Engine you wish to record.
  151093. * @param options Defines options that can be used to customize the capture.
  151094. */
  151095. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151096. /**
  151097. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151098. */
  151099. stopRecording(): void;
  151100. /**
  151101. * Starts recording the canvas for a max duration specified in parameters.
  151102. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151103. * If null no automatic download will start and you can rely on the promise to get the data back.
  151104. * @param maxDuration Defines the maximum recording time in seconds.
  151105. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151106. * @return A promise callback at the end of the recording with the video data in Blob.
  151107. */
  151108. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151109. /**
  151110. * Releases internal resources used during the recording.
  151111. */
  151112. dispose(): void;
  151113. private _handleDataAvailable;
  151114. private _handleError;
  151115. private _handleStop;
  151116. }
  151117. }
  151118. declare module BABYLON {
  151119. /**
  151120. * Class containing a set of static utilities functions for screenshots
  151121. */
  151122. export class ScreenshotTools {
  151123. /**
  151124. * Captures a screenshot of the current rendering
  151125. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151126. * @param engine defines the rendering engine
  151127. * @param camera defines the source camera
  151128. * @param size This parameter can be set to a single number or to an object with the
  151129. * following (optional) properties: precision, width, height. If a single number is passed,
  151130. * it will be used for both width and height. If an object is passed, the screenshot size
  151131. * will be derived from the parameters. The precision property is a multiplier allowing
  151132. * rendering at a higher or lower resolution
  151133. * @param successCallback defines the callback receives a single parameter which contains the
  151134. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151135. * src parameter of an <img> to display it
  151136. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151137. * Check your browser for supported MIME types
  151138. */
  151139. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151140. /**
  151141. * Captures a screenshot of the current rendering
  151142. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151143. * @param engine defines the rendering engine
  151144. * @param camera defines the source camera
  151145. * @param size This parameter can be set to a single number or to an object with the
  151146. * following (optional) properties: precision, width, height. If a single number is passed,
  151147. * it will be used for both width and height. If an object is passed, the screenshot size
  151148. * will be derived from the parameters. The precision property is a multiplier allowing
  151149. * rendering at a higher or lower resolution
  151150. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151151. * Check your browser for supported MIME types
  151152. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151153. * to the src parameter of an <img> to display it
  151154. */
  151155. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151156. /**
  151157. * Generates an image screenshot from the specified camera.
  151158. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151159. * @param engine The engine to use for rendering
  151160. * @param camera The camera to use for rendering
  151161. * @param size This parameter can be set to a single number or to an object with the
  151162. * following (optional) properties: precision, width, height. If a single number is passed,
  151163. * it will be used for both width and height. If an object is passed, the screenshot size
  151164. * will be derived from the parameters. The precision property is a multiplier allowing
  151165. * rendering at a higher or lower resolution
  151166. * @param successCallback The callback receives a single parameter which contains the
  151167. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151168. * src parameter of an <img> to display it
  151169. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151170. * Check your browser for supported MIME types
  151171. * @param samples Texture samples (default: 1)
  151172. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151173. * @param fileName A name for for the downloaded file.
  151174. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151175. */
  151176. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151177. /**
  151178. * Generates an image screenshot from the specified camera.
  151179. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151180. * @param engine The engine to use for rendering
  151181. * @param camera The camera to use for rendering
  151182. * @param size This parameter can be set to a single number or to an object with the
  151183. * following (optional) properties: precision, width, height. If a single number is passed,
  151184. * it will be used for both width and height. If an object is passed, the screenshot size
  151185. * will be derived from the parameters. The precision property is a multiplier allowing
  151186. * rendering at a higher or lower resolution
  151187. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151188. * Check your browser for supported MIME types
  151189. * @param samples Texture samples (default: 1)
  151190. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151191. * @param fileName A name for for the downloaded file.
  151192. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151193. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151194. * to the src parameter of an <img> to display it
  151195. */
  151196. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151197. /**
  151198. * Gets height and width for screenshot size
  151199. * @private
  151200. */
  151201. private static _getScreenshotSize;
  151202. }
  151203. }
  151204. declare module BABYLON {
  151205. /**
  151206. * Interface for a data buffer
  151207. */
  151208. export interface IDataBuffer {
  151209. /**
  151210. * Reads bytes from the data buffer.
  151211. * @param byteOffset The byte offset to read
  151212. * @param byteLength The byte length to read
  151213. * @returns A promise that resolves when the bytes are read
  151214. */
  151215. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151216. /**
  151217. * The byte length of the buffer.
  151218. */
  151219. readonly byteLength: number;
  151220. }
  151221. /**
  151222. * Utility class for reading from a data buffer
  151223. */
  151224. export class DataReader {
  151225. /**
  151226. * The data buffer associated with this data reader.
  151227. */
  151228. readonly buffer: IDataBuffer;
  151229. /**
  151230. * The current byte offset from the beginning of the data buffer.
  151231. */
  151232. byteOffset: number;
  151233. private _dataView;
  151234. private _dataByteOffset;
  151235. /**
  151236. * Constructor
  151237. * @param buffer The buffer to read
  151238. */
  151239. constructor(buffer: IDataBuffer);
  151240. /**
  151241. * Loads the given byte length.
  151242. * @param byteLength The byte length to load
  151243. * @returns A promise that resolves when the load is complete
  151244. */
  151245. loadAsync(byteLength: number): Promise<void>;
  151246. /**
  151247. * Read a unsigned 32-bit integer from the currently loaded data range.
  151248. * @returns The 32-bit integer read
  151249. */
  151250. readUint32(): number;
  151251. /**
  151252. * Read a byte array from the currently loaded data range.
  151253. * @param byteLength The byte length to read
  151254. * @returns The byte array read
  151255. */
  151256. readUint8Array(byteLength: number): Uint8Array;
  151257. /**
  151258. * Read a string from the currently loaded data range.
  151259. * @param byteLength The byte length to read
  151260. * @returns The string read
  151261. */
  151262. readString(byteLength: number): string;
  151263. /**
  151264. * Skips the given byte length the currently loaded data range.
  151265. * @param byteLength The byte length to skip
  151266. */
  151267. skipBytes(byteLength: number): void;
  151268. }
  151269. }
  151270. declare module BABYLON {
  151271. /**
  151272. * Class for storing data to local storage if available or in-memory storage otherwise
  151273. */
  151274. export class DataStorage {
  151275. private static _Storage;
  151276. private static _GetStorage;
  151277. /**
  151278. * Reads a string from the data storage
  151279. * @param key The key to read
  151280. * @param defaultValue The value if the key doesn't exist
  151281. * @returns The string value
  151282. */
  151283. static ReadString(key: string, defaultValue: string): string;
  151284. /**
  151285. * Writes a string to the data storage
  151286. * @param key The key to write
  151287. * @param value The value to write
  151288. */
  151289. static WriteString(key: string, value: string): void;
  151290. /**
  151291. * Reads a boolean from the data storage
  151292. * @param key The key to read
  151293. * @param defaultValue The value if the key doesn't exist
  151294. * @returns The boolean value
  151295. */
  151296. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151297. /**
  151298. * Writes a boolean to the data storage
  151299. * @param key The key to write
  151300. * @param value The value to write
  151301. */
  151302. static WriteBoolean(key: string, value: boolean): void;
  151303. /**
  151304. * Reads a number from the data storage
  151305. * @param key The key to read
  151306. * @param defaultValue The value if the key doesn't exist
  151307. * @returns The number value
  151308. */
  151309. static ReadNumber(key: string, defaultValue: number): number;
  151310. /**
  151311. * Writes a number to the data storage
  151312. * @param key The key to write
  151313. * @param value The value to write
  151314. */
  151315. static WriteNumber(key: string, value: number): void;
  151316. }
  151317. }
  151318. declare module BABYLON {
  151319. /**
  151320. * An interface for all Hit test features
  151321. */
  151322. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151323. /**
  151324. * Triggered when new babylon (transformed) hit test results are available
  151325. */
  151326. onHitTestResultObservable: Observable<T[]>;
  151327. }
  151328. /**
  151329. * Options used for hit testing
  151330. */
  151331. export interface IWebXRLegacyHitTestOptions {
  151332. /**
  151333. * Only test when user interacted with the scene. Default - hit test every frame
  151334. */
  151335. testOnPointerDownOnly?: boolean;
  151336. /**
  151337. * The node to use to transform the local results to world coordinates
  151338. */
  151339. worldParentNode?: TransformNode;
  151340. }
  151341. /**
  151342. * Interface defining the babylon result of raycasting/hit-test
  151343. */
  151344. export interface IWebXRLegacyHitResult {
  151345. /**
  151346. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151347. */
  151348. transformationMatrix: Matrix;
  151349. /**
  151350. * The native hit test result
  151351. */
  151352. xrHitResult: XRHitResult | XRHitTestResult;
  151353. }
  151354. /**
  151355. * The currently-working hit-test module.
  151356. * Hit test (or Ray-casting) is used to interact with the real world.
  151357. * For further information read here - https://github.com/immersive-web/hit-test
  151358. */
  151359. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151360. /**
  151361. * options to use when constructing this feature
  151362. */
  151363. readonly options: IWebXRLegacyHitTestOptions;
  151364. private _direction;
  151365. private _mat;
  151366. private _onSelectEnabled;
  151367. private _origin;
  151368. /**
  151369. * The module's name
  151370. */
  151371. static readonly Name: string;
  151372. /**
  151373. * The (Babylon) version of this module.
  151374. * This is an integer representing the implementation version.
  151375. * This number does not correspond to the WebXR specs version
  151376. */
  151377. static readonly Version: number;
  151378. /**
  151379. * Populated with the last native XR Hit Results
  151380. */
  151381. lastNativeXRHitResults: XRHitResult[];
  151382. /**
  151383. * Triggered when new babylon (transformed) hit test results are available
  151384. */
  151385. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151386. /**
  151387. * Creates a new instance of the (legacy version) hit test feature
  151388. * @param _xrSessionManager an instance of WebXRSessionManager
  151389. * @param options options to use when constructing this feature
  151390. */
  151391. constructor(_xrSessionManager: WebXRSessionManager,
  151392. /**
  151393. * options to use when constructing this feature
  151394. */
  151395. options?: IWebXRLegacyHitTestOptions);
  151396. /**
  151397. * execute a hit test with an XR Ray
  151398. *
  151399. * @param xrSession a native xrSession that will execute this hit test
  151400. * @param xrRay the ray (position and direction) to use for ray-casting
  151401. * @param referenceSpace native XR reference space to use for the hit-test
  151402. * @param filter filter function that will filter the results
  151403. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151404. */
  151405. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151406. /**
  151407. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151408. * @param event the (select) event to use to select with
  151409. * @param referenceSpace the reference space to use for this hit test
  151410. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151411. */
  151412. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151413. /**
  151414. * attach this feature
  151415. * Will usually be called by the features manager
  151416. *
  151417. * @returns true if successful.
  151418. */
  151419. attach(): boolean;
  151420. /**
  151421. * detach this feature.
  151422. * Will usually be called by the features manager
  151423. *
  151424. * @returns true if successful.
  151425. */
  151426. detach(): boolean;
  151427. /**
  151428. * Dispose this feature and all of the resources attached
  151429. */
  151430. dispose(): void;
  151431. protected _onXRFrame(frame: XRFrame): void;
  151432. private _onHitTestResults;
  151433. private _onSelect;
  151434. }
  151435. }
  151436. declare module BABYLON {
  151437. /**
  151438. * Options used for hit testing (version 2)
  151439. */
  151440. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151441. /**
  151442. * Do not create a permanent hit test. Will usually be used when only
  151443. * transient inputs are needed.
  151444. */
  151445. disablePermanentHitTest?: boolean;
  151446. /**
  151447. * Enable transient (for example touch-based) hit test inspections
  151448. */
  151449. enableTransientHitTest?: boolean;
  151450. /**
  151451. * Offset ray for the permanent hit test
  151452. */
  151453. offsetRay?: Vector3;
  151454. /**
  151455. * Offset ray for the transient hit test
  151456. */
  151457. transientOffsetRay?: Vector3;
  151458. /**
  151459. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151460. */
  151461. useReferenceSpace?: boolean;
  151462. }
  151463. /**
  151464. * Interface defining the babylon result of hit-test
  151465. */
  151466. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151467. /**
  151468. * The input source that generated this hit test (if transient)
  151469. */
  151470. inputSource?: XRInputSource;
  151471. /**
  151472. * Is this a transient hit test
  151473. */
  151474. isTransient?: boolean;
  151475. /**
  151476. * Position of the hit test result
  151477. */
  151478. position: Vector3;
  151479. /**
  151480. * Rotation of the hit test result
  151481. */
  151482. rotationQuaternion: Quaternion;
  151483. /**
  151484. * The native hit test result
  151485. */
  151486. xrHitResult: XRHitTestResult;
  151487. }
  151488. /**
  151489. * The currently-working hit-test module.
  151490. * Hit test (or Ray-casting) is used to interact with the real world.
  151491. * For further information read here - https://github.com/immersive-web/hit-test
  151492. *
  151493. * Tested on chrome (mobile) 80.
  151494. */
  151495. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151496. /**
  151497. * options to use when constructing this feature
  151498. */
  151499. readonly options: IWebXRHitTestOptions;
  151500. private _tmpMat;
  151501. private _tmpPos;
  151502. private _tmpQuat;
  151503. private _transientXrHitTestSource;
  151504. private _xrHitTestSource;
  151505. private initHitTestSource;
  151506. /**
  151507. * The module's name
  151508. */
  151509. static readonly Name: string;
  151510. /**
  151511. * The (Babylon) version of this module.
  151512. * This is an integer representing the implementation version.
  151513. * This number does not correspond to the WebXR specs version
  151514. */
  151515. static readonly Version: number;
  151516. /**
  151517. * When set to true, each hit test will have its own position/rotation objects
  151518. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151519. * the developers will clone them or copy them as they see fit.
  151520. */
  151521. autoCloneTransformation: boolean;
  151522. /**
  151523. * Triggered when new babylon (transformed) hit test results are available
  151524. */
  151525. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151526. /**
  151527. * Use this to temporarily pause hit test checks.
  151528. */
  151529. paused: boolean;
  151530. /**
  151531. * Creates a new instance of the hit test feature
  151532. * @param _xrSessionManager an instance of WebXRSessionManager
  151533. * @param options options to use when constructing this feature
  151534. */
  151535. constructor(_xrSessionManager: WebXRSessionManager,
  151536. /**
  151537. * options to use when constructing this feature
  151538. */
  151539. options?: IWebXRHitTestOptions);
  151540. /**
  151541. * attach this feature
  151542. * Will usually be called by the features manager
  151543. *
  151544. * @returns true if successful.
  151545. */
  151546. attach(): boolean;
  151547. /**
  151548. * detach this feature.
  151549. * Will usually be called by the features manager
  151550. *
  151551. * @returns true if successful.
  151552. */
  151553. detach(): boolean;
  151554. /**
  151555. * Dispose this feature and all of the resources attached
  151556. */
  151557. dispose(): void;
  151558. protected _onXRFrame(frame: XRFrame): void;
  151559. private _processWebXRHitTestResult;
  151560. }
  151561. }
  151562. declare module BABYLON {
  151563. /**
  151564. * Configuration options of the anchor system
  151565. */
  151566. export interface IWebXRAnchorSystemOptions {
  151567. /**
  151568. * a node that will be used to convert local to world coordinates
  151569. */
  151570. worldParentNode?: TransformNode;
  151571. /**
  151572. * If set to true a reference of the created anchors will be kept until the next session starts
  151573. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151574. */
  151575. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151576. }
  151577. /**
  151578. * A babylon container for an XR Anchor
  151579. */
  151580. export interface IWebXRAnchor {
  151581. /**
  151582. * A babylon-assigned ID for this anchor
  151583. */
  151584. id: number;
  151585. /**
  151586. * Transformation matrix to apply to an object attached to this anchor
  151587. */
  151588. transformationMatrix: Matrix;
  151589. /**
  151590. * The native anchor object
  151591. */
  151592. xrAnchor: XRAnchor;
  151593. /**
  151594. * if defined, this object will be constantly updated by the anchor's position and rotation
  151595. */
  151596. attachedNode?: TransformNode;
  151597. }
  151598. /**
  151599. * An implementation of the anchor system for WebXR.
  151600. * For further information see https://github.com/immersive-web/anchors/
  151601. */
  151602. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151603. private _options;
  151604. private _lastFrameDetected;
  151605. private _trackedAnchors;
  151606. private _referenceSpaceForFrameAnchors;
  151607. private _futureAnchors;
  151608. /**
  151609. * The module's name
  151610. */
  151611. static readonly Name: string;
  151612. /**
  151613. * The (Babylon) version of this module.
  151614. * This is an integer representing the implementation version.
  151615. * This number does not correspond to the WebXR specs version
  151616. */
  151617. static readonly Version: number;
  151618. /**
  151619. * Observers registered here will be executed when a new anchor was added to the session
  151620. */
  151621. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151622. /**
  151623. * Observers registered here will be executed when an anchor was removed from the session
  151624. */
  151625. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151626. /**
  151627. * Observers registered here will be executed when an existing anchor updates
  151628. * This can execute N times every frame
  151629. */
  151630. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151631. /**
  151632. * Set the reference space to use for anchor creation, when not using a hit test.
  151633. * Will default to the session's reference space if not defined
  151634. */
  151635. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151636. /**
  151637. * constructs a new anchor system
  151638. * @param _xrSessionManager an instance of WebXRSessionManager
  151639. * @param _options configuration object for this feature
  151640. */
  151641. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151642. private _tmpVector;
  151643. private _tmpQuaternion;
  151644. private _populateTmpTransformation;
  151645. /**
  151646. * Create a new anchor point using a hit test result at a specific point in the scene
  151647. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151648. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151649. *
  151650. * @param hitTestResult The hit test result to use for this anchor creation
  151651. * @param position an optional position offset for this anchor
  151652. * @param rotationQuaternion an optional rotation offset for this anchor
  151653. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151654. */
  151655. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151656. /**
  151657. * Add a new anchor at a specific position and rotation
  151658. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151659. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151660. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151661. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151662. *
  151663. * @param position the position in which to add an anchor
  151664. * @param rotationQuaternion an optional rotation for the anchor transformation
  151665. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151666. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151667. */
  151668. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151669. /**
  151670. * detach this feature.
  151671. * Will usually be called by the features manager
  151672. *
  151673. * @returns true if successful.
  151674. */
  151675. detach(): boolean;
  151676. /**
  151677. * Dispose this feature and all of the resources attached
  151678. */
  151679. dispose(): void;
  151680. protected _onXRFrame(frame: XRFrame): void;
  151681. /**
  151682. * avoiding using Array.find for global support.
  151683. * @param xrAnchor the plane to find in the array
  151684. */
  151685. private _findIndexInAnchorArray;
  151686. private _updateAnchorWithXRFrame;
  151687. private _createAnchorAtTransformation;
  151688. }
  151689. }
  151690. declare module BABYLON {
  151691. /**
  151692. * Options used in the plane detector module
  151693. */
  151694. export interface IWebXRPlaneDetectorOptions {
  151695. /**
  151696. * The node to use to transform the local results to world coordinates
  151697. */
  151698. worldParentNode?: TransformNode;
  151699. /**
  151700. * If set to true a reference of the created planes will be kept until the next session starts
  151701. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151702. */
  151703. doNotRemovePlanesOnSessionEnded?: boolean;
  151704. }
  151705. /**
  151706. * A babylon interface for a WebXR plane.
  151707. * A Plane is actually a polygon, built from N points in space
  151708. *
  151709. * Supported in chrome 79, not supported in canary 81 ATM
  151710. */
  151711. export interface IWebXRPlane {
  151712. /**
  151713. * a babylon-assigned ID for this polygon
  151714. */
  151715. id: number;
  151716. /**
  151717. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151718. */
  151719. polygonDefinition: Array<Vector3>;
  151720. /**
  151721. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151722. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151723. */
  151724. transformationMatrix: Matrix;
  151725. /**
  151726. * the native xr-plane object
  151727. */
  151728. xrPlane: XRPlane;
  151729. }
  151730. /**
  151731. * The plane detector is used to detect planes in the real world when in AR
  151732. * For more information see https://github.com/immersive-web/real-world-geometry/
  151733. */
  151734. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151735. private _options;
  151736. private _detectedPlanes;
  151737. private _enabled;
  151738. private _lastFrameDetected;
  151739. /**
  151740. * The module's name
  151741. */
  151742. static readonly Name: string;
  151743. /**
  151744. * The (Babylon) version of this module.
  151745. * This is an integer representing the implementation version.
  151746. * This number does not correspond to the WebXR specs version
  151747. */
  151748. static readonly Version: number;
  151749. /**
  151750. * Observers registered here will be executed when a new plane was added to the session
  151751. */
  151752. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151753. /**
  151754. * Observers registered here will be executed when a plane is no longer detected in the session
  151755. */
  151756. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151757. /**
  151758. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151759. * This can execute N times every frame
  151760. */
  151761. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151762. /**
  151763. * construct a new Plane Detector
  151764. * @param _xrSessionManager an instance of xr Session manager
  151765. * @param _options configuration to use when constructing this feature
  151766. */
  151767. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151768. /**
  151769. * detach this feature.
  151770. * Will usually be called by the features manager
  151771. *
  151772. * @returns true if successful.
  151773. */
  151774. detach(): boolean;
  151775. /**
  151776. * Dispose this feature and all of the resources attached
  151777. */
  151778. dispose(): void;
  151779. protected _onXRFrame(frame: XRFrame): void;
  151780. private _init;
  151781. private _updatePlaneWithXRPlane;
  151782. /**
  151783. * avoiding using Array.find for global support.
  151784. * @param xrPlane the plane to find in the array
  151785. */
  151786. private findIndexInPlaneArray;
  151787. }
  151788. }
  151789. declare module BABYLON {
  151790. /**
  151791. * Options interface for the background remover plugin
  151792. */
  151793. export interface IWebXRBackgroundRemoverOptions {
  151794. /**
  151795. * Further background meshes to disable when entering AR
  151796. */
  151797. backgroundMeshes?: AbstractMesh[];
  151798. /**
  151799. * flags to configure the removal of the environment helper.
  151800. * If not set, the entire background will be removed. If set, flags should be set as well.
  151801. */
  151802. environmentHelperRemovalFlags?: {
  151803. /**
  151804. * Should the skybox be removed (default false)
  151805. */
  151806. skyBox?: boolean;
  151807. /**
  151808. * Should the ground be removed (default false)
  151809. */
  151810. ground?: boolean;
  151811. };
  151812. /**
  151813. * don't disable the environment helper
  151814. */
  151815. ignoreEnvironmentHelper?: boolean;
  151816. }
  151817. /**
  151818. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151819. */
  151820. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151821. /**
  151822. * read-only options to be used in this module
  151823. */
  151824. readonly options: IWebXRBackgroundRemoverOptions;
  151825. /**
  151826. * The module's name
  151827. */
  151828. static readonly Name: string;
  151829. /**
  151830. * The (Babylon) version of this module.
  151831. * This is an integer representing the implementation version.
  151832. * This number does not correspond to the WebXR specs version
  151833. */
  151834. static readonly Version: number;
  151835. /**
  151836. * registered observers will be triggered when the background state changes
  151837. */
  151838. onBackgroundStateChangedObservable: Observable<boolean>;
  151839. /**
  151840. * constructs a new background remover module
  151841. * @param _xrSessionManager the session manager for this module
  151842. * @param options read-only options to be used in this module
  151843. */
  151844. constructor(_xrSessionManager: WebXRSessionManager,
  151845. /**
  151846. * read-only options to be used in this module
  151847. */
  151848. options?: IWebXRBackgroundRemoverOptions);
  151849. /**
  151850. * attach this feature
  151851. * Will usually be called by the features manager
  151852. *
  151853. * @returns true if successful.
  151854. */
  151855. attach(): boolean;
  151856. /**
  151857. * detach this feature.
  151858. * Will usually be called by the features manager
  151859. *
  151860. * @returns true if successful.
  151861. */
  151862. detach(): boolean;
  151863. /**
  151864. * Dispose this feature and all of the resources attached
  151865. */
  151866. dispose(): void;
  151867. protected _onXRFrame(_xrFrame: XRFrame): void;
  151868. private _setBackgroundState;
  151869. }
  151870. }
  151871. declare module BABYLON {
  151872. /**
  151873. * Options for the controller physics feature
  151874. */
  151875. export class IWebXRControllerPhysicsOptions {
  151876. /**
  151877. * Should the headset get its own impostor
  151878. */
  151879. enableHeadsetImpostor?: boolean;
  151880. /**
  151881. * Optional parameters for the headset impostor
  151882. */
  151883. headsetImpostorParams?: {
  151884. /**
  151885. * The type of impostor to create. Default is sphere
  151886. */
  151887. impostorType: number;
  151888. /**
  151889. * the size of the impostor. Defaults to 10cm
  151890. */
  151891. impostorSize?: number | {
  151892. width: number;
  151893. height: number;
  151894. depth: number;
  151895. };
  151896. /**
  151897. * Friction definitions
  151898. */
  151899. friction?: number;
  151900. /**
  151901. * Restitution
  151902. */
  151903. restitution?: number;
  151904. };
  151905. /**
  151906. * The physics properties of the future impostors
  151907. */
  151908. physicsProperties?: {
  151909. /**
  151910. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151911. * Note that this requires a physics engine that supports mesh impostors!
  151912. */
  151913. useControllerMesh?: boolean;
  151914. /**
  151915. * The type of impostor to create. Default is sphere
  151916. */
  151917. impostorType?: number;
  151918. /**
  151919. * the size of the impostor. Defaults to 10cm
  151920. */
  151921. impostorSize?: number | {
  151922. width: number;
  151923. height: number;
  151924. depth: number;
  151925. };
  151926. /**
  151927. * Friction definitions
  151928. */
  151929. friction?: number;
  151930. /**
  151931. * Restitution
  151932. */
  151933. restitution?: number;
  151934. };
  151935. /**
  151936. * the xr input to use with this pointer selection
  151937. */
  151938. xrInput: WebXRInput;
  151939. }
  151940. /**
  151941. * Add physics impostor to your webxr controllers,
  151942. * including naive calculation of their linear and angular velocity
  151943. */
  151944. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151945. private readonly _options;
  151946. private _attachController;
  151947. private _controllers;
  151948. private _debugMode;
  151949. private _delta;
  151950. private _headsetImpostor?;
  151951. private _headsetMesh?;
  151952. private _lastTimestamp;
  151953. private _tmpQuaternion;
  151954. private _tmpVector;
  151955. /**
  151956. * The module's name
  151957. */
  151958. static readonly Name: string;
  151959. /**
  151960. * The (Babylon) version of this module.
  151961. * This is an integer representing the implementation version.
  151962. * This number does not correspond to the webxr specs version
  151963. */
  151964. static readonly Version: number;
  151965. /**
  151966. * Construct a new Controller Physics Feature
  151967. * @param _xrSessionManager the corresponding xr session manager
  151968. * @param _options options to create this feature with
  151969. */
  151970. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151971. /**
  151972. * @hidden
  151973. * enable debugging - will show console outputs and the impostor mesh
  151974. */
  151975. _enablePhysicsDebug(): void;
  151976. /**
  151977. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151978. * @param xrController the controller to add
  151979. */
  151980. addController(xrController: WebXRInputSource): void;
  151981. /**
  151982. * attach this feature
  151983. * Will usually be called by the features manager
  151984. *
  151985. * @returns true if successful.
  151986. */
  151987. attach(): boolean;
  151988. /**
  151989. * detach this feature.
  151990. * Will usually be called by the features manager
  151991. *
  151992. * @returns true if successful.
  151993. */
  151994. detach(): boolean;
  151995. /**
  151996. * Get the headset impostor, if enabled
  151997. * @returns the impostor
  151998. */
  151999. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152000. /**
  152001. * Get the physics impostor of a specific controller.
  152002. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152003. * @param controller the controller or the controller id of which to get the impostor
  152004. * @returns the impostor or null
  152005. */
  152006. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152007. /**
  152008. * Update the physics properties provided in the constructor
  152009. * @param newProperties the new properties object
  152010. */
  152011. setPhysicsProperties(newProperties: {
  152012. impostorType?: number;
  152013. impostorSize?: number | {
  152014. width: number;
  152015. height: number;
  152016. depth: number;
  152017. };
  152018. friction?: number;
  152019. restitution?: number;
  152020. }): void;
  152021. protected _onXRFrame(_xrFrame: any): void;
  152022. private _detachController;
  152023. }
  152024. }
  152025. declare module BABYLON {
  152026. /**
  152027. * The motion controller class for all microsoft mixed reality controllers
  152028. */
  152029. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152030. protected readonly _mapping: {
  152031. defaultButton: {
  152032. valueNodeName: string;
  152033. unpressedNodeName: string;
  152034. pressedNodeName: string;
  152035. };
  152036. defaultAxis: {
  152037. valueNodeName: string;
  152038. minNodeName: string;
  152039. maxNodeName: string;
  152040. };
  152041. buttons: {
  152042. "xr-standard-trigger": {
  152043. rootNodeName: string;
  152044. componentProperty: string;
  152045. states: string[];
  152046. };
  152047. "xr-standard-squeeze": {
  152048. rootNodeName: string;
  152049. componentProperty: string;
  152050. states: string[];
  152051. };
  152052. "xr-standard-touchpad": {
  152053. rootNodeName: string;
  152054. labelAnchorNodeName: string;
  152055. touchPointNodeName: string;
  152056. };
  152057. "xr-standard-thumbstick": {
  152058. rootNodeName: string;
  152059. componentProperty: string;
  152060. states: string[];
  152061. };
  152062. };
  152063. axes: {
  152064. "xr-standard-touchpad": {
  152065. "x-axis": {
  152066. rootNodeName: string;
  152067. };
  152068. "y-axis": {
  152069. rootNodeName: string;
  152070. };
  152071. };
  152072. "xr-standard-thumbstick": {
  152073. "x-axis": {
  152074. rootNodeName: string;
  152075. };
  152076. "y-axis": {
  152077. rootNodeName: string;
  152078. };
  152079. };
  152080. };
  152081. };
  152082. /**
  152083. * The base url used to load the left and right controller models
  152084. */
  152085. static MODEL_BASE_URL: string;
  152086. /**
  152087. * The name of the left controller model file
  152088. */
  152089. static MODEL_LEFT_FILENAME: string;
  152090. /**
  152091. * The name of the right controller model file
  152092. */
  152093. static MODEL_RIGHT_FILENAME: string;
  152094. profileId: string;
  152095. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152096. protected _getFilenameAndPath(): {
  152097. filename: string;
  152098. path: string;
  152099. };
  152100. protected _getModelLoadingConstraints(): boolean;
  152101. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152102. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152103. protected _updateModel(): void;
  152104. }
  152105. }
  152106. declare module BABYLON {
  152107. /**
  152108. * The motion controller class for oculus touch (quest, rift).
  152109. * This class supports legacy mapping as well the standard xr mapping
  152110. */
  152111. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152112. private _forceLegacyControllers;
  152113. private _modelRootNode;
  152114. /**
  152115. * The base url used to load the left and right controller models
  152116. */
  152117. static MODEL_BASE_URL: string;
  152118. /**
  152119. * The name of the left controller model file
  152120. */
  152121. static MODEL_LEFT_FILENAME: string;
  152122. /**
  152123. * The name of the right controller model file
  152124. */
  152125. static MODEL_RIGHT_FILENAME: string;
  152126. /**
  152127. * Base Url for the Quest controller model.
  152128. */
  152129. static QUEST_MODEL_BASE_URL: string;
  152130. profileId: string;
  152131. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152132. protected _getFilenameAndPath(): {
  152133. filename: string;
  152134. path: string;
  152135. };
  152136. protected _getModelLoadingConstraints(): boolean;
  152137. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152138. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152139. protected _updateModel(): void;
  152140. /**
  152141. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152142. * between the touch and touch 2.
  152143. */
  152144. private _isQuest;
  152145. }
  152146. }
  152147. declare module BABYLON {
  152148. /**
  152149. * The motion controller class for the standard HTC-Vive controllers
  152150. */
  152151. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152152. private _modelRootNode;
  152153. /**
  152154. * The base url used to load the left and right controller models
  152155. */
  152156. static MODEL_BASE_URL: string;
  152157. /**
  152158. * File name for the controller model.
  152159. */
  152160. static MODEL_FILENAME: string;
  152161. profileId: string;
  152162. /**
  152163. * Create a new Vive motion controller object
  152164. * @param scene the scene to use to create this controller
  152165. * @param gamepadObject the corresponding gamepad object
  152166. * @param handedness the handedness of the controller
  152167. */
  152168. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152169. protected _getFilenameAndPath(): {
  152170. filename: string;
  152171. path: string;
  152172. };
  152173. protected _getModelLoadingConstraints(): boolean;
  152174. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152175. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152176. protected _updateModel(): void;
  152177. }
  152178. }
  152179. declare module BABYLON {
  152180. /**
  152181. * A cursor which tracks a point on a path
  152182. */
  152183. export class PathCursor {
  152184. private path;
  152185. /**
  152186. * Stores path cursor callbacks for when an onchange event is triggered
  152187. */
  152188. private _onchange;
  152189. /**
  152190. * The value of the path cursor
  152191. */
  152192. value: number;
  152193. /**
  152194. * The animation array of the path cursor
  152195. */
  152196. animations: Animation[];
  152197. /**
  152198. * Initializes the path cursor
  152199. * @param path The path to track
  152200. */
  152201. constructor(path: Path2);
  152202. /**
  152203. * Gets the cursor point on the path
  152204. * @returns A point on the path cursor at the cursor location
  152205. */
  152206. getPoint(): Vector3;
  152207. /**
  152208. * Moves the cursor ahead by the step amount
  152209. * @param step The amount to move the cursor forward
  152210. * @returns This path cursor
  152211. */
  152212. moveAhead(step?: number): PathCursor;
  152213. /**
  152214. * Moves the cursor behind by the step amount
  152215. * @param step The amount to move the cursor back
  152216. * @returns This path cursor
  152217. */
  152218. moveBack(step?: number): PathCursor;
  152219. /**
  152220. * Moves the cursor by the step amount
  152221. * If the step amount is greater than one, an exception is thrown
  152222. * @param step The amount to move the cursor
  152223. * @returns This path cursor
  152224. */
  152225. move(step: number): PathCursor;
  152226. /**
  152227. * Ensures that the value is limited between zero and one
  152228. * @returns This path cursor
  152229. */
  152230. private ensureLimits;
  152231. /**
  152232. * Runs onchange callbacks on change (used by the animation engine)
  152233. * @returns This path cursor
  152234. */
  152235. private raiseOnChange;
  152236. /**
  152237. * Executes a function on change
  152238. * @param f A path cursor onchange callback
  152239. * @returns This path cursor
  152240. */
  152241. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152242. }
  152243. }
  152244. declare module BABYLON {
  152245. /** @hidden */
  152246. export var blurPixelShader: {
  152247. name: string;
  152248. shader: string;
  152249. };
  152250. }
  152251. declare module BABYLON {
  152252. /** @hidden */
  152253. export var pointCloudVertexDeclaration: {
  152254. name: string;
  152255. shader: string;
  152256. };
  152257. }
  152258. // Mixins
  152259. interface Window {
  152260. mozIndexedDB: IDBFactory;
  152261. webkitIndexedDB: IDBFactory;
  152262. msIndexedDB: IDBFactory;
  152263. webkitURL: typeof URL;
  152264. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152265. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152266. WebGLRenderingContext: WebGLRenderingContext;
  152267. MSGesture: MSGesture;
  152268. CANNON: any;
  152269. AudioContext: AudioContext;
  152270. webkitAudioContext: AudioContext;
  152271. PointerEvent: any;
  152272. Math: Math;
  152273. Uint8Array: Uint8ArrayConstructor;
  152274. Float32Array: Float32ArrayConstructor;
  152275. mozURL: typeof URL;
  152276. msURL: typeof URL;
  152277. VRFrameData: any; // WebVR, from specs 1.1
  152278. DracoDecoderModule: any;
  152279. setImmediate(handler: (...args: any[]) => void): number;
  152280. }
  152281. interface HTMLCanvasElement {
  152282. requestPointerLock(): void;
  152283. msRequestPointerLock?(): void;
  152284. mozRequestPointerLock?(): void;
  152285. webkitRequestPointerLock?(): void;
  152286. /** Track wether a record is in progress */
  152287. isRecording: boolean;
  152288. /** Capture Stream method defined by some browsers */
  152289. captureStream(fps?: number): MediaStream;
  152290. }
  152291. interface CanvasRenderingContext2D {
  152292. msImageSmoothingEnabled: boolean;
  152293. }
  152294. interface MouseEvent {
  152295. mozMovementX: number;
  152296. mozMovementY: number;
  152297. webkitMovementX: number;
  152298. webkitMovementY: number;
  152299. msMovementX: number;
  152300. msMovementY: number;
  152301. }
  152302. interface Navigator {
  152303. mozGetVRDevices: (any: any) => any;
  152304. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152305. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152306. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152307. webkitGetGamepads(): Gamepad[];
  152308. msGetGamepads(): Gamepad[];
  152309. webkitGamepads(): Gamepad[];
  152310. }
  152311. interface HTMLVideoElement {
  152312. mozSrcObject: any;
  152313. }
  152314. interface Math {
  152315. fround(x: number): number;
  152316. imul(a: number, b: number): number;
  152317. }
  152318. interface WebGLRenderingContext {
  152319. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152320. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152321. vertexAttribDivisor(index: number, divisor: number): void;
  152322. createVertexArray(): any;
  152323. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152324. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152325. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152326. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152327. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152328. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152329. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152330. // Queries
  152331. createQuery(): WebGLQuery;
  152332. deleteQuery(query: WebGLQuery): void;
  152333. beginQuery(target: number, query: WebGLQuery): void;
  152334. endQuery(target: number): void;
  152335. getQueryParameter(query: WebGLQuery, pname: number): any;
  152336. getQuery(target: number, pname: number): any;
  152337. MAX_SAMPLES: number;
  152338. RGBA8: number;
  152339. READ_FRAMEBUFFER: number;
  152340. DRAW_FRAMEBUFFER: number;
  152341. UNIFORM_BUFFER: number;
  152342. HALF_FLOAT_OES: number;
  152343. RGBA16F: number;
  152344. RGBA32F: number;
  152345. R32F: number;
  152346. RG32F: number;
  152347. RGB32F: number;
  152348. R16F: number;
  152349. RG16F: number;
  152350. RGB16F: number;
  152351. RED: number;
  152352. RG: number;
  152353. R8: number;
  152354. RG8: number;
  152355. UNSIGNED_INT_24_8: number;
  152356. DEPTH24_STENCIL8: number;
  152357. MIN: number;
  152358. MAX: number;
  152359. /* Multiple Render Targets */
  152360. drawBuffers(buffers: number[]): void;
  152361. readBuffer(src: number): void;
  152362. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152363. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152364. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152365. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152366. // Occlusion Query
  152367. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152368. ANY_SAMPLES_PASSED: number;
  152369. QUERY_RESULT_AVAILABLE: number;
  152370. QUERY_RESULT: number;
  152371. }
  152372. interface WebGLProgram {
  152373. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152374. }
  152375. interface EXT_disjoint_timer_query {
  152376. QUERY_COUNTER_BITS_EXT: number;
  152377. TIME_ELAPSED_EXT: number;
  152378. TIMESTAMP_EXT: number;
  152379. GPU_DISJOINT_EXT: number;
  152380. QUERY_RESULT_EXT: number;
  152381. QUERY_RESULT_AVAILABLE_EXT: number;
  152382. queryCounterEXT(query: WebGLQuery, target: number): void;
  152383. createQueryEXT(): WebGLQuery;
  152384. beginQueryEXT(target: number, query: WebGLQuery): void;
  152385. endQueryEXT(target: number): void;
  152386. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152387. deleteQueryEXT(query: WebGLQuery): void;
  152388. }
  152389. interface WebGLUniformLocation {
  152390. _currentState: any;
  152391. }
  152392. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152393. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152394. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152395. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152396. interface WebGLRenderingContext {
  152397. readonly RASTERIZER_DISCARD: number;
  152398. readonly DEPTH_COMPONENT24: number;
  152399. readonly TEXTURE_3D: number;
  152400. readonly TEXTURE_2D_ARRAY: number;
  152401. readonly TEXTURE_COMPARE_FUNC: number;
  152402. readonly TEXTURE_COMPARE_MODE: number;
  152403. readonly COMPARE_REF_TO_TEXTURE: number;
  152404. readonly TEXTURE_WRAP_R: number;
  152405. readonly HALF_FLOAT: number;
  152406. readonly RGB8: number;
  152407. readonly RED_INTEGER: number;
  152408. readonly RG_INTEGER: number;
  152409. readonly RGB_INTEGER: number;
  152410. readonly RGBA_INTEGER: number;
  152411. readonly R8_SNORM: number;
  152412. readonly RG8_SNORM: number;
  152413. readonly RGB8_SNORM: number;
  152414. readonly RGBA8_SNORM: number;
  152415. readonly R8I: number;
  152416. readonly RG8I: number;
  152417. readonly RGB8I: number;
  152418. readonly RGBA8I: number;
  152419. readonly R8UI: number;
  152420. readonly RG8UI: number;
  152421. readonly RGB8UI: number;
  152422. readonly RGBA8UI: number;
  152423. readonly R16I: number;
  152424. readonly RG16I: number;
  152425. readonly RGB16I: number;
  152426. readonly RGBA16I: number;
  152427. readonly R16UI: number;
  152428. readonly RG16UI: number;
  152429. readonly RGB16UI: number;
  152430. readonly RGBA16UI: number;
  152431. readonly R32I: number;
  152432. readonly RG32I: number;
  152433. readonly RGB32I: number;
  152434. readonly RGBA32I: number;
  152435. readonly R32UI: number;
  152436. readonly RG32UI: number;
  152437. readonly RGB32UI: number;
  152438. readonly RGBA32UI: number;
  152439. readonly RGB10_A2UI: number;
  152440. readonly R11F_G11F_B10F: number;
  152441. readonly RGB9_E5: number;
  152442. readonly RGB10_A2: number;
  152443. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152444. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152445. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152446. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152447. readonly DEPTH_COMPONENT32F: number;
  152448. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152449. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152450. 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;
  152451. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152452. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152453. readonly TRANSFORM_FEEDBACK: number;
  152454. readonly INTERLEAVED_ATTRIBS: number;
  152455. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152456. createTransformFeedback(): WebGLTransformFeedback;
  152457. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152458. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152459. beginTransformFeedback(primitiveMode: number): void;
  152460. endTransformFeedback(): void;
  152461. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152462. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152463. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152464. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152465. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152466. }
  152467. interface ImageBitmap {
  152468. readonly width: number;
  152469. readonly height: number;
  152470. close(): void;
  152471. }
  152472. interface WebGLQuery extends WebGLObject {
  152473. }
  152474. declare var WebGLQuery: {
  152475. prototype: WebGLQuery;
  152476. new(): WebGLQuery;
  152477. };
  152478. interface WebGLSampler extends WebGLObject {
  152479. }
  152480. declare var WebGLSampler: {
  152481. prototype: WebGLSampler;
  152482. new(): WebGLSampler;
  152483. };
  152484. interface WebGLSync extends WebGLObject {
  152485. }
  152486. declare var WebGLSync: {
  152487. prototype: WebGLSync;
  152488. new(): WebGLSync;
  152489. };
  152490. interface WebGLTransformFeedback extends WebGLObject {
  152491. }
  152492. declare var WebGLTransformFeedback: {
  152493. prototype: WebGLTransformFeedback;
  152494. new(): WebGLTransformFeedback;
  152495. };
  152496. interface WebGLVertexArrayObject extends WebGLObject {
  152497. }
  152498. declare var WebGLVertexArrayObject: {
  152499. prototype: WebGLVertexArrayObject;
  152500. new(): WebGLVertexArrayObject;
  152501. };
  152502. // Type definitions for WebVR API
  152503. // Project: https://w3c.github.io/webvr/
  152504. // Definitions by: six a <https://github.com/lostfictions>
  152505. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152506. interface VRDisplay extends EventTarget {
  152507. /**
  152508. * Dictionary of capabilities describing the VRDisplay.
  152509. */
  152510. readonly capabilities: VRDisplayCapabilities;
  152511. /**
  152512. * z-depth defining the far plane of the eye view frustum
  152513. * enables mapping of values in the render target depth
  152514. * attachment to scene coordinates. Initially set to 10000.0.
  152515. */
  152516. depthFar: number;
  152517. /**
  152518. * z-depth defining the near plane of the eye view frustum
  152519. * enables mapping of values in the render target depth
  152520. * attachment to scene coordinates. Initially set to 0.01.
  152521. */
  152522. depthNear: number;
  152523. /**
  152524. * An identifier for this distinct VRDisplay. Used as an
  152525. * association point in the Gamepad API.
  152526. */
  152527. readonly displayId: number;
  152528. /**
  152529. * A display name, a user-readable name identifying it.
  152530. */
  152531. readonly displayName: string;
  152532. readonly isConnected: boolean;
  152533. readonly isPresenting: boolean;
  152534. /**
  152535. * If this VRDisplay supports room-scale experiences, the optional
  152536. * stage attribute contains details on the room-scale parameters.
  152537. */
  152538. readonly stageParameters: VRStageParameters | null;
  152539. /**
  152540. * Passing the value returned by `requestAnimationFrame` to
  152541. * `cancelAnimationFrame` will unregister the callback.
  152542. * @param handle Define the hanle of the request to cancel
  152543. */
  152544. cancelAnimationFrame(handle: number): void;
  152545. /**
  152546. * Stops presenting to the VRDisplay.
  152547. * @returns a promise to know when it stopped
  152548. */
  152549. exitPresent(): Promise<void>;
  152550. /**
  152551. * Return the current VREyeParameters for the given eye.
  152552. * @param whichEye Define the eye we want the parameter for
  152553. * @returns the eye parameters
  152554. */
  152555. getEyeParameters(whichEye: string): VREyeParameters;
  152556. /**
  152557. * Populates the passed VRFrameData with the information required to render
  152558. * the current frame.
  152559. * @param frameData Define the data structure to populate
  152560. * @returns true if ok otherwise false
  152561. */
  152562. getFrameData(frameData: VRFrameData): boolean;
  152563. /**
  152564. * Get the layers currently being presented.
  152565. * @returns the list of VR layers
  152566. */
  152567. getLayers(): VRLayer[];
  152568. /**
  152569. * Return a VRPose containing the future predicted pose of the VRDisplay
  152570. * when the current frame will be presented. The value returned will not
  152571. * change until JavaScript has returned control to the browser.
  152572. *
  152573. * The VRPose will contain the position, orientation, velocity,
  152574. * and acceleration of each of these properties.
  152575. * @returns the pose object
  152576. */
  152577. getPose(): VRPose;
  152578. /**
  152579. * Return the current instantaneous pose of the VRDisplay, with no
  152580. * prediction applied.
  152581. * @returns the current instantaneous pose
  152582. */
  152583. getImmediatePose(): VRPose;
  152584. /**
  152585. * The callback passed to `requestAnimationFrame` will be called
  152586. * any time a new frame should be rendered. When the VRDisplay is
  152587. * presenting the callback will be called at the native refresh
  152588. * rate of the HMD. When not presenting this function acts
  152589. * identically to how window.requestAnimationFrame acts. Content should
  152590. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152591. * asynchronously from other displays and at differing refresh rates.
  152592. * @param callback Define the eaction to run next frame
  152593. * @returns the request handle it
  152594. */
  152595. requestAnimationFrame(callback: FrameRequestCallback): number;
  152596. /**
  152597. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152598. * Repeat calls while already presenting will update the VRLayers being displayed.
  152599. * @param layers Define the list of layer to present
  152600. * @returns a promise to know when the request has been fulfilled
  152601. */
  152602. requestPresent(layers: VRLayer[]): Promise<void>;
  152603. /**
  152604. * Reset the pose for this display, treating its current position and
  152605. * orientation as the "origin/zero" values. VRPose.position,
  152606. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152607. * updated when calling resetPose(). This should be called in only
  152608. * sitting-space experiences.
  152609. */
  152610. resetPose(): void;
  152611. /**
  152612. * The VRLayer provided to the VRDisplay will be captured and presented
  152613. * in the HMD. Calling this function has the same effect on the source
  152614. * canvas as any other operation that uses its source image, and canvases
  152615. * created without preserveDrawingBuffer set to true will be cleared.
  152616. * @param pose Define the pose to submit
  152617. */
  152618. submitFrame(pose?: VRPose): void;
  152619. }
  152620. declare var VRDisplay: {
  152621. prototype: VRDisplay;
  152622. new(): VRDisplay;
  152623. };
  152624. interface VRLayer {
  152625. leftBounds?: number[] | Float32Array | null;
  152626. rightBounds?: number[] | Float32Array | null;
  152627. source?: HTMLCanvasElement | null;
  152628. }
  152629. interface VRDisplayCapabilities {
  152630. readonly canPresent: boolean;
  152631. readonly hasExternalDisplay: boolean;
  152632. readonly hasOrientation: boolean;
  152633. readonly hasPosition: boolean;
  152634. readonly maxLayers: number;
  152635. }
  152636. interface VREyeParameters {
  152637. /** @deprecated */
  152638. readonly fieldOfView: VRFieldOfView;
  152639. readonly offset: Float32Array;
  152640. readonly renderHeight: number;
  152641. readonly renderWidth: number;
  152642. }
  152643. interface VRFieldOfView {
  152644. readonly downDegrees: number;
  152645. readonly leftDegrees: number;
  152646. readonly rightDegrees: number;
  152647. readonly upDegrees: number;
  152648. }
  152649. interface VRFrameData {
  152650. readonly leftProjectionMatrix: Float32Array;
  152651. readonly leftViewMatrix: Float32Array;
  152652. readonly pose: VRPose;
  152653. readonly rightProjectionMatrix: Float32Array;
  152654. readonly rightViewMatrix: Float32Array;
  152655. readonly timestamp: number;
  152656. }
  152657. interface VRPose {
  152658. readonly angularAcceleration: Float32Array | null;
  152659. readonly angularVelocity: Float32Array | null;
  152660. readonly linearAcceleration: Float32Array | null;
  152661. readonly linearVelocity: Float32Array | null;
  152662. readonly orientation: Float32Array | null;
  152663. readonly position: Float32Array | null;
  152664. readonly timestamp: number;
  152665. }
  152666. interface VRStageParameters {
  152667. sittingToStandingTransform?: Float32Array;
  152668. sizeX?: number;
  152669. sizeY?: number;
  152670. }
  152671. interface Navigator {
  152672. getVRDisplays(): Promise<VRDisplay[]>;
  152673. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152674. }
  152675. interface Window {
  152676. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152677. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152678. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152679. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152680. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152681. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152682. }
  152683. interface Gamepad {
  152684. readonly displayId: number;
  152685. }
  152686. type XRSessionMode =
  152687. | "inline"
  152688. | "immersive-vr"
  152689. | "immersive-ar";
  152690. type XRReferenceSpaceType =
  152691. | "viewer"
  152692. | "local"
  152693. | "local-floor"
  152694. | "bounded-floor"
  152695. | "unbounded";
  152696. type XREnvironmentBlendMode =
  152697. | "opaque"
  152698. | "additive"
  152699. | "alpha-blend";
  152700. type XRVisibilityState =
  152701. | "visible"
  152702. | "visible-blurred"
  152703. | "hidden";
  152704. type XRHandedness =
  152705. | "none"
  152706. | "left"
  152707. | "right";
  152708. type XRTargetRayMode =
  152709. | "gaze"
  152710. | "tracked-pointer"
  152711. | "screen";
  152712. type XREye =
  152713. | "none"
  152714. | "left"
  152715. | "right";
  152716. type XREventType =
  152717. | "devicechange"
  152718. | "visibilitychange"
  152719. | "end"
  152720. | "inputsourceschange"
  152721. | "select"
  152722. | "selectstart"
  152723. | "selectend"
  152724. | "squeeze"
  152725. | "squeezestart"
  152726. | "squeezeend"
  152727. | "reset";
  152728. interface XRSpace extends EventTarget {
  152729. }
  152730. interface XRRenderState {
  152731. depthNear?: number;
  152732. depthFar?: number;
  152733. inlineVerticalFieldOfView?: number;
  152734. baseLayer?: XRWebGLLayer;
  152735. }
  152736. interface XRInputSource {
  152737. handedness: XRHandedness;
  152738. targetRayMode: XRTargetRayMode;
  152739. targetRaySpace: XRSpace;
  152740. gripSpace: XRSpace | undefined;
  152741. gamepad: Gamepad | undefined;
  152742. profiles: Array<string>;
  152743. }
  152744. interface XRSessionInit {
  152745. optionalFeatures?: string[];
  152746. requiredFeatures?: string[];
  152747. }
  152748. interface XRSession {
  152749. addEventListener: Function;
  152750. removeEventListener: Function;
  152751. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152752. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152753. requestAnimationFrame: Function;
  152754. end(): Promise<void>;
  152755. renderState: XRRenderState;
  152756. inputSources: Array<XRInputSource>;
  152757. // hit test
  152758. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152759. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152760. // legacy AR hit test
  152761. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152762. // legacy plane detection
  152763. updateWorldTrackingState(options: {
  152764. planeDetectionState?: { enabled: boolean; }
  152765. }): void;
  152766. }
  152767. interface XRReferenceSpace extends XRSpace {
  152768. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152769. onreset: any;
  152770. }
  152771. type XRPlaneSet = Set<XRPlane>;
  152772. type XRAnchorSet = Set<XRAnchor>;
  152773. interface XRFrame {
  152774. session: XRSession;
  152775. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152776. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152777. // AR
  152778. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152779. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152780. // Anchors
  152781. trackedAnchors?: XRAnchorSet;
  152782. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152783. // Planes
  152784. worldInformation: {
  152785. detectedPlanes?: XRPlaneSet;
  152786. };
  152787. }
  152788. interface XRViewerPose extends XRPose {
  152789. views: Array<XRView>;
  152790. }
  152791. interface XRPose {
  152792. transform: XRRigidTransform;
  152793. emulatedPosition: boolean;
  152794. }
  152795. interface XRWebGLLayerOptions {
  152796. antialias?: boolean;
  152797. depth?: boolean;
  152798. stencil?: boolean;
  152799. alpha?: boolean;
  152800. multiview?: boolean;
  152801. framebufferScaleFactor?: number;
  152802. }
  152803. declare var XRWebGLLayer: {
  152804. prototype: XRWebGLLayer;
  152805. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152806. };
  152807. interface XRWebGLLayer {
  152808. framebuffer: WebGLFramebuffer;
  152809. framebufferWidth: number;
  152810. framebufferHeight: number;
  152811. getViewport: Function;
  152812. }
  152813. declare class XRRigidTransform {
  152814. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152815. position: DOMPointReadOnly;
  152816. orientation: DOMPointReadOnly;
  152817. matrix: Float32Array;
  152818. inverse: XRRigidTransform;
  152819. }
  152820. interface XRView {
  152821. eye: XREye;
  152822. projectionMatrix: Float32Array;
  152823. transform: XRRigidTransform;
  152824. }
  152825. interface XRInputSourceChangeEvent {
  152826. session: XRSession;
  152827. removed: Array<XRInputSource>;
  152828. added: Array<XRInputSource>;
  152829. }
  152830. interface XRInputSourceEvent extends Event {
  152831. readonly frame: XRFrame;
  152832. readonly inputSource: XRInputSource;
  152833. }
  152834. // Experimental(er) features
  152835. declare class XRRay {
  152836. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152837. origin: DOMPointReadOnly;
  152838. direction: DOMPointReadOnly;
  152839. matrix: Float32Array;
  152840. }
  152841. declare enum XRHitTestTrackableType {
  152842. "point",
  152843. "plane"
  152844. }
  152845. interface XRHitResult {
  152846. hitMatrix: Float32Array;
  152847. }
  152848. interface XRTransientInputHitTestResult {
  152849. readonly inputSource: XRInputSource;
  152850. readonly results: Array<XRHitTestResult>;
  152851. }
  152852. interface XRHitTestResult {
  152853. getPose(baseSpace: XRSpace): XRPose | undefined;
  152854. // When anchor system is enabled
  152855. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152856. }
  152857. interface XRHitTestSource {
  152858. cancel(): void;
  152859. }
  152860. interface XRTransientInputHitTestSource {
  152861. cancel(): void;
  152862. }
  152863. interface XRHitTestOptionsInit {
  152864. space: XRSpace;
  152865. entityTypes?: Array<XRHitTestTrackableType>;
  152866. offsetRay?: XRRay;
  152867. }
  152868. interface XRTransientInputHitTestOptionsInit {
  152869. profile: string;
  152870. entityTypes?: Array<XRHitTestTrackableType>;
  152871. offsetRay?: XRRay;
  152872. }
  152873. interface XRAnchor {
  152874. anchorSpace: XRSpace;
  152875. delete(): void;
  152876. }
  152877. interface XRPlane {
  152878. orientation: "Horizontal" | "Vertical";
  152879. planeSpace: XRSpace;
  152880. polygon: Array<DOMPointReadOnly>;
  152881. lastChangedTime: number;
  152882. }